@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; }
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; }
protected BaseBind createBindRequest(SmppSessionConfiguration config) throws UnrecoverablePduException { BaseBind bind = null; if (config.getType() == SmppBindType.TRANSCEIVER) { bind = new BindTransceiver(); } else if (config.getType() == SmppBindType.RECEIVER) { bind = new BindReceiver(); } else if (config.getType() == SmppBindType.TRANSMITTER) { bind = new BindTransmitter(); } else { throw new UnrecoverablePduException("Unable to convert SmppSessionConfiguration into a BaseBind request"); } bind.setSystemId(config.getSystemId()); bind.setPassword(config.getPassword()); bind.setSystemType(config.getSystemType()); bind.setInterfaceVersion(config.getInterfaceVersion()); bind.setAddressRange(config.getAddressRange()); return bind; }
protected SmppSessionConfiguration createSessionConfiguration(BaseBind bindRequest) { SmppSessionConfiguration sessionConfiguration = new SmppSessionConfiguration(); sessionConfiguration.setName("SmppServerSession." + bindRequest.getSystemId() + "." + bindRequest.getSystemType()); sessionConfiguration.setSystemId(bindRequest.getSystemId()); sessionConfiguration.setPassword(bindRequest.getPassword()); sessionConfiguration.setSystemType(bindRequest.getSystemType()); sessionConfiguration.setBindTimeout(server.getConfiguration().getBindTimeout()); sessionConfiguration.setAddressRange(bindRequest.getAddressRange()); sessionConfiguration.setHost(ChannelUtil.getChannelRemoteHost(channel)); sessionConfiguration.setPort(ChannelUtil.getChannelRemotePort(channel)); sessionConfiguration.setInterfaceVersion(bindRequest.getInterfaceVersion());
SmppBindType smppBindType = this.getSmppBindType(bindRequest.getCommandId()); Esme esme = this.esmeManagement.getEsmeByPrimaryKey(bindRequest.getSystemId(), sessionConfiguration.getHost(), sessionConfiguration.getPort(), smppBindType); logger.error(String.format( "Received BIND request but no ESME configured for SystemId=%s Host=%s Port=%d SmppBindType=%s", bindRequest.getSystemId(), sessionConfiguration.getHost(), sessionConfiguration.getPort(), smppBindType)); throw new SmppProcessingException(SmppConstants.STATUS_INVSYSID); logger.error(String.format( "Received BIND request but ESME Already in Bound State Name=%s SystemId=%s Host=%s Port=%d", esme.getName(), bindRequest.getSystemId(), esme.getHost(), esme.getPort())); throw new SmppProcessingException(SmppConstants.STATUS_ALYBND); if (esme.getPassword() != null && !(esme.getPassword().equals(bindRequest.getPassword()))) { logger.error(String.format( "Received BIND request with password=%s but password set for ESME=%s for SystemId=%s", bindRequest.getPassword(), esme.getPassword(), bindRequest.getSystemId())); throw new SmppProcessingException(SmppConstants.STATUS_INVPASWD); Address bindRequestAddressRange = bindRequest.getAddressRange();
logger.debug("Bound failed for systemId=" + request.getSystemId()); this.close(); } catch (Exception e) { logger.debug("Exception after bind failed for systemId=" + request.getSystemId());
protected SmppSessionConfiguration createSessionConfiguration(BaseBind bindRequest) { SmppSessionConfiguration sessionConfiguration = new SmppSessionConfiguration(); sessionConfiguration.setName("SmppServerSession." + bindRequest.getSystemId() + "." + bindRequest.getSystemType()); sessionConfiguration.setSystemId(bindRequest.getSystemId()); sessionConfiguration.setPassword(bindRequest.getPassword()); sessionConfiguration.setSystemType(bindRequest.getSystemType()); sessionConfiguration.setBindTimeout(server.getConfiguration().getBindTimeout()); sessionConfiguration.setAddressRange(bindRequest.getAddressRange()); sessionConfiguration.setHost(ChannelUtil.getChannelRemoteHost(channel)); sessionConfiguration.setPort(ChannelUtil.getChannelRemotePort(channel)); sessionConfiguration.setInterfaceVersion(bindRequest.getInterfaceVersion());
SmppBindType smppBindType = this.getSmppBindType(bindRequest.getCommandId()); Esme esme = this.esmeManagement.getEsmeByPrimaryKey(bindRequest.getSystemId(), sessionConfiguration.getHost(), sessionConfiguration.getPort(), smppBindType); logger.error(String.format( "Received BIND request but no ESME configured for SystemId=%s Host=%s Port=%d SmppBindType=%s", bindRequest.getSystemId(), sessionConfiguration.getHost(), sessionConfiguration.getPort(), smppBindType)); throw new SmppProcessingException(SmppConstants.STATUS_INVSYSID); logger.error(String.format( "Received BIND request but ESME Already in Bound State Name=%s SystemId=%s Host=%s Port=%d", esme.getName(), bindRequest.getSystemId(), esme.getHost(), esme.getPort())); throw new SmppProcessingException(SmppConstants.STATUS_ALYBND); if (esme.getPassword() != null && !(esme.getPassword().equals(bindRequest.getPassword()))) { logger.error(String.format( "Received BIND request with password=%s but password set for ESME=%s for SystemId=%s", bindRequest.getPassword(), esme.getPassword(), bindRequest.getSystemId())); throw new SmppProcessingException(SmppConstants.STATUS_INVPASWD); Address bindRequestAddressRange = bindRequest.getAddressRange();
protected SmppSessionConfiguration createSessionConfiguration(BaseBind bindRequest) { SmppSessionConfiguration sessionConfiguration = new SmppSessionConfiguration(); sessionConfiguration.setName("SmppServerSession." + bindRequest.getSystemId() + "." + bindRequest.getSystemType()); sessionConfiguration.setSystemId(bindRequest.getSystemId()); sessionConfiguration.setPassword(bindRequest.getPassword()); sessionConfiguration.setSystemType(bindRequest.getSystemType()); sessionConfiguration.setBindTimeout(server.getConfiguration().getBindTimeout()); sessionConfiguration.setAddressRange(bindRequest.getAddressRange()); sessionConfiguration.setHost(ChannelUtil.getChannelRemoteHost(channel)); sessionConfiguration.setPort(ChannelUtil.getChannelRemotePort(channel)); sessionConfiguration.setInterfaceVersion(bindRequest.getInterfaceVersion());
protected BaseBind createBindRequest(SmppSessionConfiguration config) throws UnrecoverablePduException { BaseBind bind = null; if (config.getType() == SmppBindType.TRANSCEIVER) { bind = new BindTransceiver(); } else if (config.getType() == SmppBindType.RECEIVER) { bind = new BindReceiver(); } else if (config.getType() == SmppBindType.TRANSMITTER) { bind = new BindTransmitter(); } else { throw new UnrecoverablePduException("Unable to convert SmppSessionConfiguration into a BaseBind request"); } bind.setSystemId(config.getSystemId()); bind.setPassword(config.getPassword()); bind.setSystemType(config.getSystemType()); bind.setInterfaceVersion(config.getInterfaceVersion()); bind.setAddressRange(config.getAddressRange()); return bind; }
@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; }
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; }
protected SmppSessionConfiguration createSessionConfiguration(BaseBind bindRequest) { SmppSessionConfiguration sessionConfiguration = new SmppSessionConfiguration(); sessionConfiguration.setName("SmppServerSession." + bindRequest.getSystemId() + "." + bindRequest.getSystemType()); sessionConfiguration.setSystemId(bindRequest.getSystemId()); sessionConfiguration.setPassword(bindRequest.getPassword()); sessionConfiguration.setSystemType(bindRequest.getSystemType()); sessionConfiguration.setBindTimeout(server.getConfiguration().getBindTimeout()); sessionConfiguration.setAddressRange(bindRequest.getAddressRange()); sessionConfiguration.setHost(ChannelUtil.getChannelRemoteHost(channel)); sessionConfiguration.setPort(ChannelUtil.getChannelRemotePort(channel)); sessionConfiguration.setInterfaceVersion(bindRequest.getInterfaceVersion());
protected BaseBind createBindRequest(SmppSessionConfiguration config) throws UnrecoverablePduException { BaseBind bind = null; if (config.getType() == SmppBindType.TRANSCEIVER) { bind = new BindTransceiver(); } else if (config.getType() == SmppBindType.RECEIVER) { bind = new BindReceiver(); } else if (config.getType() == SmppBindType.TRANSMITTER) { bind = new BindTransmitter(); } else { throw new UnrecoverablePduException("Unable to convert SmppSessionConfiguration into a BaseBind request"); } bind.setSystemId(config.getSystemId()); bind.setPassword(config.getPassword()); bind.setSystemType(config.getSystemType()); bind.setInterfaceVersion(config.getInterfaceVersion()); bind.setAddressRange(config.getAddressRange()); return bind; }
@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; }
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; }
protected BaseBind createBindRequest(SmppSessionConfiguration config) throws UnrecoverablePduException { BaseBind bind = null; if (config.getType() == SmppBindType.TRANSCEIVER) { bind = new BindTransceiver(); } else if (config.getType() == SmppBindType.RECEIVER) { bind = new BindReceiver(); } else if (config.getType() == SmppBindType.TRANSMITTER) { bind = new BindTransmitter(); } else { throw new UnrecoverablePduException("Unable to convert SmppSessionConfiguration into a BaseBind request"); } bind.setSystemId(config.getSystemId()); bind.setPassword(config.getPassword()); bind.setSystemType(config.getSystemType()); bind.setInterfaceVersion(config.getInterfaceVersion()); bind.setAddressRange(config.getAddressRange()); return bind; }
@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; }
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; }