title: How to create TLV encode/decode msg data using C?
body: <p>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. </p>
  
  <pre><code>unsigned char *tlv_buffer = NULL;
  int size = 1;
  int len = 0;
  int result;
  
  tlv_buffer = BKS_MALLOC(size);
  result = append_bertlv_data(&amp;tlv_buffer, &amp;size, &amp;len, 0xDF04, 2, "\x34\x56");
  result = append_bertlv_data(&amp;tlv_buffer, &amp;size, &amp;len, 0xDF81, 3, "ref");
  </code></pre>
  
  <p><strong>append_bertlv_data:</strong></p>
  
  <pre><code>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 )
  </code></pre>
  
  <p><strong>buf_data</strong></p>
  
  <p>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. </p>
  
  <p><strong>buf_size</strong></p>
  
  <p>The size of the allocated memory. </p>
  
  <p><strong>buf_len</strong></p>
  
  <p>The length of data written in the buffer. </p>
  
  <p>I just need to understand buf_data (buffer) and its obliagtion. Anyone help me pls?</p>