@@ -20,20 +20,14 @@ static const NLType genl_ctrl_mcast_group_types[] = {
2020 [CTRL_ATTR_MCAST_GRP_ID ] = { .type = NETLINK_TYPE_U32 },
2121};
2222
23- static const NLTypeSystem genl_ctrl_mcast_group_type_system = {
24- .count = ELEMENTSOF (genl_ctrl_mcast_group_types ),
25- .types = genl_ctrl_mcast_group_types ,
26- };
23+ DEFINE_TYPE_SYSTEM (genl_ctrl_mcast_group );
2724
2825static const NLType genl_ctrl_ops_types [] = {
2926 [CTRL_ATTR_OP_ID ] = { .type = NETLINK_TYPE_U32 },
3027 [CTRL_ATTR_OP_FLAGS ] = { .type = NETLINK_TYPE_U32 },
3128};
3229
33- static const NLTypeSystem genl_ctrl_ops_type_system = {
34- .count = ELEMENTSOF (genl_ctrl_ops_types ),
35- .types = genl_ctrl_ops_types ,
36- };
30+ DEFINE_TYPE_SYSTEM (genl_ctrl_ops );
3731
3832static const NLType genl_ctrl_types [] = {
3933 [CTRL_ATTR_FAMILY_ID ] = { .type = NETLINK_TYPE_U16 },
@@ -50,10 +44,7 @@ static const NLType genl_ctrl_types[] = {
5044 [CTRL_ATTR_OP ] = { .type = NETLINK_TYPE_U32 },
5145};
5246
53- static const NLTypeSystem genl_ctrl_type_system = {
54- .count = ELEMENTSOF (genl_ctrl_types ),
55- .types = genl_ctrl_types ,
56- };
47+ DEFINE_TYPE_SYSTEM (genl_ctrl );
5748
5849/***************** genl batadv type systems *****************/
5950static const NLType genl_batadv_types [] = {
@@ -119,10 +110,7 @@ static const NLType genl_batadv_types[] = {
119110 [BATADV_ATTR_THROUGHPUT_OVERRIDE ] = { .type = NETLINK_TYPE_U32 },
120111};
121112
122- static const NLTypeSystem genl_batadv_type_system = {
123- .count = ELEMENTSOF (genl_batadv_types ),
124- .types = genl_batadv_types ,
125- };
113+ DEFINE_TYPE_SYSTEM (genl_batadv );
126114
127115/***************** genl fou type systems *****************/
128116static const NLType genl_fou_types [] = {
@@ -139,10 +127,7 @@ static const NLType genl_fou_types[] = {
139127 [FOU_ATTR_IFINDEX ] = { .type = NETLINK_TYPE_U32 },
140128};
141129
142- static const NLTypeSystem genl_fou_type_system = {
143- .count = ELEMENTSOF (genl_fou_types ),
144- .types = genl_fou_types ,
145- };
130+ DEFINE_TYPE_SYSTEM (genl_fou );
146131
147132/***************** genl l2tp type systems *****************/
148133static const NLType genl_l2tp_types [] = {
@@ -175,20 +160,14 @@ static const NLType genl_l2tp_types[] = {
175160 [L2TP_ATTR_UDP_ZERO_CSUM6_RX ] = { .type = NETLINK_TYPE_FLAG },
176161};
177162
178- static const NLTypeSystem genl_l2tp_type_system = {
179- .count = ELEMENTSOF (genl_l2tp_types ),
180- .types = genl_l2tp_types ,
181- };
163+ DEFINE_TYPE_SYSTEM (genl_l2tp );
182164
183165/***************** genl macsec type systems *****************/
184166static const NLType genl_macsec_rxsc_types [] = {
185167 [MACSEC_RXSC_ATTR_SCI ] = { .type = NETLINK_TYPE_U64 },
186168};
187169
188- static const NLTypeSystem genl_macsec_rxsc_type_system = {
189- .count = ELEMENTSOF (genl_macsec_rxsc_types ),
190- .types = genl_macsec_rxsc_types ,
191- };
170+ DEFINE_TYPE_SYSTEM (genl_macsec_rxsc );
192171
193172static const NLType genl_macsec_sa_types [] = {
194173 [MACSEC_SA_ATTR_AN ] = { .type = NETLINK_TYPE_U8 },
@@ -198,21 +177,15 @@ static const NLType genl_macsec_sa_types[] = {
198177 [MACSEC_SA_ATTR_KEY ] = { .size = MACSEC_MAX_KEY_LEN },
199178};
200179
201- static const NLTypeSystem genl_macsec_sa_type_system = {
202- .count = ELEMENTSOF (genl_macsec_sa_types ),
203- .types = genl_macsec_sa_types ,
204- };
180+ DEFINE_TYPE_SYSTEM (genl_macsec_sa );
205181
206182static const NLType genl_macsec_types [] = {
207183 [MACSEC_ATTR_IFINDEX ] = { .type = NETLINK_TYPE_U32 },
208184 [MACSEC_ATTR_RXSC_CONFIG ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_macsec_rxsc_type_system },
209185 [MACSEC_ATTR_SA_CONFIG ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_macsec_sa_type_system },
210186};
211187
212- static const NLTypeSystem genl_macsec_type_system = {
213- .count = ELEMENTSOF (genl_macsec_types ),
214- .types = genl_macsec_types ,
215- };
188+ DEFINE_TYPE_SYSTEM (genl_macsec );
216189
217190/***************** genl nl80211 type systems *****************/
218191static const NLType genl_nl80211_types [] = {
@@ -222,10 +195,7 @@ static const NLType genl_nl80211_types[] = {
222195 [NL80211_ATTR_IFTYPE ] = { .type = NETLINK_TYPE_U32 },
223196};
224197
225- static const NLTypeSystem genl_nl80211_type_system = {
226- .count = ELEMENTSOF (genl_nl80211_types ),
227- .types = genl_nl80211_types ,
228- };
198+ DEFINE_TYPE_SYSTEM (genl_nl80211 );
229199
230200/***************** genl wireguard type systems *****************/
231201static const NLType genl_wireguard_allowedip_types [] = {
@@ -234,10 +204,7 @@ static const NLType genl_wireguard_allowedip_types[] = {
234204 [WGALLOWEDIP_A_CIDR_MASK ] = { .type = NETLINK_TYPE_U8 },
235205};
236206
237- static const NLTypeSystem genl_wireguard_allowedip_type_system = {
238- .count = ELEMENTSOF (genl_wireguard_allowedip_types ),
239- .types = genl_wireguard_allowedip_types ,
240- };
207+ DEFINE_TYPE_SYSTEM (genl_wireguard_allowedip );
241208
242209static const NLType genl_wireguard_peer_types [] = {
243210 [WGPEER_A_PUBLIC_KEY ] = { .size = WG_KEY_LEN },
@@ -248,10 +215,7 @@ static const NLType genl_wireguard_peer_types[] = {
248215 [WGPEER_A_ALLOWEDIPS ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_wireguard_allowedip_type_system },
249216};
250217
251- static const NLTypeSystem genl_wireguard_peer_type_system = {
252- .count = ELEMENTSOF (genl_wireguard_peer_types ),
253- .types = genl_wireguard_peer_types ,
254- };
218+ DEFINE_TYPE_SYSTEM (genl_wireguard_peer );
255219
256220static const NLType genl_wireguard_types [] = {
257221 [WGDEVICE_A_IFINDEX ] = { .type = NETLINK_TYPE_U32 },
@@ -263,26 +227,20 @@ static const NLType genl_wireguard_types[] = {
263227 [WGDEVICE_A_PEERS ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_wireguard_peer_type_system },
264228};
265229
266- static const NLTypeSystem genl_wireguard_type_system = {
267- .count = ELEMENTSOF (genl_wireguard_types ),
268- .types = genl_wireguard_types ,
269- };
230+ DEFINE_TYPE_SYSTEM (genl_wireguard );
270231
271232/***************** genl families *****************/
272233static const NLType genl_types [] = {
273- [SD_GENL_ID_CTRL ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_ctrl_type_system , .size = sizeof (struct genlmsghdr ) },
234+ [SD_GENL_ID_CTRL ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_ctrl_type_system , .size = sizeof (struct genlmsghdr ) },
274235 [SD_GENL_WIREGUARD ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_wireguard_type_system , .size = sizeof (struct genlmsghdr ) },
275- [SD_GENL_FOU ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_fou_type_system , .size = sizeof (struct genlmsghdr ) },
276- [SD_GENL_L2TP ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_l2tp_type_system , .size = sizeof (struct genlmsghdr ) },
277- [SD_GENL_MACSEC ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_macsec_type_system , .size = sizeof (struct genlmsghdr ) },
278- [SD_GENL_NL80211 ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_nl80211_type_system , .size = sizeof (struct genlmsghdr ) },
279- [SD_GENL_BATADV ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_batadv_type_system , .size = sizeof (struct genlmsghdr ) },
236+ [SD_GENL_FOU ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_fou_type_system , .size = sizeof (struct genlmsghdr ) },
237+ [SD_GENL_L2TP ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_l2tp_type_system , .size = sizeof (struct genlmsghdr ) },
238+ [SD_GENL_MACSEC ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_macsec_type_system , .size = sizeof (struct genlmsghdr ) },
239+ [SD_GENL_NL80211 ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_nl80211_type_system , .size = sizeof (struct genlmsghdr ) },
240+ [SD_GENL_BATADV ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_batadv_type_system , .size = sizeof (struct genlmsghdr ) },
280241};
281242
282- static const NLTypeSystem genl_type_system = {
283- .count = ELEMENTSOF (genl_types ),
284- .types = genl_types ,
285- };
243+ DEFINE_TYPE_SYSTEM (genl );
286244
287245int genl_get_type (sd_netlink * genl , uint16_t nlmsg_type , const NLType * * ret ) {
288246 sd_genl_family_t family ;
0 commit comments