submit.addOptionalParameter(new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, textBytes, "message_payload")); } else {
public static void setMessagePayloadOptionalParams(DeliverSm pdu, byte[] messagePayload) { pdu.addOptionalParameter(new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, messagePayload)); }
/** * Writes a variable length C-String (null terminated) TLV. If the String * is null this method will only write out the NULL byte (0x00) TLV. * @param tag The TLV tag value * @param value The String to include in the TLV value * @param charsetName The charsetName to use to convert the String into bytes * @return A new TLV * @throws TlvConvertException Thrown if there is an error during conversion * of the value into TLV. */ static public Tlv createNullTerminatedStringTlv(short tag, String value, String charsetName) throws TlvConvertException { try { if (value == null) { value = ""; } // convert the string into a byte array byte[] bytes = value.getBytes(charsetName); // create a new byte array with a null byte byte[] bytes0 = new byte[bytes.length+1]; System.arraycopy(bytes, 0, bytes0, 0, bytes.length); return new Tlv(tag, bytes0); } catch (UnsupportedEncodingException e) { throw new TlvConvertException("String", "unsupported charset " + e.getMessage()); } }
/** * Writes a variable length C-String (null terminated) TLV. If the String * is null this method will only write out the NULL byte (0x00) TLV. * @param tag The TLV tag value * @param value The String to include in the TLV value * @param charsetName The charsetName to use to convert the String into bytes * @return A new TLV * @throws TlvConvertException Thrown if there is an error during conversion * of the value into TLV. */ static public Tlv createNullTerminatedStringTlv(short tag, String value, String charsetName) throws TlvConvertException { try { if (value == null) { value = ""; } // convert the string into a byte array byte[] bytes = value.getBytes(charsetName); // create a new byte array with a null byte byte[] bytes0 = new byte[bytes.length+1]; System.arraycopy(bytes, 0, bytes0, 0, bytes.length); return new Tlv(tag, bytes0); } catch (UnsupportedEncodingException e) { throw new TlvConvertException("String", "unsupported charset " + e.getMessage()); } }
/** * Writes a variable length C-String (null terminated) TLV. If the String * is null this method will only write out the NULL byte (0x00) TLV. * @param tag The TLV tag value * @param value The String to include in the TLV value * @param charsetName The charsetName to use to convert the String into bytes * @return A new TLV * @throws TlvConvertException Thrown if there is an error during conversion * of the value into TLV. */ static public Tlv createNullTerminatedStringTlv(short tag, String value, String charsetName) throws TlvConvertException { try { if (value == null) { value = ""; } // convert the string into a byte array byte[] bytes = value.getBytes(charsetName); // create a new byte array with a null byte byte[] bytes0 = new byte[bytes.length+1]; System.arraycopy(bytes, 0, bytes0, 0, bytes.length); return new Tlv(tag, bytes0); } catch (UnsupportedEncodingException e) { throw new TlvConvertException("String", "unsupported charset " + e.getMessage()); } }
/** * Writes a variable length C-String (null terminated) TLV. If the String * is null this method will only write out the NULL byte (0x00) TLV. * @param tag The TLV tag value * @param value The String to include in the TLV value * @param charsetName The charsetName to use to convert the String into bytes * @return A new TLV * @throws TlvConvertException Thrown if there is an error during conversion * of the value into TLV. */ static public Tlv createNullTerminatedStringTlv(short tag, String value, String charsetName) throws TlvConvertException { try { if (value == null) { value = ""; } // convert the string into a byte array byte[] bytes = value.getBytes(charsetName); // create a new byte array with a null byte byte[] bytes0 = new byte[bytes.length+1]; System.arraycopy(bytes, 0, bytes0, 0, bytes.length); return new Tlv(tag, bytes0); } catch (UnsupportedEncodingException e) { throw new TlvConvertException("String", "unsupported charset " + e.getMessage()); } }
public static void setSegmentOptionalParams(DeliverSm pdu, int msgRefNum, int segmentNum, int totalSegmentCount) { pdu.addOptionalParameter(new Tlv(SmppConstants.TAG_SAR_MSG_REF_NUM, intToUnsignedShort(msgRefNum))); pdu.addOptionalParameter(new Tlv(SmppConstants.TAG_SAR_SEGMENT_SEQNUM, intToUnsignedByte(segmentNum))); pdu.addOptionalParameter(new Tlv(SmppConstants.TAG_SAR_TOTAL_SEGMENTS, intToUnsignedByte(totalSegmentCount))); }
return new Tlv(tag, bytes); } catch (UnsupportedEncodingException e) { throw new TlvConvertException("String", "unsupported charset " + e.getMessage());
return new Tlv(tag, bytes); } catch (UnsupportedEncodingException e) { throw new TlvConvertException("String", "unsupported charset " + e.getMessage());
return new Tlv(tag, bytes); } catch (UnsupportedEncodingException e) { throw new TlvConvertException("String", "unsupported charset " + e.getMessage());
@Override public void read(javolution.xml.XMLFormat.InputElement xml, TlvSet tlvSet) throws XMLStreamException { tlvSet.optionalParameters.clear(); while (xml.hasNext()) { TlvProxy tlvProxy = xml.get(TLV, TlvProxy.class); if (tlvProxy != null && tlvProxy.tag >= 0 && tlvProxy.value != null) { Tlv tlv = new Tlv(tlvProxy.tag, tlvProxy.value); tlvSet.optionalParameters.add(tlv); } } }
@Override public void read(javolution.xml.XMLFormat.InputElement xml, TlvSet tlvSet) throws XMLStreamException { tlvSet.optionalParameters.clear(); while (xml.hasNext()) { TlvProxy tlvProxy = xml.get(TLV, TlvProxy.class); if (tlvProxy != null && tlvProxy.tag >= 0 && tlvProxy.value != null) { Tlv tlv = new Tlv(tlvProxy.tag, tlvProxy.value); tlvSet.optionalParameters.add(tlv); } } }
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 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 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 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; }
/** * Reads a TLV from a buffer. This method is greedy and will read bytes * even if it won't be able to successfully complete. It's assumed this * method will only be called if its known ahead of time that all bytes * will be available ahead of time. * @param buffer The buffer to read from * @return A new TLV instance * @throws NotEnoughDataInBufferException */ static public Tlv readTlv(ChannelBuffer buffer) throws NotEnoughDataInBufferException { // a TLV is at least 4 bytes (tag+length) if (buffer.readableBytes() < 4) { throw new NotEnoughDataInBufferException("Parsing TLV tag and length", buffer.readableBytes(), 4); } short tag = buffer.readShort(); int length = buffer.readUnsignedShort(); // check if we have enough data for the TLV if (buffer.readableBytes() < length) { throw new NotEnoughDataInBufferException("Parsing TLV value", buffer.readableBytes(), length); } byte[] value = new byte[length]; buffer.readBytes(value); return new Tlv(tag, value); }
/** * Reads a TLV from a buffer. This method is greedy and will read bytes * even if it won't be able to successfully complete. It's assumed this * method will only be called if its known ahead of time that all bytes * will be available ahead of time. * @param buffer The buffer to read from * @return A new TLV instance * @throws NotEnoughDataInBufferException */ static public Tlv readTlv(ChannelBuffer buffer) throws NotEnoughDataInBufferException { // a TLV is at least 4 bytes (tag+length) if (buffer.readableBytes() < 4) { throw new NotEnoughDataInBufferException("Parsing TLV tag and length", buffer.readableBytes(), 4); } short tag = buffer.readShort(); int length = buffer.readUnsignedShort(); // check if we have enough data for the TLV if (buffer.readableBytes() < length) { throw new NotEnoughDataInBufferException("Parsing TLV value", buffer.readableBytes(), length); } byte[] value = new byte[length]; buffer.readBytes(value); return new Tlv(tag, value); }
/** * Reads a TLV from a buffer. This method is greedy and will read bytes * even if it won't be able to successfully complete. It's assumed this * method will only be called if its known ahead of time that all bytes * will be available ahead of time. * @param buffer The buffer to read from * @return A new TLV instance * @throws NotEnoughDataInBufferException */ static public Tlv readTlv(ChannelBuffer buffer) throws NotEnoughDataInBufferException { // a TLV is at least 4 bytes (tag+length) if (buffer.readableBytes() < 4) { throw new NotEnoughDataInBufferException("Parsing TLV tag and length", buffer.readableBytes(), 4); } short tag = buffer.readShort(); int length = buffer.readUnsignedShort(); // check if we have enough data for the TLV if (buffer.readableBytes() < length) { throw new NotEnoughDataInBufferException("Parsing TLV value", buffer.readableBytes(), length); } byte[] value = new byte[length]; buffer.readBytes(value); return new Tlv(tag, value); }
/** * Reads a TLV from a buffer. This method is greedy and will read bytes * even if it won't be able to successfully complete. It's assumed this * method will only be called if its known ahead of time that all bytes * will be available ahead of time. * @param buffer The buffer to read from * @return A new TLV instance * @throws NotEnoughDataInBufferException */ static public Tlv readTlv(ChannelBuffer buffer) throws NotEnoughDataInBufferException { // a TLV is at least 4 bytes (tag+length) if (buffer.readableBytes() < 4) { throw new NotEnoughDataInBufferException("Parsing TLV tag and length", buffer.readableBytes(), 4); } short tag = buffer.readShort(); int length = buffer.readUnsignedShort(); // check if we have enough data for the TLV if (buffer.readableBytes() < length) { throw new NotEnoughDataInBufferException("Parsing TLV value", buffer.readableBytes(), length); } byte[] value = new byte[length]; buffer.readBytes(value); return new Tlv(tag, value); }