The library main focus is to work in packaging and unpackaging of data structures. Independently that this implementation is about SMPP-3.4, the aim is to generate a simple way to implement any proprietary protocol on TCP.
Any developer that attempts to enter in SMPP world, must go through Kannel software (http://www.kannel.org/). However, Kannel project is so big that it discourages anybody willing to develop a simple SMPP application.
So the library focus is to provide an implementation of SMPP-3.4 protocol but just for PDUs handling, taking as independent the managing of TCP connection and SMPP session. As we see, the library is directed to solve just the protocol issue, left to programmers the handling of the other levels in the communication
The API is defined in four functions:
Packed function: In this function the first and last parameters are identifying the data structure that we want to pack. The first parameter indetifies the data structure through an integer and the last one refers to data object.
int smpp34_pack( uint32_t type, /* in */ uint8_t *ptrBuf, /* out */ int ptrSize, /* out */ int *ptrLen, /* out */ void *tt /* in */ ) |
Unpacked function: In this function a pointer to the buffer and its lenght is passed as parameters. The function returns a pointer to a data structure defined by a type field.
int smpp34_unpack( uint32_t type, /* in */ void *tt, /* out */ uint8_t *ptrBuf, /* in */ int ptrLen, /* in */ ) |
Structure dump function: The utility of this function is to provide with a tool for to see the parameters and values of a PDU (data structure). The in parameters refers to data object and the out parameters is a string buffer where the new representation is done.
int smpp34_dumpPdu( uint32_t type, /* in */ uint8_t *dest, /* out */ int size_dest, /* in */ void *tt /* in */ ) |
Buffer dump function: In this function, the in parameters refers to a buffer and the its lenght. This function prints in a external buffer a hexa representation of the binary source.
int smpp34_dumpBuf( uint8_t *dest, /* out */ int destL, /* in */ uint8_t *src, /* in */ int srcL /* in */ ) |
In addition to this function, the global variables that complete the API for developing are defined.
int smpp34_errno; char smpp34_strerror[2048]; |
Besides, all the data structure proprietary of th SMPP protocol are defined. There is a data structure for each PDU definition. For more information about SMPP please refer to SMPP protocol specification.
typedef struct tlv_t tlv_t; typedef struct dad_t dad_t; /* used in SUBMIT_MULTI PDU */ typedef struct udad_t udad_t; /* used in SUBMIT_MULTI_RESP PDU */ typedef struct bind_transmitter_t bind_transmitter_t; typedef struct bind_transmitter_resp_t bind_transmitter_resp_t; typedef struct bind_receiver_t bind_receiver_t; typedef struct bind_receiver_resp_t bind_receiver_resp_t; typedef struct bind_transceiver_t bind_transceiver_t; typedef struct bind_transceiver_resp_t bind_transceiver_resp_t; typedef struct outbind_t outbind_t; typedef struct unbind_t unbind_t; typedef struct unbind_resp_t unbind_resp_t; typedef struct generic_nack_t generic_nack_t; typedef struct submit_sm_t submit_sm_t; typedef struct submit_sm_resp_t submit_sm_resp_t; typedef struct submit_multi_t submit_multi_t; typedef struct submit_multi_resp_t submit_multi_resp_t; typedef struct deliver_sm_t deliver_sm_t; typedef struct deliver_sm_resp_t deliver_sm_resp_t; typedef struct data_sm_t data_sm_t; typedef struct data_sm_resp_t data_sm_resp_t; typedef struct query_sm_t query_sm_t; typedef struct query_sm_resp_t query_sm_resp_t; typedef struct cancel_sm_t cancel_sm_t; typedef struct cancel_sm_resp_t cancel_sm_resp_t; typedef struct replace_sm_t replace_sm_t; typedef struct replace_sm_resp_t replace_sm_resp_t; typedef struct enquire_link_t enquire_link_t; typedef struct alert_notification_t alert_notification_t; |
So if you want to handle optional parameters in SMPP-3.4 protocol, you must use two functions:
int build_tlv( tlv_t **dest, tlv_t *source ); int destroy_tlv( tlv_t *sourceList ); |
int build_dad( dad_t **dest, dad_t *source ); int destroy_dad( dad_t *sourceList ); int build_udad( udad_t **dest, udad_t *source ); int destroy_udad( udad_t *sourceList ); |
We'll see each function in detail. The library gives you an example of each PDU handled.