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
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>
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);
26 } netlink_sock_diag_info_t
;
28 static int proto_netlink_sock_diag
;
30 static dissector_handle_t netlink_sock_diag_handle
;
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,
45 /* </usr/include/<platform>/bits/socket_type.h> */
50 WS_SOCK_SEQPACKET
= 5,
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,
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,
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,
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
148 /* based on kernel include <include/net/tcp_states.h> with WS_ without TCP_ (it's not only used by tcp) */
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" },
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" },
254 _tvb_check_if_zeros(tvbuff_t
*tvb
, int offset
, int len
)
256 /* padding, all bytes should be 0, if not display as unknown */
258 if (tvb_get_uint8(tvb
, offset
) != 0)
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 */
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
,
293 if (len
== 0 || (len
% 4) != 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;
308 /* Sock diag Cookie */
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
)
315 cookie
= tvb_get_letohl(tvb
, offset
+ 4);
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" },
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" },
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
;
362 case WS_UNIX_DIAG_NAME
:
366 /* XXX make it nicer */
367 if (len
> 0 && tvb_get_uint8(tvb
, offset
) == '\0') {
368 name
= wmem_strconcat(wmem_packet_scope(),
370 tvb_get_string_enc(wmem_packet_scope(), tvb
, offset
+1, len
-1, ENC_ASCII
| ENC_NA
),
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
);
380 case WS_UNIX_DIAG_PEER
:
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
);
389 case WS_UNIX_DIAG_RQLEN
:
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
);
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
:
403 sock_diag_proto_tree_add_shutdown(tree
, tvb
, offset
);
406 case WS_UNIX_DIAG_VFS
:
407 case WS_UNIX_DIAG_ICONS
:
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
);
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
);
426 proto_tree_add_item(tree
, hf_netlink_sock_diag_state
, tvb
, offset
, 1, ENC_NA
);
429 _dissect_padding(tree
, tvb
, offset
, 1);
432 proto_tree_add_item(tree
, hf_netlink_sock_diag_inode
, tvb
, offset
, 4, nl_data
->encoding
);
435 sock_diag_proto_tree_add_cookie(tree
, info
, nl_data
, tvb
, offset
);
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 */
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
)
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
);
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
);
471 /* XXX, AF_UNIX don't have protocols - 0 */
474 _dissect_padding(tree
, tvb
, offset
, 2);
480 proto_tree_add_item(tree
, hf_netlink_sock_diag_inode
, tvb
, offset
, 4, nl_data
->encoding
);
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
);
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" },
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
;
526 case WS_INET_DIAG_MEMINFO
:
528 proto_tree_add_item(tree
, hf_netlink_sock_diag_rmem_alloc
, tvb
, offset
, 4, nl_data
->encoding
);
531 proto_tree_add_item(tree
, hf_netlink_sock_diag_wmem_queued
, tvb
, offset
, 4, nl_data
->encoding
);
534 proto_tree_add_item(tree
, hf_netlink_sock_diag_fwd_alloc
, tvb
, offset
, 4, nl_data
->encoding
);
537 proto_tree_add_item(tree
, hf_netlink_sock_diag_wmem_alloc
, tvb
, offset
, 4, nl_data
->encoding
);
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
:
549 sock_diag_proto_tree_add_shutdown(tree
, tvb
, offset
);
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
:
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
);
578 proto_tree_add_item(tree
, hf_netlink_sock_diag_inet_dport
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
583 proto_tree_add_item(tree
, hf_netlink_sock_diag_inet_src_ip4
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
586 _dissect_padding(tree
, tvb
, offset
, 12);
589 proto_tree_add_item(tree
, hf_netlink_sock_diag_inet_dst_ip4
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
592 _dissect_padding(tree
, tvb
, offset
, 12);
597 proto_tree_add_item(tree
, hf_netlink_sock_diag_inet_src_ip6
, tvb
, offset
, 16, ENC_NA
);
600 proto_tree_add_item(tree
, hf_netlink_sock_diag_inet_dst_ip6
, tvb
, offset
, 16, ENC_NA
);
605 DISSECTOR_ASSERT_NOT_REACHED();
609 proto_tree_add_item(tree
, hf_netlink_sock_diag_inet_interface
, tvb
, offset
, 4, nl_data
->encoding
);
612 sock_diag_proto_tree_add_cookie(tree
, info
, nl_data
, tvb
, offset
);
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
)
625 af_family
= tvb_get_uint8(tvb
, offset
);
626 proto_tree_add_item(tree
, hf_netlink_sock_diag_family
, tvb
, offset
, 1, ENC_NA
);
629 proto_tree_add_item(tree
, hf_netlink_sock_diag_state
, tvb
, offset
, 1, ENC_NA
);
632 /* XXX timer retrans */
635 offset
= dissect_sock_diag_inet_sockid(tvb
, info
, nl_data
, tree
, offset
, af_family
);
640 proto_tree_add_item(tree
, hf_netlink_sock_diag_rqueue
, tvb
, offset
, 4, nl_data
->encoding
);
643 proto_tree_add_item(tree
, hf_netlink_sock_diag_wqueue
, tvb
, offset
, 4, nl_data
->encoding
);
649 proto_tree_add_item(tree
, hf_netlink_sock_diag_inode
, tvb
, offset
, 4, nl_data
->encoding
);
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 */
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
)
662 af_family
= tvb_get_uint8(tvb
, offset
);
663 proto_tree_add_item(tree
, hf_netlink_sock_diag_family
, tvb
, offset
, 1, ENC_NA
);
666 proto_tree_add_item(tree
, hf_netlink_sock_diag_inet_proto
, tvb
, offset
, 1, ENC_NA
);
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
);
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
);
679 /* XXX states (bit of sk_state) */
680 proto_tree_add_item(tree
, hf_netlink_sock_diag_inet_states
, tvb
, offset
, 4, ENC_NA
);
683 offset
= dissect_sock_diag_inet_sockid(tvb
, info
, nl_data
, tree
, offset
, af_family
);
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" },
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
;
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
:
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
);
724 /* ti = */ proto_tree_add_item(tree
, hf_netlink_sock_diag_type
, tvb
, offset
, 1, ENC_NA
);
725 switch (tvb_get_uint8(tvb
, offset
)) {
730 /* XXX expert_add_info(info->pinfo, ti, &ei_netlink_sock_diag_incorrect_type); */
735 proto_tree_add_item(tree
, hf_netlink_sock_diag_netlink_proto
, tvb
, offset
, 1, ENC_NA
);
739 proto_tree_add_item(tree
, hf_netlink_sock_diag_state
, tvb
, offset
, 1, ENC_NA
);
742 proto_tree_add_item(tree
, hf_netlink_sock_diag_netlink_port_id
, tvb
, offset
, 4, nl_data
->encoding
);
745 proto_tree_add_item(tree
, hf_netlink_sock_diag_netlink_dst_port_id
, tvb
, offset
, 4, nl_data
->encoding
);
751 proto_tree_add_item(tree
, hf_netlink_sock_diag_inode
, tvb
, offset
, 4, nl_data
->encoding
);
754 sock_diag_proto_tree_add_cookie(tree
, info
, nl_data
, tvb
, offset
);
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 */
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
)
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
);
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
);
788 proto_tree_add_item(tree
, hf_netlink_sock_diag_netlink_proto
, tvb
, offset
, 1, ENC_NA
);
791 _dissect_padding(tree
, tvb
, offset
, 2);
794 proto_tree_add_item(tree
, hf_netlink_sock_diag_inode
, tvb
, offset
, 4, nl_data
->encoding
);
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
);
805 /* AF_PACKET attributes */
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
;
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
:
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" },
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
);
849 proto_tree_add_item(tree
, hf_netlink_sock_diag_type
, tvb
, offset
, 1, ENC_NA
);
852 proto_tree_add_item(tree
, hf_netlink_sock_diag_packet_proto
, tvb
, offset
, 2, nl_data
->encoding
);
855 proto_tree_add_item(tree
, hf_netlink_sock_diag_inode
, tvb
, offset
, 4, nl_data
->encoding
);
858 sock_diag_proto_tree_add_cookie(tree
, info
, nl_data
, tvb
, offset
);
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 */
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
)
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
);
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
);
894 proto_tree_add_item(tree
, hf_netlink_sock_diag_packet_proto
, tvb
, offset
, 1, ENC_NA
);
897 _dissect_padding(tree
, tvb
, offset
, 2);
900 proto_tree_add_item(tree
, hf_netlink_sock_diag_inode
, tvb
, offset
, 4, nl_data
->encoding
);
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
);
911 /* WS_SOCK_DIAG_BY_FAMILY dissection */
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
);
919 af_family
= tvb_get_uint8(tvb
, offset
);
924 dissect_sock_diag_unix_request(tvb
, info
, nl_data
, tree
, offset
) :
925 dissect_sock_diag_unix_reply(tvb
, info
, nl_data
, tree
, offset
);
931 dissect_sock_diag_inet_request(tvb
, info
, nl_data
, tree
, offset
) :
932 dissect_sock_diag_inet_reply(tvb
, info
, nl_data
, tree
, offset
);
935 case LINUX_AF_NETLINK
:
937 dissect_sock_diag_netlink_request(tvb
, info
, nl_data
, tree
, offset
) :
938 dissect_sock_diag_netlink_reply(tvb
, info
, nl_data
, tree
, offset
);
941 case LINUX_AF_PACKET
:
943 dissect_sock_diag_packet_request(tvb
, info
, nl_data
, tree
, offset
) :
944 dissect_sock_diag_packet_reply(tvb
, info
, nl_data
, tree
, 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" },
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
;
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
);
981 switch (nl_data
->type
) {
982 case WS_TCPDIAG_GETSOCK
:
983 case WS_DCCPDIAG_GETSOCK
:
984 /* XXX, inet_diag_rcv_msg_compat */
987 case WS_SOCK_DIAG_BY_FAMILY
:
988 offset
= dissect_sock_diag_by_family(tvb
, &info
, nl_data
, nlmsg_tree
, offset
);
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,
1004 { &hf_netlink_sock_diag_type
,
1005 { "Type", "netlink-sock_diag.type",
1006 FT_UINT8
, BASE_DEC
, VALS(socket_type_vals
), 0x00,
1009 { &hf_netlink_sock_diag_state
,
1010 { "State", "netlink-sock_diag.state",
1011 FT_UINT8
, BASE_DEC
, VALS(socket_state_vals
), 0x00,
1014 { &hf_netlink_sock_diag_inode
,
1015 { "Inode", "netlink-sock_diag.inode",
1016 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
1019 { &hf_netlink_sock_diag_rqueue
,
1020 { "Recv Queue", "netlink-sock_diag.recv_queue",
1021 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
1024 { &hf_netlink_sock_diag_wqueue
,
1025 { "Send Queue", "netlink-sock_diag.send_queue",
1026 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
1029 { &hf_netlink_sock_diag_rmem_alloc
,
1030 { "Read allocation", "netlink-sock_diag.rmem_alloc",
1031 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
1034 { &hf_netlink_sock_diag_rcvbuf
,
1035 { "Recv buffer", "netlink-sock_diag.rcvbuf",
1036 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
1039 { &hf_netlink_sock_diag_wmem_alloc
,
1040 { "Write allocation", "netlink-sock_diag.wmem_alloc",
1041 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
1044 { &hf_netlink_sock_diag_sndbuf
,
1045 { "Send buffer", "netlink-sock_diag.sndbuf",
1046 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
1049 { &hf_netlink_sock_diag_fwd_alloc
,
1050 { "Forward allocation", "netlink-sock_diag.fwd_alloc",
1051 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
1054 { &hf_netlink_sock_diag_wmem_queued
,
1055 { "Write allocation queued", "netlink-sock_diag.wmem_queued",
1056 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
1059 { &hf_netlink_sock_diag_cookie
,
1060 { "Cookie", "netlink-sock_diag.cookie",
1061 FT_UINT64
, BASE_HEX
, NULL
, 0x00,
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,
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
,
1074 { &hf_netlink_sock_diag_unix_name
,
1075 { "Name", "netlink-sock_diag.unix_name",
1076 FT_STRINGZ
, BASE_NONE
, NULL
, 0x00,
1079 { &hf_netlink_sock_diag_unix_peer_inode
,
1080 { "Peer inode", "netlink-sock_diag.unix_peer_inode",
1081 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
1084 { &hf_netlink_sock_diag_unix_show
,
1085 { "Show", "netlink-sock_diag.unix_show",
1086 FT_UINT32
, BASE_HEX
, NULL
, 0x00,
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
,
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
,
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
,
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
,
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
,
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
,
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
,
1124 { &hf_netlink_sock_diag_inet_sport
,
1125 { "Source port", "netlink-sock_diag.inet_sport",
1126 FT_UINT16
, BASE_DEC
, NULL
, 0x00,
1129 { &hf_netlink_sock_diag_inet_dport
,
1130 { "Dest port", "netlink-sock_diag.inet_dport",
1131 FT_UINT16
, BASE_DEC
, NULL
, 0x00,
1134 { &hf_netlink_sock_diag_inet_src_ip4
,
1135 { "Source IP", "netlink-sock_diag.inet_src_ip4",
1136 FT_IPv4
, BASE_NONE
, NULL
, 0x00,
1139 { &hf_netlink_sock_diag_inet_dst_ip4
,
1140 { "Dest IP", "netlink-sock_diag.inet_dest_ip4",
1141 FT_IPv4
, BASE_NONE
, NULL
, 0x00,
1144 { &hf_netlink_sock_diag_inet_src_ip6
,
1145 { "Source IP", "netlink-sock_diag.inet_src_ip6",
1146 FT_IPv6
, BASE_NONE
, NULL
, 0x00,
1149 { &hf_netlink_sock_diag_inet_dst_ip6
,
1150 { "Dest IP", "netlink-sock_diag.inet_dest_ip6",
1151 FT_IPv6
, BASE_NONE
, NULL
, 0x00,
1154 { &hf_netlink_sock_diag_inet_interface
,
1155 { "Interface", "netlink-sock_diag.inet_interface",
1156 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
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,
1164 { &hf_netlink_sock_diag_inet_extended
,
1165 { "Requested info", "netlink-sock_diag.inet_extended",
1166 FT_UINT8
, BASE_DEC
, NULL
, 0x00,
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,
1174 { &hf_netlink_sock_diag_inet_states
,
1175 { "State filter", "netlink-sock_diag.inet_states",
1176 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
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
,
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,
1189 { &hf_netlink_sock_diag_netlink_port_id
,
1190 { "Port ID", "netlink-sock_diag.netlink_portid",
1191 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
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,
1199 { &hf_netlink_sock_diag_netlink_show
,
1200 { "Show", "netlink-sock_diag.netlink_show",
1201 FT_UINT32
, BASE_HEX
, NULL
, 0x00,
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
,
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
,
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
,
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
,
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,
1229 { &hf_netlink_sock_diag_packet_show
,
1230 { "Show", "netlink-sock_diag.packet_show",
1231 FT_UINT32
, BASE_HEX
, NULL
, 0x00,
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
,
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
,
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
,
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
,
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
,
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
,
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,
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
);
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
1296 * indent-tabs-mode: t
1299 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1300 * :indentSize=8:tabSize=8:noTabs=false: