diff options
author | Martin Kaiser <wireshark@kaiser.cx> | 2018-05-21 18:45:44 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-05-23 13:18:00 +0000 |
commit | 675e0649c04d1c55ea570c6f5c9efb90a0f81e6e (patch) | |
tree | 56d80eb9d780a6374a399cdcc34809afa2415f16 /wsutil | |
parent | 1d2b0d91e3d90062367052c4ac9753a6b78e0fcd (diff) |
make our version of nla_for_each_nested() public
caputils/ws80211_utils.c contains a re-definition of the linux kernel's
nla_for_each_nested() macro that applies the correct casts to allow
compilation with a C++ compiler.
Make this definition public by moving it into a new wsutil/netlink.h
file. Include the kernel's original definition before we overwrite it. This
way, it's not necessary for a .c file to include wsutil/netlink.h after
the system includes.
Use our nla_for_each_nested() version in extcap/dpauxmon.c to squelch the
following compiler warning:
[1664/2251] Building C object
extcap/CMakeFiles/dpauxmon.dir/dpauxmon.c.o
../extcap/dpauxmon.c: In function ‘family_handler’:
../extcap/dpauxmon.c:168:13: warning: request for implicit conversion
from ‘void *’ to ‘struct nlattr *’ not permitted in C++ [-Wc++-compat]
nla_for_each_nested(mcgrp, tb[CTRL_ATTR_MCAST_GROUPS], rem_mcgrp) {
Change-Id: I6ba40ef6343c5d168c1b0c4554f13202911ded76
Reviewed-on: https://code.wireshark.org/review/27688
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/CMakeLists.txt | 1 | ||||
-rw-r--r-- | wsutil/netlink.h | 66 |
2 files changed, 67 insertions, 0 deletions
diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index 0974866756..1980641fcd 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -45,6 +45,7 @@ set(WSUTIL_PUBLIC_HEADERS interface.h jsmn.h mpeg-audio.h + netlink.h nstime.h os_version_info.h pint.h diff --git a/wsutil/netlink.h b/wsutil/netlink.h new file mode 100644 index 0000000000..e9d32968e2 --- /dev/null +++ b/wsutil/netlink.h @@ -0,0 +1,66 @@ +/* netlink.h + * netlink-related definitions shared between libwireshark and other parts + * + * Copyright 2018, Martin Kaiser + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _WS_NETLINK_H +#define _WS_NETLINK_H + +#include "config.h" + +#if defined(HAVE_LIBNL) + +/* + * Pull in the include files where the kernel's nla_for_each_nested is defined. + * This is to make sure that the kernel's definition will not overwrite our + * version if msg.h or attr.h are included again explicitly after this file. + */ +DIAG_OFF_PEDANTIC +#include <netlink/msg.h> +DIAG_ON_PEDANTIC +#include <netlink/attr.h> + +/* + * And now for a steaming heap of suck. + * + * The nla_for_each_nested() macro defined by at least some versions of the + * Linux kernel's headers doesn't do the casting required when compiling + * with a C++ compiler or with -Wc++-compat, so we get warnings, and those + * warnings are fatal when we compile this file. + * + * So we replace it with our own version, which does the requisite cast. + */ + +/** + * nla_for_each_nested - iterate over nested attributes + * @pos: loop counter, set to current attribute + * @nla: attribute containing the nested attributes + * @rem: initialized to len, holds bytes currently remaining in stream + */ +#undef nla_for_each_nested +#define nla_for_each_nested(pos, nla, rem) \ + nla_for_each_attr(pos, (struct nlattr *)nla_data(nla), nla_len(nla), rem) + +#endif /* HAVE_LIBNL */ + +#endif /* _WS_NETLINK_H */ + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ |