4. Other unpackaging function of data structures

The function smpp34_unpack2( ... ) has the same efect that smpp34_unpack( ... ), but it doesn't need the command_id parameter. All functions need to identify the command_id, because buffer parsing depend about command_id. The function smpp34_unpack2( ... ) returns an integer value that describes the operation result. A value distinct of 0 (zero) is an internal error in the unpackaging attempt. Then there is a text description in the global variable smpp34_strerror. The complete code is showed.

extern int smpp34_errno;
extern char smpp34_strerror[2048];

int smpp34_unpack2( void    *tt,     /* out */
                    uint8_t *ptrBuf, /* in  */
                    int     ptrLen,  /* in  */ )
{
    uint32_t cmdid;
    uint32_t tempo;
    memcpy(&tempo, ptrBuf + 4, sizeof(uint32_t)); /* get command_id PDU */
    cmdid = ntohl( tempo );
    return( smpp34_unpack(cmdid, tt, ptrBuf, ptrLen) );
};
 
    
Where:

tt: It's a pointer to one of the data structures listed in the introduction and it corresponds to the first parameter value. The pointer to that structure describes where the content of the buffer is to be stored.

ptrBuf: Is a buffer pointer, where the packaged PDU is stored and is ready to be processed.

ptrLen: This variable refers to the buffer lenght above described.