Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-netlink-sock_diag.c
blob207c64b517f6d9836591a813bca96cf74785bc16
1 /* packet-netlink-sock_diag.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 #include "config.h"
12 #include <epan/packet.h>
13 #include <epan/aftypes.h>
14 #include <epan/etypes.h>
15 #include <epan/ipproto.h>
16 #include <epan/strutil.h>
17 #include <epan/tfs.h>
18 #include <wsutil/array.h>
19 #include "packet-netlink.h"
21 void proto_register_netlink_sock_diag(void);
22 void proto_reg_handoff_netlink_sock_diag(void);
24 typedef struct {
25 packet_info *pinfo;
26 } netlink_sock_diag_info_t;
28 static int proto_netlink_sock_diag;
30 static dissector_handle_t netlink_sock_diag_handle;
32 enum {
33 /* sock diag values for nlmsghdr.nlmsg_type from: */
35 /* <include/uapi/linux/inet_diag.h> (compat) */
36 WS_TCPDIAG_GETSOCK = 18,
37 WS_DCCPDIAG_GETSOCK = 19,
39 /* <include/uapi/linux/sock_diag.h> */
40 WS_SOCK_DIAG_BY_FAMILY = 20,
41 WS_SOCK_DESTROY = 21
44 enum {
45 /* </usr/include/<platform>/bits/socket_type.h> */
46 WS_SOCK_STREAM = 1,
47 WS_SOCK_DGRAM = 2,
48 WS_SOCK_RAW = 3,
49 WS_SOCK_RDM = 4,
50 WS_SOCK_SEQPACKET = 5,
51 WS_SOCK_DCCP = 6,
52 WS_SOCK_PACKET = 10
55 /* SOCK_CLOEXEC = 02000000 */
56 /* SOCK_NONBLOCK = 00004000 */
58 enum ws_unix_diag_show_mask {
59 /* show mask for unix diag from <include/uapi/linux/unix_diag.h> */
60 WS_UDIAG_SHOW_NAME = 0x00000001,
61 WS_UDIAG_SHOW_VFS = 0x00000002,
62 WS_UDIAG_SHOW_PEER = 0x00000004,
63 WS_UDIAG_SHOW_ICONS = 0x00000008,
64 WS_UDIAG_SHOW_RQLEN = 0x00000010,
65 WS_UDIAG_SHOW_MEMINFO = 0x00000020,
66 WS_UDIAG_SHOW_UID = 0x00000040
69 enum ws_unix_diag_attr_type {
70 /* netlink attributes for unix diag from <include/uapi/linux/unix_diag.h> */
71 WS_UNIX_DIAG_NAME = 0,
72 WS_UNIX_DIAG_VFS = 1,
73 WS_UNIX_DIAG_PEER = 2,
74 WS_UNIX_DIAG_ICONS = 3,
75 WS_UNIX_DIAG_RQLEN = 4,
76 WS_UNIX_DIAG_MEMINFO = 5,
77 WS_UNIX_DIAG_SHUTDOWN = 6,
78 WS_UNIX_DIAG_UID = 7
81 enum ws_inet_diag_attr_type {
82 /* netlink attributes for inet diag from <include/uapi/linux/inet_diag.h> */
83 WS_INET_DIAG_NONE = 0,
84 WS_INET_DIAG_MEMINFO = 1,
85 WS_INET_DIAG_INFO = 2,
86 WS_INET_DIAG_VEGASINFO = 3,
87 WS_INET_DIAG_CONG = 4,
88 WS_INET_DIAG_TOS = 5,
89 WS_INET_DIAG_TCLASS = 6,
90 WS_INET_DIAG_SKMEMINFO = 7,
91 WS_INET_DIAG_SHUTDOWN = 8,
92 WS_INET_DIAG_DCTCPINFO = 9,
93 WS_INET_DIAG_PROTOCOL = 10,
94 WS_INET_DIAG_SKV6ONLY = 11,
95 WS_INET_DIAG_LOCALS = 12,
96 WS_INET_DIAG_PEERS = 13,
97 WS_INET_DIAG_PAD = 14,
98 WS_INET_DIAG_MARK = 15,
99 WS_INET_DIAG_BBRINFO = 16,
100 WS_INET_DIAG_CLASS_ID = 17,
101 WS_INET_DIAG_MD5SIG = 18,
102 WS_INET_DIAG_ULP_INFO = 19,
103 WS_INET_DIAG_SK_BPF_STORAGES = 20,
104 WS_INET_DIAG_CGROUP_ID = 21,
105 WS_INET_DIAG_SOCKOPT = 22,
108 enum ws_netlink_diag_show_type {
109 /* show mask for netlink diag from <include/uapi/linux/netlink_diag.h> */
110 WS_NDIAG_SHOW_MEMINFO = 0x00000001,
111 WS_NDIAG_SHOW_GROUPS = 0x00000002,
112 WS_NDIAG_SHOW_RING_CFG = 0x00000004,
113 WS_NDIAG_SHOW_FLAGS = 0x00000008,
116 enum ws_netlink_diag_attr_type {
117 /* netlink attributes for netlink diag from <include/uapi/linux/netlink_diag.h> */
118 WS_NETLINK_DIAG_MEMINFO = 0,
119 WS_NETLINK_DIAG_GROUPS = 1,
120 WS_NETLINK_DIAG_RX_RING = 2,
121 WS_NETLINK_DIAG_TX_RING = 3,
122 WS_NETLINK_DIAG_FLAGS = 4,
125 enum ws_packet_diag_show_mask {
126 /* show mask for packet diag from <include/uapi/linux/packet_diag.h> */
127 WS_PACKET_SHOW_INFO = 0x00000001,
128 WS_PACKET_SHOW_MCLIST = 0x00000002,
129 WS_PACKET_SHOW_RING_CFG = 0x00000004,
130 WS_PACKET_SHOW_FANOUT = 0x00000008,
131 WS_PACKET_SHOW_MEMINFO = 0x00000010,
132 WS_PACKET_SHOW_FILTER = 0x00000020
135 enum ws_packet_diag_attr_type {
136 /* netlink attributes for packet diag from <include/uapi/linux/packet_diag.h> */
137 WS_PACKET_DIAG_INFO = 0,
138 WS_PACKET_DIAG_MCLIST = 1,
139 WS_PACKET_DIAG_RX_RING = 2,
140 WS_PACKET_DIAG_TX_RING = 3,
141 WS_PACKET_DIAG_FANOUT = 4,
142 WS_PACKET_DIAG_UID = 5,
143 WS_PACKET_DIAG_MEMINFO = 6,
144 WS_PACKET_DIAG_FILTER = 7
147 enum {
148 /* based on kernel include <include/net/tcp_states.h> with WS_ without TCP_ (it's not only used by tcp) */
149 WS_ESTABLISHED = 1,
150 WS_SYN_SENT = 2,
151 WS_SYN_RECV = 3,
152 WS_FIN_WAIT1 = 4,
153 WS_FIN_WAIT2 = 5,
154 WS_TIME_WAIT = 6,
155 WS_CLOSE = 7,
156 WS_CLOSE_WAIT = 8,
157 WS_LAST_ACK = 9,
158 WS_LISTEN = 10,
159 WS_CLOSING = 11,
160 WS_NEW_SYNC_RECV = 12
163 static int hf_netlink_sock_diag_cookie;
164 static int hf_netlink_sock_diag_family;
165 static int hf_netlink_sock_diag_fwd_alloc;
166 static int hf_netlink_sock_diag_inet_attr;
167 static int hf_netlink_sock_diag_inet_dport;
168 static int hf_netlink_sock_diag_inet_dst_ip4;
169 static int hf_netlink_sock_diag_inet_dst_ip6;
170 static int hf_netlink_sock_diag_inet_extended;
171 static int hf_netlink_sock_diag_inet_interface;
172 static int hf_netlink_sock_diag_inet_padding;
173 static int hf_netlink_sock_diag_inet_proto;
174 static int hf_netlink_sock_diag_inet_sport;
175 static int hf_netlink_sock_diag_inet_src_ip4;
176 static int hf_netlink_sock_diag_inet_src_ip6;
177 static int hf_netlink_sock_diag_inet_states;
178 static int hf_netlink_sock_diag_inode;
179 static int hf_netlink_sock_diag_netlink_attr;
180 static int hf_netlink_sock_diag_netlink_dst_port_id;
181 static int hf_netlink_sock_diag_netlink_port_id;
182 static int hf_netlink_sock_diag_netlink_proto;
183 static int hf_netlink_sock_diag_netlink_show;
184 static int hf_netlink_sock_diag_netlink_show_groups;
185 static int hf_netlink_sock_diag_netlink_show_meminfo;
186 static int hf_netlink_sock_diag_netlink_show_ring_cfg;
187 static int hf_netlink_sock_diag_nltype;
188 static int hf_netlink_sock_diag_packet_attr;
189 static int hf_netlink_sock_diag_packet_proto;
190 static int hf_netlink_sock_diag_packet_show;
191 static int hf_netlink_sock_diag_packet_show_fanout;
192 static int hf_netlink_sock_diag_packet_show_filter;
193 static int hf_netlink_sock_diag_packet_show_info;
194 static int hf_netlink_sock_diag_packet_show_mclist;
195 static int hf_netlink_sock_diag_packet_show_meminfo;
196 static int hf_netlink_sock_diag_packet_show_ring_cfg;
197 static int hf_netlink_sock_diag_rcvbuf;
198 static int hf_netlink_sock_diag_rmem_alloc;
199 static int hf_netlink_sock_diag_rqueue;
200 static int hf_netlink_sock_diag_shutdown;
201 static int hf_netlink_sock_diag_sndbuf;
202 static int hf_netlink_sock_diag_state;
203 static int hf_netlink_sock_diag_type;
204 static int hf_netlink_sock_diag_unix_attr;
205 static int hf_netlink_sock_diag_unix_name;
206 static int hf_netlink_sock_diag_unix_peer_inode;
207 static int hf_netlink_sock_diag_unix_show;
208 static int hf_netlink_sock_diag_unix_show_icons;
209 static int hf_netlink_sock_diag_unix_show_meminfo;
210 static int hf_netlink_sock_diag_unix_show_name;
211 static int hf_netlink_sock_diag_unix_show_peer;
212 static int hf_netlink_sock_diag_unix_show_rqlen;
213 static int hf_netlink_sock_diag_unix_show_vfs;
214 static int hf_netlink_sock_diag_wmem_alloc;
215 static int hf_netlink_sock_diag_wmem_queued;
216 static int hf_netlink_sock_diag_wqueue;
218 static int ett_netlink_sock_diag;
219 static int ett_netlink_sock_diag_show;
220 static int ett_netlink_sock_diag_attr;
222 static const true_false_string _tfs_show_do_not_show = { "Show", "Don't show" };
224 static const value_string socket_type_vals[] = {
225 { WS_SOCK_STREAM, "SOCK_STREAM" },
226 { WS_SOCK_DGRAM, "SOCK_DGRAM" },
227 { WS_SOCK_RAW, "SOCK_RAW" },
228 { WS_SOCK_RDM, "SOCK_RDM" },
229 { WS_SOCK_SEQPACKET, "SOCK_SEQPACKET" },
230 { WS_SOCK_DCCP, "SOCK_DCCP" },
231 { WS_SOCK_PACKET, "SOCK_PACKET" },
232 { 0, NULL }
235 static const value_string socket_state_vals[] = {
236 { WS_ESTABLISHED, "ESTABLISHED" },
237 { WS_SYN_SENT, "SYN_SENT" },
238 { WS_SYN_RECV, "SYN_RECV" },
239 { WS_FIN_WAIT1, "FIN_WAIT1" },
240 { WS_FIN_WAIT2, "FIN_WAIT2" },
241 { WS_TIME_WAIT, "TIME_WAIT" },
242 { WS_CLOSE, "CLOSE" },
243 { WS_CLOSE_WAIT, "CLOSE_WAIT" },
244 { WS_LAST_ACK, "LAST_ACK" },
245 { WS_LISTEN, "LISTEN" },
246 { WS_CLOSING, "CLOSING" },
247 { WS_NEW_SYNC_RECV, "NEW_SYNC_RECV" },
248 { 0, NULL }
251 /* Generic */
253 static int
254 _tvb_check_if_zeros(tvbuff_t *tvb, int offset, int len)
256 /* padding, all bytes should be 0, if not display as unknown */
257 while (len >= 0) {
258 if (tvb_get_uint8(tvb, offset) != 0)
259 return 1;
261 offset++;
262 len--;
264 return 0;
267 static void
268 _dissect_padding(proto_tree *tree _U_, tvbuff_t *tvb, int offset, int len)
270 if (_tvb_check_if_zeros(tvb, offset, len)) {
271 /* XXX, tree, expert info */
275 /* Sock diag meminfo */
277 static int
278 dissect_sock_diag_meminfo(proto_tree *tree, netlink_sock_diag_info_t *info _U_, struct packet_netlink_data *nl_data, tvbuff_t *tvb, int offset, int len)
280 static int *hfs[] = {
281 &hf_netlink_sock_diag_rmem_alloc,
282 &hf_netlink_sock_diag_rcvbuf,
283 &hf_netlink_sock_diag_wmem_alloc,
284 &hf_netlink_sock_diag_sndbuf,
285 &hf_netlink_sock_diag_fwd_alloc,
286 &hf_netlink_sock_diag_wmem_queued,
287 /* XXX OPTMEM */
288 /* XXX BACKLOG */
291 unsigned i;
293 if (len == 0 || (len % 4) != 0)
294 return 0;
296 for (i = 0; len >= 4 && i < G_N_ELEMENTS(hfs); i++) {
297 proto_tree_add_item(tree, *hfs[i], tvb, offset, 4, nl_data->encoding);
298 offset += 4; len -= 4;
301 if (len != 0) {
302 /* XXX, unknown */
305 return 1;
308 /* Sock diag Cookie */
310 static void
311 sock_diag_proto_tree_add_cookie(proto_tree *tree, netlink_sock_diag_info_t *info _U_, struct packet_netlink_data *nl_data _U_, tvbuff_t *tvb, int offset)
313 uint64_t cookie;
315 cookie = tvb_get_letohl(tvb, offset + 4);
316 cookie <<= 32;
317 cookie |= tvb_get_letohl(tvb, offset);
319 /* XXX support for INET_DIAG_NOCOOKIE (~0) */
321 proto_tree_add_uint64(tree, hf_netlink_sock_diag_cookie, tvb, offset, 8, cookie);
324 static const value_string netlink_sock_diag_shutdown_flags_vals[] = {
325 { 0, "No shutdown" },
326 { 1, "Receptions disallowed" },
327 { 2, "Transmissions disallowed" },
328 { 3, "Receptions and transmissions disallowed" },
329 { 0, NULL }
332 static void
333 sock_diag_proto_tree_add_shutdown(proto_tree *tree, tvbuff_t *tvb, int offset)
335 uint8_t how = tvb_get_uint8(tvb, offset);
337 proto_tree_add_item(tree, hf_netlink_sock_diag_shutdown, tvb, offset, 1, ENC_NA);
339 proto_item_append_text(tree, ": %s", val_to_str(how, netlink_sock_diag_shutdown_flags_vals, "Invalid how value (%x)"));
342 /* AF_UNIX attributes */
344 static const value_string netlink_sock_diag_unix_attr_vals[] = {
345 { WS_UNIX_DIAG_NAME, "Name" },
346 { WS_UNIX_DIAG_VFS, "VFS" },
347 { WS_UNIX_DIAG_PEER, "Peer" },
348 { WS_UNIX_DIAG_ICONS, "Icons" },
349 { WS_UNIX_DIAG_RQLEN, "RQ len" },
350 { WS_UNIX_DIAG_MEMINFO, "meminfo" },
351 { WS_UNIX_DIAG_SHUTDOWN, "shutdown" },
352 { 0, NULL }
355 static int
356 dissect_netlink_unix_sock_diag_reply_attrs(tvbuff_t *tvb, void *data, struct packet_netlink_data *nl_data, proto_tree *tree, int nla_type, int offset, int len)
358 enum ws_unix_diag_attr_type type = (enum ws_unix_diag_attr_type) nla_type;
359 netlink_sock_diag_info_t *info = (netlink_sock_diag_info_t *) data;
361 switch (type) {
362 case WS_UNIX_DIAG_NAME:
364 const char *name;
366 /* XXX make it nicer */
367 if (len > 0 && tvb_get_uint8(tvb, offset) == '\0') {
368 name = wmem_strconcat(wmem_packet_scope(),
369 "@",
370 tvb_get_string_enc(wmem_packet_scope(), tvb, offset+1, len-1, ENC_ASCII | ENC_NA),
371 NULL);
372 } else
373 name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset, len, ENC_ASCII | ENC_NA);
375 proto_item_append_text(tree, ": %s", name);
376 proto_tree_add_string(tree, hf_netlink_sock_diag_unix_name, tvb, offset, len, name);
377 return 1;
380 case WS_UNIX_DIAG_PEER:
381 if (len == 4) {
382 uint32_t value;
383 proto_tree_add_item_ret_uint(tree, hf_netlink_sock_diag_unix_peer_inode, tvb, offset, 4, nl_data->encoding, &value);
384 proto_item_append_text(tree, ": Peer inode %u", value);
385 return 1;
387 return 0;
389 case WS_UNIX_DIAG_RQLEN:
390 if (len == 8) {
391 /* XXX, if socket in WS_LISTEN it's reporting sk->sk_receive_queue.qlen, sk->sk_max_ack_backlog */
392 proto_tree_add_item(tree, hf_netlink_sock_diag_rqueue, tvb, offset, 4, nl_data->encoding);
393 proto_tree_add_item(tree, hf_netlink_sock_diag_wqueue, tvb, offset, 4, nl_data->encoding);
394 return 1;
396 return 0;
398 case WS_UNIX_DIAG_MEMINFO:
399 return dissect_sock_diag_meminfo(tree, info, nl_data, tvb, offset, len);
401 case WS_UNIX_DIAG_SHUTDOWN:
402 if (len == 1)
403 sock_diag_proto_tree_add_shutdown(tree, tvb, offset);
404 return 0;
406 case WS_UNIX_DIAG_VFS:
407 case WS_UNIX_DIAG_ICONS:
408 default:
409 return 0;
413 /* AF_UNIX */
415 static int
416 dissect_sock_diag_unix_reply(tvbuff_t *tvb, netlink_sock_diag_info_t *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
418 proto_tree_add_item(tree, hf_netlink_sock_diag_family, tvb, offset, 1, ENC_NA);
419 offset += 1;
421 /* XXX, validate: SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET */
422 proto_tree_add_item(tree, hf_netlink_sock_diag_type, tvb, offset, 1, ENC_NA);
423 offset += 1;
425 /* XXX, validate */
426 proto_tree_add_item(tree, hf_netlink_sock_diag_state, tvb, offset, 1, ENC_NA);
427 offset += 1;
429 _dissect_padding(tree, tvb, offset, 1);
430 offset += 1;
432 proto_tree_add_item(tree, hf_netlink_sock_diag_inode, tvb, offset, 4, nl_data->encoding);
433 offset += 4;
435 sock_diag_proto_tree_add_cookie(tree, info, nl_data, tvb, offset);
436 offset += 8;
438 return dissect_netlink_attributes_to_end(tvb, hf_netlink_sock_diag_unix_attr, ett_netlink_sock_diag_attr, info, nl_data, tree, offset, dissect_netlink_unix_sock_diag_reply_attrs);
441 /* AF_UNIX request */
443 static int
444 dissect_sock_diag_unix_request_show(tvbuff_t *tvb, netlink_sock_diag_info_t *info _U_, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
446 proto_item *ti;
447 proto_tree *flags_tree;
449 ti = proto_tree_add_item(tree, hf_netlink_sock_diag_unix_show, tvb, offset, 4, nl_data->encoding);
450 flags_tree = proto_item_add_subtree(ti, ett_netlink_sock_diag_show);
452 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_unix_show_name, tvb, offset, 4, nl_data->encoding);
453 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_unix_show_vfs, tvb, offset, 4, nl_data->encoding);
454 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_unix_show_peer, tvb, offset, 4, nl_data->encoding);
455 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_unix_show_icons, tvb, offset, 4, nl_data->encoding);
456 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_unix_show_rqlen, tvb, offset, 4, nl_data->encoding);
457 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_unix_show_meminfo, tvb, offset, 4, nl_data->encoding);
458 /* XXX, unknown */
460 offset += 4;
462 return offset;
465 static int
466 dissect_sock_diag_unix_request(tvbuff_t *tvb, netlink_sock_diag_info_t *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
468 proto_tree_add_item(tree, hf_netlink_sock_diag_family, tvb, offset, 1, ENC_NA);
469 offset += 1;
471 /* XXX, AF_UNIX don't have protocols - 0 */
472 offset += 1;
474 _dissect_padding(tree, tvb, offset, 2);
475 offset += 2;
477 /* states */
478 offset += 4;
480 proto_tree_add_item(tree, hf_netlink_sock_diag_inode, tvb, offset, 4, nl_data->encoding);
481 offset += 4;
483 offset = dissect_sock_diag_unix_request_show(tvb, info, nl_data, tree, offset);
485 sock_diag_proto_tree_add_cookie(tree, info, nl_data, tvb, offset);
486 offset += 8;
488 return offset;
491 /* AF_INET attributes */
493 static const value_string netlink_sock_diag_inet_attr_vals[] = {
494 { WS_INET_DIAG_MEMINFO, "meminfo" },
495 { WS_INET_DIAG_INFO, "info" },
496 { WS_INET_DIAG_VEGASINFO, "vegasinfo" },
497 { WS_INET_DIAG_CONG, "cong" },
498 { WS_INET_DIAG_TOS, "tos" },
499 { WS_INET_DIAG_TCLASS, "tclass" },
500 { WS_INET_DIAG_SKMEMINFO, "skmeminfo" },
501 { WS_INET_DIAG_SHUTDOWN, "shutdown" },
502 { WS_INET_DIAG_DCTCPINFO, "dctcpinfo" },
503 { WS_INET_DIAG_PROTOCOL, "protocol" },
504 { WS_INET_DIAG_SKV6ONLY, "skv6only" },
505 { WS_INET_DIAG_LOCALS, "locals" },
506 { WS_INET_DIAG_PEERS, "peers" },
507 { WS_INET_DIAG_PAD, "pad" },
508 { WS_INET_DIAG_MARK, "mark" },
509 { WS_INET_DIAG_BBRINFO, "bbrinfo" },
510 { WS_INET_DIAG_CLASS_ID, "class_id" },
511 { WS_INET_DIAG_MD5SIG, "md5sig" },
512 { WS_INET_DIAG_ULP_INFO, "ulp_info" },
513 { WS_INET_DIAG_SK_BPF_STORAGES, "sk_bpf_storages" },
514 { WS_INET_DIAG_CGROUP_ID, "cgroup_id" },
515 { WS_INET_DIAG_SOCKOPT, "sockopt" },
516 { 0, NULL }
519 static int
520 dissect_sock_diag_inet_attributes(tvbuff_t *tvb, void *data, struct packet_netlink_data *nl_data, proto_tree *tree, int nla_type, int offset, int len)
522 enum ws_inet_diag_attr_type type = (enum ws_inet_diag_attr_type) nla_type;
523 netlink_sock_diag_info_t *info = (netlink_sock_diag_info_t *) data;
525 switch (type) {
526 case WS_INET_DIAG_MEMINFO:
527 if (len == 16) {
528 proto_tree_add_item(tree, hf_netlink_sock_diag_rmem_alloc, tvb, offset, 4, nl_data->encoding);
529 offset += 4;
531 proto_tree_add_item(tree, hf_netlink_sock_diag_wmem_queued, tvb, offset, 4, nl_data->encoding);
532 offset += 4;
534 proto_tree_add_item(tree, hf_netlink_sock_diag_fwd_alloc, tvb, offset, 4, nl_data->encoding);
535 offset += 4;
537 proto_tree_add_item(tree, hf_netlink_sock_diag_wmem_alloc, tvb, offset, 4, nl_data->encoding);
538 /*offset += 4;*/
540 return 1;
542 return 0;
544 case WS_INET_DIAG_SKMEMINFO:
545 return dissect_sock_diag_meminfo(tree, info, nl_data, tvb, offset, len);
547 case WS_INET_DIAG_SHUTDOWN:
548 if (len == 1)
549 sock_diag_proto_tree_add_shutdown(tree, tvb, offset);
550 return 0;
552 case WS_INET_DIAG_INFO:
553 case WS_INET_DIAG_VEGASINFO:
554 case WS_INET_DIAG_CONG:
555 case WS_INET_DIAG_TOS:
556 case WS_INET_DIAG_TCLASS:
557 case WS_INET_DIAG_DCTCPINFO:
558 case WS_INET_DIAG_PROTOCOL:
559 case WS_INET_DIAG_SKV6ONLY:
560 case WS_INET_DIAG_LOCALS:
561 case WS_INET_DIAG_PEERS:
562 case WS_INET_DIAG_PAD:
563 case WS_INET_DIAG_MARK:
564 case WS_INET_DIAG_BBRINFO:
565 default:
566 return 0;
570 /* AF_INET sockid */
572 static int
573 dissect_sock_diag_inet_sockid(tvbuff_t *tvb, netlink_sock_diag_info_t *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset, int family)
575 proto_tree_add_item(tree, hf_netlink_sock_diag_inet_sport, tvb, offset, 2, ENC_BIG_ENDIAN);
576 offset += 2;
578 proto_tree_add_item(tree, hf_netlink_sock_diag_inet_dport, tvb, offset, 2, ENC_BIG_ENDIAN);
579 offset += 2;
581 switch (family) {
582 case LINUX_AF_INET:
583 proto_tree_add_item(tree, hf_netlink_sock_diag_inet_src_ip4, tvb, offset, 4, ENC_BIG_ENDIAN);
584 offset += 4;
586 _dissect_padding(tree, tvb, offset, 12);
587 offset += 12;
589 proto_tree_add_item(tree, hf_netlink_sock_diag_inet_dst_ip4, tvb, offset, 4, ENC_BIG_ENDIAN);
590 offset += 4;
592 _dissect_padding(tree, tvb, offset, 12);
593 offset += 12;
594 break;
596 case LINUX_AF_INET6:
597 proto_tree_add_item(tree, hf_netlink_sock_diag_inet_src_ip6, tvb, offset, 16, ENC_NA);
598 offset += 16;
600 proto_tree_add_item(tree, hf_netlink_sock_diag_inet_dst_ip6, tvb, offset, 16, ENC_NA);
601 offset += 16;
602 break;
604 default:
605 DISSECTOR_ASSERT_NOT_REACHED();
606 break;
609 proto_tree_add_item(tree, hf_netlink_sock_diag_inet_interface, tvb, offset, 4, nl_data->encoding);
610 offset += 4;
612 sock_diag_proto_tree_add_cookie(tree, info, nl_data, tvb, offset);
613 offset += 8;
615 return offset;
618 /* AF_INET */
620 static int
621 dissect_sock_diag_inet_reply(tvbuff_t *tvb, netlink_sock_diag_info_t *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
623 uint8_t af_family;
625 af_family = tvb_get_uint8(tvb, offset);
626 proto_tree_add_item(tree, hf_netlink_sock_diag_family, tvb, offset, 1, ENC_NA);
627 offset += 1;
629 proto_tree_add_item(tree, hf_netlink_sock_diag_state, tvb, offset, 1, ENC_NA);
630 offset += 1;
632 /* XXX timer retrans */
633 offset += 2;
635 offset = dissect_sock_diag_inet_sockid(tvb, info, nl_data, tree, offset, af_family);
637 /* XXX expires */
638 offset += 4;
640 proto_tree_add_item(tree, hf_netlink_sock_diag_rqueue, tvb, offset, 4, nl_data->encoding);
641 offset += 4;
643 proto_tree_add_item(tree, hf_netlink_sock_diag_wqueue, tvb, offset, 4, nl_data->encoding);
644 offset += 4;
646 /* XXX uid */
647 offset += 4;
649 proto_tree_add_item(tree, hf_netlink_sock_diag_inode, tvb, offset, 4, nl_data->encoding);
650 offset += 4;
652 return dissect_netlink_attributes_to_end(tvb, hf_netlink_sock_diag_inet_attr, ett_netlink_sock_diag_attr, info, nl_data, tree, offset, dissect_sock_diag_inet_attributes);
655 /* AF_INET request */
657 static int
658 dissect_sock_diag_inet_request(tvbuff_t *tvb, netlink_sock_diag_info_t *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
660 uint8_t af_family;
662 af_family = tvb_get_uint8(tvb, offset);
663 proto_tree_add_item(tree, hf_netlink_sock_diag_family, tvb, offset, 1, ENC_NA);
664 offset += 1;
666 proto_tree_add_item(tree, hf_netlink_sock_diag_inet_proto, tvb, offset, 1, ENC_NA);
667 offset += 1;
669 /* XXX ext: INET_DIAG_MEMINFO, INET_DIAG_INFO, ... */
671 proto_tree_add_item(tree, hf_netlink_sock_diag_inet_extended, tvb, offset, 1, ENC_NA);
672 offset += 1;
674 /* padding for backwards compatibility */
675 _dissect_padding(tree, tvb, offset, 1);
676 proto_tree_add_item(tree, hf_netlink_sock_diag_inet_padding, tvb, offset, 1, ENC_NA);
677 offset += 1;
679 /* XXX states (bit of sk_state) */
680 proto_tree_add_item(tree, hf_netlink_sock_diag_inet_states, tvb, offset, 4, ENC_NA);
681 offset += 4;
683 offset = dissect_sock_diag_inet_sockid(tvb, info, nl_data, tree, offset, af_family);
685 return offset;
688 /* AF_NETLINK attributes */
690 static const value_string netlink_sock_diag_netlink_vals[] = {
691 { WS_NETLINK_DIAG_MEMINFO, "Memory info" },
692 { WS_NETLINK_DIAG_GROUPS, "groups" },
693 { WS_NETLINK_DIAG_RX_RING, "RX ring configuration" },
694 { WS_NETLINK_DIAG_TX_RING, "TX ring configuration" },
695 { 0, NULL }
698 static int
699 dissect_sock_diag_netlink_attributes(tvbuff_t *tvb, void *data, struct packet_netlink_data *nl_data, proto_tree *tree, int nla_type, int offset, int len)
701 enum ws_netlink_diag_attr_type type = (enum ws_netlink_diag_attr_type) nla_type;
702 netlink_sock_diag_info_t *info = (netlink_sock_diag_info_t *) data;
704 switch (type) {
705 case WS_NETLINK_DIAG_MEMINFO:
706 return dissect_sock_diag_meminfo(tree, info, nl_data, tvb, offset, len);
708 case WS_NETLINK_DIAG_GROUPS:
709 case WS_NETLINK_DIAG_RX_RING:
710 case WS_NETLINK_DIAG_TX_RING:
711 default:
712 return 0;
716 /* AF_NETLINK */
718 static int
719 dissect_sock_diag_netlink_reply(tvbuff_t *tvb, netlink_sock_diag_info_t *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
721 proto_tree_add_item(tree, hf_netlink_sock_diag_family, tvb, offset, 1, ENC_NA);
722 offset += 1;
724 /* ti = */ proto_tree_add_item(tree, hf_netlink_sock_diag_type, tvb, offset, 1, ENC_NA);
725 switch (tvb_get_uint8(tvb, offset)) {
726 case WS_SOCK_DGRAM:
727 case WS_SOCK_RAW:
728 break;
729 default:
730 /* XXX expert_add_info(info->pinfo, ti, &ei_netlink_sock_diag_incorrect_type); */
731 break;
733 offset += 1;
735 proto_tree_add_item(tree, hf_netlink_sock_diag_netlink_proto, tvb, offset, 1, ENC_NA);
736 offset += 1;
738 /* XXX, validate */
739 proto_tree_add_item(tree, hf_netlink_sock_diag_state, tvb, offset, 1, ENC_NA);
740 offset += 1;
742 proto_tree_add_item(tree, hf_netlink_sock_diag_netlink_port_id, tvb, offset, 4, nl_data->encoding);
743 offset += 4;
745 proto_tree_add_item(tree, hf_netlink_sock_diag_netlink_dst_port_id, tvb, offset, 4, nl_data->encoding);
746 offset += 4;
748 /* XXX dst group */
749 offset += 4;
751 proto_tree_add_item(tree, hf_netlink_sock_diag_inode, tvb, offset, 4, nl_data->encoding);
752 offset += 4;
754 sock_diag_proto_tree_add_cookie(tree, info, nl_data, tvb, offset);
755 offset += 8;
757 return dissect_netlink_attributes_to_end(tvb, hf_netlink_sock_diag_netlink_attr, ett_netlink_sock_diag_attr, info, nl_data, tree, offset, dissect_sock_diag_netlink_attributes);
760 /* AF_NETLINK request */
762 static int
763 dissect_sock_diag_netlink_request_show(tvbuff_t *tvb, netlink_sock_diag_info_t *info _U_, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
765 proto_item *ti;
766 proto_tree *flags_tree;
768 ti = proto_tree_add_item(tree, hf_netlink_sock_diag_netlink_show, tvb, offset, 4, nl_data->encoding);
769 flags_tree = proto_item_add_subtree(ti, ett_netlink_sock_diag_show);
771 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_netlink_show_meminfo, tvb, offset, 4, nl_data->encoding);
772 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_netlink_show_groups, tvb, offset, 4, nl_data->encoding);
773 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_netlink_show_ring_cfg, tvb, offset, 4, nl_data->encoding);
774 /* XXX, unknown */
776 offset += 4;
778 return offset;
781 static int
782 dissect_sock_diag_netlink_request(tvbuff_t *tvb, netlink_sock_diag_info_t *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
784 /* XXX, 255 for all */
785 proto_tree_add_item(tree, hf_netlink_sock_diag_family, tvb, offset, 1, ENC_NA);
786 offset += 1;
788 proto_tree_add_item(tree, hf_netlink_sock_diag_netlink_proto, tvb, offset, 1, ENC_NA);
789 offset += 1;
791 _dissect_padding(tree, tvb, offset, 2);
792 offset += 2;
794 proto_tree_add_item(tree, hf_netlink_sock_diag_inode, tvb, offset, 4, nl_data->encoding);
795 offset += 4;
797 offset = dissect_sock_diag_netlink_request_show(tvb, info, nl_data, tree, offset);
799 sock_diag_proto_tree_add_cookie(tree, info, nl_data, tvb, offset);
800 offset += 8;
802 return offset;
805 /* AF_PACKET attributes */
807 static int
808 dissect_netlink_packet_sock_diag_reply_attrs(tvbuff_t *tvb, void *data, struct packet_netlink_data *nl_data, proto_tree *tree, int nla_type, int offset, int len)
810 enum ws_packet_diag_attr_type type = (enum ws_packet_diag_attr_type) nla_type;
811 netlink_sock_diag_info_t *info = (netlink_sock_diag_info_t *) data;
813 switch (type) {
814 case WS_PACKET_DIAG_MEMINFO:
815 return dissect_sock_diag_meminfo(tree, info, nl_data, tvb, offset, len);
817 case WS_PACKET_DIAG_INFO:
818 case WS_PACKET_DIAG_MCLIST:
819 case WS_PACKET_DIAG_RX_RING:
820 case WS_PACKET_DIAG_TX_RING:
821 case WS_PACKET_DIAG_FANOUT:
822 case WS_PACKET_DIAG_UID:
823 case WS_PACKET_DIAG_FILTER:
824 default:
825 return 0;
829 static const value_string netlink_sock_diag_packet_vals[] = {
830 { WS_PACKET_DIAG_INFO, "info" },
831 { WS_PACKET_DIAG_MCLIST, "mclist" },
832 { WS_PACKET_DIAG_RX_RING, "rxring" },
833 { WS_PACKET_DIAG_TX_RING, "txring" },
834 { WS_PACKET_DIAG_FANOUT, "fanout" },
835 { WS_PACKET_DIAG_UID, "uid" },
836 { WS_PACKET_DIAG_MEMINFO, "meminfo" },
837 { WS_PACKET_DIAG_FILTER, "filter" },
838 { 0, NULL }
841 /* AF_PACKET */
843 static int
844 dissect_sock_diag_packet_reply(tvbuff_t *tvb, netlink_sock_diag_info_t *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
846 proto_tree_add_item(tree, hf_netlink_sock_diag_family, tvb, offset, 1, ENC_NA);
847 offset += 1;
849 proto_tree_add_item(tree, hf_netlink_sock_diag_type, tvb, offset, 1, ENC_NA);
850 offset += 1;
852 proto_tree_add_item(tree, hf_netlink_sock_diag_packet_proto, tvb, offset, 2, nl_data->encoding);
853 offset += 2;
855 proto_tree_add_item(tree, hf_netlink_sock_diag_inode, tvb, offset, 4, nl_data->encoding);
856 offset += 4;
858 sock_diag_proto_tree_add_cookie(tree, info, nl_data, tvb, offset);
859 offset += 8;
861 return dissect_netlink_attributes_to_end(tvb, hf_netlink_sock_diag_packet_attr, ett_netlink_sock_diag_attr, info, nl_data, tree, offset, dissect_netlink_packet_sock_diag_reply_attrs);
864 /* AF_PACKET request */
866 static int
867 dissect_sock_diag_packet_request_show(tvbuff_t *tvb, netlink_sock_diag_info_t *info _U_, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
869 proto_item *ti;
870 proto_tree *flags_tree;
872 ti = proto_tree_add_item(tree, hf_netlink_sock_diag_packet_show, tvb, offset, 4, nl_data->encoding);
873 flags_tree = proto_item_add_subtree(ti, ett_netlink_sock_diag_show);
875 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_packet_show_info, tvb, offset, 4, nl_data->encoding);
876 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_packet_show_mclist, tvb, offset, 4, nl_data->encoding);
877 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_packet_show_ring_cfg, tvb, offset, 4, nl_data->encoding);
878 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_packet_show_fanout, tvb, offset, 4, nl_data->encoding);
879 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_packet_show_meminfo, tvb, offset, 4, nl_data->encoding);
880 proto_tree_add_item(flags_tree, hf_netlink_sock_diag_packet_show_filter, tvb, offset, 4, nl_data->encoding);
881 /* XXX, unknown */
883 offset += 4;
885 return offset;
888 static int
889 dissect_sock_diag_packet_request(tvbuff_t *tvb, netlink_sock_diag_info_t *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
891 proto_tree_add_item(tree, hf_netlink_sock_diag_family, tvb, offset, 1, ENC_NA);
892 offset += 1;
894 proto_tree_add_item(tree, hf_netlink_sock_diag_packet_proto, tvb, offset, 1, ENC_NA);
895 offset += 1;
897 _dissect_padding(tree, tvb, offset, 2);
898 offset += 2;
900 proto_tree_add_item(tree, hf_netlink_sock_diag_inode, tvb, offset, 4, nl_data->encoding);
901 offset += 4;
903 offset = dissect_sock_diag_packet_request_show(tvb, info, nl_data, tree, offset);
905 sock_diag_proto_tree_add_cookie(tree, info, nl_data, tvb, offset);
906 offset += 8;
908 return offset;
911 /* WS_SOCK_DIAG_BY_FAMILY dissection */
913 static int
914 dissect_sock_diag_by_family(tvbuff_t *tvb, netlink_sock_diag_info_t *info, struct packet_netlink_data *nl_data, proto_tree *tree, int offset)
916 const bool is_req = (info->pinfo->p2p_dir == P2P_DIR_SENT);
917 uint8_t af_family;
919 af_family = tvb_get_uint8(tvb, offset);
921 switch (af_family) {
922 case LINUX_AF_LOCAL:
923 offset = (is_req) ?
924 dissect_sock_diag_unix_request(tvb, info, nl_data, tree, offset) :
925 dissect_sock_diag_unix_reply(tvb, info, nl_data, tree, offset);
926 break;
928 case LINUX_AF_INET:
929 case LINUX_AF_INET6:
930 offset = (is_req) ?
931 dissect_sock_diag_inet_request(tvb, info, nl_data, tree, offset) :
932 dissect_sock_diag_inet_reply(tvb, info, nl_data, tree, offset);
933 break;
935 case LINUX_AF_NETLINK:
936 offset = (is_req) ?
937 dissect_sock_diag_netlink_request(tvb, info, nl_data, tree, offset) :
938 dissect_sock_diag_netlink_reply(tvb, info, nl_data, tree, offset);
939 break;
941 case LINUX_AF_PACKET:
942 offset = (is_req) ?
943 dissect_sock_diag_packet_request(tvb, info, nl_data, tree, offset) :
944 dissect_sock_diag_packet_reply(tvb, info, nl_data, tree, offset);
945 break;
948 return offset;
951 static const value_string netlink_sock_diag_type_vals[] = {
952 { WS_TCPDIAG_GETSOCK, "TCPDIAG_GETSOCK" },
953 { WS_DCCPDIAG_GETSOCK, "DCCPDIAG_GETSOCK" },
954 { WS_SOCK_DIAG_BY_FAMILY, "SOCK_DIAG_BY_FAMILY" },
955 { WS_SOCK_DESTROY, "SOCK_DESTROY" },
956 { 0, NULL }
959 static int
960 dissect_netlink_sock_diag(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
962 struct packet_netlink_data *nl_data = (struct packet_netlink_data *)data;
963 netlink_sock_diag_info_t info;
964 proto_tree *nlmsg_tree;
965 proto_item *pi;
966 int offset = 0;
968 DISSECTOR_ASSERT(nl_data && nl_data->magic == PACKET_NETLINK_MAGIC);
970 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Netlink sock diag");
971 col_clear(pinfo->cinfo, COL_INFO);
973 pi = proto_tree_add_item(tree, proto_netlink_sock_diag, tvb, 0, -1, ENC_NA);
974 nlmsg_tree = proto_item_add_subtree(pi, ett_netlink_sock_diag);
976 /* Netlink message header (nlmsghdr) */
977 offset = dissect_netlink_header(tvb, nlmsg_tree, offset, nl_data->encoding, hf_netlink_sock_diag_nltype, NULL);
979 info.pinfo = pinfo;
981 switch (nl_data->type) {
982 case WS_TCPDIAG_GETSOCK:
983 case WS_DCCPDIAG_GETSOCK:
984 /* XXX, inet_diag_rcv_msg_compat */
985 break;
987 case WS_SOCK_DIAG_BY_FAMILY:
988 offset = dissect_sock_diag_by_family(tvb, &info, nl_data, nlmsg_tree, offset);
989 break;
992 return offset;
995 void
996 proto_register_netlink_sock_diag(void)
998 static hf_register_info hf[] = {
999 { &hf_netlink_sock_diag_family,
1000 { "Family", "netlink-sock_diag.family",
1001 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &linux_af_vals_ext, 0x00,
1002 NULL, HFILL }
1004 { &hf_netlink_sock_diag_type,
1005 { "Type", "netlink-sock_diag.type",
1006 FT_UINT8, BASE_DEC, VALS(socket_type_vals), 0x00,
1007 NULL, HFILL }
1009 { &hf_netlink_sock_diag_state,
1010 { "State", "netlink-sock_diag.state",
1011 FT_UINT8, BASE_DEC, VALS(socket_state_vals), 0x00,
1012 NULL, HFILL }
1014 { &hf_netlink_sock_diag_inode,
1015 { "Inode", "netlink-sock_diag.inode",
1016 FT_UINT32, BASE_DEC, NULL, 0x00,
1017 NULL, HFILL }
1019 { &hf_netlink_sock_diag_rqueue,
1020 { "Recv Queue", "netlink-sock_diag.recv_queue",
1021 FT_UINT32, BASE_DEC, NULL, 0x00,
1022 NULL, HFILL }
1024 { &hf_netlink_sock_diag_wqueue,
1025 { "Send Queue", "netlink-sock_diag.send_queue",
1026 FT_UINT32, BASE_DEC, NULL, 0x00,
1027 NULL, HFILL }
1029 { &hf_netlink_sock_diag_rmem_alloc,
1030 { "Read allocation", "netlink-sock_diag.rmem_alloc",
1031 FT_UINT32, BASE_DEC, NULL, 0x00,
1032 NULL, HFILL }
1034 { &hf_netlink_sock_diag_rcvbuf,
1035 { "Recv buffer", "netlink-sock_diag.rcvbuf",
1036 FT_UINT32, BASE_DEC, NULL, 0x00,
1037 NULL, HFILL }
1039 { &hf_netlink_sock_diag_wmem_alloc,
1040 { "Write allocation", "netlink-sock_diag.wmem_alloc",
1041 FT_UINT32, BASE_DEC, NULL, 0x00,
1042 NULL, HFILL }
1044 { &hf_netlink_sock_diag_sndbuf,
1045 { "Send buffer", "netlink-sock_diag.sndbuf",
1046 FT_UINT32, BASE_DEC, NULL, 0x00,
1047 NULL, HFILL }
1049 { &hf_netlink_sock_diag_fwd_alloc,
1050 { "Forward allocation", "netlink-sock_diag.fwd_alloc",
1051 FT_UINT32, BASE_DEC, NULL, 0x00,
1052 NULL, HFILL }
1054 { &hf_netlink_sock_diag_wmem_queued,
1055 { "Write allocation queued", "netlink-sock_diag.wmem_queued",
1056 FT_UINT32, BASE_DEC, NULL, 0x00,
1057 NULL, HFILL }
1059 { &hf_netlink_sock_diag_cookie,
1060 { "Cookie", "netlink-sock_diag.cookie",
1061 FT_UINT64, BASE_HEX, NULL, 0x00,
1062 NULL, HFILL }
1064 { &hf_netlink_sock_diag_shutdown,
1065 { "Shutdown flag", "netlink-sock_diag.shutdown",
1066 FT_UINT8, BASE_HEX, VALS(netlink_sock_diag_shutdown_flags_vals), 0x00,
1067 NULL, HFILL }
1069 { &hf_netlink_sock_diag_unix_attr,
1070 { "Type", "netlink-sock_diag.unix_attr",
1071 FT_UINT16, BASE_DEC, VALS(netlink_sock_diag_unix_attr_vals), NLA_TYPE_MASK,
1072 NULL, HFILL }
1074 { &hf_netlink_sock_diag_unix_name,
1075 { "Name", "netlink-sock_diag.unix_name",
1076 FT_STRINGZ, BASE_NONE, NULL, 0x00,
1077 NULL, HFILL }
1079 { &hf_netlink_sock_diag_unix_peer_inode,
1080 { "Peer inode", "netlink-sock_diag.unix_peer_inode",
1081 FT_UINT32, BASE_DEC, NULL, 0x00,
1082 NULL, HFILL }
1084 { &hf_netlink_sock_diag_unix_show,
1085 { "Show", "netlink-sock_diag.unix_show",
1086 FT_UINT32, BASE_HEX, NULL, 0x00,
1087 NULL, HFILL }
1089 { &hf_netlink_sock_diag_unix_show_name,
1090 { "Name", "netlink-sock_diag.unix_show.name",
1091 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_UDIAG_SHOW_NAME,
1092 NULL, HFILL }
1094 { &hf_netlink_sock_diag_unix_show_vfs,
1095 { "VFS inode info", "netlink-sock_diag.unix_show.vfs",
1096 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_UDIAG_SHOW_VFS,
1097 NULL, HFILL }
1099 { &hf_netlink_sock_diag_unix_show_peer,
1100 { "Peer socket info", "netlink-sock_diag.unix_show.peer",
1101 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_UDIAG_SHOW_PEER,
1102 NULL, HFILL }
1104 { &hf_netlink_sock_diag_unix_show_icons,
1105 { "Pending connections", "netlink-sock_diag.unix_show.icons",
1106 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_UDIAG_SHOW_ICONS,
1107 NULL, HFILL }
1109 { &hf_netlink_sock_diag_unix_show_rqlen,
1110 { "skb receive queue len", "netlink-sock_diag.unix_show.rqlen",
1111 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_UDIAG_SHOW_RQLEN,
1112 NULL, HFILL }
1114 { &hf_netlink_sock_diag_unix_show_meminfo,
1115 { "Memory info of a socket", "netlink-sock_diag.unix_show.meminfo",
1116 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_UDIAG_SHOW_MEMINFO,
1117 NULL, HFILL }
1119 { &hf_netlink_sock_diag_inet_attr,
1120 { "Type", "netlink-sock_diag.inet_attr",
1121 FT_UINT16, BASE_DEC, VALS(netlink_sock_diag_inet_attr_vals), NLA_TYPE_MASK,
1122 NULL, HFILL }
1124 { &hf_netlink_sock_diag_inet_sport,
1125 { "Source port", "netlink-sock_diag.inet_sport",
1126 FT_UINT16, BASE_DEC, NULL, 0x00,
1127 NULL, HFILL }
1129 { &hf_netlink_sock_diag_inet_dport,
1130 { "Dest port", "netlink-sock_diag.inet_dport",
1131 FT_UINT16, BASE_DEC, NULL, 0x00,
1132 NULL, HFILL }
1134 { &hf_netlink_sock_diag_inet_src_ip4,
1135 { "Source IP", "netlink-sock_diag.inet_src_ip4",
1136 FT_IPv4, BASE_NONE, NULL, 0x00,
1137 NULL, HFILL }
1139 { &hf_netlink_sock_diag_inet_dst_ip4,
1140 { "Dest IP", "netlink-sock_diag.inet_dest_ip4",
1141 FT_IPv4, BASE_NONE, NULL, 0x00,
1142 NULL, HFILL }
1144 { &hf_netlink_sock_diag_inet_src_ip6,
1145 { "Source IP", "netlink-sock_diag.inet_src_ip6",
1146 FT_IPv6, BASE_NONE, NULL, 0x00,
1147 NULL, HFILL }
1149 { &hf_netlink_sock_diag_inet_dst_ip6,
1150 { "Dest IP", "netlink-sock_diag.inet_dest_ip6",
1151 FT_IPv6, BASE_NONE, NULL, 0x00,
1152 NULL, HFILL }
1154 { &hf_netlink_sock_diag_inet_interface,
1155 { "Interface", "netlink-sock_diag.inet_interface",
1156 FT_UINT32, BASE_DEC, NULL, 0x00,
1157 NULL, HFILL }
1159 { &hf_netlink_sock_diag_inet_proto,
1160 { "Protocol", "netlink-sock_diag.inet_protocol",
1161 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &ipproto_val_ext, 0x00,
1162 NULL, HFILL }
1164 { &hf_netlink_sock_diag_inet_extended,
1165 { "Requested info", "netlink-sock_diag.inet_extended",
1166 FT_UINT8, BASE_DEC, NULL, 0x00,
1167 NULL, HFILL }
1169 { &hf_netlink_sock_diag_inet_padding,
1170 { "v2 Padding or v1 info", "netlink-sock_diag.inet_padding",
1171 FT_UINT8, BASE_DEC, NULL, 0x00,
1172 NULL, HFILL }
1174 { &hf_netlink_sock_diag_inet_states,
1175 { "State filter", "netlink-sock_diag.inet_states",
1176 FT_UINT32, BASE_DEC, NULL, 0x00,
1177 NULL, HFILL }
1179 { &hf_netlink_sock_diag_netlink_attr,
1180 { "Type", "netlink-sock_diag.netlink_attr",
1181 FT_UINT16, BASE_DEC, VALS(netlink_sock_diag_netlink_vals), NLA_TYPE_MASK,
1182 NULL, HFILL }
1184 { &hf_netlink_sock_diag_netlink_proto,
1185 { "Protocol", "netlink-sock_diag.netlink_protocol",
1186 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &netlink_family_vals_ext, 0x00,
1187 NULL, HFILL }
1189 { &hf_netlink_sock_diag_netlink_port_id,
1190 { "Port ID", "netlink-sock_diag.netlink_portid",
1191 FT_UINT32, BASE_DEC, NULL, 0x00,
1192 NULL, HFILL }
1194 { &hf_netlink_sock_diag_netlink_dst_port_id,
1195 { "Dest Port ID", "netlink-sock_diag.netlink_dst_portid",
1196 FT_UINT32, BASE_DEC, NULL, 0x00,
1197 NULL, HFILL }
1199 { &hf_netlink_sock_diag_netlink_show,
1200 { "Show", "netlink-sock_diag.netlink_show",
1201 FT_UINT32, BASE_HEX, NULL, 0x00,
1202 NULL, HFILL }
1204 { &hf_netlink_sock_diag_netlink_show_meminfo,
1205 { "Memory info of a socket", "netlink-sock_diag.netlink_show.meminfo",
1206 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_NDIAG_SHOW_MEMINFO,
1207 NULL, HFILL }
1209 { &hf_netlink_sock_diag_netlink_show_groups,
1210 { "Groups of a netlink socket", "netlink-sock_diag.netlink_show.groups",
1211 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_NDIAG_SHOW_GROUPS,
1212 NULL, HFILL }
1214 { &hf_netlink_sock_diag_netlink_show_ring_cfg,
1215 { "Ring configuration", "netlink-sock_diag.netlink_show.ring_cfg",
1216 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_NDIAG_SHOW_RING_CFG,
1217 NULL, HFILL }
1219 { &hf_netlink_sock_diag_packet_attr,
1220 { "Type", "netlink-sock_diag.netlink_attr",
1221 FT_UINT16, BASE_DEC, VALS(netlink_sock_diag_packet_vals), NLA_TYPE_MASK,
1222 NULL, HFILL }
1224 { &hf_netlink_sock_diag_packet_proto,
1225 { "Protocol", "netlink-sock_diag.packet_protocol",
1226 FT_UINT16, BASE_HEX, VALS(etype_vals) /* XXX + Linux specific */, 0x00,
1227 NULL, HFILL }
1229 { &hf_netlink_sock_diag_packet_show,
1230 { "Show", "netlink-sock_diag.packet_show",
1231 FT_UINT32, BASE_HEX, NULL, 0x00,
1232 NULL, HFILL }
1234 { &hf_netlink_sock_diag_packet_show_info,
1235 { "Basic packet_sk information", "netlink-sock_diag.packet_show.info",
1236 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_PACKET_SHOW_INFO,
1237 NULL, HFILL }
1239 { &hf_netlink_sock_diag_packet_show_mclist,
1240 { "Set of packet_diag_mclist-s", "netlink-sock_diag.packet_show.mclist",
1241 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_PACKET_SHOW_MCLIST,
1242 NULL, HFILL }
1244 { &hf_netlink_sock_diag_packet_show_ring_cfg,
1245 { "Rings configuration parameters", "netlink-sock_diag.packet_show.ring_cfg",
1246 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_PACKET_SHOW_RING_CFG,
1247 NULL, HFILL }
1249 { &hf_netlink_sock_diag_packet_show_fanout,
1250 { "Fanout", "netlink-sock_diag.packet_show.fanout",
1251 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_PACKET_SHOW_FANOUT,
1252 NULL, HFILL }
1254 { &hf_netlink_sock_diag_packet_show_meminfo,
1255 { "memory info", "netlink-sock_diag.packet_show.meminfo",
1256 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_PACKET_SHOW_MEMINFO,
1257 NULL, HFILL }
1259 { &hf_netlink_sock_diag_packet_show_filter,
1260 { "Filter", "netlink-sock_diag.packet_show.filter",
1261 FT_BOOLEAN, 32, TFS(&_tfs_show_do_not_show), WS_PACKET_SHOW_FILTER,
1262 NULL, HFILL }
1264 { &hf_netlink_sock_diag_nltype,
1265 { "Message type", "netlink-sock_diag.nltype",
1266 FT_UINT16, BASE_DEC, VALS(netlink_sock_diag_type_vals), 0x00,
1267 NULL, HFILL }
1271 static int *ett[] = {
1272 &ett_netlink_sock_diag,
1273 &ett_netlink_sock_diag_show,
1274 &ett_netlink_sock_diag_attr
1277 proto_netlink_sock_diag = proto_register_protocol("Linux netlink sock diag protocol", "sock_diag", "netlink-sock_diag" );
1278 proto_register_field_array(proto_netlink_sock_diag, hf, array_length(hf));
1279 proto_register_subtree_array(ett, array_length(ett));
1281 netlink_sock_diag_handle = register_dissector("netlink-sock_diag", dissect_netlink_sock_diag, proto_netlink_sock_diag);
1284 void
1285 proto_reg_handoff_netlink_sock_diag(void)
1287 dissector_add_uint("netlink.protocol", WS_NETLINK_SOCK_DIAG, netlink_sock_diag_handle);
1291 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1293 * Local variables:
1294 * c-basic-offset: 8
1295 * tab-width: 8
1296 * indent-tabs-mode: t
1297 * End:
1299 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1300 * :indentSize=8:tabSize=8:noTabs=false: