From ec01895b5fde5f55dbaf9e918ee7468c7583d4f5 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Sat, 11 Mar 2017 19:20:25 +0900 Subject: [PATCH] update it --- lib/core/include/core_tlv.h | 24 +++++++++++------------- lib/core/src/tlv.c | 15 +++++++++------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/core/include/core_tlv.h b/lib/core/include/core_tlv.h index 8c9eadd312..cd054fec26 100644 --- a/lib/core/include/core_tlv.h +++ b/lib/core/include/core_tlv.h @@ -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); diff --git a/lib/core/src/tlv.c b/lib/core/src/tlv.c index de8573cdd6..940a5f5fb2 100644 --- a/lib/core/src/tlv.c +++ b/lib/core/src/tlv.c @@ -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;