update it

This commit is contained in:
Sukchan Lee 2017-03-11 19:20:25 +09:00
parent 2dcc5e985b
commit ec01895b5f
2 changed files with 20 additions and 19 deletions

View File

@ -11,8 +11,9 @@ extern "C" {
#define TLV_MODE_T1_L1 1
#define TLV_MODE_T1_L2 2
#define TLV_MODE_T1_L2_I1 3
#define TLV_MODE_T2_L2 4
#define TLV_MODE_T2_L2 3
#define TLV_NO_INSTANCE -1
#define NUM_OF_TLV_NODE 100
@ -32,7 +33,7 @@ typedef struct _tlv_t
/* tlv basic element */
c_uint32_t type;
c_uint32_t length;
c_uint32_t instance;
c_uint8_t instance;
void* value;
/* can be needed in encoding tlv_t*/
@ -57,21 +58,18 @@ CORE_DECLARE(status_t) tlv_final(void);
/* tlv_t encoding functions */
CORE_DECLARE(tlv_t*) tlv_add(tlv_t *headTlv,
c_uint32_t type, c_uint32_t length, c_uint8_t *value);
c_uint32_t type, c_uint32_t length, c_uint8_t *value);
CORE_DECLARE(tlv_t*) tlv_add_with_instance(tlv_t *headTlv,
c_uint32_t type, c_uint32_t length,
c_uint32_t instance, c_uint8_t *value);
c_uint32_t type, c_uint32_t length, c_uint8_t instance, c_uint8_t *value);
CORE_DECLARE(tlv_t*) tlv_copy(c_uint8_t *buff, c_uint32_t buff_len,
c_uint32_t type, c_uint32_t length, c_uint8_t *value);
c_uint32_t type, c_uint32_t length, c_uint8_t *value);
CORE_DECLARE(tlv_t*) tlv_copy_with_instance(
c_uint8_t *buff, c_uint32_t buff_len,
c_uint32_t type, c_uint32_t length,
c_uint32_t instance, c_uint8_t *value);
c_uint8_t *buff, c_uint32_t buff_len,
c_uint32_t type, c_uint32_t length, c_uint8_t instance, c_uint8_t *value);
CORE_DECLARE(tlv_t*) tlv_embed(tlv_t *parent_tlv,
c_uint32_t type, c_uint32_t length, c_uint8_t *value);
c_uint32_t type, c_uint32_t length, c_uint8_t *value);
CORE_DECLARE(tlv_t*) tlv_embed_with_instance(tlv_t *parent_tlv,
c_uint32_t type, c_uint32_t length,
c_uint32_t instance, c_uint8_t *value);
c_uint32_t type, c_uint32_t length, c_uint8_t instance, c_uint8_t *value);
CORE_DECLARE(c_uint32_t) tlv_render(
tlv_t *rootTlv, c_uint8_t *blk, c_uint32_t length, c_uint8_t mode);

View File

@ -259,11 +259,12 @@ tlv_t *tlv_find_root(tlv_t* p_tlv)
tlv_t *tlv_add(tlv_t *head_tlv,
c_uint32_t type, c_uint32_t length, c_uint8_t *value)
{
return tlv_add_with_instance(head_tlv, type, length, 0, value);
return tlv_add_with_instance(head_tlv,
type, length, TLV_NO_INSTANCE, value);
}
tlv_t *tlv_add_with_instance(tlv_t *head_tlv,
c_uint32_t type, c_uint32_t length, c_uint32_t instance, c_uint8_t *value)
c_uint32_t type, c_uint32_t length, c_uint8_t instance, c_uint8_t *value)
{
tlv_t* curr_tlv = head_tlv;
tlv_t* new_tlv = NULL;
@ -309,11 +310,12 @@ tlv_t *tlv_add_with_instance(tlv_t *head_tlv,
tlv_t *tlv_copy(c_uint8_t *buff, c_uint32_t buff_len,
c_uint32_t type, c_uint32_t length, c_uint8_t *value)
{
return tlv_copy_with_instance(buff, buff_len, type, length, 0, value);
return tlv_copy_with_instance(buff, buff_len,
type, length, TLV_NO_INSTANCE, value);
}
tlv_t *tlv_copy_with_instance(c_uint8_t *buff, c_uint32_t buff_len,
c_uint32_t type, c_uint32_t length, c_uint32_t instance, c_uint8_t *value)
c_uint32_t type, c_uint32_t length, c_uint8_t instance, c_uint8_t *value)
{
tlv_t* new_tlv = NULL;
@ -338,11 +340,12 @@ tlv_t *tlv_copy_with_instance(c_uint8_t *buff, c_uint32_t buff_len,
tlv_t *tlv_embed(tlv_t *parent_tlv,
c_uint32_t type, c_uint32_t length, c_uint8_t *value)
{
return tlv_embed_with_instance(parent_tlv, type, length, 0, value);
return tlv_embed_with_instance(parent_tlv,
type, length, TLV_NO_INSTANCE, value);
}
tlv_t *tlv_embed_with_instance(tlv_t *parent_tlv,
c_uint32_t type, c_uint32_t length, c_uint32_t instance, c_uint8_t *value)
c_uint32_t type, c_uint32_t length, c_uint8_t instance, c_uint8_t *value)
{
tlv_t* new_tlv = NULL, *root_tlv = NULL;