@@ -50,9 +50,116 @@ struct ynl_policy_nest nfsd_rpc_status_nest = {
50
50
/* Common nested types */
51
51
/* ============== NFSD_CMD_RPC_STATUS_GET ============== */
52
52
/* NFSD_CMD_RPC_STATUS_GET - dump */
53
- void nfsd_rpc_status_get_list_free ( struct nfsd_rpc_status_get_list * rsp )
53
+ int nfsd_rpc_status_get_rsp_dump_parse ( const struct nlmsghdr * nlh , void * data )
54
54
{
55
- struct nfsd_rpc_status_get_list * next = rsp ;
55
+ struct nfsd_rpc_status_get_rsp_dump * dst ;
56
+ struct ynl_parse_arg * yarg = data ;
57
+ unsigned int n_compound_ops = 0 ;
58
+ const struct nlattr * attr ;
59
+ int i ;
60
+
61
+ dst = yarg -> data ;
62
+
63
+ if (dst -> compound_ops )
64
+ return ynl_error_parse (yarg , "attribute already present (rpc-status.compound-ops)" );
65
+
66
+ mnl_attr_for_each (attr , nlh , sizeof (struct genlmsghdr )) {
67
+ unsigned int type = mnl_attr_get_type (attr );
68
+
69
+ if (type == NFSD_A_RPC_STATUS_XID ) {
70
+ if (ynl_attr_validate (yarg , attr ))
71
+ return MNL_CB_ERROR ;
72
+ dst -> _present .xid = 1 ;
73
+ dst -> xid = mnl_attr_get_u32 (attr );
74
+ } else if (type == NFSD_A_RPC_STATUS_FLAGS ) {
75
+ if (ynl_attr_validate (yarg , attr ))
76
+ return MNL_CB_ERROR ;
77
+ dst -> _present .flags = 1 ;
78
+ dst -> flags = mnl_attr_get_u32 (attr );
79
+ } else if (type == NFSD_A_RPC_STATUS_PROG ) {
80
+ if (ynl_attr_validate (yarg , attr ))
81
+ return MNL_CB_ERROR ;
82
+ dst -> _present .prog = 1 ;
83
+ dst -> prog = mnl_attr_get_u32 (attr );
84
+ } else if (type == NFSD_A_RPC_STATUS_VERSION ) {
85
+ if (ynl_attr_validate (yarg , attr ))
86
+ return MNL_CB_ERROR ;
87
+ dst -> _present .version = 1 ;
88
+ dst -> version = mnl_attr_get_u8 (attr );
89
+ } else if (type == NFSD_A_RPC_STATUS_PROC ) {
90
+ if (ynl_attr_validate (yarg , attr ))
91
+ return MNL_CB_ERROR ;
92
+ dst -> _present .proc = 1 ;
93
+ dst -> proc = mnl_attr_get_u32 (attr );
94
+ } else if (type == NFSD_A_RPC_STATUS_SERVICE_TIME ) {
95
+ if (ynl_attr_validate (yarg , attr ))
96
+ return MNL_CB_ERROR ;
97
+ dst -> _present .service_time = 1 ;
98
+ dst -> service_time = mnl_attr_get_u64 (attr );
99
+ } else if (type == NFSD_A_RPC_STATUS_SADDR4 ) {
100
+ if (ynl_attr_validate (yarg , attr ))
101
+ return MNL_CB_ERROR ;
102
+ dst -> _present .saddr4 = 1 ;
103
+ dst -> saddr4 = mnl_attr_get_u32 (attr );
104
+ } else if (type == NFSD_A_RPC_STATUS_DADDR4 ) {
105
+ if (ynl_attr_validate (yarg , attr ))
106
+ return MNL_CB_ERROR ;
107
+ dst -> _present .daddr4 = 1 ;
108
+ dst -> daddr4 = mnl_attr_get_u32 (attr );
109
+ } else if (type == NFSD_A_RPC_STATUS_SADDR6 ) {
110
+ unsigned int len ;
111
+
112
+ if (ynl_attr_validate (yarg , attr ))
113
+ return MNL_CB_ERROR ;
114
+
115
+ len = mnl_attr_get_payload_len (attr );
116
+ dst -> _present .saddr6_len = len ;
117
+ dst -> saddr6 = malloc (len );
118
+ memcpy (dst -> saddr6 , mnl_attr_get_payload (attr ), len );
119
+ } else if (type == NFSD_A_RPC_STATUS_DADDR6 ) {
120
+ unsigned int len ;
121
+
122
+ if (ynl_attr_validate (yarg , attr ))
123
+ return MNL_CB_ERROR ;
124
+
125
+ len = mnl_attr_get_payload_len (attr );
126
+ dst -> _present .daddr6_len = len ;
127
+ dst -> daddr6 = malloc (len );
128
+ memcpy (dst -> daddr6 , mnl_attr_get_payload (attr ), len );
129
+ } else if (type == NFSD_A_RPC_STATUS_SPORT ) {
130
+ if (ynl_attr_validate (yarg , attr ))
131
+ return MNL_CB_ERROR ;
132
+ dst -> _present .sport = 1 ;
133
+ dst -> sport = mnl_attr_get_u16 (attr );
134
+ } else if (type == NFSD_A_RPC_STATUS_DPORT ) {
135
+ if (ynl_attr_validate (yarg , attr ))
136
+ return MNL_CB_ERROR ;
137
+ dst -> _present .dport = 1 ;
138
+ dst -> dport = mnl_attr_get_u16 (attr );
139
+ } else if (type == NFSD_A_RPC_STATUS_COMPOUND_OPS ) {
140
+ n_compound_ops ++ ;
141
+ }
142
+ }
143
+
144
+ if (n_compound_ops ) {
145
+ dst -> compound_ops = calloc (n_compound_ops , sizeof (* dst -> compound_ops ));
146
+ dst -> n_compound_ops = n_compound_ops ;
147
+ i = 0 ;
148
+ mnl_attr_for_each (attr , nlh , sizeof (struct genlmsghdr )) {
149
+ if (mnl_attr_get_type (attr ) == NFSD_A_RPC_STATUS_COMPOUND_OPS ) {
150
+ dst -> compound_ops [i ] = mnl_attr_get_u32 (attr );
151
+ i ++ ;
152
+ }
153
+ }
154
+ }
155
+
156
+ return MNL_CB_OK ;
157
+ }
158
+
159
+ void
160
+ nfsd_rpc_status_get_rsp_list_free (struct nfsd_rpc_status_get_rsp_list * rsp )
161
+ {
162
+ struct nfsd_rpc_status_get_rsp_list * next = rsp ;
56
163
57
164
while ((void * )next != YNL_LIST_END ) {
58
165
rsp = next ;
@@ -65,15 +172,16 @@ void nfsd_rpc_status_get_list_free(struct nfsd_rpc_status_get_list *rsp)
65
172
}
66
173
}
67
174
68
- struct nfsd_rpc_status_get_list * nfsd_rpc_status_get_dump (struct ynl_sock * ys )
175
+ struct nfsd_rpc_status_get_rsp_list *
176
+ nfsd_rpc_status_get_dump (struct ynl_sock * ys )
69
177
{
70
178
struct ynl_dump_state yds = {};
71
179
struct nlmsghdr * nlh ;
72
180
int err ;
73
181
74
182
yds .ys = ys ;
75
- yds .alloc_sz = sizeof (struct nfsd_rpc_status_get_list );
76
- yds .cb = nfsd_rpc_status_get_rsp_parse ;
183
+ yds .alloc_sz = sizeof (struct nfsd_rpc_status_get_rsp_list );
184
+ yds .cb = nfsd_rpc_status_get_rsp_dump_parse ;
77
185
yds .rsp_cmd = NFSD_CMD_RPC_STATUS_GET ;
78
186
yds .rsp_policy = & nfsd_rpc_status_nest ;
79
187
@@ -86,7 +194,7 @@ struct nfsd_rpc_status_get_list *nfsd_rpc_status_get_dump(struct ynl_sock *ys)
86
194
return yds .first ;
87
195
88
196
free_list :
89
- nfsd_rpc_status_get_list_free (yds .first );
197
+ nfsd_rpc_status_get_rsp_list_free (yds .first );
90
198
return NULL ;
91
199
}
92
200
0 commit comments