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
},
107 static const NLType rtnl_link_info_data_macvlan_types
[] = {
108 [IFLA_MACVLAN_MODE
] = { .type
= NETLINK_TYPE_U32
},
109 [IFLA_MACVLAN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
112 static const NLType rtnl_link_info_data_bridge_types
[] = {
113 [IFLA_BR_FORWARD_DELAY
] = { .type
= NETLINK_TYPE_U32
},
114 [IFLA_BR_HELLO_TIME
] = { .type
= NETLINK_TYPE_U32
},
115 [IFLA_BR_MAX_AGE
] = { .type
= NETLINK_TYPE_U32
},
116 [IFLA_BR_AGEING_TIME
] = { .type
= NETLINK_TYPE_U32
},
117 [IFLA_BR_STP_STATE
] = { .type
= NETLINK_TYPE_U32
},
118 [IFLA_BR_PRIORITY
] = { .type
= NETLINK_TYPE_U16
},
119 [IFLA_BR_VLAN_FILTERING
] = { .type
= NETLINK_TYPE_U8
},
120 [IFLA_BR_VLAN_PROTOCOL
] = { .type
= NETLINK_TYPE_U16
},
121 [IFLA_BR_GROUP_FWD_MASK
] = { .type
= NETLINK_TYPE_U16
},
122 [IFLA_BR_ROOT_PORT
] = { .type
= NETLINK_TYPE_U16
},
123 [IFLA_BR_ROOT_PATH_COST
] = { .type
= NETLINK_TYPE_U32
},
124 [IFLA_BR_TOPOLOGY_CHANGE
] = { .type
= NETLINK_TYPE_U8
},
125 [IFLA_BR_TOPOLOGY_CHANGE_DETECTED
] = { .type
= NETLINK_TYPE_U8
},
126 [IFLA_BR_HELLO_TIMER
] = { .type
= NETLINK_TYPE_U16
},
127 [IFLA_BR_TCN_TIMER
] = { .type
= NETLINK_TYPE_U16
},
128 [IFLA_BR_TOPOLOGY_CHANGE_TIMER
] = { .type
= NETLINK_TYPE_U16
},
129 [IFLA_BR_GC_TIMER
] = { .type
= NETLINK_TYPE_U64
},
130 [IFLA_BR_GROUP_ADDR
] = { .type
= NETLINK_TYPE_U16
},
131 [IFLA_BR_FDB_FLUSH
] = { .type
= NETLINK_TYPE_U16
},
132 [IFLA_BR_MCAST_ROUTER
] = { .type
= NETLINK_TYPE_U8
},
133 [IFLA_BR_MCAST_SNOOPING
] = { .type
= NETLINK_TYPE_U8
},
134 [IFLA_BR_MCAST_QUERY_USE_IFADDR
] = { .type
= NETLINK_TYPE_U8
},
135 [IFLA_BR_MCAST_QUERIER
] = { .type
= NETLINK_TYPE_U8
},
136 [IFLA_BR_MCAST_HASH_ELASTICITY
] = { .type
= NETLINK_TYPE_U32
},
137 [IFLA_BR_MCAST_HASH_MAX
] = { .type
= NETLINK_TYPE_U16
},
138 [IFLA_BR_MCAST_LAST_MEMBER_CNT
] = { .type
= NETLINK_TYPE_U32
},
139 [IFLA_BR_MCAST_STARTUP_QUERY_CNT
] = { .type
= NETLINK_TYPE_U16
},
140 [IFLA_BR_MCAST_LAST_MEMBER_INTVL
] = { .type
= NETLINK_TYPE_U64
},
141 [IFLA_BR_MCAST_MEMBERSHIP_INTVL
] = { .type
= NETLINK_TYPE_U64
},
142 [IFLA_BR_MCAST_QUERIER_INTVL
] = { .type
= NETLINK_TYPE_U64
},
143 [IFLA_BR_MCAST_QUERY_INTVL
] = { .type
= NETLINK_TYPE_U64
},
144 [IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
] = { .type
= NETLINK_TYPE_U64
},
145 [IFLA_BR_MCAST_STARTUP_QUERY_INTVL
] = { .type
= NETLINK_TYPE_U64
},
146 [IFLA_BR_NF_CALL_IPTABLES
] = { .type
= NETLINK_TYPE_U8
},
147 [IFLA_BR_NF_CALL_IP6TABLES
] = { .type
= NETLINK_TYPE_U8
},
148 [IFLA_BR_NF_CALL_ARPTABLES
] = { .type
= NETLINK_TYPE_U8
},
149 [IFLA_BR_VLAN_DEFAULT_PVID
] = { .type
= NETLINK_TYPE_U16
},
152 static const NLType rtnl_link_info_data_vlan_types
[] = {
153 [IFLA_VLAN_ID
] = { .type
= NETLINK_TYPE_U16
},
155 [IFLA_VLAN_FLAGS] = { .len = sizeof(struct ifla_vlan_flags) },
156 [IFLA_VLAN_EGRESS_QOS] = { .type = NETLINK_TYPE_NESTED },
157 [IFLA_VLAN_INGRESS_QOS] = { .type = NETLINK_TYPE_NESTED },
159 [IFLA_VLAN_PROTOCOL
] = { .type
= NETLINK_TYPE_U16
},
162 static const NLType rtnl_link_info_data_vxlan_types
[] = {
163 [IFLA_VXLAN_ID
] = { .type
= NETLINK_TYPE_U32
},
164 [IFLA_VXLAN_GROUP
] = { .type
= NETLINK_TYPE_IN_ADDR
},
165 [IFLA_VXLAN_LINK
] = { .type
= NETLINK_TYPE_U32
},
166 [IFLA_VXLAN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
167 [IFLA_VXLAN_TTL
] = { .type
= NETLINK_TYPE_U8
},
168 [IFLA_VXLAN_TOS
] = { .type
= NETLINK_TYPE_U8
},
169 [IFLA_VXLAN_LEARNING
] = { .type
= NETLINK_TYPE_U8
},
170 [IFLA_VXLAN_AGEING
] = { .type
= NETLINK_TYPE_U32
},
171 [IFLA_VXLAN_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
172 [IFLA_VXLAN_PORT_RANGE
] = { .type
= NETLINK_TYPE_U32
},
173 [IFLA_VXLAN_PROXY
] = { .type
= NETLINK_TYPE_U8
},
174 [IFLA_VXLAN_RSC
] = { .type
= NETLINK_TYPE_U8
},
175 [IFLA_VXLAN_L2MISS
] = { .type
= NETLINK_TYPE_U8
},
176 [IFLA_VXLAN_L3MISS
] = { .type
= NETLINK_TYPE_U8
},
177 [IFLA_VXLAN_PORT
] = { .type
= NETLINK_TYPE_U16
},
178 [IFLA_VXLAN_GROUP6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
179 [IFLA_VXLAN_LOCAL6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
180 [IFLA_VXLAN_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
181 [IFLA_VXLAN_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_U8
},
182 [IFLA_VXLAN_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_U8
},
183 [IFLA_VXLAN_REMCSUM_TX
] = { .type
= NETLINK_TYPE_U8
},
184 [IFLA_VXLAN_REMCSUM_RX
] = { .type
= NETLINK_TYPE_U8
},
185 [IFLA_VXLAN_GBP
] = { .type
= NETLINK_TYPE_FLAG
},
186 [IFLA_VXLAN_REMCSUM_NOPARTIAL
] = { .type
= NETLINK_TYPE_FLAG
},
187 [IFLA_VXLAN_COLLECT_METADATA
] = { .type
= NETLINK_TYPE_U8
},
188 [IFLA_VXLAN_LABEL
] = { .type
= NETLINK_TYPE_U32
},
189 [IFLA_VXLAN_GPE
] = { .type
= NETLINK_TYPE_FLAG
},
192 static const NLType rtnl_bond_arp_target_types
[] = {
193 [BOND_ARP_TARGETS_0
] = { .type
= NETLINK_TYPE_U32
},
194 [BOND_ARP_TARGETS_1
] = { .type
= NETLINK_TYPE_U32
},
195 [BOND_ARP_TARGETS_2
] = { .type
= NETLINK_TYPE_U32
},
196 [BOND_ARP_TARGETS_3
] = { .type
= NETLINK_TYPE_U32
},
197 [BOND_ARP_TARGETS_4
] = { .type
= NETLINK_TYPE_U32
},
198 [BOND_ARP_TARGETS_5
] = { .type
= NETLINK_TYPE_U32
},
199 [BOND_ARP_TARGETS_6
] = { .type
= NETLINK_TYPE_U32
},
200 [BOND_ARP_TARGETS_7
] = { .type
= NETLINK_TYPE_U32
},
201 [BOND_ARP_TARGETS_8
] = { .type
= NETLINK_TYPE_U32
},
202 [BOND_ARP_TARGETS_9
] = { .type
= NETLINK_TYPE_U32
},
203 [BOND_ARP_TARGETS_10
] = { .type
= NETLINK_TYPE_U32
},
204 [BOND_ARP_TARGETS_11
] = { .type
= NETLINK_TYPE_U32
},
205 [BOND_ARP_TARGETS_12
] = { .type
= NETLINK_TYPE_U32
},
206 [BOND_ARP_TARGETS_13
] = { .type
= NETLINK_TYPE_U32
},
207 [BOND_ARP_TARGETS_14
] = { .type
= NETLINK_TYPE_U32
},
208 [BOND_ARP_TARGETS_MAX
] = { .type
= NETLINK_TYPE_U32
},
211 static const NLTypeSystem rtnl_bond_arp_type_system
= {
212 .count
= ELEMENTSOF(rtnl_bond_arp_target_types
),
213 .types
= rtnl_bond_arp_target_types
,
216 static const NLType rtnl_link_info_data_bond_types
[] = {
217 [IFLA_BOND_MODE
] = { .type
= NETLINK_TYPE_U8
},
218 [IFLA_BOND_ACTIVE_SLAVE
] = { .type
= NETLINK_TYPE_U32
},
219 [IFLA_BOND_MIIMON
] = { .type
= NETLINK_TYPE_U32
},
220 [IFLA_BOND_UPDELAY
] = { .type
= NETLINK_TYPE_U32
},
221 [IFLA_BOND_DOWNDELAY
] = { .type
= NETLINK_TYPE_U32
},
222 [IFLA_BOND_USE_CARRIER
] = { .type
= NETLINK_TYPE_U8
},
223 [IFLA_BOND_ARP_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
224 [IFLA_BOND_ARP_IP_TARGET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_bond_arp_type_system
},
225 [IFLA_BOND_ARP_VALIDATE
] = { .type
= NETLINK_TYPE_U32
},
226 [IFLA_BOND_ARP_ALL_TARGETS
] = { .type
= NETLINK_TYPE_U32
},
227 [IFLA_BOND_PRIMARY
] = { .type
= NETLINK_TYPE_U32
},
228 [IFLA_BOND_PRIMARY_RESELECT
] = { .type
= NETLINK_TYPE_U8
},
229 [IFLA_BOND_FAIL_OVER_MAC
] = { .type
= NETLINK_TYPE_U8
},
230 [IFLA_BOND_XMIT_HASH_POLICY
] = { .type
= NETLINK_TYPE_U8
},
231 [IFLA_BOND_RESEND_IGMP
] = { .type
= NETLINK_TYPE_U32
},
232 [IFLA_BOND_NUM_PEER_NOTIF
] = { .type
= NETLINK_TYPE_U8
},
233 [IFLA_BOND_ALL_SLAVES_ACTIVE
] = { .type
= NETLINK_TYPE_U8
},
234 [IFLA_BOND_MIN_LINKS
] = { .type
= NETLINK_TYPE_U32
},
235 [IFLA_BOND_LP_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
236 [IFLA_BOND_PACKETS_PER_SLAVE
] = { .type
= NETLINK_TYPE_U32
},
237 [IFLA_BOND_AD_LACP_RATE
] = { .type
= NETLINK_TYPE_U8
},
238 [IFLA_BOND_AD_SELECT
] = { .type
= NETLINK_TYPE_U8
},
239 [IFLA_BOND_AD_INFO
] = { .type
= NETLINK_TYPE_NESTED
},
242 static const NLType rtnl_link_info_data_iptun_types
[] = {
243 [IFLA_IPTUN_LINK
] = { .type
= NETLINK_TYPE_U32
},
244 [IFLA_IPTUN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
245 [IFLA_IPTUN_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
246 [IFLA_IPTUN_TTL
] = { .type
= NETLINK_TYPE_U8
},
247 [IFLA_IPTUN_TOS
] = { .type
= NETLINK_TYPE_U8
},
248 [IFLA_IPTUN_PMTUDISC
] = { .type
= NETLINK_TYPE_U8
},
249 [IFLA_IPTUN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
250 [IFLA_IPTUN_PROTO
] = { .type
= NETLINK_TYPE_U8
},
251 [IFLA_IPTUN_6RD_PREFIX
] = { .type
= NETLINK_TYPE_IN_ADDR
},
252 [IFLA_IPTUN_6RD_RELAY_PREFIX
] = { .type
= NETLINK_TYPE_U32
},
253 [IFLA_IPTUN_6RD_PREFIXLEN
] = { .type
= NETLINK_TYPE_U16
},
254 [IFLA_IPTUN_6RD_RELAY_PREFIXLEN
] = { .type
= NETLINK_TYPE_U16
},
255 [IFLA_IPTUN_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
256 [IFLA_IPTUN_ENCAP_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
257 [IFLA_IPTUN_ENCAP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
258 [IFLA_IPTUN_ENCAP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
261 static const NLType rtnl_link_info_data_ipgre_types
[] = {
262 [IFLA_GRE_LINK
] = { .type
= NETLINK_TYPE_U32
},
263 [IFLA_GRE_IFLAGS
] = { .type
= NETLINK_TYPE_U16
},
264 [IFLA_GRE_OFLAGS
] = { .type
= NETLINK_TYPE_U16
},
265 [IFLA_GRE_IKEY
] = { .type
= NETLINK_TYPE_U32
},
266 [IFLA_GRE_OKEY
] = { .type
= NETLINK_TYPE_U32
},
267 [IFLA_GRE_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
268 [IFLA_GRE_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
269 [IFLA_GRE_TTL
] = { .type
= NETLINK_TYPE_U8
},
270 [IFLA_GRE_TOS
] = { .type
= NETLINK_TYPE_U8
},
271 [IFLA_GRE_PMTUDISC
] = { .type
= NETLINK_TYPE_U8
},
272 [IFLA_GRE_FLOWINFO
] = { .type
= NETLINK_TYPE_U32
},
273 [IFLA_GRE_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
274 [IFLA_GRE_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
275 [IFLA_GRE_ENCAP_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
276 [IFLA_GRE_ENCAP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
277 [IFLA_GRE_ENCAP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
280 static const NLType rtnl_link_info_data_ipvti_types
[] = {
281 [IFLA_VTI_LINK
] = { .type
= NETLINK_TYPE_U32
},
282 [IFLA_VTI_IKEY
] = { .type
= NETLINK_TYPE_U32
},
283 [IFLA_VTI_OKEY
] = { .type
= NETLINK_TYPE_U32
},
284 [IFLA_VTI_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
285 [IFLA_VTI_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
288 static const NLType rtnl_link_info_data_ip6tnl_types
[] = {
289 [IFLA_IPTUN_LINK
] = { .type
= NETLINK_TYPE_U32
},
290 [IFLA_IPTUN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
291 [IFLA_IPTUN_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
292 [IFLA_IPTUN_TTL
] = { .type
= NETLINK_TYPE_U8
},
293 [IFLA_IPTUN_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
294 [IFLA_IPTUN_PROTO
] = { .type
= NETLINK_TYPE_U8
},
295 [IFLA_IPTUN_ENCAP_LIMIT
] = { .type
= NETLINK_TYPE_U8
},
296 [IFLA_IPTUN_FLOWINFO
] = { .type
= NETLINK_TYPE_U32
},
299 static const NLType rtnl_link_info_data_vrf_types
[] = {
300 [IFLA_VRF_TABLE
] = { .type
= NETLINK_TYPE_U32
},
303 static const NLType rtnl_link_info_data_geneve_types
[] = {
304 [IFLA_GENEVE_ID
] = { .type
= NETLINK_TYPE_U32
},
305 [IFLA_GENEVE_TTL
] = { .type
= NETLINK_TYPE_U8
},
306 [IFLA_GENEVE_TOS
] = { .type
= NETLINK_TYPE_U8
},
307 [IFLA_GENEVE_PORT
] = { .type
= NETLINK_TYPE_U16
},
308 [IFLA_GENEVE_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
309 [IFLA_GENEVE_REMOTE6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
310 [IFLA_GENEVE_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
311 [IFLA_GENEVE_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_U8
},
312 [IFLA_GENEVE_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_U8
},
313 [IFLA_GENEVE_LABEL
] = { .type
= NETLINK_TYPE_U32
},
316 /* these strings must match the .kind entries in the kernel */
317 static const char* const nl_union_link_info_data_table
[] = {
318 [NL_UNION_LINK_INFO_DATA_BOND
] = "bond",
319 [NL_UNION_LINK_INFO_DATA_BRIDGE
] = "bridge",
320 [NL_UNION_LINK_INFO_DATA_VLAN
] = "vlan",
321 [NL_UNION_LINK_INFO_DATA_VETH
] = "veth",
322 [NL_UNION_LINK_INFO_DATA_DUMMY
] = "dummy",
323 [NL_UNION_LINK_INFO_DATA_MACVLAN
] = "macvlan",
324 [NL_UNION_LINK_INFO_DATA_MACVTAP
] = "macvtap",
325 [NL_UNION_LINK_INFO_DATA_IPVLAN
] = "ipvlan",
326 [NL_UNION_LINK_INFO_DATA_VXLAN
] = "vxlan",
327 [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL
] = "ipip",
328 [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL
] = "gre",
329 [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL
] = "gretap",
330 [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL
] = "ip6gre",
331 [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL
] = "ip6gretap",
332 [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL
] = "sit",
333 [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL
] = "vti",
334 [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL
] = "vti6",
335 [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL
] = "ip6tnl",
336 [NL_UNION_LINK_INFO_DATA_VRF
] = "vrf",
337 [NL_UNION_LINK_INFO_DATA_VCAN
] = "vcan",
338 [NL_UNION_LINK_INFO_DATA_GENEVE
] = "geneve",
339 [NL_UNION_LINK_INFO_DATA_VXCAN
] = "vxcan",
343 DEFINE_STRING_TABLE_LOOKUP(nl_union_link_info_data
, NLUnionLinkInfoData
);
345 static const NLTypeSystem rtnl_link_info_data_type_systems
[] = {
346 [NL_UNION_LINK_INFO_DATA_BOND
] = { .count
= ELEMENTSOF(rtnl_link_info_data_bond_types
),
347 .types
= rtnl_link_info_data_bond_types
},
348 [NL_UNION_LINK_INFO_DATA_BRIDGE
] = { .count
= ELEMENTSOF(rtnl_link_info_data_bridge_types
),
349 .types
= rtnl_link_info_data_bridge_types
},
350 [NL_UNION_LINK_INFO_DATA_VLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vlan_types
),
351 .types
= rtnl_link_info_data_vlan_types
},
352 [NL_UNION_LINK_INFO_DATA_VETH
] = { .count
= ELEMENTSOF(rtnl_link_info_data_veth_types
),
353 .types
= rtnl_link_info_data_veth_types
},
354 [NL_UNION_LINK_INFO_DATA_MACVLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macvlan_types
),
355 .types
= rtnl_link_info_data_macvlan_types
},
356 [NL_UNION_LINK_INFO_DATA_MACVTAP
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macvlan_types
),
357 .types
= rtnl_link_info_data_macvlan_types
},
358 [NL_UNION_LINK_INFO_DATA_IPVLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvlan_types
),
359 .types
= rtnl_link_info_data_ipvlan_types
},
360 [NL_UNION_LINK_INFO_DATA_VXLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vxlan_types
),
361 .types
= rtnl_link_info_data_vxlan_types
},
362 [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_iptun_types
),
363 .types
= rtnl_link_info_data_iptun_types
},
364 [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
365 .types
= rtnl_link_info_data_ipgre_types
},
366 [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
367 .types
= rtnl_link_info_data_ipgre_types
},
368 [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
369 .types
= rtnl_link_info_data_ipgre_types
},
370 [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
371 .types
= rtnl_link_info_data_ipgre_types
},
372 [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_iptun_types
),
373 .types
= rtnl_link_info_data_iptun_types
},
374 [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvti_types
),
375 .types
= rtnl_link_info_data_ipvti_types
},
376 [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvti_types
),
377 .types
= rtnl_link_info_data_ipvti_types
},
378 [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ip6tnl_types
),
379 .types
= rtnl_link_info_data_ip6tnl_types
},
380 [NL_UNION_LINK_INFO_DATA_VRF
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vrf_types
),
381 .types
= rtnl_link_info_data_vrf_types
},
382 [NL_UNION_LINK_INFO_DATA_GENEVE
] = { .count
= ELEMENTSOF(rtnl_link_info_data_geneve_types
),
383 .types
= rtnl_link_info_data_geneve_types
},
384 [NL_UNION_LINK_INFO_DATA_VXCAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vxcan_types
),
385 .types
= rtnl_link_info_data_vxcan_types
},
388 static const NLTypeSystemUnion rtnl_link_info_data_type_system_union
= {
389 .num
= _NL_UNION_LINK_INFO_DATA_MAX
,
390 .lookup
= nl_union_link_info_data_from_string
,
391 .type_systems
= rtnl_link_info_data_type_systems
,
392 .match_type
= NL_MATCH_SIBLING
,
393 .match
= IFLA_INFO_KIND
,
396 static const NLType rtnl_link_info_types
[] = {
397 [IFLA_INFO_KIND
] = { .type
= NETLINK_TYPE_STRING
},
398 [IFLA_INFO_DATA
] = { .type
= NETLINK_TYPE_UNION
, .type_system_union
= &rtnl_link_info_data_type_system_union
},
401 [IFLA_INFO_SLAVE_KIND] = { .type = NETLINK_TYPE_STRING },
402 [IFLA_INFO_SLAVE_DATA] = { .type = NETLINK_TYPE_NESTED },
406 static const NLTypeSystem rtnl_link_info_type_system
= {
407 .count
= ELEMENTSOF(rtnl_link_info_types
),
408 .types
= rtnl_link_info_types
,
411 static const struct NLType rtnl_prot_info_bridge_port_types
[] = {
412 [IFLA_BRPORT_STATE
] = { .type
= NETLINK_TYPE_U8
},
413 [IFLA_BRPORT_COST
] = { .type
= NETLINK_TYPE_U32
},
414 [IFLA_BRPORT_PRIORITY
] = { .type
= NETLINK_TYPE_U16
},
415 [IFLA_BRPORT_MODE
] = { .type
= NETLINK_TYPE_U8
},
416 [IFLA_BRPORT_GUARD
] = { .type
= NETLINK_TYPE_U8
},
417 [IFLA_BRPORT_PROTECT
] = { .type
= NETLINK_TYPE_U8
},
418 [IFLA_BRPORT_FAST_LEAVE
] = { .type
= NETLINK_TYPE_U8
},
419 [IFLA_BRPORT_LEARNING
] = { .type
= NETLINK_TYPE_U8
},
420 [IFLA_BRPORT_UNICAST_FLOOD
] = { .type
= NETLINK_TYPE_U8
},
421 [IFLA_BRPORT_PROXYARP
] = { .type
= NETLINK_TYPE_U8
},
422 [IFLA_BRPORT_LEARNING_SYNC
] = { .type
= NETLINK_TYPE_U8
},
425 static const NLTypeSystem rtnl_prot_info_type_systems
[] = {
426 [AF_BRIDGE
] = { .count
= ELEMENTSOF(rtnl_prot_info_bridge_port_types
),
427 .types
= rtnl_prot_info_bridge_port_types
},
430 static const NLTypeSystemUnion rtnl_prot_info_type_system_union
= {
432 .type_systems
= rtnl_prot_info_type_systems
,
433 .match_type
= NL_MATCH_PROTOCOL
,
436 static const struct NLType rtnl_af_spec_inet6_types
[] = {
437 [IFLA_INET6_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
442 IFLA_INET6_CACHEINFO,
443 IFLA_INET6_ICMP6STATS,
445 [IFLA_INET6_TOKEN
] = { .type
= NETLINK_TYPE_IN_ADDR
},
446 [IFLA_INET6_ADDR_GEN_MODE
] = { .type
= NETLINK_TYPE_U8
},
449 static const NLTypeSystem rtnl_af_spec_inet6_type_system
= {
450 .count
= ELEMENTSOF(rtnl_af_spec_inet6_types
),
451 .types
= rtnl_af_spec_inet6_types
,
454 static const NLType rtnl_af_spec_types
[] = {
455 [AF_INET6
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_af_spec_inet6_type_system
},
458 static const NLTypeSystem rtnl_af_spec_type_system
= {
459 .count
= ELEMENTSOF(rtnl_af_spec_types
),
460 .types
= rtnl_af_spec_types
,
463 static const NLType rtnl_link_types
[] = {
464 [IFLA_ADDRESS
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
465 [IFLA_BROADCAST
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
466 [IFLA_IFNAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
- 1 },
467 [IFLA_MTU
] = { .type
= NETLINK_TYPE_U32
},
468 [IFLA_LINK
] = { .type
= NETLINK_TYPE_U32
},
475 [IFLA_MASTER
] = { .type
= NETLINK_TYPE_U32
},
479 [IFLA_PROTINFO
] = { .type
= NETLINK_TYPE_UNION
, .type_system_union
= &rtnl_prot_info_type_system_union
},
480 [IFLA_TXQLEN
] = { .type
= NETLINK_TYPE_U32
},
482 [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
484 [IFLA_WEIGHT
] = { .type
= NETLINK_TYPE_U32
},
485 [IFLA_OPERSTATE
] = { .type
= NETLINK_TYPE_U8
},
486 [IFLA_LINKMODE
] = { .type
= NETLINK_TYPE_U8
},
487 [IFLA_LINKINFO
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_info_type_system
},
488 [IFLA_NET_NS_PID
] = { .type
= NETLINK_TYPE_U32
},
489 [IFLA_IFALIAS
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFALIASZ
- 1 },
492 [IFLA_VFINFO_LIST] = {. type = NETLINK_TYPE_NESTED, },
494 [IFLA_VF_PORTS] = { .type = NETLINK_TYPE_NESTED },
495 [IFLA_PORT_SELF] = { .type = NETLINK_TYPE_NESTED },
497 [IFLA_AF_SPEC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_af_spec_type_system
},
503 [IFLA_GROUP
] = { .type
= NETLINK_TYPE_U32
},
504 [IFLA_NET_NS_FD
] = { .type
= NETLINK_TYPE_U32
},
505 [IFLA_EXT_MASK
] = { .type
= NETLINK_TYPE_U32
},
506 [IFLA_PROMISCUITY
] = { .type
= NETLINK_TYPE_U32
},
507 [IFLA_NUM_TX_QUEUES
] = { .type
= NETLINK_TYPE_U32
},
508 [IFLA_NUM_RX_QUEUES
] = { .type
= NETLINK_TYPE_U32
},
509 [IFLA_CARRIER
] = { .type
= NETLINK_TYPE_U8
},
511 [IFLA_PHYS_PORT_ID] = { .type = NETLINK_TYPE_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
515 static const NLTypeSystem rtnl_link_type_system
= {
516 .count
= ELEMENTSOF(rtnl_link_types
),
517 .types
= rtnl_link_types
,
520 /* IFA_FLAGS was defined in kernel 3.14, but we still support older
521 * kernels where IFA_MAX is lower. */
522 static const NLType rtnl_address_types
[] = {
523 [IFA_ADDRESS
] = { .type
= NETLINK_TYPE_IN_ADDR
},
524 [IFA_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
525 [IFA_LABEL
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
- 1 },
526 [IFA_BROADCAST
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
527 [IFA_CACHEINFO
] = { .type
= NETLINK_TYPE_CACHE_INFO
, .size
= sizeof(struct ifa_cacheinfo
) },
532 [IFA_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
535 static const NLTypeSystem rtnl_address_type_system
= {
536 .count
= ELEMENTSOF(rtnl_address_types
),
537 .types
= rtnl_address_types
,
540 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
542 static const NLType rtnl_route_metrics_types
[] = {
543 [RTAX_MTU
] = { .type
= NETLINK_TYPE_U32
},
544 [RTAX_WINDOW
] = { .type
= NETLINK_TYPE_U32
},
545 [RTAX_RTT
] = { .type
= NETLINK_TYPE_U32
},
546 [RTAX_RTTVAR
] = { .type
= NETLINK_TYPE_U32
},
547 [RTAX_SSTHRESH
] = { .type
= NETLINK_TYPE_U32
},
548 [RTAX_CWND
] = { .type
= NETLINK_TYPE_U32
},
549 [RTAX_ADVMSS
] = { .type
= NETLINK_TYPE_U32
},
550 [RTAX_REORDERING
] = { .type
= NETLINK_TYPE_U32
},
551 [RTAX_HOPLIMIT
] = { .type
= NETLINK_TYPE_U32
},
552 [RTAX_INITCWND
] = { .type
= NETLINK_TYPE_U32
},
553 [RTAX_FEATURES
] = { .type
= NETLINK_TYPE_U32
},
554 [RTAX_RTO_MIN
] = { .type
= NETLINK_TYPE_U32
},
557 static const NLTypeSystem rtnl_route_metrics_type_system
= {
558 .count
= ELEMENTSOF(rtnl_route_metrics_types
),
559 .types
= rtnl_route_metrics_types
,
562 static const NLType rtnl_route_types
[] = {
563 [RTA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
564 [RTA_SRC
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
565 [RTA_IIF
] = { .type
= NETLINK_TYPE_U32
},
566 [RTA_OIF
] = { .type
= NETLINK_TYPE_U32
},
567 [RTA_GATEWAY
] = { .type
= NETLINK_TYPE_IN_ADDR
},
568 [RTA_PRIORITY
] = { .type
= NETLINK_TYPE_U32
},
569 [RTA_PREFSRC
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
570 [RTA_METRICS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_metrics_type_system
},
571 /* [RTA_MULTIPATH] = { .len = sizeof(struct rtnexthop) },
573 [RTA_FLOW
] = { .type
= NETLINK_TYPE_U32
}, /* 6? */
582 [RTA_PREF
] = { .type
= NETLINK_TYPE_U8
},
586 static const NLTypeSystem rtnl_route_type_system
= {
587 .count
= ELEMENTSOF(rtnl_route_types
),
588 .types
= rtnl_route_types
,
591 static const NLType rtnl_neigh_types
[] = {
592 [NDA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
},
593 [NDA_LLADDR
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
594 [NDA_CACHEINFO
] = { .type
= NETLINK_TYPE_CACHE_INFO
, .size
= sizeof(struct nda_cacheinfo
) },
595 [NDA_PROBES
] = { .type
= NETLINK_TYPE_U32
},
596 [NDA_VLAN
] = { .type
= NETLINK_TYPE_U16
},
597 [NDA_PORT
] = { .type
= NETLINK_TYPE_U16
},
598 [NDA_VNI
] = { .type
= NETLINK_TYPE_U32
},
599 [NDA_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
602 static const NLTypeSystem rtnl_neigh_type_system
= {
603 .count
= ELEMENTSOF(rtnl_neigh_types
),
604 .types
= rtnl_neigh_types
,
607 static const NLType rtnl_addrlabel_types
[] = {
608 [IFAL_ADDRESS
] = { .type
= NETLINK_TYPE_IN_ADDR
, .size
= sizeof(struct in6_addr
) },
609 [IFAL_LABEL
] = { .type
= NETLINK_TYPE_U32
},
612 static const NLTypeSystem rtnl_addrlabel_type_system
= {
613 .count
= ELEMENTSOF(rtnl_addrlabel_types
),
614 .types
= rtnl_addrlabel_types
,
617 static const NLType rtnl_routing_policy_rule_types
[] = {
618 [FRA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
},
619 [FRA_SRC
] = { .type
= NETLINK_TYPE_IN_ADDR
},
620 [FRA_IIFNAME
] = { .type
= NETLINK_TYPE_STRING
},
621 [RTA_OIF
] = { .type
= NETLINK_TYPE_U32
},
622 [RTA_GATEWAY
] = { .type
= NETLINK_TYPE_IN_ADDR
},
623 [FRA_PRIORITY
] = { .type
= NETLINK_TYPE_U32
},
624 [FRA_FWMARK
] = { .type
= NETLINK_TYPE_U32
},
625 [FRA_FLOW
] = { .type
= NETLINK_TYPE_U32
},
626 [FRA_TUN_ID
] = { .type
= NETLINK_TYPE_U32
},
627 [FRA_SUPPRESS_IFGROUP
] = { .type
= NETLINK_TYPE_U32
},
628 [FRA_SUPPRESS_PREFIXLEN
] = { .type
= NETLINK_TYPE_U32
},
629 [FRA_TABLE
] = { .type
= NETLINK_TYPE_U32
},
630 [FRA_FWMASK
] = { .type
= NETLINK_TYPE_U32
},
631 [FRA_OIFNAME
] = { .type
= NETLINK_TYPE_STRING
},
632 [FRA_PAD
] = { .type
= NETLINK_TYPE_U32
},
633 [FRA_L3MDEV
] = { .type
= NETLINK_TYPE_U64
},
634 [FRA_UID_RANGE
] = { .size
= sizeof(struct fib_rule_uid_range
) },
637 static const NLTypeSystem rtnl_routing_policy_rule_type_system
= {
638 .count
= ELEMENTSOF(rtnl_routing_policy_rule_types
),
639 .types
= rtnl_routing_policy_rule_types
,
642 static const NLType rtnl_types
[] = {
643 [NLMSG_DONE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &empty_type_system
, .size
= 0 },
644 [NLMSG_ERROR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &empty_type_system
, .size
= sizeof(struct nlmsgerr
) },
645 [RTM_NEWLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
646 [RTM_DELLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
647 [RTM_GETLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
648 [RTM_SETLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
649 [RTM_NEWADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
650 [RTM_DELADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
651 [RTM_GETADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
652 [RTM_NEWROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
653 [RTM_DELROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
654 [RTM_GETROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
655 [RTM_NEWNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
656 [RTM_DELNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
657 [RTM_GETNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
658 [RTM_NEWADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
659 [RTM_DELADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
660 [RTM_GETADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
661 [RTM_NEWRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct rtmsg
) },
662 [RTM_DELRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct rtmsg
) },
663 [RTM_GETRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct rtmsg
) },
666 const NLTypeSystem type_system_root
= {
667 .count
= ELEMENTSOF(rtnl_types
),
671 uint16_t type_get_type(const NLType
*type
) {
676 size_t type_get_size(const NLType
*type
) {
681 void type_get_type_system(const NLType
*nl_type
, const NLTypeSystem
**ret
) {
684 assert(nl_type
->type
== NETLINK_TYPE_NESTED
);
685 assert(nl_type
->type_system
);
687 *ret
= nl_type
->type_system
;
690 void type_get_type_system_union(const NLType
*nl_type
, const NLTypeSystemUnion
**ret
) {
693 assert(nl_type
->type
== NETLINK_TYPE_UNION
);
694 assert(nl_type
->type_system_union
);
696 *ret
= nl_type
->type_system_union
;
699 uint16_t type_system_get_count(const NLTypeSystem
*type_system
) {
701 return type_system
->count
;
704 int type_system_get_type(const NLTypeSystem
*type_system
, const NLType
**ret
, uint16_t type
) {
705 const NLType
*nl_type
;
709 assert(type_system
->types
);
711 if (type
>= type_system
->count
)
714 nl_type
= &type_system
->types
[type
];
716 if (nl_type
->type
== NETLINK_TYPE_UNSPEC
)
724 int type_system_get_type_system(const NLTypeSystem
*type_system
, const NLTypeSystem
**ret
, uint16_t type
) {
725 const NLType
*nl_type
;
730 r
= type_system_get_type(type_system
, &nl_type
, type
);
734 type_get_type_system(nl_type
, ret
);
738 int type_system_get_type_system_union(const NLTypeSystem
*type_system
, const NLTypeSystemUnion
**ret
, uint16_t type
) {
739 const NLType
*nl_type
;
744 r
= type_system_get_type(type_system
, &nl_type
, type
);
748 type_get_type_system_union(nl_type
, ret
);
752 int type_system_union_get_type_system(const NLTypeSystemUnion
*type_system_union
, const NLTypeSystem
**ret
, const char *key
) {
755 assert(type_system_union
);
756 assert(type_system_union
->match_type
== NL_MATCH_SIBLING
);
757 assert(type_system_union
->lookup
);
758 assert(type_system_union
->type_systems
);
762 type
= type_system_union
->lookup(key
);
766 assert(type
< type_system_union
->num
);
768 *ret
= &type_system_union
->type_systems
[type
];
773 int type_system_union_protocol_get_type_system(const NLTypeSystemUnion
*type_system_union
, const NLTypeSystem
**ret
, uint16_t protocol
) {
774 const NLTypeSystem
*type_system
;
776 assert(type_system_union
);
777 assert(type_system_union
->type_systems
);
778 assert(type_system_union
->match_type
== NL_MATCH_PROTOCOL
);
781 if (protocol
>= type_system_union
->num
)
784 type_system
= &type_system_union
->type_systems
[protocol
];
785 if (!type_system
->types
)