1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2014 Tom Gundersen <teg@jklm.no>
7 systemd is free software; you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation; either version 2.1 of the License, or
10 (at your option) any later version.
12 systemd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public License
18 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 #include <sys/socket.h>
23 #include <linux/netlink.h>
24 #include <linux/rtnetlink.h>
25 #include <linux/can/netlink.h>
26 #include <linux/fib_rules.h>
27 #include <linux/in6.h>
28 #include <linux/veth.h>
29 #include <linux/if_bridge.h>
30 #include <linux/if_addr.h>
31 #include <linux/if_addrlabel.h>
34 #include <linux/if_addr.h>
35 #include <linux/if_bridge.h>
36 #include <linux/if_link.h>
37 #include <linux/if_tunnel.h>
38 #include <linux/fib_rules.h>
40 #if HAVE_VXCAN_INFO_PEER
41 #include <linux/can/vxcan.h>
46 #include "netlink-types.h"
47 #include "string-table.h"
50 /* Maximum ARP IP target defined in kernel */
51 #define BOND_MAX_ARP_TARGETS 16
69 BOND_ARP_TARGETS_MAX
= BOND_MAX_ARP_TARGETS
,
75 const NLTypeSystem
*type_system
;
76 const NLTypeSystemUnion
*type_system_union
;
84 static const NLTypeSystem rtnl_link_type_system
;
86 static const NLType empty_types
[1] = {
87 /* fake array to avoid .types==NULL, which denotes invalid type-systems */
90 static const NLTypeSystem empty_type_system
= {
95 static const NLType rtnl_link_info_data_veth_types
[] = {
96 [VETH_INFO_PEER
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
99 static const NLType rtnl_link_info_data_vxcan_types
[] = {
100 [VXCAN_INFO_PEER
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
103 static const NLType rtnl_link_info_data_ipvlan_types
[] = {
104 [IFLA_IPVLAN_MODE
] = { .type
= NETLINK_TYPE_U16
},
105 [IFLA_IPVLAN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
108 static const NLType rtnl_link_info_data_macvlan_types
[] = {
109 [IFLA_MACVLAN_MODE
] = { .type
= NETLINK_TYPE_U32
},
110 [IFLA_MACVLAN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
113 static const NLType rtnl_link_info_data_bridge_types
[] = {
114 [IFLA_BR_FORWARD_DELAY
] = { .type
= NETLINK_TYPE_U32
},
115 [IFLA_BR_HELLO_TIME
] = { .type
= NETLINK_TYPE_U32
},
116 [IFLA_BR_MAX_AGE
] = { .type
= NETLINK_TYPE_U32
},
117 [IFLA_BR_AGEING_TIME
] = { .type
= NETLINK_TYPE_U32
},
118 [IFLA_BR_STP_STATE
] = { .type
= NETLINK_TYPE_U32
},
119 [IFLA_BR_PRIORITY
] = { .type
= NETLINK_TYPE_U16
},
120 [IFLA_BR_VLAN_FILTERING
] = { .type
= NETLINK_TYPE_U8
},
121 [IFLA_BR_VLAN_PROTOCOL
] = { .type
= NETLINK_TYPE_U16
},
122 [IFLA_BR_GROUP_FWD_MASK
] = { .type
= NETLINK_TYPE_U16
},
123 [IFLA_BR_ROOT_PORT
] = { .type
= NETLINK_TYPE_U16
},
124 [IFLA_BR_ROOT_PATH_COST
] = { .type
= NETLINK_TYPE_U32
},
125 [IFLA_BR_TOPOLOGY_CHANGE
] = { .type
= NETLINK_TYPE_U8
},
126 [IFLA_BR_TOPOLOGY_CHANGE_DETECTED
] = { .type
= NETLINK_TYPE_U8
},
127 [IFLA_BR_HELLO_TIMER
] = { .type
= NETLINK_TYPE_U16
},
128 [IFLA_BR_TCN_TIMER
] = { .type
= NETLINK_TYPE_U16
},
129 [IFLA_BR_TOPOLOGY_CHANGE_TIMER
] = { .type
= NETLINK_TYPE_U16
},
130 [IFLA_BR_GC_TIMER
] = { .type
= NETLINK_TYPE_U64
},
131 [IFLA_BR_GROUP_ADDR
] = { .type
= NETLINK_TYPE_U16
},
132 [IFLA_BR_FDB_FLUSH
] = { .type
= NETLINK_TYPE_U16
},
133 [IFLA_BR_MCAST_ROUTER
] = { .type
= NETLINK_TYPE_U8
},
134 [IFLA_BR_MCAST_SNOOPING
] = { .type
= NETLINK_TYPE_U8
},
135 [IFLA_BR_MCAST_QUERY_USE_IFADDR
] = { .type
= NETLINK_TYPE_U8
},
136 [IFLA_BR_MCAST_QUERIER
] = { .type
= NETLINK_TYPE_U8
},
137 [IFLA_BR_MCAST_HASH_ELASTICITY
] = { .type
= NETLINK_TYPE_U32
},
138 [IFLA_BR_MCAST_HASH_MAX
] = { .type
= NETLINK_TYPE_U16
},
139 [IFLA_BR_MCAST_LAST_MEMBER_CNT
] = { .type
= NETLINK_TYPE_U32
},
140 [IFLA_BR_MCAST_STARTUP_QUERY_CNT
] = { .type
= NETLINK_TYPE_U16
},
141 [IFLA_BR_MCAST_LAST_MEMBER_INTVL
] = { .type
= NETLINK_TYPE_U64
},
142 [IFLA_BR_MCAST_MEMBERSHIP_INTVL
] = { .type
= NETLINK_TYPE_U64
},
143 [IFLA_BR_MCAST_QUERIER_INTVL
] = { .type
= NETLINK_TYPE_U64
},
144 [IFLA_BR_MCAST_QUERY_INTVL
] = { .type
= NETLINK_TYPE_U64
},
145 [IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
] = { .type
= NETLINK_TYPE_U64
},
146 [IFLA_BR_MCAST_STARTUP_QUERY_INTVL
] = { .type
= NETLINK_TYPE_U64
},
147 [IFLA_BR_NF_CALL_IPTABLES
] = { .type
= NETLINK_TYPE_U8
},
148 [IFLA_BR_NF_CALL_IP6TABLES
] = { .type
= NETLINK_TYPE_U8
},
149 [IFLA_BR_NF_CALL_ARPTABLES
] = { .type
= NETLINK_TYPE_U8
},
150 [IFLA_BR_VLAN_DEFAULT_PVID
] = { .type
= NETLINK_TYPE_U16
},
153 static const NLType rtnl_link_info_data_vlan_types
[] = {
154 [IFLA_VLAN_ID
] = { .type
= NETLINK_TYPE_U16
},
156 [IFLA_VLAN_FLAGS] = { .len = sizeof(struct ifla_vlan_flags) },
157 [IFLA_VLAN_EGRESS_QOS] = { .type = NETLINK_TYPE_NESTED },
158 [IFLA_VLAN_INGRESS_QOS] = { .type = NETLINK_TYPE_NESTED },
160 [IFLA_VLAN_PROTOCOL
] = { .type
= NETLINK_TYPE_U16
},
163 static const NLType rtnl_link_info_data_vxlan_types
[] = {
164 [IFLA_VXLAN_ID
] = { .type
= NETLINK_TYPE_U32
},
165 [IFLA_VXLAN_GROUP
] = { .type
= NETLINK_TYPE_IN_ADDR
},
166 [IFLA_VXLAN_LINK
] = { .type
= NETLINK_TYPE_U32
},
167 [IFLA_VXLAN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
168 [IFLA_VXLAN_TTL
] = { .type
= NETLINK_TYPE_U8
},
169 [IFLA_VXLAN_TOS
] = { .type
= NETLINK_TYPE_U8
},
170 [IFLA_VXLAN_LEARNING
] = { .type
= NETLINK_TYPE_U8
},
171 [IFLA_VXLAN_AGEING
] = { .type
= NETLINK_TYPE_U32
},
172 [IFLA_VXLAN_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
173 [IFLA_VXLAN_PORT_RANGE
] = { .type
= NETLINK_TYPE_U32
},
174 [IFLA_VXLAN_PROXY
] = { .type
= NETLINK_TYPE_U8
},
175 [IFLA_VXLAN_RSC
] = { .type
= NETLINK_TYPE_U8
},
176 [IFLA_VXLAN_L2MISS
] = { .type
= NETLINK_TYPE_U8
},
177 [IFLA_VXLAN_L3MISS
] = { .type
= NETLINK_TYPE_U8
},
178 [IFLA_VXLAN_PORT
] = { .type
= NETLINK_TYPE_U16
},
179 [IFLA_VXLAN_GROUP6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
180 [IFLA_VXLAN_LOCAL6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
181 [IFLA_VXLAN_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
182 [IFLA_VXLAN_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_U8
},
183 [IFLA_VXLAN_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_U8
},
184 [IFLA_VXLAN_REMCSUM_TX
] = { .type
= NETLINK_TYPE_U8
},
185 [IFLA_VXLAN_REMCSUM_RX
] = { .type
= NETLINK_TYPE_U8
},
186 [IFLA_VXLAN_GBP
] = { .type
= NETLINK_TYPE_FLAG
},
187 [IFLA_VXLAN_REMCSUM_NOPARTIAL
] = { .type
= NETLINK_TYPE_FLAG
},
188 [IFLA_VXLAN_COLLECT_METADATA
] = { .type
= NETLINK_TYPE_U8
},
189 [IFLA_VXLAN_LABEL
] = { .type
= NETLINK_TYPE_U32
},
190 [IFLA_VXLAN_GPE
] = { .type
= NETLINK_TYPE_FLAG
},
193 static const NLType rtnl_bond_arp_target_types
[] = {
194 [BOND_ARP_TARGETS_0
] = { .type
= NETLINK_TYPE_U32
},
195 [BOND_ARP_TARGETS_1
] = { .type
= NETLINK_TYPE_U32
},
196 [BOND_ARP_TARGETS_2
] = { .type
= NETLINK_TYPE_U32
},
197 [BOND_ARP_TARGETS_3
] = { .type
= NETLINK_TYPE_U32
},
198 [BOND_ARP_TARGETS_4
] = { .type
= NETLINK_TYPE_U32
},
199 [BOND_ARP_TARGETS_5
] = { .type
= NETLINK_TYPE_U32
},
200 [BOND_ARP_TARGETS_6
] = { .type
= NETLINK_TYPE_U32
},
201 [BOND_ARP_TARGETS_7
] = { .type
= NETLINK_TYPE_U32
},
202 [BOND_ARP_TARGETS_8
] = { .type
= NETLINK_TYPE_U32
},
203 [BOND_ARP_TARGETS_9
] = { .type
= NETLINK_TYPE_U32
},
204 [BOND_ARP_TARGETS_10
] = { .type
= NETLINK_TYPE_U32
},
205 [BOND_ARP_TARGETS_11
] = { .type
= NETLINK_TYPE_U32
},
206 [BOND_ARP_TARGETS_12
] = { .type
= NETLINK_TYPE_U32
},
207 [BOND_ARP_TARGETS_13
] = { .type
= NETLINK_TYPE_U32
},
208 [BOND_ARP_TARGETS_14
] = { .type
= NETLINK_TYPE_U32
},
209 [BOND_ARP_TARGETS_MAX
] = { .type
= NETLINK_TYPE_U32
},
212 static const NLTypeSystem rtnl_bond_arp_type_system
= {
213 .count
= ELEMENTSOF(rtnl_bond_arp_target_types
),
214 .types
= rtnl_bond_arp_target_types
,
217 static const NLType rtnl_link_info_data_bond_types
[] = {
218 [IFLA_BOND_MODE
] = { .type
= NETLINK_TYPE_U8
},
219 [IFLA_BOND_ACTIVE_SLAVE
] = { .type
= NETLINK_TYPE_U32
},
220 [IFLA_BOND_MIIMON
] = { .type
= NETLINK_TYPE_U32
},
221 [IFLA_BOND_UPDELAY
] = { .type
= NETLINK_TYPE_U32
},
222 [IFLA_BOND_DOWNDELAY
] = { .type
= NETLINK_TYPE_U32
},
223 [IFLA_BOND_USE_CARRIER
] = { .type
= NETLINK_TYPE_U8
},
224 [IFLA_BOND_ARP_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
225 [IFLA_BOND_ARP_IP_TARGET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_bond_arp_type_system
},
226 [IFLA_BOND_ARP_VALIDATE
] = { .type
= NETLINK_TYPE_U32
},
227 [IFLA_BOND_ARP_ALL_TARGETS
] = { .type
= NETLINK_TYPE_U32
},
228 [IFLA_BOND_PRIMARY
] = { .type
= NETLINK_TYPE_U32
},
229 [IFLA_BOND_PRIMARY_RESELECT
] = { .type
= NETLINK_TYPE_U8
},
230 [IFLA_BOND_FAIL_OVER_MAC
] = { .type
= NETLINK_TYPE_U8
},
231 [IFLA_BOND_XMIT_HASH_POLICY
] = { .type
= NETLINK_TYPE_U8
},
232 [IFLA_BOND_RESEND_IGMP
] = { .type
= NETLINK_TYPE_U32
},
233 [IFLA_BOND_NUM_PEER_NOTIF
] = { .type
= NETLINK_TYPE_U8
},
234 [IFLA_BOND_ALL_SLAVES_ACTIVE
] = { .type
= NETLINK_TYPE_U8
},
235 [IFLA_BOND_MIN_LINKS
] = { .type
= NETLINK_TYPE_U32
},
236 [IFLA_BOND_LP_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
237 [IFLA_BOND_PACKETS_PER_SLAVE
] = { .type
= NETLINK_TYPE_U32
},
238 [IFLA_BOND_AD_LACP_RATE
] = { .type
= NETLINK_TYPE_U8
},
239 [IFLA_BOND_AD_SELECT
] = { .type
= NETLINK_TYPE_U8
},
240 [IFLA_BOND_AD_INFO
] = { .type
= NETLINK_TYPE_NESTED
},
243 static const NLType rtnl_link_info_data_iptun_types
[] = {
244 [IFLA_IPTUN_LINK
] = { .type
= NETLINK_TYPE_U32
},
245 [IFLA_IPTUN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
246 [IFLA_IPTUN_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
247 [IFLA_IPTUN_TTL
] = { .type
= NETLINK_TYPE_U8
},
248 [IFLA_IPTUN_TOS
] = { .type
= NETLINK_TYPE_U8
},
249 [IFLA_IPTUN_PMTUDISC
] = { .type
= NETLINK_TYPE_U8
},
250 [IFLA_IPTUN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
251 [IFLA_IPTUN_PROTO
] = { .type
= NETLINK_TYPE_U8
},
252 [IFLA_IPTUN_6RD_PREFIX
] = { .type
= NETLINK_TYPE_IN_ADDR
},
253 [IFLA_IPTUN_6RD_RELAY_PREFIX
] = { .type
= NETLINK_TYPE_U32
},
254 [IFLA_IPTUN_6RD_PREFIXLEN
] = { .type
= NETLINK_TYPE_U16
},
255 [IFLA_IPTUN_6RD_RELAY_PREFIXLEN
] = { .type
= NETLINK_TYPE_U16
},
256 [IFLA_IPTUN_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
257 [IFLA_IPTUN_ENCAP_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
258 [IFLA_IPTUN_ENCAP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
259 [IFLA_IPTUN_ENCAP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
262 static const NLType rtnl_link_info_data_ipgre_types
[] = {
263 [IFLA_GRE_LINK
] = { .type
= NETLINK_TYPE_U32
},
264 [IFLA_GRE_IFLAGS
] = { .type
= NETLINK_TYPE_U16
},
265 [IFLA_GRE_OFLAGS
] = { .type
= NETLINK_TYPE_U16
},
266 [IFLA_GRE_IKEY
] = { .type
= NETLINK_TYPE_U32
},
267 [IFLA_GRE_OKEY
] = { .type
= NETLINK_TYPE_U32
},
268 [IFLA_GRE_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
269 [IFLA_GRE_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
270 [IFLA_GRE_TTL
] = { .type
= NETLINK_TYPE_U8
},
271 [IFLA_GRE_TOS
] = { .type
= NETLINK_TYPE_U8
},
272 [IFLA_GRE_PMTUDISC
] = { .type
= NETLINK_TYPE_U8
},
273 [IFLA_GRE_FLOWINFO
] = { .type
= NETLINK_TYPE_U32
},
274 [IFLA_GRE_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
275 [IFLA_GRE_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
276 [IFLA_GRE_ENCAP_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
277 [IFLA_GRE_ENCAP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
278 [IFLA_GRE_ENCAP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
281 static const NLType rtnl_link_info_data_ipvti_types
[] = {
282 [IFLA_VTI_LINK
] = { .type
= NETLINK_TYPE_U32
},
283 [IFLA_VTI_IKEY
] = { .type
= NETLINK_TYPE_U32
},
284 [IFLA_VTI_OKEY
] = { .type
= NETLINK_TYPE_U32
},
285 [IFLA_VTI_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
286 [IFLA_VTI_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
289 static const NLType rtnl_link_info_data_ip6tnl_types
[] = {
290 [IFLA_IPTUN_LINK
] = { .type
= NETLINK_TYPE_U32
},
291 [IFLA_IPTUN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
292 [IFLA_IPTUN_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
293 [IFLA_IPTUN_TTL
] = { .type
= NETLINK_TYPE_U8
},
294 [IFLA_IPTUN_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
295 [IFLA_IPTUN_PROTO
] = { .type
= NETLINK_TYPE_U8
},
296 [IFLA_IPTUN_ENCAP_LIMIT
] = { .type
= NETLINK_TYPE_U8
},
297 [IFLA_IPTUN_FLOWINFO
] = { .type
= NETLINK_TYPE_U32
},
300 static const NLType rtnl_link_info_data_vrf_types
[] = {
301 [IFLA_VRF_TABLE
] = { .type
= NETLINK_TYPE_U32
},
304 static const NLType rtnl_link_info_data_geneve_types
[] = {
305 [IFLA_GENEVE_ID
] = { .type
= NETLINK_TYPE_U32
},
306 [IFLA_GENEVE_TTL
] = { .type
= NETLINK_TYPE_U8
},
307 [IFLA_GENEVE_TOS
] = { .type
= NETLINK_TYPE_U8
},
308 [IFLA_GENEVE_PORT
] = { .type
= NETLINK_TYPE_U16
},
309 [IFLA_GENEVE_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
310 [IFLA_GENEVE_REMOTE6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
311 [IFLA_GENEVE_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
312 [IFLA_GENEVE_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_U8
},
313 [IFLA_GENEVE_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_U8
},
314 [IFLA_GENEVE_LABEL
] = { .type
= NETLINK_TYPE_U32
},
317 /* these strings must match the .kind entries in the kernel */
318 static const char* const nl_union_link_info_data_table
[] = {
319 [NL_UNION_LINK_INFO_DATA_BOND
] = "bond",
320 [NL_UNION_LINK_INFO_DATA_BRIDGE
] = "bridge",
321 [NL_UNION_LINK_INFO_DATA_VLAN
] = "vlan",
322 [NL_UNION_LINK_INFO_DATA_VETH
] = "veth",
323 [NL_UNION_LINK_INFO_DATA_DUMMY
] = "dummy",
324 [NL_UNION_LINK_INFO_DATA_MACVLAN
] = "macvlan",
325 [NL_UNION_LINK_INFO_DATA_MACVTAP
] = "macvtap",
326 [NL_UNION_LINK_INFO_DATA_IPVLAN
] = "ipvlan",
327 [NL_UNION_LINK_INFO_DATA_VXLAN
] = "vxlan",
328 [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL
] = "ipip",
329 [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL
] = "gre",
330 [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL
] = "gretap",
331 [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL
] = "ip6gre",
332 [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL
] = "ip6gretap",
333 [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL
] = "sit",
334 [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL
] = "vti",
335 [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL
] = "vti6",
336 [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL
] = "ip6tnl",
337 [NL_UNION_LINK_INFO_DATA_VRF
] = "vrf",
338 [NL_UNION_LINK_INFO_DATA_VCAN
] = "vcan",
339 [NL_UNION_LINK_INFO_DATA_GENEVE
] = "geneve",
340 [NL_UNION_LINK_INFO_DATA_VXCAN
] = "vxcan",
344 DEFINE_STRING_TABLE_LOOKUP(nl_union_link_info_data
, NLUnionLinkInfoData
);
346 static const NLTypeSystem rtnl_link_info_data_type_systems
[] = {
347 [NL_UNION_LINK_INFO_DATA_BOND
] = { .count
= ELEMENTSOF(rtnl_link_info_data_bond_types
),
348 .types
= rtnl_link_info_data_bond_types
},
349 [NL_UNION_LINK_INFO_DATA_BRIDGE
] = { .count
= ELEMENTSOF(rtnl_link_info_data_bridge_types
),
350 .types
= rtnl_link_info_data_bridge_types
},
351 [NL_UNION_LINK_INFO_DATA_VLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vlan_types
),
352 .types
= rtnl_link_info_data_vlan_types
},
353 [NL_UNION_LINK_INFO_DATA_VETH
] = { .count
= ELEMENTSOF(rtnl_link_info_data_veth_types
),
354 .types
= rtnl_link_info_data_veth_types
},
355 [NL_UNION_LINK_INFO_DATA_MACVLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macvlan_types
),
356 .types
= rtnl_link_info_data_macvlan_types
},
357 [NL_UNION_LINK_INFO_DATA_MACVTAP
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macvlan_types
),
358 .types
= rtnl_link_info_data_macvlan_types
},
359 [NL_UNION_LINK_INFO_DATA_IPVLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvlan_types
),
360 .types
= rtnl_link_info_data_ipvlan_types
},
361 [NL_UNION_LINK_INFO_DATA_VXLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vxlan_types
),
362 .types
= rtnl_link_info_data_vxlan_types
},
363 [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_iptun_types
),
364 .types
= rtnl_link_info_data_iptun_types
},
365 [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
366 .types
= rtnl_link_info_data_ipgre_types
},
367 [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
368 .types
= rtnl_link_info_data_ipgre_types
},
369 [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
370 .types
= rtnl_link_info_data_ipgre_types
},
371 [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
372 .types
= rtnl_link_info_data_ipgre_types
},
373 [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_iptun_types
),
374 .types
= rtnl_link_info_data_iptun_types
},
375 [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvti_types
),
376 .types
= rtnl_link_info_data_ipvti_types
},
377 [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvti_types
),
378 .types
= rtnl_link_info_data_ipvti_types
},
379 [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ip6tnl_types
),
380 .types
= rtnl_link_info_data_ip6tnl_types
},
381 [NL_UNION_LINK_INFO_DATA_VRF
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vrf_types
),
382 .types
= rtnl_link_info_data_vrf_types
},
383 [NL_UNION_LINK_INFO_DATA_GENEVE
] = { .count
= ELEMENTSOF(rtnl_link_info_data_geneve_types
),
384 .types
= rtnl_link_info_data_geneve_types
},
385 [NL_UNION_LINK_INFO_DATA_VXCAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vxcan_types
),
386 .types
= rtnl_link_info_data_vxcan_types
},
389 static const NLTypeSystemUnion rtnl_link_info_data_type_system_union
= {
390 .num
= _NL_UNION_LINK_INFO_DATA_MAX
,
391 .lookup
= nl_union_link_info_data_from_string
,
392 .type_systems
= rtnl_link_info_data_type_systems
,
393 .match_type
= NL_MATCH_SIBLING
,
394 .match
= IFLA_INFO_KIND
,
397 static const NLType rtnl_link_info_types
[] = {
398 [IFLA_INFO_KIND
] = { .type
= NETLINK_TYPE_STRING
},
399 [IFLA_INFO_DATA
] = { .type
= NETLINK_TYPE_UNION
, .type_system_union
= &rtnl_link_info_data_type_system_union
},
402 [IFLA_INFO_SLAVE_KIND] = { .type = NETLINK_TYPE_STRING },
403 [IFLA_INFO_SLAVE_DATA] = { .type = NETLINK_TYPE_NESTED },
407 static const NLTypeSystem rtnl_link_info_type_system
= {
408 .count
= ELEMENTSOF(rtnl_link_info_types
),
409 .types
= rtnl_link_info_types
,
412 static const struct NLType rtnl_prot_info_bridge_port_types
[] = {
413 [IFLA_BRPORT_STATE
] = { .type
= NETLINK_TYPE_U8
},
414 [IFLA_BRPORT_COST
] = { .type
= NETLINK_TYPE_U32
},
415 [IFLA_BRPORT_PRIORITY
] = { .type
= NETLINK_TYPE_U16
},
416 [IFLA_BRPORT_MODE
] = { .type
= NETLINK_TYPE_U8
},
417 [IFLA_BRPORT_GUARD
] = { .type
= NETLINK_TYPE_U8
},
418 [IFLA_BRPORT_PROTECT
] = { .type
= NETLINK_TYPE_U8
},
419 [IFLA_BRPORT_FAST_LEAVE
] = { .type
= NETLINK_TYPE_U8
},
420 [IFLA_BRPORT_LEARNING
] = { .type
= NETLINK_TYPE_U8
},
421 [IFLA_BRPORT_UNICAST_FLOOD
] = { .type
= NETLINK_TYPE_U8
},
422 [IFLA_BRPORT_PROXYARP
] = { .type
= NETLINK_TYPE_U8
},
423 [IFLA_BRPORT_LEARNING_SYNC
] = { .type
= NETLINK_TYPE_U8
},
426 static const NLTypeSystem rtnl_prot_info_type_systems
[] = {
427 [AF_BRIDGE
] = { .count
= ELEMENTSOF(rtnl_prot_info_bridge_port_types
),
428 .types
= rtnl_prot_info_bridge_port_types
},
431 static const NLTypeSystemUnion rtnl_prot_info_type_system_union
= {
433 .type_systems
= rtnl_prot_info_type_systems
,
434 .match_type
= NL_MATCH_PROTOCOL
,
437 static const struct NLType rtnl_af_spec_inet6_types
[] = {
438 [IFLA_INET6_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
443 IFLA_INET6_CACHEINFO,
444 IFLA_INET6_ICMP6STATS,
446 [IFLA_INET6_TOKEN
] = { .type
= NETLINK_TYPE_IN_ADDR
},
447 [IFLA_INET6_ADDR_GEN_MODE
] = { .type
= NETLINK_TYPE_U8
},
450 static const NLTypeSystem rtnl_af_spec_inet6_type_system
= {
451 .count
= ELEMENTSOF(rtnl_af_spec_inet6_types
),
452 .types
= rtnl_af_spec_inet6_types
,
455 static const NLType rtnl_af_spec_types
[] = {
456 [AF_INET6
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_af_spec_inet6_type_system
},
459 static const NLTypeSystem rtnl_af_spec_type_system
= {
460 .count
= ELEMENTSOF(rtnl_af_spec_types
),
461 .types
= rtnl_af_spec_types
,
464 static const NLType rtnl_link_types
[] = {
465 [IFLA_ADDRESS
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
466 [IFLA_BROADCAST
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
467 [IFLA_IFNAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
- 1 },
468 [IFLA_MTU
] = { .type
= NETLINK_TYPE_U32
},
469 [IFLA_LINK
] = { .type
= NETLINK_TYPE_U32
},
476 [IFLA_MASTER
] = { .type
= NETLINK_TYPE_U32
},
480 [IFLA_PROTINFO
] = { .type
= NETLINK_TYPE_UNION
, .type_system_union
= &rtnl_prot_info_type_system_union
},
481 [IFLA_TXQLEN
] = { .type
= NETLINK_TYPE_U32
},
483 [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
485 [IFLA_WEIGHT
] = { .type
= NETLINK_TYPE_U32
},
486 [IFLA_OPERSTATE
] = { .type
= NETLINK_TYPE_U8
},
487 [IFLA_LINKMODE
] = { .type
= NETLINK_TYPE_U8
},
488 [IFLA_LINKINFO
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_info_type_system
},
489 [IFLA_NET_NS_PID
] = { .type
= NETLINK_TYPE_U32
},
490 [IFLA_IFALIAS
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFALIASZ
- 1 },
493 [IFLA_VFINFO_LIST] = {. type = NETLINK_TYPE_NESTED, },
495 [IFLA_VF_PORTS] = { .type = NETLINK_TYPE_NESTED },
496 [IFLA_PORT_SELF] = { .type = NETLINK_TYPE_NESTED },
498 [IFLA_AF_SPEC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_af_spec_type_system
},
504 [IFLA_GROUP
] = { .type
= NETLINK_TYPE_U32
},
505 [IFLA_NET_NS_FD
] = { .type
= NETLINK_TYPE_U32
},
506 [IFLA_EXT_MASK
] = { .type
= NETLINK_TYPE_U32
},
507 [IFLA_PROMISCUITY
] = { .type
= NETLINK_TYPE_U32
},
508 [IFLA_NUM_TX_QUEUES
] = { .type
= NETLINK_TYPE_U32
},
509 [IFLA_NUM_RX_QUEUES
] = { .type
= NETLINK_TYPE_U32
},
510 [IFLA_CARRIER
] = { .type
= NETLINK_TYPE_U8
},
512 [IFLA_PHYS_PORT_ID] = { .type = NETLINK_TYPE_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
516 static const NLTypeSystem rtnl_link_type_system
= {
517 .count
= ELEMENTSOF(rtnl_link_types
),
518 .types
= rtnl_link_types
,
521 /* IFA_FLAGS was defined in kernel 3.14, but we still support older
522 * kernels where IFA_MAX is lower. */
523 static const NLType rtnl_address_types
[] = {
524 [IFA_ADDRESS
] = { .type
= NETLINK_TYPE_IN_ADDR
},
525 [IFA_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
526 [IFA_LABEL
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
- 1 },
527 [IFA_BROADCAST
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
528 [IFA_CACHEINFO
] = { .type
= NETLINK_TYPE_CACHE_INFO
, .size
= sizeof(struct ifa_cacheinfo
) },
533 [IFA_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
536 static const NLTypeSystem rtnl_address_type_system
= {
537 .count
= ELEMENTSOF(rtnl_address_types
),
538 .types
= rtnl_address_types
,
541 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
543 static const NLType rtnl_route_metrics_types
[] = {
544 [RTAX_MTU
] = { .type
= NETLINK_TYPE_U32
},
545 [RTAX_WINDOW
] = { .type
= NETLINK_TYPE_U32
},
546 [RTAX_RTT
] = { .type
= NETLINK_TYPE_U32
},
547 [RTAX_RTTVAR
] = { .type
= NETLINK_TYPE_U32
},
548 [RTAX_SSTHRESH
] = { .type
= NETLINK_TYPE_U32
},
549 [RTAX_CWND
] = { .type
= NETLINK_TYPE_U32
},
550 [RTAX_ADVMSS
] = { .type
= NETLINK_TYPE_U32
},
551 [RTAX_REORDERING
] = { .type
= NETLINK_TYPE_U32
},
552 [RTAX_HOPLIMIT
] = { .type
= NETLINK_TYPE_U32
},
553 [RTAX_INITCWND
] = { .type
= NETLINK_TYPE_U32
},
554 [RTAX_FEATURES
] = { .type
= NETLINK_TYPE_U32
},
555 [RTAX_RTO_MIN
] = { .type
= NETLINK_TYPE_U32
},
558 static const NLTypeSystem rtnl_route_metrics_type_system
= {
559 .count
= ELEMENTSOF(rtnl_route_metrics_types
),
560 .types
= rtnl_route_metrics_types
,
563 static const NLType rtnl_route_types
[] = {
564 [RTA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
565 [RTA_SRC
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
566 [RTA_IIF
] = { .type
= NETLINK_TYPE_U32
},
567 [RTA_OIF
] = { .type
= NETLINK_TYPE_U32
},
568 [RTA_GATEWAY
] = { .type
= NETLINK_TYPE_IN_ADDR
},
569 [RTA_PRIORITY
] = { .type
= NETLINK_TYPE_U32
},
570 [RTA_PREFSRC
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
571 [RTA_METRICS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_metrics_type_system
},
572 /* [RTA_MULTIPATH] = { .len = sizeof(struct rtnexthop) },
574 [RTA_FLOW
] = { .type
= NETLINK_TYPE_U32
}, /* 6? */
583 [RTA_PREF
] = { .type
= NETLINK_TYPE_U8
},
587 static const NLTypeSystem rtnl_route_type_system
= {
588 .count
= ELEMENTSOF(rtnl_route_types
),
589 .types
= rtnl_route_types
,
592 static const NLType rtnl_neigh_types
[] = {
593 [NDA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
},
594 [NDA_LLADDR
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
595 [NDA_CACHEINFO
] = { .type
= NETLINK_TYPE_CACHE_INFO
, .size
= sizeof(struct nda_cacheinfo
) },
596 [NDA_PROBES
] = { .type
= NETLINK_TYPE_U32
},
597 [NDA_VLAN
] = { .type
= NETLINK_TYPE_U16
},
598 [NDA_PORT
] = { .type
= NETLINK_TYPE_U16
},
599 [NDA_VNI
] = { .type
= NETLINK_TYPE_U32
},
600 [NDA_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
603 static const NLTypeSystem rtnl_neigh_type_system
= {
604 .count
= ELEMENTSOF(rtnl_neigh_types
),
605 .types
= rtnl_neigh_types
,
608 static const NLType rtnl_addrlabel_types
[] = {
609 [IFAL_ADDRESS
] = { .type
= NETLINK_TYPE_IN_ADDR
, .size
= sizeof(struct in6_addr
) },
610 [IFAL_LABEL
] = { .type
= NETLINK_TYPE_U32
},
613 static const NLTypeSystem rtnl_addrlabel_type_system
= {
614 .count
= ELEMENTSOF(rtnl_addrlabel_types
),
615 .types
= rtnl_addrlabel_types
,
618 static const NLType rtnl_routing_policy_rule_types
[] = {
619 [FRA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
},
620 [FRA_SRC
] = { .type
= NETLINK_TYPE_IN_ADDR
},
621 [FRA_IIFNAME
] = { .type
= NETLINK_TYPE_STRING
},
622 [RTA_OIF
] = { .type
= NETLINK_TYPE_U32
},
623 [RTA_GATEWAY
] = { .type
= NETLINK_TYPE_IN_ADDR
},
624 [FRA_PRIORITY
] = { .type
= NETLINK_TYPE_U32
},
625 [FRA_FWMARK
] = { .type
= NETLINK_TYPE_U32
},
626 [FRA_FLOW
] = { .type
= NETLINK_TYPE_U32
},
627 [FRA_TUN_ID
] = { .type
= NETLINK_TYPE_U32
},
628 [FRA_SUPPRESS_IFGROUP
] = { .type
= NETLINK_TYPE_U32
},
629 [FRA_SUPPRESS_PREFIXLEN
] = { .type
= NETLINK_TYPE_U32
},
630 [FRA_TABLE
] = { .type
= NETLINK_TYPE_U32
},
631 [FRA_FWMASK
] = { .type
= NETLINK_TYPE_U32
},
632 [FRA_OIFNAME
] = { .type
= NETLINK_TYPE_STRING
},
633 [FRA_PAD
] = { .type
= NETLINK_TYPE_U32
},
634 [FRA_L3MDEV
] = { .type
= NETLINK_TYPE_U64
},
635 [FRA_UID_RANGE
] = { .size
= sizeof(struct fib_rule_uid_range
) },
638 static const NLTypeSystem rtnl_routing_policy_rule_type_system
= {
639 .count
= ELEMENTSOF(rtnl_routing_policy_rule_types
),
640 .types
= rtnl_routing_policy_rule_types
,
643 static const NLType rtnl_types
[] = {
644 [NLMSG_DONE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &empty_type_system
, .size
= 0 },
645 [NLMSG_ERROR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &empty_type_system
, .size
= sizeof(struct nlmsgerr
) },
646 [RTM_NEWLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
647 [RTM_DELLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
648 [RTM_GETLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
649 [RTM_SETLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
650 [RTM_NEWADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
651 [RTM_DELADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
652 [RTM_GETADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
653 [RTM_NEWROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
654 [RTM_DELROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
655 [RTM_GETROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
656 [RTM_NEWNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
657 [RTM_DELNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
658 [RTM_GETNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
659 [RTM_NEWADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
660 [RTM_DELADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
661 [RTM_GETADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
662 [RTM_NEWRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct rtmsg
) },
663 [RTM_DELRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct rtmsg
) },
664 [RTM_GETRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct rtmsg
) },
667 const NLTypeSystem type_system_root
= {
668 .count
= ELEMENTSOF(rtnl_types
),
672 uint16_t type_get_type(const NLType
*type
) {
677 size_t type_get_size(const NLType
*type
) {
682 void type_get_type_system(const NLType
*nl_type
, const NLTypeSystem
**ret
) {
685 assert(nl_type
->type
== NETLINK_TYPE_NESTED
);
686 assert(nl_type
->type_system
);
688 *ret
= nl_type
->type_system
;
691 void type_get_type_system_union(const NLType
*nl_type
, const NLTypeSystemUnion
**ret
) {
694 assert(nl_type
->type
== NETLINK_TYPE_UNION
);
695 assert(nl_type
->type_system_union
);
697 *ret
= nl_type
->type_system_union
;
700 uint16_t type_system_get_count(const NLTypeSystem
*type_system
) {
702 return type_system
->count
;
705 int type_system_get_type(const NLTypeSystem
*type_system
, const NLType
**ret
, uint16_t type
) {
706 const NLType
*nl_type
;
710 assert(type_system
->types
);
712 if (type
>= type_system
->count
)
715 nl_type
= &type_system
->types
[type
];
717 if (nl_type
->type
== NETLINK_TYPE_UNSPEC
)
725 int type_system_get_type_system(const NLTypeSystem
*type_system
, const NLTypeSystem
**ret
, uint16_t type
) {
726 const NLType
*nl_type
;
731 r
= type_system_get_type(type_system
, &nl_type
, type
);
735 type_get_type_system(nl_type
, ret
);
739 int type_system_get_type_system_union(const NLTypeSystem
*type_system
, const NLTypeSystemUnion
**ret
, uint16_t type
) {
740 const NLType
*nl_type
;
745 r
= type_system_get_type(type_system
, &nl_type
, type
);
749 type_get_type_system_union(nl_type
, ret
);
753 int type_system_union_get_type_system(const NLTypeSystemUnion
*type_system_union
, const NLTypeSystem
**ret
, const char *key
) {
756 assert(type_system_union
);
757 assert(type_system_union
->match_type
== NL_MATCH_SIBLING
);
758 assert(type_system_union
->lookup
);
759 assert(type_system_union
->type_systems
);
763 type
= type_system_union
->lookup(key
);
767 assert(type
< type_system_union
->num
);
769 *ret
= &type_system_union
->type_systems
[type
];
774 int type_system_union_protocol_get_type_system(const NLTypeSystemUnion
*type_system_union
, const NLTypeSystem
**ret
, uint16_t protocol
) {
775 const NLTypeSystem
*type_system
;
777 assert(type_system_union
);
778 assert(type_system_union
->type_systems
);
779 assert(type_system_union
->match_type
== NL_MATCH_PROTOCOL
);
782 if (protocol
>= type_system_union
->num
)
785 type_system
= &type_system_union
->type_systems
[protocol
];
786 if (!type_system
->types
)