The functions build_tlv( ... ) and destroy_tlv( ... ) allow to create and destroy elements linked
in a list of variables called optional parameters. This parameters are in
some data structures in the SMPP-3.4 protocol, and they are called optional
parameters.
int build_tlv( tlv_t **dest,
tlv_t *source );
int destroy_tlv( tlv_t *sourceList );
|
dest: This pointer is a reference to pointer of data type tlv_t. In an example, we'll see how use this function.
source: This pointer is a reference to tlv_t.
sourceList: This pointer is a
reference to tlv_t. In destroy_tlv( ... )
the parameter is a list linked reference.
The use of optional parameters is bounded to data type tlv_t that is not present in all data structures of SMPP-3.4 protocol We'll see an example of this function.
#define TEXTO "mensaje de texto numero 01"
:
{
submit_sm_t pdu;
tlv_t tlv;
memset(&tlv, 0, sizeof(tlv_t));
tlv.tag = TLVID_user_message_reference; /* tag present in submit_sm */
tlv.length = sizeof(uint16_t);
tlv.value.val16 = 0x0024; /* valor */
build_tlv( &(pdu.tlv), &tlv ); /* value attached to main structure */
memset(&tlv, 0, sizeof(tlv_t));
tlv.tag = TLVID_more_messages_to_send; /* tag present in submit_sm */
tlv.length = sizeof(uint8_t);
tlv.value.val8 = 0x24; /* valor */
build_tlv( &(pdu.tlv), &tlv ); /* value attached to main structure */
memset(&tlv, 0, sizeof(tlv_t));
tlv.tag = TLVID_message_payload; /* tag present in submit_sm */
tlv.length = strlen(TEXTO);
memcpy(tlv.value.octet, TEXTO, tlv.length); /* valor */
build_tlv( &(pdu.tlv), &tlv ); /* value attached to main structure */
/* Pack and send data in pdu */
destroy_tlv( pdu.tlv ); /* Free pdu list */
}
|