Skip to content

Commit e2e9cc5

Browse files
committed
Prepare for submsg
Prepare for construting Struct that represent sub messages. Signed-off-by: Zibo Gong <[email protected]>
1 parent 95b890c commit e2e9cc5

File tree

4 files changed

+287
-50
lines changed

4 files changed

+287
-50
lines changed

lib/ynl-priv.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum ynl_policy_type {
2727
YNL_PT_UINT,
2828
YNL_PT_NUL_STR,
2929
YNL_PT_BITFIELD32,
30+
YNL_PT_SUBMSG,
3031
};
3132

3233
enum ynl_parse_result {
@@ -46,6 +47,9 @@ typedef int (
4647
struct ynl_policy_attr {
4748
const char* name;
4849
enum ynl_policy_type type;
50+
__u8 is_submsg;
51+
__u8 is_selector;
52+
__u16 selector_type;
4953
unsigned int len;
5054
struct ynl_policy_nest* nest;
5155
};
@@ -103,6 +107,8 @@ struct nlmsghdr*
103107
ynl_gemsg_start_dump(struct ynl_sock* ys, __u32 id, __u8 cmd, __u8 version);
104108

105109
int ynl_attr_validate(struct ynl_parse_arg* yarg, const struct nlattr* attr);
110+
int ynl_submsg_failed(struct ynl_parse_arg *yarg, const char *field_name,
111+
const char *sel_name);
106112

107113
/* YNL specific helpers used by the auto-generated code */
108114

lib/ynl.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,15 @@ int ynl_attr_validate(struct ynl_parse_arg* yarg, const struct nlattr* attr) {
455455
return 0;
456456
}
457457

458+
int ynl_submsg_failed(struct ynl_parse_arg *yarg, const char *field_name,
459+
const char *sel_name)
460+
{
461+
yerr(yarg->ys, YNL_ERROR_SUBMSG_KEY,
462+
"Parsing error: Sub-message key not set (msg %s, key %s)",
463+
field_name, sel_name);
464+
return YNL_PARSE_CB_ERROR;
465+
}
466+
458467
/* Generic code */
459468

460469
static void ynl_err_reset(struct ynl_sock* ys) {

lib/ynl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ enum ynl_error_code {
2222
YNL_ERROR_INV_RESP,
2323
YNL_ERROR_INPUT_INVALID,
2424
YNL_ERROR_INPUT_TOO_BIG,
25+
YNL_ERROR_SUBMSG_KEY,
2526
};
2627

2728
/**

0 commit comments

Comments
 (0)