3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 /* http://www.tcpdump.org/linktypes/LINKTYPE_NETLINK.html */
24 #define NEW_PROTO_TREE_API
28 #include <epan/packet.h>
29 #include <epan/arptypes.h>
30 #include <wiretap/wtap.h>
32 #include "packet-netlink.h"
34 void proto_register_netlink(void);
35 void proto_reg_handoff_netlink(void);
38 * A DLT_LINUX_SLL fake link-layer header.
40 #define SLL_HEADER_SIZE 16 /* total header length */
42 static const value_string netlink_family_vals[] = {
43 { WS_NETLINK_ROUTE, "Route" },
44 { WS_NETLINK_UNUSED, "Unused" },
45 { WS_NETLINK_USERSOCK, "User-mode socket protocols" },
46 { WS_NETLINK_FIREWALL, "Unused (formerly: ip_queue)" },
47 { WS_NETLINK_SOCK_DIAG, "Socket monitoring" },
48 { WS_NETLINK_NFLOG, "Netfilter ULOG" },
49 { WS_NETLINK_XFRM, "IPsec" },
50 { WS_NETLINK_SELINUX, "SELinux events" },
51 { WS_NETLINK_ISCSI, "Open-iSCSI" },
52 { WS_NETLINK_AUDIT, "Auditing" },
53 { WS_NETLINK_FIB_LOOKUP, "FIB lookup" },
54 { WS_NETLINK_CONNECTOR, "Kernel connector" },
55 { WS_NETLINK_NETFILTER, "Netfilter" },
56 { WS_NETLINK_IP6_FW, "Unused (formerly: ip6_queue)" },
57 { WS_NETLINK_DNRTMSG, "DECnet routing messages" },
58 { WS_NETLINK_KOBJECT_UEVENT, "Kernel messages to userspace" },
59 { WS_NETLINK_GENERIC, "Generic" },
60 { WS_NETLINK_SCSITRANSPORT, "SCSI Transports" },
61 { WS_NETLINK_ECRYPTFS, "ecryptfs" },
62 { WS_NETLINK_RDMA, "RDMA" },
63 { WS_NETLINK_CRYPTO, "Crypto layer" },
67 value_string_ext netlink_family_vals_ext = VALUE_STRING_EXT_INIT(netlink_family_vals);
69 static const value_string type_vals[] = {
70 { WS_NLMSG_NOOP, "Nothing" },
71 { WS_NLMSG_ERROR, "Error" },
72 { WS_NLMSG_DONE, "End of a dump" },
73 { WS_NLMSG_OVERRUN, "Data lost" },
77 static const value_string ha_types[] = {
78 { ARPHRD_NETLINK, "Netlink" },
82 static dissector_handle_t netlink_handle;
84 static header_field_info *hfi_netlink = NULL;
86 #define NETLINK_HFI_INIT HFI_INIT(proto_netlink)
88 static header_field_info hfi_netlink_hatype NETLINK_HFI_INIT =
89 { "Link-layer address type", "netlink.hatype", FT_UINT16, BASE_DEC,
90 VALS(ha_types), 0x0, NULL, HFILL };
92 /* Linux netlink protocol type */
93 static header_field_info hfi_netlink_family NETLINK_HFI_INIT =
94 { "Family", "netlink.family", FT_UINT16, BASE_HEX | BASE_EXT_STRING,
95 &netlink_family_vals_ext, 0x00, NULL, HFILL };
97 static header_field_info hfi_netlink_hdr_len NETLINK_HFI_INIT =
98 { "Length", "netlink.hdr_len", FT_UINT32, BASE_DEC,
99 NULL, 0x00, "Length of message including header", HFILL };
101 static header_field_info hfi_netlink_hdr_type NETLINK_HFI_INIT =
102 { "Message type", "netlink.hdr_type", FT_UINT16, BASE_HEX,
103 VALS(type_vals), 0x00, "Type of message content", HFILL };
105 static header_field_info hfi_netlink_hdr_flags NETLINK_HFI_INIT =
106 { "Flags", "netlink.hdr_flags", FT_UINT16, BASE_HEX,
107 NULL, 0x00, "Additional flags", HFILL };
109 static header_field_info hfi_netlink_hdr_flag_dumpfiltered NETLINK_HFI_INIT =
110 { "Dump filtered", "netlink.hdr_flags.dump_filtered", FT_UINT16, BASE_DEC,
111 NULL, WS_NLM_F_DUMP_FILTERED, "Dump was filtered as requested", HFILL };
113 static header_field_info hfi_netlink_hdr_flag_dumpintr NETLINK_HFI_INIT =
114 { "Dump inconsistent", "netlink.hdr_flags.dump_intr", FT_UINT16, BASE_DEC,
115 NULL, WS_NLM_F_DUMP_INTR, "Dump was inconsistent due to sequence change", HFILL };
117 static header_field_info hfi_netlink_hdr_flag_echo NETLINK_HFI_INIT =
118 { "Echo", "netlink.hdr_flags.echo", FT_UINT16, BASE_DEC,
119 NULL, WS_NLM_F_ECHO, "Echo this request", HFILL };
121 static header_field_info hfi_netlink_hdr_flag_ack NETLINK_HFI_INIT =
122 { "Ack", "netlink.hdr_flags.ack", FT_UINT16, BASE_DEC,
123 NULL, WS_NLM_F_ACK, "Asking for an ack", HFILL };
125 static header_field_info hfi_netlink_hdr_flag_multi NETLINK_HFI_INIT =
126 { "Multipart message", "netlink.hdr_flags.multi", FT_UINT16, BASE_DEC,
127 NULL, WS_NLM_F_MULTI, "Part of multi-part message terminated by NLMSG_DONE", HFILL };
129 static header_field_info hfi_netlink_hdr_flag_request NETLINK_HFI_INIT =
130 { "Request", "netlink.hdr_flags.request", FT_UINT16, BASE_DEC,
131 NULL, WS_NLM_F_REQUEST, "It is a request message", HFILL };
133 static header_field_info hfi_netlink_hdr_flag_root NETLINK_HFI_INIT =
134 { "Specify tree root", "netlink.hdr_flags.root", FT_UINT16, BASE_DEC,
135 NULL, WS_NLM_F_ROOT, "Return the complete table instead of a single entry", HFILL };
137 static header_field_info hfi_netlink_hdr_flag_match NETLINK_HFI_INIT =
138 { "Return all matching", "netlink.hdr_flags.match", FT_UINT16, BASE_DEC,
139 NULL, WS_NLM_F_MATCH, "Return all entries matching criteria in request", HFILL };
141 static header_field_info hfi_netlink_hdr_flag_atomic NETLINK_HFI_INIT =
142 { "Atomic", "netlink.hdr_flags.atomic", FT_UINT16, BASE_DEC,
143 NULL, WS_NLM_F_ATOMIC, "Return an atomic snapshot of the table", HFILL };
145 static header_field_info hfi_netlink_hdr_flag_replace NETLINK_HFI_INIT =
146 { "Replace", "netlink.hdr_flags.replace", FT_UINT16, BASE_DEC,
147 NULL, WS_NLM_F_REPLACE, "Replace existing objects", HFILL };
149 static header_field_info hfi_netlink_hdr_flag_excl NETLINK_HFI_INIT =
150 { "Excl", "netlink.hdr_flags.excl", FT_UINT16, BASE_DEC,
151 NULL, WS_NLM_F_EXCL, "Do not replace existing objects", HFILL };
153 static header_field_info hfi_netlink_hdr_flag_create NETLINK_HFI_INIT =
154 { "Create", "netlink.hdr_flags.create", FT_UINT16, BASE_DEC,
155 NULL, WS_NLM_F_CREATE, "Create objects if it does not already exist", HFILL };
157 static header_field_info hfi_netlink_hdr_flag_append NETLINK_HFI_INIT =
158 { "Append", "netlink.hdr_flags.append", FT_UINT16, BASE_DEC,
159 NULL, WS_NLM_F_APPEND, "Add to end of object list", HFILL };
161 static header_field_info hfi_netlink_hdr_seq NETLINK_HFI_INIT =
162 { "Sequence", "netlink.hdr_seq", FT_UINT32, BASE_DEC,
163 NULL, 0x00, "Sequence number", HFILL };
165 static header_field_info hfi_netlink_hdr_pid NETLINK_HFI_INIT =
166 { "Port ID", "netlink.hdr_pid", FT_UINT32, BASE_DEC,
167 NULL, 0x00, "Sender port ID", HFILL };
169 static header_field_info hfi_netlink_attr_len NETLINK_HFI_INIT =
170 { "Len", "netlink.attr_len", FT_UINT16, BASE_DEC,
171 NULL, 0x00, NULL, HFILL };
173 static header_field_info hfi_netlink_attr_type NETLINK_HFI_INIT =
174 { "Type", "netlink.attr_type", FT_UINT16, BASE_HEX,
175 NULL, 0x0000, "Netlink Attribute type", HFILL };
177 static header_field_info hfi_netlink_attr_type_nested NETLINK_HFI_INIT =
178 { "Nested", "netlink.attr_type.nested", FT_UINT16, BASE_DEC,
179 NULL, NLA_F_NESTED, "Carries nested attributes", HFILL };
181 static header_field_info hfi_netlink_attr_type_net_byteorder NETLINK_HFI_INIT =
182 { "Network byte order", "netlink.attr_type.net_byteorder", FT_UINT16, BASE_DEC,
183 NULL, NLA_F_NET_BYTEORDER, "Payload stored in network byte order", HFILL };
185 static header_field_info hfi_netlink_attr_index NETLINK_HFI_INIT =
186 { "Index", "netlink.attr_index", FT_UINT16, BASE_DEC,
187 NULL, 0x0000, "Netlink Attribute type (array index)", HFILL };
189 static header_field_info hfi_netlink_attr_data NETLINK_HFI_INIT =
190 { "Data", "netlink.attr_data", FT_BYTES, BASE_NONE,
191 NULL, 0x00, NULL, HFILL };
193 /* TODO add a value_string for errno. */
194 static header_field_info hfi_netlink_error NETLINK_HFI_INIT =
195 { "Error code", "netlink.error", FT_INT32, BASE_DEC,
196 NULL, 0x00, "Negative errno or 0 for acknowledgements", HFILL };
198 static gint ett_netlink_cooked = -1;
199 static gint ett_netlink_msghdr = -1;
200 static gint ett_netlink_msg = -1;
201 static gint ett_netlink_hdr_flags = -1;
202 static gint ett_netlink_attr_type = -1;
204 static dissector_table_t netlink_dissector_table;
207 static const int *netlink_header_get_flags[] = {
208 &hfi_netlink_hdr_flag_request.id,
209 &hfi_netlink_hdr_flag_multi.id,
210 &hfi_netlink_hdr_flag_ack.id,
211 &hfi_netlink_hdr_flag_echo.id,
212 &hfi_netlink_hdr_flag_dumpintr.id,
213 &hfi_netlink_hdr_flag_dumpfiltered.id,
215 &hfi_netlink_hdr_flag_root.id,
216 &hfi_netlink_hdr_flag_match.id,
217 &hfi_netlink_hdr_flag_atomic.id,
221 static const int *netlink_header_new_flags[] = {
222 &hfi_netlink_hdr_flag_request.id,
223 &hfi_netlink_hdr_flag_multi.id,
224 &hfi_netlink_hdr_flag_ack.id,
225 &hfi_netlink_hdr_flag_echo.id,
226 &hfi_netlink_hdr_flag_dumpintr.id,
227 &hfi_netlink_hdr_flag_dumpfiltered.id,
229 &hfi_netlink_hdr_flag_replace.id,
230 &hfi_netlink_hdr_flag_excl.id,
231 &hfi_netlink_hdr_flag_create.id,
232 &hfi_netlink_hdr_flag_append.id,
236 static const int *netlink_header_standard_flags[] = {
237 &hfi_netlink_hdr_flag_request.id,
238 &hfi_netlink_hdr_flag_multi.id,
239 &hfi_netlink_hdr_flag_ack.id,
240 &hfi_netlink_hdr_flag_echo.id,
241 &hfi_netlink_hdr_flag_dumpintr.id,
242 &hfi_netlink_hdr_flag_dumpfiltered.id,
248 dissect_netlink_attributes_common(tvbuff_t *tvb, header_field_info *hfi_type, int ett_tree, int ett_attrib, void *data, struct packet_netlink_data *nl_data, proto_tree *tree, int offset, int length, netlink_attributes_cb_t cb)
251 int padding = (4 - offset) & 3;
253 DISSECTOR_ASSERT(nl_data);
255 encoding = nl_data->encoding;
260 length = tvb_captured_length_remaining(tvb, offset);
265 while (length >= 4) {
266 guint16 rta_len, rta_type, type;
268 proto_item *ti, *type_item;
269 proto_tree *attr_tree, *type_tree;
271 rta_len = tvb_get_guint16(tvb, offset, encoding);
273 /* XXX invalid expert */
277 /* XXX expert info when rta_len < length? */
278 rta_len = MIN(rta_len, length);
280 attr_tree = proto_tree_add_subtree(tree, tvb, offset, rta_len, ett_tree, &ti, "Attribute");
282 proto_tree_add_item(attr_tree, &hfi_netlink_attr_len, tvb, offset, 2, encoding);
285 rta_type = tvb_get_guint16(tvb, offset, encoding);
286 if (ett_attrib == -1) {
287 /* List of attributes */
288 type = rta_type & NLA_TYPE_MASK;
289 type_item = proto_tree_add_item(attr_tree, &hfi_netlink_attr_type, tvb, offset, 2, encoding);
290 type_tree = proto_item_add_subtree(type_item, ett_netlink_attr_type);
291 proto_tree_add_item(type_tree, &hfi_netlink_attr_type_nested, tvb, offset, 2, encoding);
292 proto_tree_add_item(type_tree, &hfi_netlink_attr_type_net_byteorder, tvb, offset, 2, encoding);
293 proto_tree_add_item(type_tree, hfi_type, tvb, offset, 2, encoding);
296 if (rta_type & NLA_F_NESTED)
297 proto_item_append_text(type_item, ", Nested");
299 if (hfi_type->strings) {
300 /* XXX, export hf_try_val_to_str */
303 if (hfi_type->display & BASE_EXT_STRING) {
304 rta_str = try_val_to_str_ext(type, (value_string_ext *)hfi_type->strings);
306 rta_str = try_val_to_str(type, (const value_string *) hfi_type->strings);
310 proto_item_append_text(type_item, ", %s (%d)", rta_str, type);
311 proto_item_append_text(ti, ": %s", rta_str);
315 if (!cb(tvb, data, attr_tree, rta_type, offset, rta_len - 4)) {
316 proto_tree_add_item(attr_tree, &hfi_netlink_attr_data, tvb, offset, rta_len - 4, encoding);
320 * Nested attributes, constructing an array (list of
321 * attributes where its type is the array index and its
322 * value is the actual list of interesting attributes).
324 proto_tree_add_item(attr_tree, &hfi_netlink_attr_index, tvb, offset, 2, encoding);
326 proto_item_append_text(ti, " %u", rta_type);
328 dissect_netlink_attributes(tvb, hfi_type, ett_attrib, data, nl_data, attr_tree, offset, rta_len - 4, cb);
331 /* Assume offset already aligned, next offset is rta_len plus alignment. */
332 rta_len = MIN((rta_len + 3) & ~3, length);
333 offset += rta_len - 4; /* Header was already skipped */
341 dissect_netlink_attributes(tvbuff_t *tvb, header_field_info *hfi_type, int ett, void *data, struct packet_netlink_data *nl_data, proto_tree *tree, int offset, int length, netlink_attributes_cb_t cb)
343 return dissect_netlink_attributes_common(tvb, hfi_type, ett, -1, data, nl_data, tree, offset, length, cb);
347 dissect_netlink_attributes_array(tvbuff_t *tvb, header_field_info *hfi_type, int ett_array, int ett_attrib, void *data, struct packet_netlink_data *nl_data, proto_tree *tree, int offset, int length, netlink_attributes_cb_t cb)
349 DISSECTOR_ASSERT(ett_attrib != -1);
350 return dissect_netlink_attributes_common(tvb, hfi_type, ett_array, ett_attrib, data, nl_data, tree, offset, length, cb);
354 dissect_netlink_header(tvbuff_t *tvb, proto_tree *tree, int offset, int encoding, header_field_info *hfi_type, proto_item **pi_type)
361 fh_hdr = proto_tree_add_subtree(tree, tvb, offset, 16, ett_netlink_msghdr, NULL, "Netlink message header");
363 proto_tree_add_item(fh_hdr, &hfi_netlink_hdr_len, tvb, offset, 4, encoding);
366 hdr_type = tvb_get_guint16(tvb, offset, encoding);
367 if (hdr_type < WS_NLMSG_MIN_TYPE) {
368 /* Reserved control messages. */
369 hfi_type = &hfi_netlink_hdr_type;
370 pi = proto_tree_add_item(fh_hdr, hfi_type, tvb, offset, 2, encoding);
373 pi = proto_tree_add_item(fh_hdr, hfi_type, tvb, offset, 2, encoding);
375 hfi_type = &hfi_netlink_hdr_type;
376 pi = proto_tree_add_item(fh_hdr, hfi_type, tvb, offset, 2, encoding);
377 proto_item_set_text(pi, "Message type: Protocol-specific (0x%04x)", hdr_type);
383 /* TODO export hf_try_val_to_str? */
384 if (hfi_type->strings && hfi_type->display & BASE_EXT_STRING) {
385 proto_item_append_text(fh_hdr, " (type: %s)", val_to_str_ext(hdr_type, (value_string_ext *)hfi_type->strings, "0x%04x"));
386 } else if (hfi_type->strings) {
387 proto_item_append_text(fh_hdr, " (type: %s)", val_to_str(hdr_type, (const value_string *)hfi_type->strings, "0x%04x"));
389 proto_item_append_text(fh_hdr, " (type: 0x%04x)", hdr_type);
393 hdr_flags = tvb_get_guint16(tvb, offset, encoding);
394 if ((hdr_flags & WS_NLM_F_REQUEST) && (hdr_flags & 0x0f00)) {
395 /* XXX detect based on the protocol family and message type
396 * whether this is a GET, NEW or regular request. */
397 proto_tree_add_bitmask(fh_hdr, tvb, offset, hfi_netlink_hdr_flags.id,
398 ett_netlink_hdr_flags, netlink_header_get_flags, encoding);
399 proto_tree_add_bitmask(fh_hdr, tvb, offset, hfi_netlink_hdr_flags.id,
400 ett_netlink_hdr_flags, netlink_header_new_flags, encoding);
402 proto_tree_add_bitmask(fh_hdr, tvb, offset, hfi_netlink_hdr_flags.id,
403 ett_netlink_hdr_flags, netlink_header_standard_flags, encoding);
408 proto_tree_add_item(fh_hdr, &hfi_netlink_hdr_seq, tvb, offset, 4, encoding);
411 proto_tree_add_item(fh_hdr, &hfi_netlink_hdr_pid, tvb, offset, 4, encoding);
418 dissect_netlink_error(tvbuff_t *tvb, proto_tree *tree, int offset, int encoding)
421 * XXX - this should make sure we don't run past the end of the
426 * Assume sizeof(int) == 4; RFC 3549 doesn't say "32 bits", it
427 * says "integer (typically 32 bits)".
429 proto_tree_add_item(tree, &hfi_netlink_error, tvb, offset, 4, encoding);
432 dissect_netlink_header(tvb, tree, offset, encoding, NULL, NULL);
436 dissect_netlink(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *_data _U_)
438 guint16 protocol, hatype;
445 guint len_rem, len_le, len_be;
447 hatype = tvb_get_ntohs(tvb, 2);
448 if (hatype != ARPHRD_NETLINK)
451 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Netlink");
452 col_clear(pinfo->cinfo, COL_INFO);
454 ti = proto_tree_add_protocol_format(tree, hfi_netlink->id, tvb, 0,
455 SLL_HEADER_SIZE, "Linux netlink (cooked header)");
456 fh_tree = proto_item_add_subtree(ti, ett_netlink_cooked);
461 proto_tree_add_item(fh_tree, &hfi_netlink_hatype, tvb, offset, 2, ENC_BIG_ENDIAN);
467 protocol = tvb_get_ntohs(tvb, offset);
468 proto_tree_add_item(fh_tree, &hfi_netlink_family, tvb, offset, 2, ENC_BIG_ENDIAN);
471 /* DISSECTOR_ASSERT(offset == 16); */
474 * We are unable to detect the endianness, we have to guess. Compare
475 * the size of the inner package with the size of the outer package,
476 * take the endianness in which the inner package length is closer to
477 * the size of the outer package. Normally we have packages with less
478 * than 10KB here so the sizes are very huge in the wrong endianness.
480 len_rem = tvb_reported_length_remaining(tvb, offset);
481 len_le = tvb_get_letohl(tvb, offset);
482 len_be = tvb_get_ntohl(tvb, offset);
483 #define abs_diff(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))
484 if (abs_diff(len_be, len_rem) < abs_diff(len_le, len_rem)) {
485 encoding = ENC_BIG_ENDIAN;
487 encoding = ENC_LITTLE_ENDIAN;
490 while (tvb_reported_length_remaining(tvb, offset) >= 16) {
496 gboolean dissected = FALSE;
498 pkt_len = tvb_get_guint32(tvb, offset, encoding);
500 pkt_end_offset = offset + pkt_len;
504 * This field includes the length of the 16-byte header,
505 * so its value is invalid. Add it, report an error,
506 * and stop trying to dissect.
510 fh_hdr = proto_tree_add_subtree(tree, tvb, offset, 4, ett_netlink_msghdr, NULL, "Netlink message header");
512 proto_tree_add_item(fh_hdr, &hfi_netlink_hdr_len, tvb, offset, 4, encoding);
513 /* XXX invalid expert */
517 /* message type field comes after length field. */
518 msg_type = tvb_get_guint16(tvb, offset + 4, encoding);
519 port_id = tvb_get_guint32(tvb, offset + 12, encoding);
523 pinfo->p2p_dir = P2P_DIR_SENT; /* userspace -> kernel */
525 pinfo->p2p_dir = P2P_DIR_RECV; /* userspace or kernel -> userspace */
528 * Try to invoke subdissectors for non-control messages.
530 if (msg_type >= WS_NLMSG_MIN_TYPE && pkt_len > 16) {
531 struct packet_netlink_data data;
533 data.magic = PACKET_NETLINK_MAGIC;
534 data.encoding = encoding;
535 data.type = msg_type;
537 next_tvb = tvb_new_subset_length(tvb, offset, pkt_len);
539 if (dissector_try_uint_new(netlink_dissector_table, protocol, next_tvb, pinfo, tree, TRUE, &data)) {
546 * No subdissector was called, add a new layer with the
547 * header and the payload. Note that pkt_len>=16.
549 fh_msg = proto_tree_add_subtree(tree, tvb, offset, pkt_len, ett_netlink_msg, NULL, "Netlink message");
550 offset = dissect_netlink_header(tvb, fh_msg, offset, encoding, NULL, NULL);
552 if (msg_type == WS_NLMSG_ERROR) {
553 dissect_netlink_error(tvb, fh_msg, offset, encoding);
554 } else if (pkt_len > 16) {
555 next_tvb = tvb_new_subset_length(tvb, offset, pkt_len - 16);
556 call_data_dissector(next_tvb, pinfo, fh_msg);
560 offset = pkt_end_offset;
567 proto_register_netlink(void)
569 #ifndef HAVE_HFI_SECTION_INIT
570 static header_field_info *hfi[] = {
575 /* Netlink message header */
576 &hfi_netlink_hdr_len,
577 &hfi_netlink_hdr_type,
578 &hfi_netlink_hdr_flags,
579 &hfi_netlink_hdr_flag_request,
580 &hfi_netlink_hdr_flag_multi,
581 &hfi_netlink_hdr_flag_ack,
582 &hfi_netlink_hdr_flag_echo,
583 &hfi_netlink_hdr_flag_dumpintr,
584 &hfi_netlink_hdr_flag_dumpfiltered,
586 &hfi_netlink_hdr_flag_root,
587 &hfi_netlink_hdr_flag_match,
588 &hfi_netlink_hdr_flag_atomic,
590 &hfi_netlink_hdr_flag_replace,
591 &hfi_netlink_hdr_flag_excl,
592 &hfi_netlink_hdr_flag_create,
593 &hfi_netlink_hdr_flag_append,
595 &hfi_netlink_hdr_seq,
596 &hfi_netlink_hdr_pid,
598 /* Netlink message attribute */
599 &hfi_netlink_attr_len,
600 &hfi_netlink_attr_type,
601 &hfi_netlink_attr_type_nested,
602 &hfi_netlink_attr_type_net_byteorder,
603 &hfi_netlink_attr_index,
604 &hfi_netlink_attr_data,
606 /* Netlink message payloads */
611 static gint *ett[] = {
615 &ett_netlink_hdr_flags,
616 &ett_netlink_attr_type,
621 proto_netlink = proto_register_protocol("Linux netlink protocol", "NETLINK", "netlink" );
622 hfi_netlink = proto_registrar_get_nth(proto_netlink);
624 proto_register_fields(proto_netlink, hfi, array_length(hfi));
625 proto_register_subtree_array(ett, array_length(ett));
627 netlink_handle = create_dissector_handle(dissect_netlink, proto_netlink);
629 netlink_dissector_table = register_dissector_table(
631 "Linux netlink protocol type",
632 proto_netlink, FT_UINT16,
635 register_dissector("netlink", dissect_netlink, proto_netlink);
639 proto_reg_handoff_netlink(void)
641 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETLINK, netlink_handle);
645 * Editor modelines - http://www.wireshark.org/tools/modelines.html
650 * indent-tabs-mode: t
653 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
654 * :indentSize=8:tabSize=8:noTabs=false: