@@ -44,8 +44,6 @@ static const NLType genl_ctrl_types[] = {
4444 [CTRL_ATTR_OP ] = { .type = NETLINK_TYPE_U32 },
4545};
4646
47- DEFINE_TYPE_SYSTEM (genl_ctrl );
48-
4947/***************** genl batadv type systems *****************/
5048static const NLType genl_batadv_types [] = {
5149 [BATADV_ATTR_VERSION ] = { .type = NETLINK_TYPE_STRING },
@@ -110,8 +108,6 @@ static const NLType genl_batadv_types[] = {
110108 [BATADV_ATTR_THROUGHPUT_OVERRIDE ] = { .type = NETLINK_TYPE_U32 },
111109};
112110
113- DEFINE_TYPE_SYSTEM (genl_batadv );
114-
115111/***************** genl fou type systems *****************/
116112static const NLType genl_fou_types [] = {
117113 [FOU_ATTR_PORT ] = { .type = NETLINK_TYPE_U16 },
@@ -127,8 +123,6 @@ static const NLType genl_fou_types[] = {
127123 [FOU_ATTR_IFINDEX ] = { .type = NETLINK_TYPE_U32 },
128124};
129125
130- DEFINE_TYPE_SYSTEM (genl_fou );
131-
132126/***************** genl l2tp type systems *****************/
133127static const NLType genl_l2tp_types [] = {
134128 [L2TP_ATTR_PW_TYPE ] = { .type = NETLINK_TYPE_U16 },
@@ -160,8 +154,6 @@ static const NLType genl_l2tp_types[] = {
160154 [L2TP_ATTR_UDP_ZERO_CSUM6_RX ] = { .type = NETLINK_TYPE_FLAG },
161155};
162156
163- DEFINE_TYPE_SYSTEM (genl_l2tp );
164-
165157/***************** genl macsec type systems *****************/
166158static const NLType genl_macsec_rxsc_types [] = {
167159 [MACSEC_RXSC_ATTR_SCI ] = { .type = NETLINK_TYPE_U64 },
@@ -185,8 +177,6 @@ static const NLType genl_macsec_types[] = {
185177 [MACSEC_ATTR_SA_CONFIG ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_macsec_sa_type_system },
186178};
187179
188- DEFINE_TYPE_SYSTEM (genl_macsec );
189-
190180/***************** genl nl80211 type systems *****************/
191181static const NLType genl_nl80211_types [] = {
192182 [NL80211_ATTR_IFINDEX ] = { .type = NETLINK_TYPE_U32 },
@@ -195,8 +185,6 @@ static const NLType genl_nl80211_types[] = {
195185 [NL80211_ATTR_IFTYPE ] = { .type = NETLINK_TYPE_U32 },
196186};
197187
198- DEFINE_TYPE_SYSTEM (genl_nl80211 );
199-
200188/***************** genl wireguard type systems *****************/
201189static const NLType genl_wireguard_allowedip_types [] = {
202190 [WGALLOWEDIP_A_FAMILY ] = { .type = NETLINK_TYPE_U16 },
@@ -227,28 +215,20 @@ static const NLType genl_wireguard_types[] = {
227215 [WGDEVICE_A_PEERS ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_wireguard_peer_type_system },
228216};
229217
230- DEFINE_TYPE_SYSTEM (genl_wireguard );
231-
232218/***************** genl families *****************/
233- static const NLType genl_types [] = {
234- [ SD_GENL_ID_CTRL ] = { .type = NETLINK_TYPE_NESTED , .type_system = & genl_ctrl_type_system , . size = sizeof ( struct genlmsghdr ) },
235- [ SD_GENL_WIREGUARD ] = { .type = NETLINK_TYPE_NESTED , . type_system = & genl_wireguard_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 ) },
219+ static const NLTypeSystemUnionElement genl_type_systems [] = {
220+ { .name = CTRL_GENL_NAME , .type_system = TYPE_SYSTEM_FROM_TYPE ( genl_ctrl ) , },
221+ { .name = BATADV_NL_NAME , . type_system = TYPE_SYSTEM_FROM_TYPE ( genl_batadv ), },
222+ { . name = FOU_GENL_NAME , . type_system = TYPE_SYSTEM_FROM_TYPE ( genl_fou ) , },
223+ { .name = L2TP_GENL_NAME , .type_system = TYPE_SYSTEM_FROM_TYPE ( genl_l2tp ) , },
224+ { .name = MACSEC_GENL_NAME , .type_system = TYPE_SYSTEM_FROM_TYPE ( genl_macsec ) , },
225+ { .name = NL80211_GENL_NAME , .type_system = TYPE_SYSTEM_FROM_TYPE ( genl_nl80211 ) , },
226+ { .name = WG_GENL_NAME , . type_system = TYPE_SYSTEM_FROM_TYPE ( genl_wireguard ), },
241227};
242228
243- DEFINE_TYPE_SYSTEM (genl );
244-
245- int genl_get_type (sd_netlink * genl , uint16_t nlmsg_type , const NLType * * ret ) {
246- sd_genl_family_t family ;
247- int r ;
248-
249- r = nlmsg_type_to_genl_family (genl , nlmsg_type , & family );
250- if (r < 0 )
251- return r ;
229+ /* This is the root type system union, so match_attribute is not necessary. */
230+ DEFINE_TYPE_SYSTEM_UNION_MATCH_SIBLING (genl , 0 );
252231
253- return type_system_get_type (& genl_type_system , ret , family );
232+ int genl_get_type_system_by_name (const char * name , const NLTypeSystem * * ret ) {
233+ return type_system_union_get_type_system_by_string (& genl_type_system_union , ret , name );
254234}
0 commit comments