Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
packet-netlink.h
1 /* packet-netlink.h
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 2001 Gerald Combs
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9 
10 #ifndef __PACKET_NETLINK_H__
11 #define __PACKET_NETLINK_H__
12 
13 #include <epan/value_string.h>
14 
15 /* from <linux/netlink.h> prefixed with WS_ */
16 enum {
17  WS_NETLINK_ROUTE = 0,
18  WS_NETLINK_UNUSED = 1,
19  WS_NETLINK_USERSOCK = 2,
20  WS_NETLINK_FIREWALL = 3,
21  WS_NETLINK_SOCK_DIAG = 4,
22  WS_NETLINK_NFLOG = 5,
23  WS_NETLINK_XFRM = 6,
24  WS_NETLINK_SELINUX = 7,
25  WS_NETLINK_ISCSI = 8,
26  WS_NETLINK_AUDIT = 9,
27  WS_NETLINK_FIB_LOOKUP = 10,
28  WS_NETLINK_CONNECTOR = 11,
29  WS_NETLINK_NETFILTER = 12,
30  WS_NETLINK_IP6_FW = 13,
31  WS_NETLINK_DNRTMSG = 14,
32  WS_NETLINK_KOBJECT_UEVENT = 15,
33  WS_NETLINK_GENERIC = 16,
34  /* leave room for NETLINK_DM (DM Events) */
35  WS_NETLINK_SCSITRANSPORT = 18,
36  WS_NETLINK_ECRYPTFS = 19,
37  WS_NETLINK_RDMA = 20,
38  WS_NETLINK_CRYPTO = 21
39 };
40 
41 /* from <linux/netlink.h> prefixed with WS_ */
42 enum {
43  WS_NLM_F_REQUEST = 1, /* It is request message.*/
44  WS_NLM_F_MULTI = 2, /* Multipart message, terminated by NETLINK_MSG_DONE */
45  WS_NLM_F_ACK = 4, /* Reply with ack, with zero or error code */
46  WS_NLM_F_ECHO = 8, /* Echo this request */
47  WS_NLM_F_DUMP_INTR = 16, /* Dump was inconsistent due to sequence change */
48  WS_NLM_F_DUMP_FILTERED = 32, /* Dump was filtered as requested */
49 
50  /* Modifiers to Get request */
51  WS_NLM_F_ROOT = 0x100, /* specify tree root */
52  WS_NLM_F_MATCH = 0x200, /* return all matching */
53  WS_NLM_F_ATOMIC = 0x400, /* return an atomic snapshot of the table */
54 
55  /* Modifiers to NEW request */
56  WS_NLM_F_REPLACE = 0x100, /* Override existing */
57  WS_NLM_F_EXCL = 0x200, /* Do not touch, if it exists */
58  WS_NLM_F_CREATE = 0x400, /* Create, if it does */
59  WS_NLM_F_APPEND = 0x800 /* Add to end of list */
60 };
61 
62 
63 extern value_string_ext netlink_family_vals_ext;
64 
65 enum {
66  WS_NLMSG_NOOP = 0x01,
67  WS_NLMSG_ERROR = 0x02,
68  WS_NLMSG_DONE = 0x03,
69  WS_NLMSG_OVERRUN = 0x04,
70  WS_NLMSG_MIN_TYPE = 0x10
71 };
72 
73 /* from <linux/netfilter.h>. Looks like AF_xxx, except for NFPROTO_ARP */
74 enum ws_nfproto {
75  WS_NFPROTO_UNSPEC = 0,
76  WS_NFPROTO_INET = 1,
77  WS_NFPROTO_IPV4 = 2,
78  WS_NFPROTO_ARP = 3,
79  WS_NFPROTO_NETDEV = 5,
80  WS_NFPROTO_BRIDGE = 7,
81  WS_NFPROTO_IPV6 = 10,
82  WS_NFPROTO_DECNET = 12,
83 };
84 extern const value_string nfproto_family_vals[];
85 extern const value_string netfilter_hooks_vals[];
86 
87 #define PACKET_NETLINK_MAGIC 0x4A5ACCCE
88 
90  guint32 magic; /* PACKET_NETLINK_MAGIC */
91 
92  int encoding;
93  guint16 type;
94 };
95 
100 int dissect_netlink_header(tvbuff_t *tvb, proto_tree *tree, int offset, int encoding, header_field_info *hfi_type, proto_item **pi_type);
101 
102 typedef int netlink_attributes_cb_t(tvbuff_t *, void *data, proto_tree *, int nla_type, int offset, int len);
103 
104 int 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);
105 
106 /*
107  * Similar to dissect_netlink_attributes, but used to parse nested attributes
108  * that model an array of attributes. The first level (tree ett_array) contains
109  * array elements and its type field is the array index. The next level (tree
110  * ett_attrib) contains attributes (where hfi_type applies).
111  */
112 int 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);
113 
114 #define NLA_F_NESTED 0x8000
115 #define NLA_F_NET_BYTEORDER 0x4000
116 #define NLA_TYPE_MASK 0x3fff
117 
118 
119 /*
120  * Format of the data that is passed to "genl.family" dissectors.
121  */
122 typedef struct {
123  struct packet_netlink_data *data;
124  int encoding; /* copy of data->encoding */
125 
126  /* For internal use by genl. */
127  proto_tree *genl_tree;
128 
129  /* fields from genlmsghdr */
130  guint8 cmd; /* Command number */
131 } genl_info_t;
132 
133 int dissect_genl_header(tvbuff_t *tvb, genl_info_t *genl_info, header_field_info *hfi_cmd);
134 
135 #endif /* __PACKET_NETLINK_H__ */
Definition: proto.h:622
Definition: packet-netlink.h:122
Definition: tvbuff-int.h:35
Definition: value_string.h:24
Definition: value_string.h:164
Definition: proto.h:759