@Override public boolean process(SmppSimulatorSessionHandler session, Channel channel, Pdu pdu) throws Exception { // anything other than a bind is super bad! if (!(pdu instanceof BaseBind)) { if (pdu instanceof PduRequest) { session.addPduToWriteOnNextPduReceived( ((PduRequest) pdu).createGenericNack(SmppConstants.STATUS_INVBNDSTS)); return true; } else { // logger.error("PDU response received, but not bound"); channel.close(); return true; } } BaseBind bind = (BaseBind) pdu; BaseBindResp bindResp = (BaseBindResp) bind.createResponse(); if (!bind.getSystemId().equals(systemId)) { bindResp.setCommandStatus(SmppConstants.STATUS_INVSYSID); } else if (!bind.getPassword().equals(password)) { bindResp.setCommandStatus(SmppConstants.STATUS_INVPASWD); } session.addPduToWriteOnNextPduReceived(bindResp); return true; }
@Override public void sessionBindRequested( Long sessionId, SmppSessionConfiguration sessionConfiguration, final BaseBind bindRequest) throws SmppProcessingException { // test name change of sessions sessionConfiguration.setName("Test1"); if (!SYSTEMID.equals(bindRequest.getSystemId())) { throw new SmppProcessingException(SmppConstants.STATUS_INVSYSID); } if (!PASSWORD.equals(bindRequest.getPassword())) { throw new SmppProcessingException(SmppConstants.STATUS_INVPASWD); } // throw new SmppProcessingException(SmppConstants.STATUS_BINDFAIL, null); }
protected BaseBindResp createBindResponse(BaseBind bindRequest, int statusCode) { BaseBindResp bindResponse = (BaseBindResp) bindRequest.createResponse(); bindResponse.setCommandStatus(statusCode); bindResponse.setSystemId(configuration.getSystemId()); // if the server supports an SMPP server version >= 3.4 AND the bind request // included an interface version >= 3.4, include an optional parameter with configured // sc_interface_version TLV if (configuration.getInterfaceVersion() >= SmppConstants.VERSION_3_4 && bindRequest.getInterfaceVersion() >= SmppConstants.VERSION_3_4) { Tlv scInterfaceVersion = new Tlv( SmppConstants.TAG_SC_INTERFACE_VERSION, new byte[] {configuration.getInterfaceVersion()}); bindResponse.addOptionalParameter(scInterfaceVersion); } return bindResponse; }