Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-netlink-route.c
blob1706260dc2075cfb70d523a2ff0d6332d38de2ea
1 /* packet-netlink-route.c
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 /* man 7 rtnetlink */
12 #include "config.h"
14 #include <epan/packet.h>
15 #include <epan/aftypes.h>
16 #include <epan/to_str.h>
17 #include <epan/tfs.h>
18 #include <wsutil/array.h>
20 #include "packet-arp.h"
21 #include "packet-netlink.h"
23 void proto_register_netlink_route(void);
24 void proto_reg_handoff_netlink_route(void);
27 * The "legacy" flag indicates that the packet is a legacy dump
28 * request message.
30 * Some legacy tools, including iproute2 < 3.9, issue shorter RTM_GETLINK
31 * and RTM_GETADDR dump queries which only contain struct rtgenmsg rather
32 * than struct ifinfomsg. As noted in kernel comment in rtnl_dump_ifinfo(),
33 * these legacy requests will be (even with attributes) always shorter than
34 * struct ifinfomsg so that they are easy to detect.
36 * Similar problem can be observed with tools using nl_rtgen_request()
37 * function from libnl3; this also affects other RTM_GET* types.
39 * If such legacy message is detected by length shorter than expected data
40 * structure, we parse it as this legacy version with (1-byte) struct
41 * rtgenmsg so that it's shown as intended rather than as malformed.
43 * The legacy messages appear, from looking at the iproute2 3.1.0 code,
44 * to be a structure containing a struct nlmsghdr followed by a struct
45 * rtgenmsg.
47 * struct rtgenmsg contains only a 1-byte address family value, as noted.
48 * *However*, a struct nlmsghdr has a 4-byte length field, and is, as a
49 * result, aligned on a 4-byte boundary, so the structure containing those
50 * two structures is also aligned on a 4-byte boundary, and thus has a
51 * length that's a multiple of 4 bytes. Therefore, there are 3 bytes of
52 * padding following the address family byte.
54 * The message length, however, doesn't include those bytes.
56 * Legacy messages don't include any attributes - they're not large enough
57 * to contain anything other than the netlink message header and the one-byte
58 * address family. For legacy messages, the attribute we hand to
59 * dissect_netlink_route_attributes() is not aligned on a 4-byte boundary,
60 * as it's the offset right after the 1-byte address family value;
61 * dissect_netlink_route_attributes() will try to align that on a 4-byte
62 * boundary, but that will go past the "immediately after the end of
63 * the packet" offset, which can cause problems if any checking is done
64 * to make sure the offset is valid. Therefore, we don't try to dissect
65 * the attributes, rather than relying on the attributes dissector to
66 * discover that there's nothing left in the packet.
68 struct netlink_route_info {
69 packet_info *pinfo;
70 bool legacy;
73 enum {
74 /* rtnetlink values for nlmsghdr.nlmsg_type from <include/uapi/linux/rtnetlink.h> */
75 WS_RTM_NEWLINK = 16,
76 WS_RTM_DELLINK = 17,
77 WS_RTM_GETLINK = 18,
78 WS_RTM_SETLINK = 19,
79 WS_RTM_NEWADDR = 20,
80 WS_RTM_DELADDR = 21,
81 WS_RTM_GETADDR = 22,
82 WS_RTM_NEWROUTE = 24,
83 WS_RTM_DELROUTE = 25,
84 WS_RTM_GETROUTE = 26,
85 WS_RTM_NEWNEIGH = 28,
86 WS_RTM_DELNEIGH = 29,
87 WS_RTM_GETNEIGH = 30,
88 WS_RTM_NEWRULE = 32,
89 WS_RTM_DELRULE = 33,
90 WS_RTM_GETRULE = 34,
91 WS_RTM_NEWQDISC = 36,
92 WS_RTM_DELQDISC = 37,
93 WS_RTM_GETQDISC = 38,
94 WS_RTM_NEWTCLASS = 40,
95 WS_RTM_DELTCLASS = 41,
96 WS_RTM_GETTCLASS = 42,
97 WS_RTM_NEWTFILTER = 44,
98 WS_RTM_DELTFILTER = 45,
99 WS_RTM_GETTFILTER = 46,
100 WS_RTM_NEWACTION = 48,
101 WS_RTM_DELACTION = 49,
102 WS_RTM_GETACTION = 50,
103 WS_RTM_NEWPREFIX = 52,
104 WS_RTM_GETMULTICAST = 58,
105 WS_RTM_GETANYCAST = 62,
106 WS_RTM_NEWNEIGHTBL = 64,
107 WS_RTM_GETNEIGHTBL = 66,
108 WS_RTM_SETNEIGHTBL = 67,
109 WS_RTM_NEWNDUSEROPT = 68,
110 WS_RTM_NEWADDRLABEL = 72,
111 WS_RTM_DELADDRLABEL = 73,
112 WS_RTM_GETADDRLABEL = 74,
113 WS_RTM_GETDCB = 78,
114 WS_RTM_SETDCB = 79,
115 WS_RTM_NEWNETCONF = 80,
116 WS_RTM_DELNETCONF = 81,
117 WS_RTM_GETNETCONF = 82,
118 WS_RTM_NEWMDB = 84,
119 WS_RTM_DELMDB = 85,
120 WS_RTM_GETMDB = 86,
121 WS_RTM_NEWNSID = 88,
122 WS_RTM_DELNSID = 89,
123 WS_RTM_GETNSID = 90,
124 WS_RTM_NEWSTATS = 92,
125 WS_RTM_GETSTATS = 94,
126 WS_RTM_NEWCACHEREPORT = 96,
127 WS_RTM_NEWCHAIN = 100,
128 WS_RTM_DELCHAIN = 101,
129 WS_RTM_GETCHAIN = 102,
130 WS_RTM_NEWNEXTHOP = 104,
131 WS_RTM_DELNEXTHOP = 105,
132 WS_RTM_GETNEXTHOP = 106,
133 WS_RTM_NEWLINKPROP = 108,
134 WS_RTM_DELLINKPROP = 109,
135 WS_RTM_GETLINKPROP = 110,
136 WS_RTM_NEWVLAN = 112,
137 WS_RTM_DELVLAN = 113,
138 WS_RTM_GETVLAN = 114,
139 WS_RTM_NEWNEXTHOPBUCKET = 116,
140 WS_RTM_DELNEXTHOPBUCKET = 117,
141 WS_RTM_GETNEXTHOPBUCKET = 118,
142 WS_RTM_NEWTUNNEL = 120,
143 WS_RTM_DELTUNNEL = 121,
144 WS_RTM_GETTUNNEL = 122,
147 /* values for rta_type (network interface) from </include/uapi/linux/if_link.h> */
148 enum ws_ifla_attr_type {
149 WS_IFLA_UNSPEC = 0,
150 WS_IFLA_ADDRESS = 1,
151 WS_IFLA_BROADCAST = 2,
152 WS_IFLA_IFNAME = 3,
153 WS_IFLA_MTU = 4,
154 WS_IFLA_LINK = 5,
155 WS_IFLA_QDISC = 6,
156 WS_IFLA_STATS = 7,
157 WS_IFLA_COST = 8,
158 WS_IFLA_PRIORITY = 9,
159 WS_IFLA_MASTER = 10,
160 WS_IFLA_WIRELESS = 11,
161 WS_IFLA_PROTINFO = 12,
162 WS_IFLA_TXQLEN = 13,
163 WS_IFLA_MAP = 14,
164 WS_IFLA_WEIGHT = 15,
165 WS_IFLA_OPERSTATE = 16,
166 WS_IFLA_LINKMODE = 17,
167 WS_IFLA_LINKINFO = 18,
168 WS_IFLA_NET_NS_PID = 19,
169 WS_IFLA_IFALIAS = 20,
170 WS_IFLA_NUM_VF = 21,
171 WS_IFLA_VFINFO_LIST = 22,
172 WS_IFLA_STATS64 = 23,
173 WS_IFLA_VF_PORTS = 24,
174 WS_IFLA_PORT_SELF = 25,
175 WS_IFLA_AF_SPEC = 26,
176 WS_IFLA_GROUP = 27,
177 WS_IFLA_NET_NS_FD = 28,
178 WS_IFLA_EXT_MASK = 29,
179 WS_IFLA_PROMISCUITY = 30,
180 WS_IFLA_NUM_TX_QUEUES = 31,
181 WS_IFLA_NUM_RX_QUEUES = 32,
182 WS_IFLA_CARRIER = 33,
183 WS_IFLA_PHYS_PORT_ID = 34,
184 WS_IFLA_CARRIER_CHANGES = 35,
185 WS_IFLA_PHYS_SWITCH_ID = 36,
186 WS_IFLA_LINK_NETNSID = 37,
187 WS_IFLA_PHYS_PORT_NAME = 38,
188 WS_IFLA_PROTO_DOWN = 39,
189 WS_IFLA_GSO_MAX_SEGS = 40,
190 WS_IFLA_GSO_MAX_SIZE = 41,
191 WS_IFLA_PAD = 42,
192 WS_IFLA_XDP = 43,
193 WS_IFLA_EVENT = 44,
194 WS_IFLA_NEW_NETNSID = 45,
195 WS_IFLA_IF_NETNSID = 46,
196 WS_IFLA_CARRIER_UP_COUNT = 47,
197 WS_IFLA_CARRIER_DOWN_COUNT = 48,
198 WS_IFLA_NEW_IFINDEX = 49,
199 WS_IFLA_MIN_MTU = 50,
200 WS_IFLA_MAX_MTU = 51,
201 WS_IFLA_PROP_LIST = 52,
202 WS_IFLA_ALT_IFNAME = 53,
203 WS_IFLA_PERM_ADDRESS = 54,
204 WS_IFLA_PROTO_DOWN_REASON = 55,
205 WS_IFLA_PARENT_DEV_NAME = 56,
206 WS_IFLA_PARENT_DEV_BUS_NAME = 57,
207 WS_IFLA_GRO_MAX_SIZE = 58,
208 WS_IFLA_TSO_MAX_SIZE = 59,
209 WS_IFLA_TSO_MAX_SEGS = 60,
210 WS_IFLA_ALLMULTI = 61,
213 /* values for rta_type (ip address) from <include/uapi/linux/if_addr.h> */
214 enum ws_ifa_attr_type {
215 WS_IFA_UNSPEC = 0,
216 WS_IFA_ADDRESS = 1,
217 WS_IFA_LOCAL = 2,
218 WS_IFA_LABEL = 3,
219 WS_IFA_BROADCAST = 4,
220 WS_IFA_ANYCAST = 5,
221 WS_IFA_CACHEINFO = 6,
222 WS_IFA_MULTICAST = 7,
223 WS_IFA_FLAGS = 8,
224 WS_IFA_RT_PRIORITY = 9,
225 WS_IFA_TARGET_NETNSID = 10,
226 WS_IFA_PROTO = 11,
229 /* values for rta_type (route) from <include/uapi/linux/rtnetlink.h> */
230 enum ws_rta_attr_type {
231 WS_RTA_UNSPEC = 0,
232 WS_RTA_DST = 1,
233 WS_RTA_SRC = 2,
234 WS_RTA_IIF = 3,
235 WS_RTA_OIF = 4,
236 WS_RTA_GATEWAY = 5,
237 WS_RTA_PRIORITY = 6,
238 WS_RTA_PREFSRC = 7,
239 WS_RTA_METRICS = 8,
240 WS_RTA_MULTIPATH = 9,
241 WS_RTA_PROTOINFO = 10,
242 WS_RTA_FLOW = 11,
243 WS_RTA_CACHEINFO = 12,
244 WS_RTA_SESSION = 13,
245 WS_RTA_MP_ALGO = 14,
246 WS_RTA_TABLE = 15,
247 WS_RTA_MARK = 16,
248 WS_RTA_MFC_STATS = 17,
249 WS_RTA_VIA = 18,
250 WS_RTA_NEWDST = 19,
251 WS_RTA_PREF = 20,
252 WS_RTA_ENCAP_TYPE= 21,
253 WS_RTA_ENCAP = 22,
254 WS_RTA_EXPIRES = 23,
255 WS_RTA_PAD = 24,
256 WS_RTA_UID = 25,
257 WS_RTA_TTL_PROPAGATE = 26,
258 WS_RTA_IP_PROTO = 27,
259 WS_RTA_SPORT = 28,
260 WS_RTA_DPORT = 29,
261 WS_RTA_NH_ID = 30,
265 /* values for rtmsg.rtm_protocol from <include/uapi/linux/rtnetlink.h> */
266 enum {
267 /* kernel */
268 WS_RTPROT_UNSPEC = 0,
269 WS_RTPROT_REDIRECT = 1,
270 WS_RTPROT_KERNEL = 2,
271 WS_RTPROT_BOOT = 3,
272 WS_RTPROT_STATIC = 4,
273 /* user */
274 WS_RTPROT_GATED = 8,
275 WS_RTPROT_RA = 9,
276 WS_RTPROT_MRT = 10,
277 WS_RTPROT_ZEBRA = 11,
278 WS_RTPROT_BIRD = 12,
279 WS_RTPROT_DNROUTED = 13,
280 WS_RTPROT_XORP = 14,
281 WS_RTPROT_NTK = 15,
282 WS_RTPROT_DHCP = 16,
283 WS_RTPROT_MROUTED = 17,
284 WS_RTPROT_KEEPALIVED = 18,
285 WS_RTPROT_BABEL = 42,
286 WS_RTPROT_OPENR = 99,
287 WS_RTPROT_BGP = 186,
288 WS_RTPROT_ISIS = 187,
289 WS_RTPROT_OSPF = 188,
290 WS_RTPROT_RIP = 189,
291 WS_RTPROT_EIGRP = 192,
294 /* values for rtmsg.rtm_scope from <include/uapi/linux/rtnetlink.h> */
295 enum {
296 WS_RT_SCOPE_UNIVERSE = 0,
297 /* ... user defined (/etc/iproute2/rt_scopes) ... */
298 WS_RT_SCOPE_SITE = 200,
299 WS_RT_SCOPE_LINK = 253,
300 WS_RT_SCOPE_HOST = 254,
301 WS_RT_SCOPE_NOWHERE = 255
304 /* values for rtmsg.rtm_type from <include/uapi/linux/rtnetlink.h> */
305 enum {
306 WS_RTN_UNSPEC = 0,
307 WS_RTN_UNICAST = 1,
308 WS_RTN_LOCAL = 2,
309 WS_RTN_BROADCAST = 3,
310 WS_RTN_ANYCAST = 4,
311 WS_RTN_MULTICAST = 5,
312 WS_RTN_BLACKHOLE = 6,
313 WS_RTN_UNREACHABLE = 7,
314 WS_RTN_PROHIBIT = 8,
315 WS_RTN_THROW = 9,
316 WS_RTN_NAT = 10,
317 WS_RTN_XRESOLVE = 11
320 /* values for ifinfomsg.ifi_flags <include/uapi/linux/if.h> */
321 enum {
322 WS_IFF_UP = 0x1,
323 WS_IFF_BROADCAST = 0x2,
324 WS_IFF_DEBUG = 0x4,
325 WS_IFF_LOOPBACK = 0x8,
326 WS_IFF_POINTOPOINT = 0x10,
327 WS_IFF_NOTRAILERS = 0x20,
328 WS_IFF_RUNNING = 0x40,
329 WS_IFF_NOARP = 0x80,
330 WS_IFF_PROMISC = 0x100,
331 WS_IFF_ALLMULTI = 0x200,
332 WS_IFF_MASTER = 0x400,
333 WS_IFF_SLAVE = 0x800,
334 WS_IFF_MULTICAST = 0x1000,
335 WS_IFF_PORTSEL = 0x2000,
336 WS_IFF_AUTOMEDIA = 0x4000,
337 WS_IFF_DYNAMIC = 0x8000,
338 WS_IFF_LOWER_UP = 0x10000,
339 WS_IFF_DORMANT = 0x20000,
340 WS_IFF_ECHO = 0x40000
343 /* values for ifaddrmsg.ifa_flags <include/uapi/linux/if_addr.h> */
344 enum {
345 WS_IFA_F_SECONDARY = 0x01,
346 WS_IFA_F_NODAD = 0x02,
347 WS_IFA_F_OPTIMISTIC = 0x04,
348 WS_IFA_F_DADFAILED = 0x08,
349 WS_IFA_F_HOMEADDRESS = 0x10,
350 WS_IFA_F_DEPRECATED = 0x20,
351 WS_IFA_F_TENTATIVE = 0x40,
352 WS_IFA_F_PERMANENT = 0x80,
353 WS_IFA_F_MANAGETEMPADDR = 0x100,
354 WS_IFA_F_NOPREFIXROUTE = 0x200,
355 WS_IFA_F_MCAUTOJOIN = 0x400,
356 WS_IFA_F_STABLE_PRIVACY = 0x800,
359 /* values for ndmsg.ndm_state <include/uapi/linux/neighbour.h> */
360 enum {
361 WS_NUD_INCOMPLETE = 0x01,
362 WS_NUD_REACHABLE = 0x02,
363 WS_NUD_STALE = 0x04,
364 WS_NUD_DELAY = 0x08,
365 WS_NUD_PROBE = 0x10,
366 WS_NUD_FAILED = 0x20,
367 /* Dummy states */
368 WS_NUD_NOARP = 0x40,
369 WS_NUD_PERMANENT = 0x80,
370 WS_NUD_NONE = 0x00
373 /* values for ifla.operstate <include/uapi/linux/if.h> */
374 enum {
375 WS_IF_OPER_UNKNOWN,
376 WS_IF_OPER_NOTPRESENT,
377 WS_IF_OPER_DOWN,
378 WS_IF_OPER_LOWERLAYERDOWN,
379 WS_IF_OPER_TESTING,
380 WS_IF_OPER_DORMANT,
381 WS_IF_OPER_UP,
384 static int proto_netlink_route;
386 static dissector_handle_t netlink_route_handle;
388 static int hf_netlink_route_ifa_addr4;
389 static int hf_netlink_route_ifa_addr6;
390 static int hf_netlink_route_ifa_attr_type;
391 static int hf_netlink_route_ifa_family;
392 static int hf_netlink_route_ifa_flags;
393 static int hf_netlink_route_ifa_flags32;
394 static int hf_netlink_route_ifa_index;
395 static int hf_netlink_route_ifa_label;
396 static int hf_netlink_route_ifa_prefixlen;
397 static int hf_netlink_route_ifa_scope;
398 static int hf_netlink_route_ifi_change;
399 static int hf_netlink_route_ifi_family;
400 static int hf_netlink_route_ifi_flags;
401 static int hf_netlink_route_ifi_flags_iff_broadcast;
402 static int hf_netlink_route_ifi_flags_iff_up;
403 static int hf_netlink_route_ifi_index;
404 static int hf_netlink_route_ifi_type;
405 static int hf_netlink_route_ifla_attr_type;
406 static int hf_netlink_route_ifla_broadcast;
407 static int hf_netlink_route_ifla_carrier;
408 static int hf_netlink_route_ifla_carrier_changes;
409 static int hf_netlink_route_ifla_carrier_down_count;
410 static int hf_netlink_route_ifla_carrier_up_count;
411 static int hf_netlink_route_ifla_group;
412 static int hf_netlink_route_ifla_gso_maxsegs;
413 static int hf_netlink_route_ifla_gso_maxsize;
414 static int hf_netlink_route_ifla_hwaddr;
415 static int hf_netlink_route_ifla_ifname;
416 static int hf_netlink_route_ifla_linkstats_collisions;
417 static int hf_netlink_route_ifla_linkstats_multicast;
418 static int hf_netlink_route_ifla_linkstats_rx_crc_errs;
419 static int hf_netlink_route_ifla_linkstats_rx_fifo_errs;
420 static int hf_netlink_route_ifla_linkstats_rx_frame_errs;
421 static int hf_netlink_route_ifla_linkstats_rx_len_errs;
422 static int hf_netlink_route_ifla_linkstats_rx_miss_errs;
423 static int hf_netlink_route_ifla_linkstats_rx_over_errs;
424 static int hf_netlink_route_ifla_linkstats_rxbytes;
425 static int hf_netlink_route_ifla_linkstats_rxdropped;
426 static int hf_netlink_route_ifla_linkstats_rxerrors;
427 static int hf_netlink_route_ifla_linkstats_rxpackets;
428 static int hf_netlink_route_ifla_linkstats_tx_abort_errs;
429 static int hf_netlink_route_ifla_linkstats_tx_carrier_errs;
430 static int hf_netlink_route_ifla_linkstats_tx_fifo_errs;
431 static int hf_netlink_route_ifla_linkstats_tx_heartbeat_errs;
432 static int hf_netlink_route_ifla_linkstats_tx_window_errs;
433 static int hf_netlink_route_ifla_linkstats_txbytes;
434 static int hf_netlink_route_ifla_linkstats_txdropped;
435 static int hf_netlink_route_ifla_linkstats_txerrors;
436 static int hf_netlink_route_ifla_linkstats_txpackets;
437 static int hf_netlink_route_ifla_map_baseaddr;
438 static int hf_netlink_route_ifla_map_dma;
439 static int hf_netlink_route_ifla_map_irq;
440 static int hf_netlink_route_ifla_map_memend;
441 static int hf_netlink_route_ifla_map_memstart;
442 static int hf_netlink_route_ifla_map_port;
443 static int hf_netlink_route_ifla_max_mtu;
444 static int hf_netlink_route_ifla_min_mtu;
445 static int hf_netlink_route_ifla_mtu;
446 static int hf_netlink_route_ifla_operstate;
447 static int hf_netlink_route_ifla_promiscuity;
448 static int hf_netlink_route_ifla_qdisc;
449 static int hf_netlink_route_ifla_rxqnum;
450 static int hf_netlink_route_ifla_txqlen;
451 static int hf_netlink_route_ifla_txqnum;
452 static int hf_netlink_route_nd_family;
453 static int hf_netlink_route_nd_flags;
454 static int hf_netlink_route_nd_index;
455 static int hf_netlink_route_nd_state;
456 static int hf_netlink_route_nd_type;
457 static int hf_netlink_route_nltype;
458 static int hf_netlink_route_rt_dst_len;
459 static int hf_netlink_route_rt_family;
460 static int hf_netlink_route_rt_flags;
461 static int hf_netlink_route_rt_protocol;
462 static int hf_netlink_route_rt_scope;
463 static int hf_netlink_route_rt_src_len;
464 static int hf_netlink_route_rt_table;
465 static int hf_netlink_route_rt_tos;
466 static int hf_netlink_route_rt_type;
467 static int hf_netlink_route_rta_attr_type;
468 static int hf_netlink_route_rta_iif;
469 static int hf_netlink_route_rta_oif;
471 static int ett_netlink_route;
472 static int ett_netlink_route_attr;
473 static int ett_netlink_route_if_flags;
474 static int ett_netlink_route_attr_linkstats;
475 static int ett_netlink_route_attr_linkstats_rxerrs;
476 static int ett_netlink_route_attr_linkstats_txerrs;
478 static void
479 _fill_label_value_string_bitmask(char *label, uint32_t value, const value_string *vals)
481 char tmp[16];
483 label[0] = '\0';
485 while (vals->strptr) {
486 if (value & vals->value) {
487 value &= ~(vals->value);
488 if (label[0])
489 (void) g_strlcat(label, ", ", ITEM_LABEL_LENGTH);
491 (void) g_strlcat(label, vals->strptr, ITEM_LABEL_LENGTH);
494 vals++;
497 if (value) {
498 if (label[0])
499 (void) g_strlcat(label, ", ", ITEM_LABEL_LENGTH);
500 snprintf(tmp, sizeof(tmp), "0x%x", value);
501 (void) g_strlcat(label, tmp, ITEM_LABEL_LENGTH);
505 static int
506 dissect_netlink_route_attributes(tvbuff_t *tvb, int hf_type, struct netlink_route_info *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset, netlink_attributes_cb_t cb)
508 /* XXX, it's *almost* the same:
509 * - rtnetlink is using struct rtattr with shorts
510 * - generic netlink is using struct nlattr with __u16
513 /* XXX, nice */
514 return dissect_netlink_attributes_to_end(tvb, hf_type, ett_netlink_route_attr, info, nl_data, tree, offset, cb);
517 static void
518 hf_netlink_route_ifi_flags_label(char *label, uint32_t value)
520 static const value_string iff_vals[] = {
521 { WS_IFF_UP, "UP" },
522 { WS_IFF_BROADCAST, "BROADCAST" },
523 { WS_IFF_DEBUG, "DEBUG" },
524 { WS_IFF_LOOPBACK, "LOOPBACK" },
525 { WS_IFF_POINTOPOINT, "POINTOPOINT" },
526 { WS_IFF_NOTRAILERS, "NOTRAILERS" },
527 { WS_IFF_RUNNING, "RUNNING" },
528 { WS_IFF_NOARP, "NOARP" },
529 { WS_IFF_PROMISC, "PROMISC" },
530 { WS_IFF_ALLMULTI, "ALLMULTI" },
531 { WS_IFF_MASTER, "MASTER" },
532 { WS_IFF_SLAVE, "SLAVE" },
533 { WS_IFF_MULTICAST, "MULTICAST" },
534 { WS_IFF_PORTSEL, "PORTSEL" },
535 { WS_IFF_AUTOMEDIA, "AUTOMEDIA" },
536 { WS_IFF_DYNAMIC, "DYNAMIC" },
537 { WS_IFF_LOWER_UP, "LOWER_UP" },
538 { WS_IFF_DORMANT, "DORMANT" },
539 { WS_IFF_ECHO, "ECHO" },
540 { 0, NULL }
543 char tmp[16];
545 _fill_label_value_string_bitmask(label, value, iff_vals);
547 snprintf(tmp, sizeof(tmp), " (0x%.8x)", value);
548 (void) g_strlcat(label, tmp, ITEM_LABEL_LENGTH);
551 static int
552 dissect_netlink_route_ifinfomsg(tvbuff_t *tvb, struct netlink_route_info *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
554 proto_item *ti;
555 proto_tree *if_flags_tree;
557 proto_tree_add_item(tree, hf_netlink_route_ifi_family, tvb, offset, 1, nl_data->encoding);
558 offset += 1;
560 if (info->legacy) {
562 * See the comment for the netlink_route_info structure,
563 * above.
565 return offset;
568 /* XXX padding, check if 0 */
569 offset += 1;
571 proto_tree_add_item(tree, hf_netlink_route_ifi_type, tvb, offset, 2, nl_data->encoding);
572 offset += 2;
574 proto_tree_add_item(tree, hf_netlink_route_ifi_index, tvb, offset, 4, nl_data->encoding);
575 offset += 4;
577 ti = proto_tree_add_item(tree, hf_netlink_route_ifi_flags, tvb, offset, 4, nl_data->encoding);
578 if_flags_tree = proto_item_add_subtree(ti, ett_netlink_route_if_flags);
580 if (if_flags_tree) {
581 proto_tree_add_item(if_flags_tree, hf_netlink_route_ifi_flags_iff_up, tvb, offset, 4, nl_data->encoding);
582 proto_tree_add_item(if_flags_tree, hf_netlink_route_ifi_flags_iff_broadcast, tvb, offset, 4, nl_data->encoding);
583 /* XXX */
585 offset += 4;
587 proto_tree_add_item(tree, hf_netlink_route_ifi_change, tvb, offset, 4, nl_data->encoding);
588 offset += 4;
590 return offset;
593 /* Interface Attributes */
595 static const value_string netlink_route_ifla_attr_vals[] = {
596 { WS_IFLA_UNSPEC, "Unspecified" },
597 { WS_IFLA_ADDRESS, "HW Address" },
598 { WS_IFLA_BROADCAST, "Broadcast" },
599 { WS_IFLA_IFNAME, "Device name" },
600 { WS_IFLA_MTU, "MTU" },
601 { WS_IFLA_LINK, "Link type" },
602 { WS_IFLA_QDISC, "Queueing discipline" },
603 { WS_IFLA_STATS, "Interface Statistics" },
604 { WS_IFLA_COST, "Cost" },
605 { WS_IFLA_PRIORITY, "Priority" },
606 { WS_IFLA_MASTER, "Master" },
607 { WS_IFLA_WIRELESS, "Wireless" },
608 { WS_IFLA_PROTINFO, "Prot info" },
609 { WS_IFLA_TXQLEN, "TxQueue length"},
610 { WS_IFLA_MAP, "Map"},
611 { WS_IFLA_WEIGHT, "Weight"},
612 { WS_IFLA_OPERSTATE, "Operstate"},
613 { WS_IFLA_LINKMODE, "Link mode"},
614 { WS_IFLA_LINKINFO, "Link info"},
615 { WS_IFLA_NET_NS_PID, "NetNs id"},
616 { WS_IFLA_IFALIAS, "Ifalias"},
617 { WS_IFLA_NUM_VF, "Num VF"},
618 { WS_IFLA_VFINFO_LIST, "VF Info"},
619 { WS_IFLA_STATS64, "Stats" },
620 { WS_IFLA_VF_PORTS, "VF ports" },
621 { WS_IFLA_PORT_SELF, "Port self" },
622 { WS_IFLA_AF_SPEC, "AF spec" },
623 { WS_IFLA_GROUP, "Group" },
624 { WS_IFLA_NET_NS_FD, "NetNs fd" },
625 { WS_IFLA_EXT_MASK, "Ext mask" },
626 { WS_IFLA_PROMISCUITY, "Promiscuity" },
627 { WS_IFLA_NUM_TX_QUEUES, "Number of Tx queues" },
628 { WS_IFLA_NUM_RX_QUEUES, "Number of Rx queues" },
629 { WS_IFLA_CARRIER, "Carrier" },
630 { WS_IFLA_PHYS_PORT_ID, "Physical port ID" },
631 { WS_IFLA_CARRIER_CHANGES,"Carrier changes" },
632 { WS_IFLA_PHYS_SWITCH_ID, "Physical switch ID" },
633 { WS_IFLA_LINK_NETNSID, "Link network namespace ID" },
634 { WS_IFLA_PHYS_PORT_NAME, "Physical port name" },
635 { WS_IFLA_PROTO_DOWN, "IFLA_PROTO_DOWN" },
636 { WS_IFLA_GSO_MAX_SEGS, "Maximum GSO segment count" },
637 { WS_IFLA_GSO_MAX_SIZE, "Maximum GSO size" },
638 { WS_IFLA_PAD, "IFLA_PAD" },
639 { WS_IFLA_XDP, "IFLA_XDP" },
640 { WS_IFLA_EVENT, "IFLA_EVENT" },
641 { WS_IFLA_NEW_NETNSID, "IFLA_NEW_NETNSID" },
642 { WS_IFLA_IF_NETNSID, "IFLA_IF_NETNSID" },
643 { WS_IFLA_CARRIER_UP_COUNT, "Carrier up count" },
644 { WS_IFLA_CARRIER_DOWN_COUNT, "Carrier down count" },
645 { WS_IFLA_NEW_IFINDEX, "IFLA_NEW_IFINDEX" },
646 { WS_IFLA_MIN_MTU, "Minimum MTU" },
647 { WS_IFLA_MAX_MTU, "Maximum MTU" },
648 { WS_IFLA_PROP_LIST, "Property list" },
649 { WS_IFLA_ALT_IFNAME, "Alternative ifname" },
650 { WS_IFLA_PERM_ADDRESS, "Permanent address" },
651 { WS_IFLA_PROTO_DOWN_REASON, "Protocol down reason" },
652 { WS_IFLA_PARENT_DEV_NAME, "Parent device name" },
653 { WS_IFLA_PARENT_DEV_BUS_NAME, "Parent device bus name" },
654 { WS_IFLA_GRO_MAX_SIZE, "GRO maximum size" },
655 { WS_IFLA_TSO_MAX_SIZE, "TSO maximum size" },
656 { WS_IFLA_TSO_MAX_SEGS, "TSO maximum number of segments" },
657 { WS_IFLA_ALLMULTI, "Allmulti count" },
658 { 0, NULL }
661 static const value_string netlink_route_ifla_operstate_vals[] = {
662 { WS_IF_OPER_UNKNOWN, "Unknown" },
663 { WS_IF_OPER_NOTPRESENT, "Not present" },
664 { WS_IF_OPER_DOWN, "Down" },
665 { WS_IF_OPER_LOWERLAYERDOWN, "Lower layer down" },
666 { WS_IF_OPER_TESTING, "Testing" },
667 { WS_IF_OPER_DORMANT, "Dormant" },
668 { WS_IF_OPER_UP, "Up"},
669 { 0, NULL }
672 static int *linkstat_root_hfs[] = {
673 &hf_netlink_route_ifla_linkstats_rxpackets,
674 &hf_netlink_route_ifla_linkstats_txpackets,
675 &hf_netlink_route_ifla_linkstats_rxbytes,
676 &hf_netlink_route_ifla_linkstats_txbytes,
677 &hf_netlink_route_ifla_linkstats_rxerrors,
678 &hf_netlink_route_ifla_linkstats_txerrors,
679 &hf_netlink_route_ifla_linkstats_rxdropped,
680 &hf_netlink_route_ifla_linkstats_txdropped,
681 &hf_netlink_route_ifla_linkstats_multicast,
682 &hf_netlink_route_ifla_linkstats_collisions,
686 static int *linkstat_rxerr_hfs[] = {
687 &hf_netlink_route_ifla_linkstats_rx_len_errs,
688 &hf_netlink_route_ifla_linkstats_rx_over_errs,
689 &hf_netlink_route_ifla_linkstats_rx_crc_errs,
690 &hf_netlink_route_ifla_linkstats_rx_frame_errs,
691 &hf_netlink_route_ifla_linkstats_rx_fifo_errs,
692 &hf_netlink_route_ifla_linkstats_rx_miss_errs,
696 static int *linkstat_txerr_hfs[] = {
697 &hf_netlink_route_ifla_linkstats_tx_abort_errs,
698 &hf_netlink_route_ifla_linkstats_tx_carrier_errs,
699 &hf_netlink_route_ifla_linkstats_tx_fifo_errs,
700 &hf_netlink_route_ifla_linkstats_tx_heartbeat_errs,
701 &hf_netlink_route_ifla_linkstats_tx_window_errs,
704 static int
705 dissect_netlink_route_ifla_linkstats(tvbuff_t *tvb, struct netlink_route_info *info _U_, struct packet_netlink_data *nl_data, proto_tree *tree, int offset, int byte_size)
707 proto_tree* rxerr_subtree;
708 const int rxerr_hfs_len = array_length(linkstat_rxerr_hfs);
709 proto_tree* txerr_subtree;
710 const int txerr_hfs_len = array_length(linkstat_txerr_hfs);
712 for (size_t i = 0; i < array_length(linkstat_root_hfs); i++) {
713 proto_tree_add_item(tree, *linkstat_root_hfs[i], tvb, offset, byte_size, nl_data->encoding);
714 offset += byte_size;
717 rxerr_subtree = proto_tree_add_subtree(tree, tvb, offset, byte_size * rxerr_hfs_len, ett_netlink_route_attr_linkstats_rxerrs, NULL, "Rx errors");
718 for (int i = 0; i < rxerr_hfs_len; i++) {
719 proto_tree_add_item(rxerr_subtree, *linkstat_rxerr_hfs[i], tvb, offset, byte_size, nl_data->encoding);
720 offset += byte_size;
723 txerr_subtree = proto_tree_add_subtree(tree, tvb, offset, byte_size * txerr_hfs_len, ett_netlink_route_attr_linkstats_txerrs, NULL, "Tx errors");
724 for (int i = 0; i < txerr_hfs_len; i++) {
725 proto_tree_add_item(txerr_subtree, *linkstat_txerr_hfs[i], tvb, offset, byte_size, nl_data->encoding);
726 offset += byte_size;
730 return 1;
733 static int
734 dissect_netlink_route_ifla_attrs(tvbuff_t *tvb, void *data, struct packet_netlink_data *nl_data, proto_tree *tree, int rta_type, int offset, int len)
736 struct netlink_route_info *info = (struct netlink_route_info *)data;
737 enum ws_ifla_attr_type type = (enum ws_ifla_attr_type) rta_type;
738 const uint8_t* str;
739 uint32_t value;
740 bool flag;
741 proto_tree* subtree;
742 switch (type) {
743 case WS_IFLA_IFNAME:
744 proto_tree_add_item_ret_string(tree, hf_netlink_route_ifla_ifname, tvb, offset, len, ENC_ASCII | ENC_NA, wmem_packet_scope(), &str);
745 proto_item_append_text(tree, ": %s", str);
746 return 1;
747 case WS_IFLA_MTU:
748 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_mtu, tvb, offset, len, nl_data->encoding, &value);
749 proto_item_append_text(tree, ": %u", value);
750 return 1;
751 case WS_IFLA_TXQLEN:
752 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_txqlen, tvb, offset, len, nl_data->encoding, &value);
753 proto_item_append_text(tree, ": %u", value);
754 return 1;
755 case WS_IFLA_OPERSTATE:
756 proto_tree_add_item(tree, hf_netlink_route_ifla_operstate, tvb, offset, len, nl_data->encoding);
757 return 1;
758 case WS_IFLA_PROMISCUITY:
759 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_promiscuity, tvb, offset, len, nl_data->encoding, &value);
760 proto_item_append_text(tree, ": %u", value);
761 return 1;
762 case WS_IFLA_NUM_TX_QUEUES:
763 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_txqnum, tvb, offset, len, nl_data->encoding, &value);
764 proto_item_append_text(tree, ": %u", value);
765 return 1;
766 case WS_IFLA_NUM_RX_QUEUES:
767 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_rxqnum, tvb, offset, len, nl_data->encoding, &value);
768 proto_item_append_text(tree, ": %u", value);
769 return 1;
770 case WS_IFLA_GROUP:
771 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_group, tvb, offset, len, nl_data->encoding, &value);
772 proto_item_append_text(tree, ": %u", value);
773 return 1;
774 case WS_IFLA_GSO_MAX_SEGS:
775 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_gso_maxsegs, tvb, offset, len, nl_data->encoding, &value);
776 proto_item_append_text(tree, ": %u", value);
777 return 1;
778 case WS_IFLA_GSO_MAX_SIZE:
779 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_gso_maxsize, tvb, offset, len, nl_data->encoding, &value);
780 proto_item_append_text(tree, ": %u", value);
781 return 1;
782 case WS_IFLA_CARRIER:
783 proto_tree_add_item_ret_boolean(tree, hf_netlink_route_ifla_carrier, tvb, offset, len, nl_data->encoding, &flag);
784 proto_item_append_text(tree, ": %s", tfs_get_string(flag, &tfs_restricted_not_restricted));
785 return 1;
786 case WS_IFLA_CARRIER_CHANGES:
787 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_carrier_changes, tvb, offset, len, nl_data->encoding, &value);
788 proto_item_append_text(tree, ": %u", value);
789 return 1;
790 case WS_IFLA_ADDRESS:
791 proto_item_append_text(tree, ": %s", tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, offset, len, ':'));
792 proto_tree_add_item(tree, hf_netlink_route_ifla_hwaddr, tvb, offset, len, nl_data->encoding);
793 return 1;
794 case WS_IFLA_BROADCAST:
795 proto_item_append_text(tree, ": %s", tvb_bytes_to_str_punct(wmem_packet_scope(), tvb, offset, len, ':'));
796 proto_tree_add_item(tree, hf_netlink_route_ifla_broadcast, tvb, offset, len, nl_data->encoding);
797 return 1;
798 case WS_IFLA_STATS:
799 subtree = proto_tree_add_subtree(tree, tvb, offset, len, ett_netlink_route_attr_linkstats, NULL, "Statistics");
800 return dissect_netlink_route_ifla_linkstats(tvb, info, nl_data, subtree, offset, 4);
801 case WS_IFLA_STATS64:
802 subtree = proto_tree_add_subtree(tree, tvb, offset, len, ett_netlink_route_attr_linkstats, NULL, "Statistics");
803 return dissect_netlink_route_ifla_linkstats(tvb, info, nl_data, subtree, offset, 8);
804 case WS_IFLA_QDISC:
805 proto_tree_add_item_ret_string(tree, hf_netlink_route_ifla_qdisc, tvb, offset, len, ENC_ASCII | ENC_NA, wmem_packet_scope(), &str);
806 proto_item_append_text(tree, ": %s", str);
807 return 1;
808 case WS_IFLA_MAP:
809 proto_tree_add_item(tree, hf_netlink_route_ifla_map_memstart, tvb, offset, 8, nl_data->encoding);
810 proto_tree_add_item(tree, hf_netlink_route_ifla_map_memend, tvb, offset + 8, 8, nl_data->encoding);
811 proto_tree_add_item(tree, hf_netlink_route_ifla_map_baseaddr, tvb, offset + 16, 8, nl_data->encoding);
812 proto_tree_add_item(tree, hf_netlink_route_ifla_map_irq, tvb, offset + 24, 2, nl_data->encoding);
813 proto_tree_add_item(tree, hf_netlink_route_ifla_map_dma, tvb, offset + 26, 1, nl_data->encoding);
814 proto_tree_add_item(tree, hf_netlink_route_ifla_map_port, tvb, offset + 27, 1, nl_data->encoding);
815 return 1;
816 case WS_IFLA_CARRIER_UP_COUNT:
817 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_carrier_up_count, tvb, offset, len, nl_data->encoding, &value);
818 proto_item_append_text(tree, ": %u", value);
819 return 1;
820 case WS_IFLA_CARRIER_DOWN_COUNT:
821 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_carrier_down_count, tvb, offset, len, nl_data->encoding, &value);
822 proto_item_append_text(tree, ": %u", value);
823 return 1;
824 case WS_IFLA_MIN_MTU:
825 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_min_mtu, tvb, offset, len, nl_data->encoding, &value);
826 proto_item_append_text(tree, ": %u", value);
827 return 1;
828 case WS_IFLA_MAX_MTU:
829 proto_tree_add_item_ret_uint(tree, hf_netlink_route_ifla_max_mtu, tvb, offset, len, nl_data->encoding, &value);
830 proto_item_append_text(tree, ": %u", value);
831 return 1;
833 default:
834 return 0;
838 /* IP address */
840 static void
841 netlink_route_ifa_flags_label(char *label, uint32_t value)
843 static const value_string iff_vals[] = {
844 { WS_IFA_F_SECONDARY, "secondary/temporary" },
845 { WS_IFA_F_NODAD, "nodad" },
846 { WS_IFA_F_OPTIMISTIC, "optimistic" },
847 { WS_IFA_F_DADFAILED, "dadfailed" },
848 { WS_IFA_F_HOMEADDRESS, "homeaddress" },
849 { WS_IFA_F_DEPRECATED, "deprecated" },
850 { WS_IFA_F_TENTATIVE, "tentative" },
851 { WS_IFA_F_PERMANENT, "permanent" },
852 /* 32-bit IFA_FLAGS (in attribute) */
853 { WS_IFA_F_MANAGETEMPADDR, "mngtmpaddr" },
854 { WS_IFA_F_NOPREFIXROUTE, "noprefixroute" },
855 { WS_IFA_F_MCAUTOJOIN, "autojoin" },
856 { WS_IFA_F_STABLE_PRIVACY, "stable_privacy" },
857 { 0, NULL }
860 char tmp[16];
862 _fill_label_value_string_bitmask(label, value, iff_vals);
864 snprintf(tmp, sizeof(tmp), " (0x%.8x)", value);
865 (void) g_strlcat(label, tmp, ITEM_LABEL_LENGTH);
868 static int
869 dissect_netlink_route_ifaddrmsg(tvbuff_t *tvb, struct netlink_route_info *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
871 proto_tree_add_item(tree, hf_netlink_route_ifa_family, tvb, offset, 1, ENC_NA);
872 offset += 1;
874 if (info->legacy) {
876 * See the comment for the netlink_route_info structure,
877 * above.
879 return offset;
882 proto_tree_add_item(tree, hf_netlink_route_ifa_prefixlen, tvb, offset, 1, ENC_NA);
883 offset += 1;
885 proto_tree_add_item(tree, hf_netlink_route_ifa_flags, tvb, offset, 1, ENC_NA);
886 offset += 1;
888 proto_tree_add_item(tree, hf_netlink_route_ifa_scope, tvb, offset, 1, ENC_NA);
889 offset += 1;
891 proto_tree_add_item(tree, hf_netlink_route_ifa_index, tvb, offset, 4, nl_data->encoding);
892 offset += 4;
894 return offset;
897 /* IP address attributes */
899 static const value_string netlink_route_ifa_attr_vals[] = {
900 { WS_IFA_UNSPEC, "Unspecified" },
901 { WS_IFA_ADDRESS, "Interface address" },
902 { WS_IFA_LOCAL, "Local address" },
903 { WS_IFA_LABEL, "Name of interface" },
904 { WS_IFA_BROADCAST, "Broadcast address" },
905 { WS_IFA_ANYCAST, "Anycast address" },
906 { WS_IFA_CACHEINFO, "Address information" },
907 { WS_IFA_MULTICAST, "Multicast address" },
908 { WS_IFA_FLAGS, "Address flags" },
909 { WS_IFA_RT_PRIORITY, "IFA_RT_PRIORITY" },
910 { WS_IFA_TARGET_NETNSID, "IFA_TARGET_NETNSID" },
911 { WS_IFA_PROTO, "IFA_PROTO" },
912 { 0, NULL }
915 static int
916 dissect_netlink_route_ifa_attrs(tvbuff_t *tvb, void *data _U_, struct packet_netlink_data *nl_data, proto_tree *tree, int rta_type, int offset, int len)
918 enum ws_ifa_attr_type type = (enum ws_ifa_attr_type) rta_type;
919 const uint8_t* str;
921 switch (type) {
922 case WS_IFA_LABEL:
923 proto_tree_add_item_ret_string(tree, hf_netlink_route_ifa_label, tvb, offset, len, ENC_ASCII | ENC_NA, wmem_packet_scope(), &str);
924 proto_item_append_text(tree, ": %s", str);
925 return 1;
927 case WS_IFA_FLAGS:
928 proto_tree_add_item(tree, hf_netlink_route_ifa_flags32, tvb, offset, 4, nl_data->encoding);
929 return 1;
930 case WS_IFA_ADDRESS:
931 case WS_IFA_LOCAL:
932 case WS_IFA_BROADCAST:
933 if (len == 4) {
934 proto_item_append_text(tree, ": %s", tvb_ip_to_str(wmem_packet_scope(), tvb, offset));
935 proto_tree_add_item(tree, hf_netlink_route_ifa_addr4, tvb, offset, len, ENC_BIG_ENDIAN);
936 } else {
937 proto_item_append_text(tree, ": %s", tvb_ip6_to_str(wmem_packet_scope(), tvb, offset));
938 proto_tree_add_item(tree, hf_netlink_route_ifa_addr6, tvb, offset, len, ENC_NA);
940 return 1;
941 default:
942 return 0;
946 /* Route */
948 static const value_string netlink_route_rt_protocol_vals[] = {
949 { WS_RTPROT_UNSPEC, "unknown" },
950 { WS_RTPROT_REDIRECT, "ICMP redirects" },
951 { WS_RTPROT_KERNEL, "kernel" },
952 { WS_RTPROT_BOOT, "boot" },
953 { WS_RTPROT_STATIC, "static" },
954 { WS_RTPROT_GATED, "GateD" },
955 { WS_RTPROT_RA, "RDISC/ND router advertisements" },
956 { WS_RTPROT_MRT, "Merit MRT" },
957 { WS_RTPROT_ZEBRA, "Zebra" },
958 { WS_RTPROT_BIRD, "BIRD" },
959 { WS_RTPROT_DNROUTED, "DECnet routing daemon" },
960 { WS_RTPROT_XORP, "XORP" },
961 { WS_RTPROT_NTK, "Netsukuku" },
962 { WS_RTPROT_DHCP, "DHCP client" },
963 { WS_RTPROT_MROUTED, "Multicast daemon" },
964 { WS_RTPROT_KEEPALIVED, "Keepalived daemon" },
965 { WS_RTPROT_BABEL, "Babel daemon" },
966 { WS_RTPROT_OPENR, "Open Routing Routes" },
967 { WS_RTPROT_BGP, "BGP" },
968 { WS_RTPROT_ISIS, "ISIS" },
969 { WS_RTPROT_OSPF, "OSPF" },
970 { WS_RTPROT_RIP, "RIP" },
971 { WS_RTPROT_EIGRP, "EIGRP" },
972 { 0, NULL }
974 static value_string_ext hf_netlink_route_rt_protocol_vals_ext =
975 VALUE_STRING_EXT_INIT(netlink_route_rt_protocol_vals);
977 static const value_string netlink_route_rt_scope_vals[] = {
978 { WS_RT_SCOPE_UNIVERSE, "global route" },
979 { WS_RT_SCOPE_SITE, "interior route in the local autonomous system" },
980 { WS_RT_SCOPE_LINK, "route on this link" },
981 { WS_RT_SCOPE_HOST, "route on the local host" },
982 { WS_RT_SCOPE_NOWHERE, "destination doesn't exist" },
983 { 0, NULL }
986 static const value_string netlink_route_rt_type_vals[] = {
987 { WS_RTN_UNSPEC, "Unknown route" },
988 { WS_RTN_UNICAST, "Gateway or direct route" },
989 { WS_RTN_LOCAL, "Local interface route" },
990 { WS_RTN_BROADCAST, "Local broadcast route (send as broadcast)" },
991 { WS_RTN_ANYCAST, "Local broadcast route (send as unicast)" },
992 { WS_RTN_MULTICAST, "Multicast route" },
993 { WS_RTN_BLACKHOLE, "Drop" },
994 { WS_RTN_UNREACHABLE, "Unreachable destination" },
995 { WS_RTN_PROHIBIT, "Administratively prohibited" },
996 { WS_RTN_THROW, "Routing lookup in another table" },
997 { WS_RTN_NAT, "Network address translation rule" },
998 { WS_RTN_XRESOLVE, "Use external resolver" },
999 { 0, NULL }
1002 static int
1003 dissect_netlink_route_rtmsg(tvbuff_t *tvb, struct netlink_route_info *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
1005 proto_tree_add_item(tree, hf_netlink_route_rt_family, tvb, offset, 1, ENC_NA);
1006 offset += 1;
1008 if (info->legacy) {
1010 * See the comment for the netlink_route_info structure,
1011 * above.
1013 return offset;
1016 proto_tree_add_item(tree, hf_netlink_route_rt_dst_len, tvb, offset, 1, ENC_NA);
1017 offset += 1;
1019 proto_tree_add_item(tree, hf_netlink_route_rt_src_len, tvb, offset, 1, ENC_NA);
1020 offset += 1;
1022 proto_tree_add_item(tree, hf_netlink_route_rt_tos, tvb, offset, 1, ENC_NA);
1023 offset += 1;
1025 proto_tree_add_item(tree, hf_netlink_route_rt_table, tvb, offset, 1, ENC_NA);
1026 offset += 1;
1028 proto_tree_add_item(tree, hf_netlink_route_rt_protocol, tvb, offset, 1, ENC_NA);
1029 offset += 1;
1031 proto_tree_add_item(tree, hf_netlink_route_rt_scope, tvb, offset, 1, ENC_NA);
1032 offset += 1;
1034 proto_tree_add_item(tree, hf_netlink_route_rt_type, tvb, offset, 1, ENC_NA);
1035 offset += 1;
1037 proto_tree_add_item(tree, hf_netlink_route_rt_flags, tvb, offset, 4, nl_data->encoding);
1038 offset += 4;
1040 return offset;
1043 /* Route Attributes */
1045 static const value_string netlink_route_rta_attr_vals[] = {
1046 { WS_RTA_UNSPEC, "Unspecified" },
1047 { WS_RTA_DST, "Route destination address" },
1048 { WS_RTA_SRC, "Route source address" },
1049 { WS_RTA_IIF, "Input interface index" },
1050 { WS_RTA_OIF, "Output interface index" },
1051 { WS_RTA_GATEWAY, "Gateway of the route" },
1052 { WS_RTA_PRIORITY, "RTA_PRIORITY" },
1053 { WS_RTA_PREFSRC, "RTA_PREFSRC" },
1054 { WS_RTA_METRICS, "RTA_METRICS" },
1055 { WS_RTA_MULTIPATH, "RTA_MULTIPATH" },
1056 { WS_RTA_PROTOINFO, "RTA_PROTOINFO" },
1057 { WS_RTA_FLOW, "RTA_FLOW" },
1058 { WS_RTA_CACHEINFO, "RTA_CACHEINFO" },
1059 { WS_RTA_SESSION, "RTA_SESSION" },
1060 { WS_RTA_MP_ALGO, "RTA_MP_ALGO" },
1061 { WS_RTA_TABLE, "RTA_TABLE" },
1062 { WS_RTA_MARK, "RTA_MARK" },
1063 { WS_RTA_MFC_STATS, "RTA_MFC_STATS" },
1064 { WS_RTA_VIA, "RTA_VIA" },
1065 { WS_RTA_NEWDST, "RTA_NEWDST" },
1066 { WS_RTA_PREF, "RTA_PREF" },
1067 { WS_RTA_ENCAP_TYPE,"RTA_ENCAP_TYPE" },
1068 { WS_RTA_ENCAP, "RTA_ENCAP" },
1069 { WS_RTA_EXPIRES, "RTA_EXPIRES" },
1070 { WS_RTA_PAD, "RTA_PAD" },
1071 { WS_RTA_UID, "RTA_UID" },
1072 { WS_RTA_TTL_PROPAGATE, "RTA_TTL_PROPAGATE" },
1073 { WS_RTA_IP_PROTO, "RTA_IP_PROTO" },
1074 { WS_RTA_SPORT, "RTA_SPORT" },
1075 { WS_RTA_DPORT, "RTA_DPORT" },
1076 { WS_RTA_NH_ID, "RTA_NH_ID" },
1077 { 0, NULL }
1080 static int
1081 dissect_netlink_route_route_attrs(tvbuff_t *tvb, void *data _U_, struct packet_netlink_data *nl_data, proto_tree *tree, int rta_type, int offset, int len)
1083 enum ws_rta_attr_type type = (enum ws_rta_attr_type) rta_type;
1084 uint32_t value;
1086 switch (type) {
1087 case WS_RTA_IIF:
1088 if (len == 4) {
1089 proto_tree_add_item_ret_uint(tree, hf_netlink_route_rta_iif, tvb, offset, 4, nl_data->encoding, &value);
1090 proto_item_append_text(tree, ": %u", value);
1091 return 1;
1093 return 0;
1095 case WS_RTA_OIF:
1096 if (len == 4) {
1097 proto_tree_add_item_ret_uint(tree, hf_netlink_route_rta_oif, tvb, offset, 4, nl_data->encoding, &value);
1098 proto_item_append_text(tree, ": %u", value);
1099 return 1;
1101 return 0;
1103 default:
1104 return 0;
1108 static void
1109 netlink_route_nd_states_label(char *label, uint32_t value)
1111 static const value_string flags_vals[] = {
1112 { WS_NUD_NONE, "NONE" },
1113 { WS_NUD_INCOMPLETE, "INCOMPLETE" },
1114 { WS_NUD_REACHABLE, "REACHABLE" },
1115 { WS_NUD_STALE, "STALE" },
1116 { WS_NUD_DELAY, "DELAY" },
1117 { WS_NUD_PROBE, "PROBE" },
1118 { WS_NUD_FAILED, "FAILED" },
1119 { WS_NUD_NOARP, "NOARP" },
1120 { WS_NUD_PERMANENT, "PERMANENT" },
1121 { 0, NULL }
1124 char tmp[16];
1126 _fill_label_value_string_bitmask(label, value, flags_vals);
1128 snprintf(tmp, sizeof(tmp), " (0x%.4x)", value);
1129 (void) g_strlcat(label, tmp, ITEM_LABEL_LENGTH);
1132 static int
1133 dissect_netlink_route_ndmsg(tvbuff_t *tvb, struct netlink_route_info *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
1135 proto_tree_add_item(tree, hf_netlink_route_nd_family, tvb, offset, 1, ENC_NA);
1136 offset += 1;
1138 if (info->legacy) {
1140 * See the comment for the netlink_route_info structure,
1141 * above.
1143 return offset;
1146 /* XXX, 3B padding */
1147 offset += 3;
1149 proto_tree_add_item(tree, hf_netlink_route_nd_index, tvb, offset, 4, nl_data->encoding);
1150 offset += 4;
1152 proto_tree_add_item(tree, hf_netlink_route_nd_state, tvb, offset, 2, nl_data->encoding);
1153 offset += 2;
1155 proto_tree_add_item(tree, hf_netlink_route_nd_flags, tvb, offset, 1, ENC_NA);
1156 offset += 1;
1158 proto_tree_add_item(tree, hf_netlink_route_nd_type, tvb, offset, 1, ENC_NA);
1159 offset += 1;
1161 return offset;
1164 static const value_string netlink_route_type_vals[] = {
1165 { WS_RTM_NEWLINK, "Create network interface" },
1166 { WS_RTM_DELLINK, "Remove network interface" },
1167 { WS_RTM_GETLINK, "Get network interface info" },
1168 { WS_RTM_SETLINK, "Set network interface info" },
1169 { WS_RTM_NEWADDR, "Add IP address" },
1170 { WS_RTM_DELADDR, "Delete IP address" },
1171 { WS_RTM_GETADDR, "Get IP address" },
1172 { WS_RTM_NEWROUTE, "Add network route" },
1173 { WS_RTM_DELROUTE, "Delete network route" },
1174 { WS_RTM_GETROUTE, "Get network route" },
1175 { WS_RTM_NEWNEIGH, "Add neighbor table entry" },
1176 { WS_RTM_DELNEIGH, "Delete neighbor table entry" },
1177 { WS_RTM_GETNEIGH, "Get neighbor table entry" },
1178 { WS_RTM_NEWRULE, "Add routing rule" },
1179 { WS_RTM_DELRULE, "Delete routing rule" },
1180 { WS_RTM_GETRULE, "Get routing rule" },
1181 { WS_RTM_NEWQDISC, "Add queueing discipline" },
1182 { WS_RTM_DELQDISC, "Delete queueing discipline" },
1183 { WS_RTM_GETQDISC, "Get queueing discipline" },
1184 { WS_RTM_NEWTCLASS, "Add traffic class" },
1185 { WS_RTM_DELTCLASS, "Delete traffic class" },
1186 { WS_RTM_GETTCLASS, "Get traffic class" },
1187 { WS_RTM_NEWTFILTER, "Add traffic class" },
1188 { WS_RTM_DELTFILTER, "Delete traffic class" },
1189 { WS_RTM_GETTFILTER, "Get traffic class" },
1190 { WS_RTM_NEWACTION, "New Action" },
1191 { WS_RTM_DELACTION, "Delete Action" },
1192 { WS_RTM_GETACTION, "Get Action" },
1193 { WS_RTM_NEWPREFIX, "New IPv6 prefix" },
1194 { WS_RTM_GETMULTICAST, "Get multicast address" },
1195 { WS_RTM_GETANYCAST, "Get anycast address" },
1196 { WS_RTM_NEWNEIGHTBL, "New Neighbour tables" },
1197 { WS_RTM_GETNEIGHTBL, "Get Neighbour tables" },
1198 { WS_RTM_SETNEIGHTBL, "Set Neighbour tables" },
1199 { WS_RTM_NEWNDUSEROPT, "New ND Userland options" },
1200 { WS_RTM_NEWADDRLABEL, "New IPv6 Address Label" },
1201 { WS_RTM_DELADDRLABEL, "Delete IPv6 Address Label" },
1202 { WS_RTM_GETADDRLABEL, "Get IPv6 Address Label" },
1203 { WS_RTM_GETDCB, "Get Data Center Bridging" },
1204 { WS_RTM_SETDCB, "Set Data Center Bridging" },
1205 { WS_RTM_NEWNETCONF, "RTM_NEWNETCONF" },
1206 { WS_RTM_DELNETCONF, "RTM_DELNETCONF" },
1207 { WS_RTM_GETNETCONF, "RTM_GETNETCONF" },
1208 { WS_RTM_NEWMDB, "Add multicast database entry" },
1209 { WS_RTM_DELMDB, "Delete multicast database entry" },
1210 { WS_RTM_GETMDB, "Get multicast database" },
1211 { WS_RTM_NEWNSID, "New network namespace ID" },
1212 { WS_RTM_DELNSID, "Delete network namespace ID" },
1213 { WS_RTM_GETNSID, "Get network namespace ID" },
1214 { WS_RTM_NEWSTATS, "New link statistics" },
1215 { WS_RTM_GETSTATS, "Get link statistics" },
1216 { WS_RTM_NEWCACHEREPORT,"New cache report" },
1217 { WS_RTM_NEWCHAIN, "New chain" },
1218 { WS_RTM_DELCHAIN, "Delete chain" },
1219 { WS_RTM_GETCHAIN, "Get chain" },
1220 { WS_RTM_NEWNEXTHOP, "New next hop" },
1221 { WS_RTM_DELNEXTHOP, "Delete next hop" },
1222 { WS_RTM_GETNEXTHOP, "Get next hop" },
1223 { WS_RTM_NEWLINKPROP, "New link property" },
1224 { WS_RTM_DELLINKPROP, "Delete link property" },
1225 { WS_RTM_GETLINKPROP, "Get link property" },
1226 { WS_RTM_NEWVLAN, "New VLAN" },
1227 { WS_RTM_DELVLAN, "Delete VLAN" },
1228 { WS_RTM_GETVLAN, "Get VLAN" },
1229 { WS_RTM_NEWNEXTHOPBUCKET, "New next hop bucket" },
1230 { WS_RTM_DELNEXTHOPBUCKET, "Delete next hop bucket" },
1231 { WS_RTM_GETNEXTHOPBUCKET, "Get next hop bucket" },
1232 { WS_RTM_NEWTUNNEL, "New tunnel" },
1233 { WS_RTM_DELTUNNEL, "Delete tunnel" },
1234 { WS_RTM_GETTUNNEL, "Get tunnel" },
1235 { 0, NULL }
1237 static value_string_ext netlink_route_type_vals_ext = VALUE_STRING_EXT_INIT(netlink_route_type_vals);
1239 static int
1240 dissect_netlink_route(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1242 struct netlink_route_info info;
1243 struct packet_netlink_data *nl_data = (struct packet_netlink_data *)data;
1244 proto_tree *nlmsg_tree;
1245 proto_item *pi;
1246 int offset = 0;
1248 DISSECTOR_ASSERT(nl_data && nl_data->magic == PACKET_NETLINK_MAGIC);
1250 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Netlink route");
1251 col_clear(pinfo->cinfo, COL_INFO);
1253 pi = proto_tree_add_item(tree, proto_netlink_route, tvb, 0, -1, ENC_NA);
1254 nlmsg_tree = proto_item_add_subtree(pi, ett_netlink_route);
1256 /* Netlink message header (nlmsghdr) */
1257 offset = dissect_netlink_header(tvb, nlmsg_tree, offset, nl_data->encoding, hf_netlink_route_nltype, NULL);
1259 info.pinfo = pinfo;
1261 switch (nl_data->type) {
1262 case WS_RTM_NEWLINK:
1263 case WS_RTM_DELLINK:
1264 case WS_RTM_GETLINK:
1265 case WS_RTM_SETLINK:
1267 * Backward compatibility with legacy tools; 16 is
1268 * sizeof(struct ifinfomsg).
1270 * See the comment for the netlink_route_info
1271 * structure, above.
1273 info.legacy = (nl_data->type == WS_RTM_GETLINK) && (tvb_reported_length_remaining(tvb, offset) < 16);
1274 offset = dissect_netlink_route_ifinfomsg(tvb, &info, nl_data, nlmsg_tree, offset);
1275 /* Optional attributes */
1276 offset = dissect_netlink_route_attributes(tvb, hf_netlink_route_ifla_attr_type, &info, nl_data, nlmsg_tree, offset, dissect_netlink_route_ifla_attrs);
1277 break;
1279 case WS_RTM_NEWADDR:
1280 case WS_RTM_DELADDR:
1281 case WS_RTM_GETADDR:
1283 * Backward compatibility with legacy tools; 8 is
1284 * sizeof(struct ifaddrmsg).
1286 * See the comment for the netlink_route_info
1287 * structure, above.
1289 info.legacy = (nl_data->type == WS_RTM_GETADDR) && (tvb_reported_length_remaining(tvb, offset) < 8);
1290 offset = dissect_netlink_route_ifaddrmsg(tvb, &info, nl_data, nlmsg_tree, offset);
1291 if (!info.legacy) {
1293 * Optional attributes.
1295 * Not present in legacy-tool messages;
1296 * again, see the comment above.
1298 offset = dissect_netlink_route_attributes(tvb, hf_netlink_route_ifa_attr_type, &info, nl_data, nlmsg_tree, offset, dissect_netlink_route_ifa_attrs);
1300 break;
1302 case WS_RTM_NEWROUTE:
1303 case WS_RTM_DELROUTE:
1304 case WS_RTM_GETROUTE:
1306 * Backward compatibility with legacy tools; 12 is
1307 * sizeof(struct rtmsg).
1309 * See the comment for the netlink_route_info
1310 * structure, above.
1312 info.legacy = (nl_data->type == WS_RTM_GETROUTE) && (tvb_reported_length_remaining(tvb, offset) < 12);
1313 offset = dissect_netlink_route_rtmsg(tvb, &info, nl_data, nlmsg_tree, offset);
1314 /* Optional attributes */
1315 if (!info.legacy) {
1317 * Optional attributes.
1319 * Not present in legacy-tool messages;
1320 * again, see the comment above.
1322 offset = dissect_netlink_route_attributes(tvb, hf_netlink_route_rta_attr_type, &info, nl_data, nlmsg_tree, offset, dissect_netlink_route_route_attrs);
1324 break;
1326 case WS_RTM_NEWNEIGH:
1327 case WS_RTM_DELNEIGH:
1328 case WS_RTM_GETNEIGH:
1330 * Backward compatibility with legacy tools; 12 is
1331 * sizeof(struct ndmsg).
1333 * See the comment for the netlink_route_info
1334 * structure, above.
1336 info.legacy = (nl_data->type == WS_RTM_GETNEIGH) && (tvb_reported_length_remaining(tvb, offset) < 12);
1337 if (!info.legacy) {
1339 * Optional attributes.
1341 * Not present in legacy-tool messages;
1342 * again, see the comment above.
1344 offset = dissect_netlink_route_ndmsg(tvb, &info, nl_data, nlmsg_tree, offset);
1346 break;
1349 return offset;
1352 void
1353 proto_register_netlink_route(void)
1355 static hf_register_info hf[] = {
1356 { &hf_netlink_route_ifi_family,
1357 { "Interface family", "netlink-route.ifi_family",
1358 FT_UINT8, BASE_DEC, NULL, 0x00,
1359 NULL, HFILL }
1361 { &hf_netlink_route_ifi_type,
1362 { "Device type", "netlink-route.ifi_type",
1363 FT_UINT16, BASE_DEC, VALS(arp_hrd_vals), 0x00,
1364 NULL, HFILL }
1366 { &hf_netlink_route_ifi_index,
1367 { "Interface index", "netlink-route.ifi_index",
1368 FT_INT32, BASE_DEC, NULL, 0x00,
1369 NULL, HFILL }
1371 { &hf_netlink_route_ifi_flags,
1372 { "Device flags", "netlink-route.ifi_flags",
1373 FT_UINT32, BASE_CUSTOM, CF_FUNC(hf_netlink_route_ifi_flags_label), 0x00,
1374 NULL, HFILL }
1376 { &hf_netlink_route_ifi_flags_iff_up,
1377 { "Interface", "netlink-route.ifi_flags.iff_up",
1378 FT_BOOLEAN, 32, TFS(&tfs_up_down), WS_IFF_UP,
1379 NULL, HFILL }
1381 { &hf_netlink_route_ifi_flags_iff_broadcast,
1382 { "Broadcast", "netlink-route.ifi_flags.iff_broadcast",
1383 FT_BOOLEAN, 32, TFS(&tfs_valid_invalid), WS_IFF_BROADCAST,
1384 NULL, HFILL }
1386 { &hf_netlink_route_ifi_change,
1387 { "Device change flags", "netlink-route.ifi_change",
1388 FT_UINT32, BASE_DEC, NULL, 0x00,
1389 NULL, HFILL }
1391 { &hf_netlink_route_ifla_attr_type,
1392 { "Attribute type", "netlink-route.ifla_attr_type",
1393 FT_UINT16, BASE_DEC, VALS(netlink_route_ifla_attr_vals), 0x00,
1394 NULL, HFILL }
1396 { &hf_netlink_route_ifla_ifname,
1397 { "Device name", "netlink-route.ifla_ifname",
1398 FT_STRINGZ, BASE_NONE, NULL, 0x00,
1399 NULL, HFILL }
1401 { &hf_netlink_route_ifla_mtu,
1402 { "MTU of device", "netlink-route.ifla_mtu",
1403 FT_UINT32, BASE_DEC, NULL, 0x00,
1404 NULL, HFILL }
1406 { &hf_netlink_route_ifla_txqlen,
1407 { "TxQueue length", "netlink-route.ifla_txqlen",
1408 FT_UINT32, BASE_DEC, NULL, 0x00,
1409 NULL, HFILL }
1411 { &hf_netlink_route_ifla_operstate,
1412 { "Operstate", "netlink-route.ifla_operstate",
1413 FT_UINT8, BASE_DEC, VALS(netlink_route_ifla_operstate_vals), 0x00,
1414 NULL, HFILL }
1416 { &hf_netlink_route_ifla_promiscuity,
1417 { "Promiscuity", "netlink-route.ifla_promiscuity",
1418 FT_UINT32, BASE_DEC, NULL, 0x00,
1419 NULL, HFILL }
1421 { &hf_netlink_route_ifla_txqnum,
1422 { "Number of Tx queues", "netlink-route.ifla_txqnum",
1423 FT_UINT32, BASE_DEC, NULL, 0x00,
1424 NULL, HFILL }
1426 { &hf_netlink_route_ifla_rxqnum,
1427 { "Number of Rx queues", "netlink-route.ifla_rxqnum",
1428 FT_UINT32, BASE_DEC, NULL, 0x00,
1429 NULL, HFILL }
1431 { &hf_netlink_route_ifla_group,
1432 { "Group", "netlink-route.ifla_group",
1433 FT_UINT32, BASE_DEC, NULL, 0x00,
1434 NULL, HFILL }
1436 { &hf_netlink_route_ifla_gso_maxsize,
1437 { "Maximum GSO size", "netlink-route.ifla_gso_maxsize",
1438 FT_UINT32, BASE_DEC, NULL, 0x00,
1439 NULL, HFILL }
1441 { &hf_netlink_route_ifla_gso_maxsegs,
1442 { "Maximum GSO segment count", "netlink-route.ifla_gso_maxsegs",
1443 FT_UINT32, BASE_DEC, NULL, 0x00,
1444 NULL, HFILL }
1446 { &hf_netlink_route_ifla_carrier,
1447 { "Carrier", "netlink-route.ifla_carrier",
1448 FT_BOOLEAN, 32, TFS(&tfs_restricted_not_restricted), 0x00000001,
1449 NULL, HFILL }
1451 { &hf_netlink_route_ifla_qdisc,
1452 { "Queueing discipline", "netlink-route.ifla_qdisc",
1453 FT_STRINGZ, BASE_NONE, NULL, 0x00,
1454 NULL, HFILL }
1456 { &hf_netlink_route_ifla_carrier_changes,
1457 { "Carrier changes", "netlink-route.ifla_carrier_changes",
1458 FT_UINT32, BASE_DEC, NULL, 0x00,
1459 NULL, HFILL }
1461 { &hf_netlink_route_ifla_hwaddr,
1462 { "HW Address", "netlink-route.ifla_hwaddr",
1463 FT_BYTES, SEP_COLON, NULL, 0x00,
1464 NULL, HFILL }
1466 { &hf_netlink_route_ifla_broadcast,
1467 { "Broadcast", "netlink-route.ifla_broadcast",
1468 FT_BYTES, SEP_COLON, NULL, 0x00,
1469 NULL, HFILL }
1471 { &hf_netlink_route_ifla_carrier_up_count,
1472 { "Carrier changes to up", "netlink-route.ifla_carrier_up_count",
1473 FT_UINT32, BASE_DEC, NULL, 0x00,
1474 NULL, HFILL }
1476 { &hf_netlink_route_ifla_carrier_down_count,
1477 { "Carrier changes to down", "netlink-route.ifla_carrier_down_count",
1478 FT_UINT32, BASE_DEC, NULL, 0x00,
1479 NULL, HFILL }
1481 { &hf_netlink_route_ifla_min_mtu,
1482 { "Minimum MTU of device", "netlink-route.ifla_min_mtu",
1483 FT_UINT32, BASE_DEC, NULL, 0x00,
1484 NULL, HFILL }
1486 { &hf_netlink_route_ifla_max_mtu,
1487 { "Maximum MTU of device", "netlink-route.ifla_max_mtu",
1488 FT_UINT32, BASE_DEC, NULL, 0x00,
1489 NULL, HFILL }
1491 { &hf_netlink_route_ifla_map_memstart,
1492 { "Memory start", "netlink-route.ifla_map.mem_start",
1493 FT_UINT64, BASE_HEX, NULL, 0x00,
1494 NULL, HFILL }
1496 { &hf_netlink_route_ifla_map_memend,
1497 { "Memory end", "netlink-route.ifla_map.mem_end",
1498 FT_UINT64, BASE_HEX, NULL, 0x00,
1499 NULL, HFILL }
1501 { &hf_netlink_route_ifla_map_baseaddr,
1502 { "Base address", "netlink-route.ifla_map.base_addr",
1503 FT_UINT64, BASE_HEX, NULL, 0x00,
1504 NULL, HFILL }
1506 { &hf_netlink_route_ifla_map_irq,
1507 { "IRQ", "netlink-route.ifla_map.irq",
1508 FT_UINT16, BASE_DEC, NULL, 0x00,
1509 NULL, HFILL }
1511 { &hf_netlink_route_ifla_map_dma,
1512 { "DMA", "netlink-route.ifla_map.dma",
1513 FT_UINT8, BASE_DEC, NULL, 0x00,
1514 NULL, HFILL }
1516 { &hf_netlink_route_ifla_map_port,
1517 { "Port", "netlink-route.ifla_map.port",
1518 FT_UINT8, BASE_DEC, NULL, 0x00,
1519 NULL, HFILL }
1521 { &hf_netlink_route_ifla_linkstats_rxpackets,
1522 { "Rx packets", "netlink-route.ifla_linkstats.rxpackets",
1523 FT_UINT64, BASE_DEC, NULL, 0x00,
1524 NULL, HFILL }
1526 { &hf_netlink_route_ifla_linkstats_txpackets,
1527 { "Tx packets", "netlink-route.ifla_linkstats.txpackets",
1528 FT_UINT64, BASE_DEC, NULL, 0x00,
1529 NULL, HFILL }
1531 { &hf_netlink_route_ifla_linkstats_rxbytes,
1532 { "Rx bytes", "netlink-route.ifla_linkstats.rxbytes",
1533 FT_UINT64, BASE_DEC, NULL, 0x00,
1534 NULL, HFILL }
1536 { &hf_netlink_route_ifla_linkstats_txbytes,
1537 { "Tx packets", "netlink-route.ifla_linkstats.txbytes",
1538 FT_UINT64, BASE_DEC, NULL, 0x00,
1539 NULL, HFILL }
1541 { &hf_netlink_route_ifla_linkstats_rxerrors,
1542 { "Rx errors", "netlink-route.ifla_linkstats.rxerrors",
1543 FT_UINT64, BASE_DEC, NULL, 0x00,
1544 NULL, HFILL }
1546 { &hf_netlink_route_ifla_linkstats_txerrors,
1547 { "Tx errors", "netlink-route.ifla_linkstats.txerrors",
1548 FT_UINT64, BASE_DEC, NULL, 0x00,
1549 NULL, HFILL }
1551 { &hf_netlink_route_ifla_linkstats_rxdropped,
1552 { "Rx dropped", "netlink-route.ifla_linkstats.rxdropped",
1553 FT_UINT64, BASE_DEC, NULL, 0x00,
1554 NULL, HFILL }
1556 { &hf_netlink_route_ifla_linkstats_txdropped,
1557 { "Tx dropped", "netlink-route.ifla_linkstats.txdropped",
1558 FT_UINT64, BASE_DEC, NULL, 0x00,
1559 NULL, HFILL }
1561 { &hf_netlink_route_ifla_linkstats_multicast,
1562 { "Multicast Rx", "netlink-route.ifla_linkstats.multicast",
1563 FT_UINT64, BASE_DEC, NULL, 0x00,
1564 NULL, HFILL }
1566 { &hf_netlink_route_ifla_linkstats_collisions,
1567 { "Collisions", "netlink-route.ifla_linkstats.collisions",
1568 FT_UINT64, BASE_DEC, NULL, 0x00,
1569 NULL, HFILL }
1571 { &hf_netlink_route_ifla_linkstats_rx_len_errs,
1572 { "Length errors", "netlink-route.ifla_linkstats.rx_errors.length_errs",
1573 FT_UINT64, BASE_DEC, NULL, 0x00,
1574 NULL, HFILL }
1576 { &hf_netlink_route_ifla_linkstats_rx_over_errs,
1577 { "Ring buffer overflow errors", "netlink-route.ifla_linkstats.rx_errors.over_errs",
1578 FT_UINT64, BASE_DEC, NULL, 0x00,
1579 NULL, HFILL }
1581 { &hf_netlink_route_ifla_linkstats_rx_crc_errs,
1582 { "CRC errors", "netlink-route.ifla_linkstats.rx_errors.crc_errs",
1583 FT_UINT64, BASE_DEC, NULL, 0x00,
1584 NULL, HFILL }
1586 { &hf_netlink_route_ifla_linkstats_rx_frame_errs,
1587 { "Frame alignment errors", "netlink-route.ifla_linkstats.rx_errors.frame_errs",
1588 FT_UINT64, BASE_DEC, NULL, 0x00,
1589 NULL, HFILL }
1591 { &hf_netlink_route_ifla_linkstats_rx_fifo_errs,
1592 { "FIFO overrun errors", "netlink-route.ifla_linkstats.rx_errors.fifo_errs",
1593 FT_UINT64, BASE_DEC, NULL, 0x00,
1594 NULL, HFILL }
1596 { &hf_netlink_route_ifla_linkstats_rx_miss_errs,
1597 { "Missed packet errors", "netlink-route.ifla_linkstats.rx_errors.miss_errs",
1598 FT_UINT64, BASE_DEC, NULL, 0x00,
1599 NULL, HFILL }
1601 { &hf_netlink_route_ifla_linkstats_tx_abort_errs,
1602 { "Abort errors", "netlink-route.ifla_linkstats.rx_errors.abort_errs",
1603 FT_UINT64, BASE_DEC, NULL, 0x00,
1604 NULL, HFILL }
1606 { &hf_netlink_route_ifla_linkstats_tx_carrier_errs,
1607 { "Carrier errors", "netlink-route.ifla_linkstats.rx_errors.carrier_errs",
1608 FT_UINT64, BASE_DEC, NULL, 0x00,
1609 NULL, HFILL }
1611 { &hf_netlink_route_ifla_linkstats_tx_fifo_errs,
1612 { "FIFO errors", "netlink-route.ifla_linkstats.rx_errors.fifo_errs",
1613 FT_UINT64, BASE_DEC, NULL, 0x00,
1614 NULL, HFILL }
1616 { &hf_netlink_route_ifla_linkstats_tx_heartbeat_errs,
1617 { "Heartbeat errors", "netlink-route.ifla_linkstats.rx_errors.heartbeat_errs",
1618 FT_UINT64, BASE_DEC, NULL, 0x00,
1619 NULL, HFILL }
1621 { &hf_netlink_route_ifla_linkstats_tx_window_errs,
1622 { "Window errors", "netlink-route.ifla_linkstats.rx_errors.window_errs",
1623 FT_UINT64, BASE_DEC, NULL, 0x00,
1624 NULL, HFILL }
1626 { &hf_netlink_route_ifa_family,
1627 { "Address type", "netlink-route.ifa_family",
1628 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &linux_af_vals_ext, 0x00,
1629 NULL, HFILL }
1631 { &hf_netlink_route_ifa_prefixlen,
1632 { "Address prefixlength", "netlink-route.ifa_prefixlen",
1633 FT_UINT8, BASE_DEC, NULL, 0x00,
1634 NULL, HFILL }
1636 { &hf_netlink_route_ifa_flags,
1637 { "Address flags", "netlink-route.ifa_flags",
1638 FT_UINT8, BASE_CUSTOM, CF_FUNC(netlink_route_ifa_flags_label), 0x00,
1639 NULL, HFILL }
1641 { &hf_netlink_route_ifa_scope,
1642 { "Address scope", "netlink-route.ifa_scope",
1643 FT_UINT8, BASE_DEC, NULL, 0x00,
1644 NULL, HFILL }
1646 { &hf_netlink_route_ifa_index,
1647 { "Interface index", "netlink-route.ifa_index",
1648 FT_INT32, BASE_DEC, NULL, 0x00,
1649 NULL, HFILL }
1651 { &hf_netlink_route_ifa_attr_type,
1652 { "Attribute type", "netlink-route.ifa_attr_type",
1653 FT_UINT16, BASE_DEC, VALS(netlink_route_ifa_attr_vals), 0x00,
1654 NULL, HFILL }
1656 { &hf_netlink_route_ifa_label,
1657 { "Interface name", "netlink-route.ifa_label",
1658 FT_STRINGZ, BASE_NONE, NULL, 0x00,
1659 NULL, HFILL }
1661 { &hf_netlink_route_ifa_flags32,
1662 { "Address flags", "netlink-route.ifa_flags32",
1663 FT_UINT32, BASE_CUSTOM, CF_FUNC(netlink_route_ifa_flags_label), 0x00,
1664 NULL, HFILL }
1666 { &hf_netlink_route_ifa_addr6,
1667 { "Address", "netlink-route.ifa_address.ipv6",
1668 FT_IPv6, BASE_NONE, NULL, 0x00,
1669 NULL, HFILL }
1671 { &hf_netlink_route_ifa_addr4,
1672 { "Address", "netlink-route.ifa_address.ipv4",
1673 FT_IPv4, BASE_NONE, NULL, 0x00,
1674 NULL, HFILL }
1676 { &hf_netlink_route_rt_family,
1677 { "Address family", "netlink-route.rt_family",
1678 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &linux_af_vals_ext, 0x00,
1679 NULL, HFILL }
1681 { &hf_netlink_route_rt_dst_len,
1682 { "Length of destination", "netlink-route.rt_dst_len",
1683 FT_UINT8, BASE_DEC, NULL, 0x00,
1684 NULL, HFILL }
1686 { &hf_netlink_route_rt_src_len,
1687 { "Length of source", "netlink-route.rt_src_len",
1688 FT_UINT8, BASE_DEC, NULL, 0x00,
1689 NULL, HFILL }
1691 { &hf_netlink_route_rt_tos,
1692 { "TOS filter", "netlink-route.rt_tos",
1693 FT_UINT8, BASE_HEX, NULL, 0x00,
1694 NULL, HFILL }
1696 { &hf_netlink_route_rt_table,
1697 { "Routing table ID", "netlink-route.rt_table",
1698 FT_UINT8, BASE_DEC, NULL, 0x00,
1699 NULL, HFILL }
1701 { &hf_netlink_route_rt_protocol,
1702 { "Routing protocol", "netlink-route.rt_protocol",
1703 FT_UINT8, BASE_HEX | BASE_EXT_STRING, &hf_netlink_route_rt_protocol_vals_ext, 0x00,
1704 NULL, HFILL }
1706 { &hf_netlink_route_rt_scope,
1707 { "Route origin", "netlink-route.rt_scope",
1708 FT_UINT8, BASE_HEX, VALS(netlink_route_rt_scope_vals), 0x00,
1709 NULL, HFILL }
1711 { &hf_netlink_route_rt_type,
1712 { "Route type", "netlink-route.rt_type",
1713 FT_UINT8, BASE_HEX, VALS(netlink_route_rt_type_vals), 0x00,
1714 NULL, HFILL }
1716 { &hf_netlink_route_rt_flags,
1717 { "Route flags", "netlink-route.rt_flags",
1718 FT_UINT32, BASE_HEX, NULL, 0x00,
1719 NULL, HFILL }
1721 { &hf_netlink_route_rta_attr_type,
1722 { "Attribute type", "netlink-route.rta_attr_type",
1723 FT_UINT16, BASE_DEC, VALS(netlink_route_rta_attr_vals), 0x00,
1724 NULL, HFILL }
1726 { &hf_netlink_route_rta_iif,
1727 { "Input interface index", "netlink-route.rta_iif",
1728 FT_UINT32, BASE_DEC, NULL, 0x00,
1729 NULL, HFILL }
1731 { &hf_netlink_route_rta_oif,
1732 { "Output interface index", "netlink-route.rta_oif",
1733 FT_UINT32, BASE_DEC, NULL, 0x00,
1734 NULL, HFILL }
1736 { &hf_netlink_route_nd_family,
1737 { "Family", "netlink-route.nd_family",
1738 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &linux_af_vals_ext, 0x00,
1739 NULL, HFILL }
1741 { &hf_netlink_route_nd_index,
1742 { "Interface index", "netlink-route.nd_index",
1743 FT_INT32, BASE_DEC, NULL, 0x00,
1744 NULL, HFILL }
1746 { &hf_netlink_route_nd_state,
1747 { "State", "netlink-route.nd_state",
1748 FT_UINT16, BASE_CUSTOM, CF_FUNC(netlink_route_nd_states_label), 0x00,
1749 NULL, HFILL }
1751 { &hf_netlink_route_nd_flags,
1752 { "Flags", "netlink-route.nd_flags",
1753 FT_UINT8, BASE_HEX, NULL, 0x00,
1754 NULL, HFILL }
1756 { &hf_netlink_route_nd_type,
1757 { "Type", "netlink-route.nd_type",
1758 FT_UINT8, BASE_HEX, NULL, 0x00,
1759 NULL, HFILL }
1761 { &hf_netlink_route_nltype,
1762 { "Message type", "netlink-route.nltype",
1763 FT_UINT16, BASE_DEC | BASE_EXT_STRING, &netlink_route_type_vals_ext, 0x00,
1764 NULL, HFILL }
1768 static int *ett[] = {
1769 &ett_netlink_route,
1770 &ett_netlink_route_attr,
1771 &ett_netlink_route_if_flags,
1772 &ett_netlink_route_attr_linkstats,
1773 &ett_netlink_route_attr_linkstats_rxerrs,
1774 &ett_netlink_route_attr_linkstats_txerrs,
1777 proto_netlink_route = proto_register_protocol("Linux rtnetlink (route netlink) protocol", "rtnetlink", "netlink-route" );
1778 proto_register_field_array(proto_netlink_route, hf, array_length(hf));
1779 proto_register_subtree_array(ett, array_length(ett));
1781 netlink_route_handle = register_dissector("netlink-route", dissect_netlink_route, proto_netlink_route);
1784 void
1785 proto_reg_handoff_netlink_route(void)
1787 dissector_add_uint("netlink.protocol", WS_NETLINK_ROUTE, netlink_route_handle);
1791 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1793 * Local variables:
1794 * c-basic-offset: 8
1795 * tab-width: 8
1796 * indent-tabs-mode: t
1797 * End:
1799 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1800 * :indentSize=8:tabSize=8:noTabs=false: