summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/protocol.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/common/protocol.c b/src/common/protocol.c
index 90dfc92..0002a96 100644
--- a/src/common/protocol.c
+++ b/src/common/protocol.c
@@ -68,8 +68,24 @@ size_t tlv_data_size(struct tlv_parser *parser)
void tlv_destroy(struct tlv *t)
{
- free(t->data);
- t->length = 0;
+ size_t i = 0;
+ size_t tlv_count;
+ struct tlv *arr;
+ switch (t->type)
+ {
+ case REGURAL:
+ case HEARTBEAT:
+ case DISCOVERY:
+ tlv_count = t->length / sizeof(struct tlv);
+ arr = t->data;
+ for (i = 0; i < tlv_count; i++) {
+ tlv_destroy(&arr[i]);
+ }
+ default:
+ free(t->data);
+ t->length = 0;
+ break;
+ }
}
size_t tlv_raw_size(const struct tlv *t)