Revision: da01956bcdb8
Author:   [email protected] <[email protected]>
Date:     Sun Jul  8 05:48:30 2012
Log:      Added more checks when bind request comes in
http://code.google.com/p/smscgateway/source/detail?r=da01956bcdb8

Modified:
/core/smpp/src/main/java/org/mobicents/smsc/smpp/DefaultSmppServerHandler.java
 /core/smpp/src/main/java/org/mobicents/smsc/smpp/Esme.java

=======================================
--- /core/smpp/src/main/java/org/mobicents/smsc/smpp/DefaultSmppServerHandler.java Sat Jul 7 10:32:42 2012 +++ /core/smpp/src/main/java/org/mobicents/smsc/smpp/DefaultSmppServerHandler.java Sun Jul 8 05:48:30 2012
@@ -19,6 +19,7 @@
 import com.cloudhopper.smpp.jmx.DefaultSmppSessionMXBean;
 import com.cloudhopper.smpp.pdu.BaseBind;
 import com.cloudhopper.smpp.pdu.BaseBindResp;
+import com.cloudhopper.smpp.type.Address;
 import com.cloudhopper.smpp.type.SmppProcessingException;

public class DefaultSmppServerHandler implements SmppServerHandler, Serializable {
@@ -86,6 +87,30 @@
                                        bindRequest.getSystemId(), 
esme.getSmppBindType()));
                        throw new 
SmppProcessingException(SmppConstants.STATUS_INVBNDSTS);
                }
+
+               // Check if TON, NPI and Address Range matches
+               Address esmeAddressRange = esme.getAddress();
+               Address bindRequestAddressRange = bindRequest.getAddressRange();
+
+               if (esmeAddressRange.getTon() != 
bindRequestAddressRange.getTon()) {
+ logger.error(String.format("Received BIND request with TON=%d but configured TON=%d",
+                                       bindRequestAddressRange.getTon(), 
esmeAddressRange.getTon()));
+                       throw new 
SmppProcessingException(SmppConstants.STATUS_INVBNDSTS);
+               }
+
+               if (esmeAddressRange.getNpi() != 
bindRequestAddressRange.getNpi()) {
+ logger.error(String.format("Received BIND request with NPI=%d but configured NPI=%d",
+                                       bindRequestAddressRange.getNpi(), 
esmeAddressRange.getNpi()));
+                       throw new 
SmppProcessingException(SmppConstants.STATUS_INVBNDSTS);
+               }
+
+ if ((esmeAddressRange.getAddress() == null && bindRequestAddressRange.getAddress() != null) + || (esmeAddressRange.getAddress() != null && bindRequestAddressRange.getAddress() == null) + | | !(esmeAddressRange.getAddress().equals(bindRequestAddressRange.getAddress()))) { + logger.error(String.format("Received BIND request with Address_Range=%s but configured Address_Range=%s",
+                                       bindRequestAddressRange.getAddress(), 
esmeAddressRange.getAddress()));
+                       throw new 
SmppProcessingException(SmppConstants.STATUS_INVBNDSTS);
+               }

                // TODO More parameters to compare

=======================================
--- /core/smpp/src/main/java/org/mobicents/smsc/smpp/Esme.java Sun Jul 8 02:14:52 2012 +++ /core/smpp/src/main/java/org/mobicents/smsc/smpp/Esme.java Sun Jul 8 05:48:30 2012
@@ -190,6 +190,14 @@
        public void setSmppVersion(SmppInterfaceVersionType smppVersion) {
                this.smppVersion = smppVersion;
        }
+
+       public Address getAddress() {
+               return address;
+       }
+
+       public void setAddress(Address address) {
+               this.address = address;
+       }

        /**
         * XML Serialization/Deserialization

Reply via email to