Module pdu_syntax
SMPP PDU Library
Library functions for the SMPP PDU manipulation.
Changes 0.1 -> 0.2
[10 Feb 2004]
- Removed pdu_syntax:get_value/2 and
pdu_syntax:set_value/3. Using dictionary API instead.
pdu_syntax functions are no longer used beyond operation API.
[01 Mar 2004]
Changes 0.2 -> 1.2
[13 Jul 2004]
- Condition CommandId of 16#800000000 removed from
guards in functions pack/2 and
unpack/2.
There was one 0 too many on that conditions.
Now the command_status is assumed to be always 0 on request PDUs.
.Copyright © 2003 - 2004 Enrique Marcote Peña
Version: 1.2, {19 Mar 2003} 11:56:46.
Authors: Enrique Marcote Peña (mpquique_at_users.sourceforge.net) [web site: http://oserl.sourceforge.net/].
SMPP PDU Library
Library functions for the SMPP PDU manipulation.
Changes 0.1 -> 0.2
[10 Feb 2004]
- Removed pdu_syntax:get_value/2 and
pdu_syntax:set_value/3. Using dictionary API instead.
pdu_syntax functions are no longer used beyond operation API.
[01 Mar 2004]
Changes 0.2 -> 1.2
[13 Jul 2004]
- Condition CommandId of 16#800000000 removed from
guards in functions pack/2 and
unpack/2.
There was one 0 too many on that conditions.
Now the command_status is assumed to be always 0 on request PDUs.
command_id/1 | Gets the command_id of a PDU (binary or dictionary). |
new_pdu/4 | Creates a new PDU dictionary for a given the CommandId, a
CommandStatus, SequenceNumber and a list of
initial body values. |
pack/2 | Packs an SMPP PDU dictionary into the corresponding byte stream
given the PduType. |
sequence_number/1 | Gets the sequence_number of a PDU (binary or dictionary). |
unpack/2 | Unpacks an SMPP Binary PDU (octet stream) into the corresponding
PDU dictionary according to PduType. |
command_id(PduDict::Pdu) -> int()
Gets the command_id of a PDU (binary or dictionary).
If the PDU is malformed and the command_id can not be found, the
function crashes.
new_pdu(CommandId, CommandStatus, SequenceNumber, Body) -> PduDict
Creates a new PDU dictionary for a given the CommandId, a
CommandStatus, SequenceNumber and a list of
initial body values. Every pair of the Body list must be on
the form {Key, Value}.
The Body parameter list is ignored whenever
CommandStatus is different from 0.
pack(PduDict, Type::PduType) -> Result
- PduDict = dictionary()
- PduType = {pdu, StdsTypes, TlvsTypes}
- StdsTypes = [standard()]
- TlvsTypes = [tlv()]
- Result = {ok, BinaryPdu} | {error, CommandId, CommandStatus, SequenceNumber}
- BinaryPdu = bin()
- CommandId = CmdId | Other
- Other = int()
- CommandStatus = int()
- SequenceNumber = int()
Packs an SMPP PDU dictionary into the corresponding byte stream
given the PduType.
This function generates an exception if command_id,
command_status, sequence_number are not present
on the PDU dictionary.
Possible return values are:
- {error, Other, ?ESME_RINVCMDID, SequenceNumber} if the
command_id on the PduDict is Other and doesn't
match the command_id given as the parameter CmdId.
- {error, CmdId, CommandStatus, SequenceNumber} where
CommandStatus is ?ESME_RUNKNOWNERR or an
error code associated to the parameter that caused the failure. The
command_id matches CmdId but a packing error was
encountered.
- {ok, BinaryPdu} if the PDU was successfully packed.
See also: pack_body/3.
sequence_number(PduDict::Pdu) -> int()
Gets the sequence_number of a PDU (binary or dictionary).
If the PDU is malformed and the sequence_number can not be found,
the function crashes.
unpack(BinaryPdu, Type::PduType) -> Result
- BinaryPdu = bin()
- PduType = {pdu, StdsTypes, TlvsTypes}
- StdsTypes = [standard()]
- TlvsTypes = [tlv()]
- Result = {ok, PduDict} | {error, CommandId, CommandStatus, SequenceNumber}
- PduDict = dictionary()
- Error = int()
- CommandId = undefined | int()
- CommandStatus = int()
- SequenceNumber = int()
Unpacks an SMPP Binary PDU (octet stream) into the corresponding
PDU dictionary according to PduType.
This function returns:
- {error, CommandId, ?ESME_RINVCMDID, SequenceNumber} if
the command_id on the PduDict doesn't match the command_id
given on PduType
- {error, CommandId, ?ESME_RINVCMDLEN, SequenceNumber} if
the PDU is malformed. The CommandId might be the atom
undefined and the SequenceNumber 0 if the
PDU is completly unreadable.
- {error, CmdId, CommandStatus, SequenceNumber} where
CommandStatus is ?ESME_RUNKNOWNERR or an error
code associated to the parameter that caused the failure. The
command_id CmdId and the SequenceNumber are
also included in the error report.
- {ok, PduDict} if the PDU was successfully unpacked.
See also: unpack_body/3.