1 /* netlink.h
2  * netlink-related definitions shared between libwireshark and other parts
3  *
4  * Copyright 2018, Martin Kaiser
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * SPDX-License-Identifier: GPL-2.0-or-later
11  */
12 
13 #ifndef _WS_NETLINK_H
14 #define _WS_NETLINK_H
15 
16 #if defined(HAVE_LIBNL)
17 
18 /*
19  * Pull in the include files where the kernel's nla_for_each_nested is defined.
20  * This is to make sure that the kernel's definition will not overwrite our
21  * version if msg.h or attr.h are included again explicitly after this file.
22  */
23 DIAG_OFF_PEDANTIC
24 #include <netlink/msg.h>
25 DIAG_ON_PEDANTIC
26 #include <netlink/attr.h>
27 
28 /*
29  * And now for a steaming heap of suck.
30  *
31  * The nla_for_each_nested() macro defined by at least some versions of the
32  * Linux kernel's headers doesn't do the casting required when compiling
33  * with a C++ compiler or with -Wc++-compat, so we get warnings, and those
34  * warnings are fatal when we compile this file.
35  *
36  * So we replace it with our own version, which does the requisite cast.
37  */
38 
39 /**
40  * nla_for_each_nested - iterate over nested attributes
41  * @pos: loop counter, set to current attribute
42  * @nla: attribute containing the nested attributes
43  * @rem: initialized to len, holds bytes currently remaining in stream
44  */
45 #undef nla_for_each_nested
46 #define nla_for_each_nested(pos, nla, rem) \
47     nla_for_each_attr(pos, (struct nlattr *)nla_data(nla), nla_len(nla), rem)
48 
49 #endif /* HAVE_LIBNL */
50 
51 #endif /* _WS_NETLINK_H */
52 
53 /*
54  * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
55  *
56  * Local variables:
57  * c-basic-offset: 4
58  * tab-width: 8
59  * indent-tabs-mode: nil
60  * End:
61  *
62  * vi: set shiftwidth=4 tabstop=8 expandtab:
63  * :indentSize=4:tabSize=8:noTabs=true:
64  */
65