summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:34:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:34:10 +0000
commite4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc (patch)
tree68cb5ef9081156392f1dd62a00c6ccc1451b93df /include
parentInitial commit. (diff)
downloadwireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.tar.xz
wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.zip
Adding upstream version 4.2.2.upstream/4.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include')
-rw-r--r--include/wireshark.h69
-rw-r--r--include/ws_attributes.h133
-rw-r--r--include/ws_codepoints.h24
-rw-r--r--include/ws_compiler_tests.h152
-rw-r--r--include/ws_diag_control.h288
-rw-r--r--include/ws_exit_codes.h30
-rw-r--r--include/ws_log_defs.h85
-rw-r--r--include/ws_posix_compat.h27
-rw-r--r--include/ws_symbol_export.h217
9 files changed, 1025 insertions, 0 deletions
diff --git a/include/wireshark.h b/include/wireshark.h
new file mode 100644
index 00000000..f7c19c23
--- /dev/null
+++ b/include/wireshark.h
@@ -0,0 +1,69 @@
+/* wireshark.h
+ * Global public header with minimally available wireshark API
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __WIRESHARK_H__
+#define __WIRESHARK_H__
+
+/*
+ * This header can be included in any file, header or source, public or private.
+ * It is strongly recommended to be always included to provide macros that are
+ * required for the project and a consistent minimum set of interfaces that are
+ * always guaranteed to be available. There is no need to include <glib.h>
+ * directly, this header should replace it.
+ *
+ * Other public headers provided here should be minimal, with stable interfaces
+ * and have only global declarations.
+ *
+ * Everytime this header changes everything must be rebuilt so consider carefully
+ * if the other project headers included here should really have global scope.
+ *
+ * See README.developer for a more in-depth guide.
+ */
+
+/* System headers.*/
+#include <inttypes.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include <glib.h>
+
+/*
+ * Project headers and definitions.
+ *
+ * Only public headers and symbols can be included here. Nothing related
+ * with configuration.
+ */
+#include <ws_version.h>
+
+#include <ws_attributes.h>
+#include <ws_compiler_tests.h>
+#include <ws_diag_control.h>
+#include <ws_posix_compat.h>
+#include <ws_symbol_export.h>
+
+#include <wsutil/ws_assert.h>
+#include <wsutil/wslog.h>
+#include <wsutil/glib-compat.h>
+#include <wsutil/wmem/wmem.h>
+
+#endif /* __WIRESHARK_H__ */
+
+/*
+ * Editor modelines - https://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:
+ */
diff --git a/include/ws_attributes.h b/include/ws_attributes.h
new file mode 100644
index 00000000..d004280e
--- /dev/null
+++ b/include/ws_attributes.h
@@ -0,0 +1,133 @@
+/* ws_attributes.h
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __WS_ATTRIBUTES_H__
+#define __WS_ATTRIBUTES_H__
+
+#include "ws_compiler_tests.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*
+ * If we're running GCC or clang define _U_ to be "__attribute__((unused))"
+ * so we can use _U_ to flag unused function parameters and not get warnings
+ * about them. Otherwise, define _U_ to be an empty string so that _U_ used
+ * to flag an unused function parameters will compile with other compilers.
+ *
+ * XXX - similar hints for other compilers?
+ */
+#if defined(__GNUC__)
+ /* This includes clang */
+ #define _U_ __attribute__((unused))
+#elif defined(_MSC_VER)
+ #define _U_ __pragma(warning(suppress:4100 4189))
+#else
+ #define _U_
+#endif
+
+/*
+ * WS_NORETURN, before a function declaration, means "this function
+ * never returns". (It must go before the function declaration, e.g.
+ * "extern WS_NORETURN func(...)" rather than after the function
+ * declaration, as the MSVC version has to go before the declaration.)
+ */
+#ifndef __cplusplus
+ #define WS_NORETURN _Noreturn
+#else /* __cplusplus */
+#if __has_attribute(noreturn) \
+ || WS_IS_AT_LEAST_GNUC_VERSION(2,5) \
+ || WS_IS_AT_LEAST_SUNC_VERSION(5,9) \
+ || WS_IS_AT_LEAST_XL_C_VERSION(10,1) \
+ || WS_IS_AT_LEAST_HP_C_VERSION(6,10)
+ /*
+ * Compiler with support for __attribute__((noreturn)), or GCC 2.5 and
+ * later, or Solaris Studio 12 (Sun C 5.9) and later, or IBM XL C 10.1
+ * and later (do any earlier versions of XL C support this?), or
+ * HP aCC A.06.10 and later.
+ */
+ #define WS_NORETURN __attribute__((noreturn))
+#elif defined(_MSC_VER)
+ /*
+ * MSVC.
+ */
+ #define WS_NORETURN __declspec(noreturn)
+#else
+ #define WS_NORETURN
+#endif
+#endif /* __cplusplus */
+
+/*
+ * WS_RETNONNULL, before a function declaration, means "this function
+ * always returns a non-null pointer".
+ */
+#if __has_attribute(returns_nonnull) \
+ || WS_IS_AT_LEAST_GNUC_VERSION(4,9)
+ #define WS_RETNONNULL __attribute__((returns_nonnull))
+#else
+ #define WS_RETNONNULL
+#endif
+
+/*
+ * WS_DEPRECATED, before a function declaration, means "this function
+ * should not be used anymore and will be removed in a future version".
+ * WS_DEPRECATED_X() optionally takes a message saying what should be done
+ * instead (strongly recommended).
+ *
+ * This is not implemented on purpose with MSVC because that compiler has no
+ * equivalent to -Wno-error=deprecated-declarations, making it impossible
+ * to build with -Werror and deprecated declarations. The Microsoft developer
+ * team seems to not understand the requirement.
+ * https://developercommunity.visualstudio.com/t/cant-treat-deprecated-warning-as-warning-with-wx/786502
+ * https://developercommunity.visualstudio.com/t/impossible-to-treat-warning-as-error-except-specif/473936
+ */
+#if __has_attribute(deprecated)
+ #define WS_DEPRECATED __attribute__((deprecated))
+ #define WS_DEPRECATED_X(msg) __attribute__((deprecated(msg)))
+#else
+ #define WS_DEPRECATED
+ #define WS_DEPRECATED_X(msg)
+#endif
+
+/*
+ * WS_THREAD_LOCAL means "this variable should go in thread-local
+ * storage.
+ *
+ * Based on
+ *
+ * https://en.wikipedia.org/w/index.php?title=Thread-local_storage&oldid=1064900318#C_and_C++
+ *
+ * the major UN*X C compilers support __thread and the major Windows C
+ * compilers support __declspec(thread).
+ */
+#ifdef _MSC_VER
+ #define WS_THREAD_LOCAL __declspec(thread)
+#else
+ #define WS_THREAD_LOCAL __thread
+#endif
+
+/*
+ * The warn_unused_result attribute causes a warning to be emitted if a caller
+ * of the function with this attribute does not use its return value. This is
+ * useful for functions where not checking the result is either a security
+ * problem or always a bug, such as realloc.
+ */
+#if defined(__GNUC__)
+ /* This includes clang */
+ #define WS_WARN_UNUSED __attribute__((warn_unused_result))
+#else
+ #define WS_WARN_UNUSED
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __WS_ATTRIBUTES_H__ */
diff --git a/include/ws_codepoints.h b/include/ws_codepoints.h
new file mode 100644
index 00000000..338cef5a
--- /dev/null
+++ b/include/ws_codepoints.h
@@ -0,0 +1,24 @@
+/* ws_codepoints.h
+ * Unicode code point definitions
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 2006 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __WS_CODEPOINTS_H__
+#define __WS_CODEPOINTS_H__
+
+/**
+ * @file
+ * Unicode code points.
+ *
+ * (See chapter 2 of the Unicode standard for an explanation of what
+ * "characters" and "code points" are.)
+ */
+
+#define UNICODE_REPLACEMENT_CHARACTER 0x00FFFD
+
+#endif /* __WS_CODEPOINTS_H__ */
diff --git a/include/ws_compiler_tests.h b/include/ws_compiler_tests.h
new file mode 100644
index 00000000..88dae61f
--- /dev/null
+++ b/include/ws_compiler_tests.h
@@ -0,0 +1,152 @@
+/* ws_compiler_tests.h
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __WS_COMPILER_TESTS_H__
+#define __WS_COMPILER_TESTS_H__
+
+/*
+ * This was introduced by Clang:
+ *
+ * http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
+ *
+ * in some version (which version?); it has been picked up by GCC 5.0.
+ */
+#ifndef __has_attribute
+ /*
+ * It's a macro, so you can check whether it's defined to check
+ * whether it's supported.
+ *
+ * If it's not, define it to always return 0, so that we move on to
+ * the fallback checks.
+ */
+ #define __has_attribute(x) 0
+#endif
+
+/*
+ * Note that the C90 spec's "6.8.1 Conditional inclusion" and the
+ * C99 spec's and C11 spec's "6.10.1 Conditional inclusion" say:
+ *
+ * Prior to evaluation, macro invocations in the list of preprocessing
+ * tokens that will become the controlling constant expression are
+ * replaced (except for those macro names modified by the defined unary
+ * operator), just as in normal text. If the token "defined" is
+ * generated as a result of this replacement process or use of the
+ * "defined" unary operator does not match one of the two specified
+ * forms prior to macro replacement, the behavior is undefined.
+ *
+ * so you shouldn't use defined() in a #define that's used in #if or
+ * #elif. Some versions of Clang, for example, will warn about this.
+ *
+ * Instead, we check whether the pre-defined macros for particular
+ * compilers are defined and, if not, define the "is this version XXX
+ * or a later version of this compiler" macros as 0.
+ */
+
+/*
+ * Check whether this is GCC major.minor or a later release, or some
+ * compiler that claims to be "just like GCC" of that version or a
+ * later release.
+ */
+
+#if !defined(__GNUC__)
+ #define WS_IS_AT_LEAST_GNUC_VERSION(major, minor) 0
+#else
+ #define WS_IS_AT_LEAST_GNUC_VERSION(major, minor) \
+ (__GNUC__ > (major) || \
+ (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
+#endif
+
+/*
+ * Check if the compiler is GCC and not a compiler from another
+ * vendor that also defines __GNUC__ (claiming support for GNU C dialect).
+ * Unfortunately there is no way to test this directly so we need
+ * to exclude other known compilers that claim such support (hacky).
+ */
+#if defined(__GNUC__) && \
+ !defined(__clang__) && \
+ !defined(__INTEL_COMPILER) && \
+ !defined(__INTEL_LLVM_COMPILER)
+ #define WS_GCC_VERSION \
+ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL)
+#endif
+
+/*
+ * Check whether this is Clang major.minor or a later release.
+ */
+
+#if !defined(__clang__)
+ #define WS_IS_AT_LEAST_CLANG_VERSION(major, minor) 0
+#else
+ #define WS_IS_AT_LEAST_CLANG_VERSION(major, minor) \
+ (__clang_major__ > (major) || \
+ (__clang_major__ == (major) && __clang_minor__ >= (minor)))
+#endif
+
+/*
+ * Check whether this is Sun C/SunPro C/Oracle Studio major.minor
+ * or a later release.
+ *
+ * The version number in __SUNPRO_C is encoded in hex BCD, with the
+ * uppermost hex digit being the major version number, the next
+ * one or two hex digits being the minor version number, and
+ * the last digit being the patch version.
+ *
+ * It represents the *compiler* version, not the product version;
+ * see
+ *
+ * https://sourceforge.net/p/predef/wiki/Compilers/
+ *
+ * for a partial mapping, which we assume continues for later
+ * 12.x product releases.
+ */
+
+#if !defined(__SUNPRO_C)
+ #define WS_IS_AT_LEAST_SUNC_VERSION(major, minor) 0
+#else
+ #define WS_SUNPRO_VERSION_TO_BCD(major, minor) \
+ (((minor) >= 10) ? \
+ (((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \
+ (((major) << 8) | ((minor) << 4)))
+ #define WS_IS_AT_LEAST_SUNC_VERSION(major, minor) \
+ (__SUNPRO_C >= WS_SUNPRO_VERSION_TO_BCD((major), (minor)))
+#endif
+
+/*
+ * Check whether this is IBM XL C major.minor or a later release.
+ *
+ * The version number in __xlC__ has the major version in the
+ * upper 8 bits and the minor version in the lower 8 bits.
+ */
+
+#if !defined(__xlC__)
+ #define WS_IS_AT_LEAST_XL_C_VERSION(major, minor) 0
+#else
+ #define WS_IS_AT_LEAST_XL_C_VERSION(major, minor) \
+ (__xlC__ >= (((major) << 8) | (minor)))
+#endif
+
+/*
+ * Check whether this is HP aC++/HP C major.minor or a later release.
+ *
+ * The version number in __HP_aCC is encoded in zero-padded decimal BCD,
+ * with the "A." stripped off, the uppermost two decimal digits being
+ * the major version number, the next two decimal digits being the minor
+ * version number, and the last two decimal digits being the patch version.
+ * (Strip off the A., remove the . between the major and minor version
+ * number, and add two digits of patch.)
+ */
+
+#if !defined(__HP_aCC)
+ #define WS_IS_AT_LEAST_HP_C_VERSION(major, minor) 0
+#else
+ #define WS_IS_AT_LEAST_HP_C_VERSION(major, minor) \
+ (__HP_aCC >= ((major)*10000 + (minor)*100))
+#endif
+
+#endif /* __WS_COMPILER_TESTS_H__ */
diff --git a/include/ws_diag_control.h b/include/ws_diag_control.h
new file mode 100644
index 00000000..4764450b
--- /dev/null
+++ b/include/ws_diag_control.h
@@ -0,0 +1,288 @@
+/* ws_diag_control.h
+ * Turn compiler diagnostic messages on and off.
+ *
+ * From FreeRADIUS build.h.
+ *
+ * @copyright 2013 The FreeRADIUS server project
+ *
+ * That project is covered by the GPLv2, so:
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __WS_DIAG_CONTROL_H__
+#define __WS_DIAG_CONTROL_H__
+
+#include "ws_compiler_tests.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define XSTRINGIFY(x) #x
+
+/*
+ * Macros for controlling warnings in various compilers.
+ */
+#define DIAG_JOINSTR(x,y) XSTRINGIFY(x ## y)
+
+/*
+ * XXX - this is only for GCC or GCC-compatible compilers, and we only use
+ * it to have a macro that takes a warning as an argument and turns it
+ * off in the appropriate fashion for Clang and GCC; it should only be
+ * used internally in this header.
+ */
+#define DIAG_DO_PRAGMA(x) _Pragma (#x)
+
+#if defined(__clang__)
+ /*
+ * Clang, so we'd use _Pragma("clang diagnostic XXX"), if it's
+ * supported.
+ */
+ #if WS_IS_AT_LEAST_CLANG_VERSION(2,8)
+ /*
+ * This is Clang 2.8 or later: we can use "clang diagnostic ignored -Wxxx"
+ * and "clang diagnostic push/pop".
+ */
+ #define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(clang diagnostic x)
+ #define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
+ #define DIAG_WARN(x) DIAG_PRAGMA(push) DIAG_PRAGMA(warning DIAG_JOINSTR(-W,x))
+ #define DIAG_ON(x) DIAG_PRAGMA(pop)
+ #endif
+
+ /*
+ * Not all versions of Clang understand -Wpedantic. Clang 4.0 appears
+ * to be the first version to do so.
+ */
+ #if WS_IS_AT_LEAST_CLANG_VERSION(4,0)
+ #define DIAG_OFF_PEDANTIC DIAG_OFF(pedantic)
+ #define DIAG_ON_PEDANTIC DIAG_ON(pedantic)
+ #else
+ #define DIAG_OFF_PEDANTIC
+ #define DIAG_ON_PEDANTIC
+ #endif
+
+ /*
+ * Do any pre-5.0 versions of Clang understand -Winitializer-overrides?
+ */
+ #if WS_IS_AT_LEAST_CLANG_VERSION(4,0)
+ #define DIAG_OFF_INIT_TWICE DIAG_OFF(initializer-overrides)
+ #define DIAG_ON_INIT_TWICE DIAG_ON(initializer-overrides)
+ #else
+ #define DIAG_OFF_INIT_TWICE
+ #define DIAG_ON_INIT_TWICE
+ #endif
+#elif defined(__GNUC__)
+ /*
+ * GCC, or a compiler (other than Clang) that claims to be GCC.
+ * We assume that the compiler accepts _Pragma("GCC diagnostic xxx")
+ * even if it's only claiming to be GCC.
+ */
+ #if WS_IS_AT_LEAST_GNUC_VERSION(4,8)
+ /*
+ * This is GCC 4.8 or later, or a compiler claiming to be that.
+ * We can use "GCC diagnostic ignored -Wxxx" (introduced in 4.2)
+ * and "GCC diagnostic push/pop" (introduced in 4.6), *and* gcc
+ * supports "-Wpedantic" (introduced in 4.8), allowing us to
+ * turn off pedantic warnings with DIAG_OFF().
+ */
+ #define DIAG_PRAGMA(x) DIAG_DO_PRAGMA(GCC diagnostic x)
+ #define DIAG_OFF(x) DIAG_PRAGMA(push) DIAG_PRAGMA(ignored DIAG_JOINSTR(-W,x))
+ #define DIAG_WARN(x) DIAG_PRAGMA(push) DIAG_PRAGMA(warning DIAG_JOINSTR(-W,x))
+ #define DIAG_ON(x) DIAG_PRAGMA(pop)
+
+ /*
+ * We assume GCC 4.8 and later understand -Wpedantic.
+ */
+ #define DIAG_OFF_PEDANTIC DIAG_OFF(pedantic)
+ #define DIAG_ON_PEDANTIC DIAG_ON(pedantic)
+
+ /*
+ * GCC 4.2 and later understand -Woverride-init.
+ */
+ #define DIAG_OFF_INIT_TWICE DIAG_OFF(override-init)
+ #define DIAG_ON_INIT_TWICE DIAG_ON(override-init)
+ #else
+ #define DIAG_OFF_PEDANTIC
+ #define DIAG_ON_PEDANTIC
+
+ #define DIAG_OFF_INIT_TWICE
+ #define DIAG_ON_INIT_TWICE
+ #endif
+#endif
+
+#ifndef DIAG_OFF
+ /*
+ * This is none of the above; we don't have any way to turn diagnostics
+ * on or off.
+ *
+ * XXX - you can do that in MSVC, but it's done differently; we'd
+ * have to have macros for *particular* diagnostics, using the
+ * warning flag for GCC and Clang and the error number for MSVC.
+ */
+ #define DIAG_OFF(x)
+ #define DIAG_WARN(x)
+ #define DIAG_ON(x)
+ #define DIAG_OFF_PEDANTIC
+ #define DIAG_ON_PEDANTIC
+ #define DIAG_OFF_INIT_TWICE
+ #define DIAG_ON_INIT_TWICE
+#endif
+
+/* Use for clang specific pragmas, so we can keep -Wpragmas enabled */
+#ifdef __clang__
+# define DIAG_OFF_CLANG(x) DIAG_OFF(x)
+# define DIAG_WARN_CLANG(x) DIAG_WARN(x)
+# define DIAG_ON_CLANG(x) DIAG_ON(x)
+#else
+# define DIAG_OFF_CLANG(x)
+# define DIAG_ON_CLANG(x)
+#endif
+
+/*
+ * Suppress complaints about narrowing conversations and about signed vs.
+ * unsigned comparison.
+ *
+ * XXX - this is done solely to squelch complaints from code generated
+ * by Flex, but newer versions of Flex might fix the code; can we
+ * check the version of Flex and suppress only the checks that code
+ * generated by that version of Flex triggers?
+ */
+#if defined(_MSC_VER)
+ /*
+ * Suppress:
+ *
+ * warning C4018: signed/unsigned mismatch
+ * warning C4244: 'initializing' : conversion from '__int64' to 'int', possible loss of data
+ * warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
+ *
+ * as well as Visual Studio Code Analyzer warnings:
+ *
+ * warning C6011: Dereferencing NULL pointer
+ * warning C6308: 'realloc' might return null pointer
+ * warning C6386: Buffer overrun
+ * warning C6387: 'XXX' could be '0'
+ * warning C28182: Dereferencing NULL pointer
+ */
+ #define DIAG_OFF_FLEX() \
+ __pragma(warning(push)) \
+ __pragma(warning(disable:4018)) \
+ __pragma(warning(disable:4244)) \
+ __pragma(warning(disable:4267)) \
+ __pragma(warning(disable:6011)) \
+ __pragma(warning(disable:6308)) \
+ __pragma(warning(disable:6386)) \
+ __pragma(warning(disable:6387)) \
+ __pragma(warning(disable:28182))
+ #define DIAG_ON_FLEX() \
+ __pragma(warning(pop))
+#else
+ /*
+ * Suppress:
+ *
+ * -Wsigned-compare warnings
+ * -Wshorten-64-to-32 warnings, if the compiler *has* -Wshorten-64-to-32
+ * -Wunreachable-code warnings
+ * The version of Flex in the macOS Intel build bots triggers documentation warnings.
+ * -Wdocumentation
+ *
+ * We use DIAG_OFF() and DIAG_ON(), so we only use features that the
+ * compiler supports.
+ *
+ * We disable -Wshorten-64-to-32 if we're using Clang, or if __APPLE__
+ * is defined; that option was originally added to an Apple version of
+ * GCC, and at least some versions of Clang support it - given that
+ * the Clang work started at Apple, it may be in all versions of Clang.
+ *
+ * (Does no version of GCC or Clang support the same generic "you're
+ * narrowing a value, and you didn't throw in a cast to assert that
+ * you know what you're doing" warning that MSVC does?)
+ */
+ #if defined(__clang__) || defined(__APPLE__)
+ #define DIAG_OFF_FLEX() \
+ DIAG_OFF(sign-compare) \
+ DIAG_OFF(unused-parameter) \
+ DIAG_OFF(shorten-64-to-32) \
+ DIAG_OFF(unreachable-code) \
+ DIAG_OFF(documentation)
+ #define DIAG_ON_FLEX() \
+ DIAG_ON(documentation) \
+ DIAG_ON(unreachable-code) \
+ DIAG_ON(shorten-64-to-32) \
+ DIAG_ON(unused-parameter) \
+ DIAG_ON(sign-compare)
+ #else
+ #define DIAG_OFF_FLEX() \
+ DIAG_OFF(sign-compare) \
+ DIAG_OFF(unused-parameter)
+ #define DIAG_ON_FLEX() \
+ DIAG_ON(unused-parameter) \
+ DIAG_ON(sign-compare)
+ #endif
+#endif
+
+/* Disable Lemon warnings. */
+#if defined(_MSC_VER)
+ #define DIAG_OFF_LEMON()
+ #define DIAG_ON_LEMON()
+#else
+ #define DIAG_OFF_LEMON() \
+ DIAG_OFF_CLANG(unreachable-code)
+ #define DIAG_ON_LEMON() \
+ DIAG_ON_CLANG(unreachable-code)
+#endif
+
+/*
+ * Suppress warnings about casting away constness.
+ * Do this only if you know that the pointer is to something that can
+ * be written and, in this context, should be writable.
+ */
+#if defined(__GNUC__) || defined(__clang__)
+ /*
+ * GCC or a compiler that claims to be GCC-compatible.
+ * We throw in Clang just in case clang-cl doesn't define
+ * __GNUC__; if it does, __GNUC__ should suffice.
+ */
+ #define DIAG_OFF_CAST_AWAY_CONST DIAG_OFF(cast-qual)
+ #define DIAG_ON_CAST_AWAY_CONST DIAG_OFF(cast-qual)
+#elif defined(_MSC_VER)
+ #define DIAG_OFF_CAST_AWAY_CONST
+ #define DIAG_ON_CAST_AWAY_CONST
+#else
+ #define DIAG_OFF_CAST_AWAY_CONST
+ #define DIAG_ON_CAST_AWAY_CONST
+#endif
+
+/*
+ * This warning is only supported by GCC since version 7.1 (and not
+ * Clang or other compilers that claim GNU C support).
+ */
+#if WS_GCC_VERSION >= 70100
+ #define DIAG_OFF_STRINGOP_OVERFLOW() DIAG_OFF(stringop-overflow=)
+ #define DIAG_ON_STRINGOP_OVERFLOW() DIAG_ON(stringop-overflow=)
+#else
+ #define DIAG_OFF_STRINGOP_OVERFLOW()
+ #define DIAG_ON_STRINGOP_OVERFLOW()
+#endif
+
+/*
+ * For dealing with APIs which are only deprecated in macOS (like the
+ * OpenSSL and MIT/Heimdal Kerberos APIs).
+ *
+ * Dear Apple: this is a cross-platform program, and we're not
+ * going to use your Shiny New Frameworks on macOS unless there's
+ * a sufficiently clear benefit to make it worth our while to have
+ * both macOS and non-macOS versions of the code.
+ */
+#ifdef __APPLE__
+# define USES_APPLE_DEPRECATED_API DIAG_OFF(deprecated-declarations)
+# define USES_APPLE_RST DIAG_ON(deprecated-declarations)
+#else
+# define USES_APPLE_DEPRECATED_API
+# define USES_APPLE_RST
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __WS_DIAG_CONTROL_H__ */
diff --git a/include/ws_exit_codes.h b/include/ws_exit_codes.h
new file mode 100644
index 00000000..5a5f5a2b
--- /dev/null
+++ b/include/ws_exit_codes.h
@@ -0,0 +1,30 @@
+/** @file
+ *
+ * Definition of exit codes for programs.
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __WS_EXIT_CODES_H__
+#define __WS_EXIT_CODES_H__
+
+/* Exit codes */
+#define WS_EXIT_INVALID_OPTION 1
+#define WS_EXIT_INVALID_INTERFACE 2
+#define WS_EXIT_INVALID_FILE 3
+#define WS_EXIT_INVALID_FILTER 4
+#define WS_EXIT_INVALID_CAPABILITY 5
+#define WS_EXIT_IFACE_HAS_NO_LINK_TYPES 6
+#define WS_EXIT_IFACE_HAS_NO_TIMESTAMP_TYPES 7
+#define WS_EXIT_INIT_FAILED 8
+#define WS_EXIT_OPEN_ERROR 9
+#define WS_EXIT_PCAP_NOT_SUPPORTED 10
+#define WS_EXIT_DUMPCAP_NOT_SUPPORTED 11
+#define WS_EXIT_NO_INTERFACES 12
+#define WS_EXIT_PCAP_ERROR 13
+
+#endif /* __WS_EXIT_CODES_H__ */
diff --git a/include/ws_log_defs.h b/include/ws_log_defs.h
new file mode 100644
index 00000000..df2f774f
--- /dev/null
+++ b/include/ws_log_defs.h
@@ -0,0 +1,85 @@
+/* ws_log_defs.h
+ * log domain definitions
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __WS_LOG_DOMAINS_H__
+#define __WS_LOG_DOMAINS_H__
+
+/*
+ * Which log domain to use is a matter of policy. Any string is valid.
+ * There are no hard rules but using a pre-defined log domain is a good
+ * rule of thumb (there is no pre-defined domain below for dissectors
+ * though).
+ */
+
+/* Main execution domain (wireshark, tshark, etc) */
+#define LOG_DOMAIN_MAIN "Main"
+
+/* Capture domain (except for capture child, see below) */
+#define LOG_DOMAIN_CAPTURE "Capture"
+
+/* Capture child domain (the capture child might also contain
+ * file domain messages!) */
+#define LOG_DOMAIN_CAPCHILD "Capchild"
+
+#define LOG_DOMAIN_WIRETAP "Wiretap"
+
+#define LOG_DOMAIN_EPAN "Epan"
+
+#define LOG_DOMAIN_DFILTER "DFilter"
+
+#define LOG_DOMAIN_WSUTIL "WSUtil"
+
+#define LOG_DOMAIN_QTUI "GUI"
+
+#define LOG_DOMAIN_UAT "UAT"
+
+#define LOG_DOMAIN_EXTCAP "Extcap"
+
+#define LOG_DOMAIN_UTF_8 "UTF-8"
+
+#define LOG_DOMAIN_MMDB "MaxMindDB"
+
+#define LOG_DOMAIN_EINVAL "InvalidArg"
+
+#define LOG_DOMAIN_PLUGINS "Plugins"
+
+#define LOG_DOMAIN_WSLUA "Lua"
+
+/*
+ * Ascending order by priority needs to be maintained. Higher priorities have
+ * higher values.
+ */
+enum ws_log_level {
+ LOG_LEVEL_NONE, /* not user facing */
+ LOG_LEVEL_NOISY, /* extra verbose debugging */
+ LOG_LEVEL_DEBUG, /* normal debugging level */
+ LOG_LEVEL_INFO, /* chatty status but not debug */
+ LOG_LEVEL_MESSAGE, /* default level, doesn't show file/function name */
+ LOG_LEVEL_WARNING, /* can be set to fatal */
+ LOG_LEVEL_CRITICAL, /* always enabled, can be set to fatal */
+ LOG_LEVEL_ERROR, /* "error" is always fatal (aborts) */
+ LOG_LEVEL_ECHO, /* Always print message, never fatal */
+ _LOG_LEVEL_LAST
+};
+
+#endif /* __WS_LOG_DOMAINS_H__ */
+
+/*
+ * Editor modelines - https://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:
+ */
diff --git a/include/ws_posix_compat.h b/include/ws_posix_compat.h
new file mode 100644
index 00000000..61cefc93
--- /dev/null
+++ b/include/ws_posix_compat.h
@@ -0,0 +1,27 @@
+/* ws_posix_compat.h
+ * Definitions for POSIX compatibility.
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __POSIX_COMPAT_H__
+#define __POSIX_COMPAT_H__
+
+#include <stdint.h>
+#include <limits.h>
+
+#if !defined(SSIZE_MAX) && !defined(HAVE_SSIZE_T)
+#if defined(_WIN32)
+#include <BaseTsd.h>
+
+typedef SSIZE_T ssize_t;
+#define SSIZE_MAX SSIZE_T_MAX
+
+#endif /* _WIN32 */
+#endif /* !SSIZE_MAX && !HAVE_SSIZE_T */
+
+#endif /* __POSIX_COMPAT_H__ */
diff --git a/include/ws_symbol_export.h b/include/ws_symbol_export.h
new file mode 100644
index 00000000..3de71a8a
--- /dev/null
+++ b/include/ws_symbol_export.h
@@ -0,0 +1,217 @@
+/** @file
+ * Cross platform defines for exporting symbols from shared libraries
+ *
+ * Wireshark - Network traffic analyzer
+ * By Balint Reczey <balint@balintreczey.hu>
+ * Copyright 2013 Balint Reczey
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "ws_compiler_tests.h"
+
+/** Reset symbol export behavior.
+ * If you {un}define WS_BUILD_DLL on the fly you'll have to define this
+ * as well.
+ */
+#ifdef RESET_SYMBOL_EXPORT
+
+#ifdef SYMBOL_EXPORT_H
+#undef SYMBOL_EXPORT_H
+#endif
+
+#ifdef WS_DLL_PUBLIC
+#undef WS_DLL_PUBLIC
+#endif
+
+#ifdef WS_DLL_PUBLIC_DEF
+#undef WS_DLL_PUBLIC_DEF
+#endif
+
+#ifdef WS_DLL_LOCAL
+#undef WS_DLL_LOCAL
+#endif
+
+#endif /* RESET_SYMBOL_EXPORT */
+
+#ifndef SYMBOL_EXPORT_H
+#define SYMBOL_EXPORT_H
+
+/*
+ * NOTE: G_HAVE_GNUC_VISIBILITY is defined only if all of
+ *
+ * __attribute__ ((visibility ("hidden")))
+ *
+ * __attribute__ ((visibility ("internal")))
+ *
+ * __attribute__ ((visibility ("protected")))
+ *
+ * __attribute__ ((visibility ("default")))
+ *
+ * are supported, and at least some versions of GCC from Apple support
+ * "default" and "hidden" but not "internal" or "protected", so it
+ * shouldn't be used to determine whether "hidden" or "default" is
+ * supported.
+ *
+ * This also means that we shouldn't use G_GNUC_INTERNAL instead of
+ * WS_DLL_LOCAL, as GLib uses G_HAVE_GNUC_VISIBILITY to determine
+ * whether to use __attribute__ ((visibility ("hidden"))) for
+ * G_GNUC_INTERNAL, and that will not use it even with compilers
+ * that support it.
+ */
+
+/* Originally copied from GCC Wiki at https://gcc.gnu.org/wiki/Visibility */
+#if defined _WIN32 || defined __CYGWIN__
+ /* Compiling for Windows, so we use the Windows DLL declarations. */
+ #ifdef WS_BUILD_DLL
+ /*
+ * Building a DLL; for all definitions, we want dllexport, and
+ * (presumably so source from DLL and source from a program using the
+ * DLL can both include a header that declares APIs and exported data
+ * for the DLL), for declarations, either dllexport or dllimport will
+ * work (they mean the same thing for a declaration when building a DLL).
+ */
+ #ifdef __GNUC__
+ /* GCC */
+ #define WS_DLL_PUBLIC_DEF __attribute__ ((dllexport))
+ #else /* ! __GNUC__ */
+ /*
+ * Presumably MSVC.
+ * Note: actually gcc seems to also support this syntax.
+ */
+ #define WS_DLL_PUBLIC_DEF __declspec(dllexport)
+ #endif /* __GNUC__ */
+ #else /* WS_BUILD_DLL */
+ /*
+ * Building a program; we should only see declarations, not definitions,
+ * with WS_DLL_PUBLIC, and they all represent APIs or data imported
+ * from a DLL, so use dllimport.
+ *
+ * For functions, export shouldn't be necessary; for data, it might
+ * be necessary, e.g. if what's declared is an array whose size is
+ * not given in the declaration.
+ */
+ #ifdef ENABLE_STATIC
+ /*
+ * We're building all-static, so we're not building any DLLs.
+ */
+ #define WS_DLL_PUBLIC_DEF
+ #elif defined(__GNUC__)
+ /* GCC */
+ #define WS_DLL_PUBLIC_DEF __attribute__ ((dllimport))
+ #else /* ! ENABLE_STATIC && ! __GNUC__ */
+ /*
+ * Presumably MSVC, and we're not building all-static.
+ * Note: actually gcc seems to also support this syntax.
+ */
+ #define WS_DLL_PUBLIC_DEF __declspec(dllimport)
+ #endif
+ #endif /* WS_BUILD_DLL */
+
+ /*
+ * Symbols in a DLL are *not* exported unless they're specifically
+ * flagged as exported, so, for a non-static but non-exported
+ * symbol, we don't have to do anything.
+ */
+ #define WS_DLL_LOCAL
+#else /* defined _WIN32 || defined __CYGWIN__ */
+ /*
+ * Compiling for UN*X, where the dllimport and dllexport stuff
+ * is neither necessary nor supported; just specify the
+ * visibility if we have a compiler that supports doing so.
+ */
+ #if WS_IS_AT_LEAST_GNUC_VERSION(3,4) \
+ || WS_IS_AT_LEAST_XL_C_VERSION(12,0)
+ /*
+ * GCC 3.4 or later, or some compiler asserting compatibility with
+ * GCC 3.4 or later, or XL C 13.0 or later, so we have
+ * __attribute__((visibility()).
+ */
+
+ /*
+ * Symbols exported from libraries.
+ */
+ #define WS_DLL_PUBLIC_DEF __attribute__ ((visibility ("default")))
+
+ /*
+ * Non-static symbols *not* exported from libraries.
+ */
+ #define WS_DLL_LOCAL __attribute__ ((visibility ("hidden")))
+ #elif WS_IS_AT_LEAST_SUNC_VERSION(5,5)
+ /*
+ * Sun C 5.5 or later, so we have __global and __hidden.
+ * (Sun C 5.9 and later also have __attribute__((visibility()),
+ * but there's no reason to prefer it with Sun C.)
+ */
+
+ /*
+ * Symbols exported from libraries.
+ */
+ #define WS_DLL_PUBLIC_DEF __global
+
+ /*
+ * Non-static symbols *not* exported from libraries.
+ */
+ #define WS_DLL_LOCAL __hidden
+ #else
+ /*
+ * We have neither a way to make stuff not explicitly marked as
+ * visible invisible outside a library nor a way to make stuff
+ * explicitly marked as local invisible outside the library.
+ */
+
+ /*
+ * Symbols exported from libraries.
+ */
+ #define WS_DLL_PUBLIC_DEF
+
+ /*
+ * Non-static symbols *not* exported from libraries.
+ */
+ #define WS_DLL_LOCAL
+ #endif
+#endif
+
+/*
+ * You *must* use this for exported data *declarations*; if you use
+ * WS_DLL_PUBLIC_DEF, some compilers, such as MSVC++, will complain
+ * about array definitions with no size.
+ *
+ * You must *not* use this for exported data *definitions*, as that
+ * will, for some compilers, cause warnings about items being initialized
+ * and declared extern.
+ *
+ * Either can be used for exported *function* declarations and definitions.
+ */
+#define WS_DLL_PUBLIC WS_DLL_PUBLIC_DEF extern
+
+/*
+ * This is necessary to export symbols from wsutil to another DLL
+ * (not an executable) using MSVC.
+ */
+#ifdef _MSC_VER
+# ifdef BUILD_WSUTIL
+# define WSUTIL_EXPORT __declspec(dllexport) extern
+# else
+# define WSUTIL_EXPORT __declspec(dllimport) extern
+# endif
+#else /* _MSC_VER */
+# define WSUTIL_EXPORT WS_DLL_PUBLIC
+#endif /* _MSC_VER */
+
+
+
+#endif /* SYMBOL_EXPORT_H */
+
+/*
+ * Editor modelines - https://www.wireshark.org/tools/modelines.html
+ *
+ * Local Variables:
+ * c-basic-offset: 2
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=2 tabstop=8 expandtab:
+ * :indentSize=2:tabSize=8:noTabs=true:
+ */