I'm trying to encode/decode tlv msg data using C. Actually im newbie about TLV formatting. I just found few codes from the Google and i do not understand them.
unsigned char *tlv_buffer = NULL;
int size = 1;
int len = 0;
int result;
tlv_buffer = BKS_MALLOC(size);
result = append_bertlv_data(&tlv_buffer, &size, &len, 0xDF04, 2, "\x34\x56");
result = append_bertlv_data(&tlv_buffer, &size, &len, 0xDF81, 3, "ref");
append_bertlv_data:
int append_bertlv_data ( unsigned char ** buf_data, unsigned int buf_size,unsigned int * buf_len, unsigned int tag, unsigned int len, constunsigned char * value )
buf_data
As input, a pointer to the existing buffer to which the BER-TLV data element shall be appended. As output, the pointer to the possibly re-allocated buffer.
buf_size
The size of the allocated memory.
buf_len
The length of data written in the buffer.
I just need to understand buf_data (buffer) and its obliagtion. Anyone help me pls?