tlvast.h

Mon, 01 Sep 2025 00:14:59 +0800

author
Gong Zhile <gongzl@stu.hebust.edu.cn>
date
Mon, 01 Sep 2025 00:14:59 +0800
changeset 0
59c92fa19678
permissions
-rw-r--r--

Initial Lexer/Parser

0
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
1 #ifndef _TLVAST_H_
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
2 #define _TLVAST_H_
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
3
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
4 #include <stddef.h>
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
5 #include <sys/queue.h>
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
6
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
7 enum tlv_ftype {
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
8 TLV_TYPE_NONE,
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
9 TLV_TYPE_STRING,
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
10 TLV_TYPE_U8,
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
11 TLV_TYPE_U16,
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
12 TLV_TYPE_U32,
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
13 TLV_TYPE_U64,
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
14 };
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
15
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
16 struct tlv_field {
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
17 enum tlv_ftype type;
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
18 char *name;
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
19 int tag;
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
20 TAILQ_ENTRY(tlv_field) entries;
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
21 };
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
22
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
23 TAILQ_HEAD(tlv_field_list_head, tlv_field);
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
24
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
25 struct tlv {
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
26 char *name;
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
27 int tag;
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
28 TAILQ_HEAD(fields_head, tlv_field) fields;
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
29 TAILQ_ENTRY(tlv) entries;
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
30 };
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
31
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
32 TAILQ_HEAD(tlv_list_head, tlv);
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
33
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
34 extern struct tlv_list_head g_tlvs;
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
35
59c92fa19678 Initial Lexer/Parser
Gong Zhile <gongzl@stu.hebust.edu.cn>
parents:
diff changeset
36 #endif /* _TLBAST_H_ */

mercurial