netkitty 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +2 -2
- package/.idea/inspectionProfiles/Project_Default.xml +2 -1
- package/.idea/netkitty.iml +0 -1
- package/cpp/nodepcap/deps/include/Packet32.h +429 -429
- package/cpp/nodepcap/deps/include/pcap/bluetooth.h +56 -56
- package/cpp/nodepcap/deps/include/pcap/bpf.h +292 -292
- package/cpp/nodepcap/deps/include/pcap/can_socketcan.h +56 -56
- package/cpp/nodepcap/deps/include/pcap/compiler-tests.h +163 -163
- package/cpp/nodepcap/deps/include/pcap/dlt.h +1514 -1514
- package/cpp/nodepcap/deps/include/pcap/funcattrs.h +325 -325
- package/cpp/nodepcap/deps/include/pcap/ipnet.h +43 -43
- package/cpp/nodepcap/deps/include/pcap/namedb.h +84 -84
- package/cpp/nodepcap/deps/include/pcap/nflog.h +94 -94
- package/cpp/nodepcap/deps/include/pcap/pcap-inttypes.h +101 -101
- package/cpp/nodepcap/deps/include/pcap/pcap.h +1219 -1219
- package/cpp/nodepcap/deps/include/pcap/sll.h +149 -149
- package/cpp/nodepcap/deps/include/pcap/socket.h +84 -84
- package/cpp/nodepcap/deps/include/pcap/usb.h +143 -143
- package/cpp/nodepcap/deps/include/pcap/vlan.h +46 -46
- package/cpp/nodepcap/deps/include/pcap-bpf.h +45 -45
- package/cpp/nodepcap/deps/include/pcap-namedb.h +40 -40
- package/cpp/nodepcap/deps/include/pcap.h +43 -43
- package/dist/CodecExports.d.ts +1 -0
- package/dist/CodecExports.d.ts.map +1 -1
- package/dist/lib/codec/Codec.js +1 -1
- package/dist/lib/codec/PacketHeaders.d.ts +5 -0
- package/dist/lib/codec/PacketHeaders.d.ts.map +1 -1
- package/dist/lib/codec/PacketHeaders.js +13 -1
- package/dist/lib/codec/abstracts/BaseHeader.d.ts +2 -2
- package/dist/lib/codec/abstracts/BaseHeader.d.ts.map +1 -1
- package/dist/lib/codec/abstracts/BaseHeader.js +4 -4
- package/dist/lib/codec/headers/EthernetII.js +1 -1
- package/dist/lib/codec/headers/Goose.js +5 -5
- package/dist/lib/codec/headers/IEC61850SampledValues.js +1 -1
- package/dist/lib/codec/headers/IPv4.js +2 -2
- package/dist/lib/codec/headers/TLS_Alert.d.ts +10 -0
- package/dist/lib/codec/headers/TLS_Alert.d.ts.map +1 -0
- package/dist/lib/codec/headers/TLS_Alert.js +624 -0
- package/dist/lib/codec/headers/TLS_ApplicationData.d.ts +10 -0
- package/dist/lib/codec/headers/TLS_ApplicationData.d.ts.map +1 -0
- package/dist/lib/codec/headers/TLS_ApplicationData.js +155 -0
- package/dist/lib/codec/headers/TLS_ChangeCipherSpec.d.ts +10 -0
- package/dist/lib/codec/headers/TLS_ChangeCipherSpec.d.ts.map +1 -0
- package/dist/lib/codec/headers/TLS_ChangeCipherSpec.js +154 -0
- package/dist/lib/codec/headers/TLS_Handshake.d.ts +10 -0
- package/dist/lib/codec/headers/TLS_Handshake.d.ts.map +1 -0
- package/dist/lib/codec/headers/TLS_Handshake.js +339 -0
- package/dist/lib/codec/headers/TLS_Heartbeat.d.ts +10 -0
- package/dist/lib/codec/headers/TLS_Heartbeat.d.ts.map +1 -0
- package/dist/lib/codec/headers/TLS_Heartbeat.js +206 -0
- package/dist/lib/codec/headers/VLAN_802dot1Q.js +1 -1
- package/package.json +1 -1
- package/src/CodecExports.ts +1 -1
- package/src/lib/codec/Codec.ts +1 -1
- package/src/lib/codec/PacketHeaders.ts +7 -0
- package/src/lib/codec/abstracts/BaseHeader.ts +4 -4
- package/src/lib/codec/headers/EthernetII.ts +1 -1
- package/src/lib/codec/headers/Goose.ts +5 -5
- package/src/lib/codec/headers/IEC61850SampledValues.ts +1 -1
- package/src/lib/codec/headers/IPv4.ts +2 -2
- package/src/lib/codec/headers/TLS_Alert.ts +539 -0
- package/src/lib/codec/headers/TLS_ApplicationData.ts +145 -0
- package/src/lib/codec/headers/TLS_ChangeCipherSpec.ts +146 -0
- package/src/lib/codec/headers/TLS_Handshake.ts +313 -0
- package/src/lib/codec/headers/TLS_Heartbeat.ts +188 -0
- package/src/lib/codec/headers/VLAN_802dot1Q.ts +1 -1
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
/*-
|
|
2
|
-
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
|
3
|
-
* The Regents of the University of California. All rights reserved.
|
|
4
|
-
*
|
|
5
|
-
* This code is derived from the Stanford/CMU enet packet filter,
|
|
6
|
-
* (net/enet.c) distributed as part of 4.3BSD, and code contributed
|
|
7
|
-
* to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
|
|
8
|
-
* Berkeley Laboratory.
|
|
9
|
-
*
|
|
10
|
-
* Redistribution and use in source and binary forms, with or without
|
|
11
|
-
* modification, are permitted provided that the following conditions
|
|
12
|
-
* are met:
|
|
13
|
-
* 1. Redistributions of source code must retain the above copyright
|
|
14
|
-
* notice, this list of conditions and the following disclaimer.
|
|
15
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
|
16
|
-
* notice, this list of conditions and the following disclaimer in the
|
|
17
|
-
* documentation and/or other materials provided with the distribution.
|
|
18
|
-
* 3. All advertising materials mentioning features or use of this software
|
|
19
|
-
* must display the following acknowledgement:
|
|
20
|
-
* This product includes software developed by the University of
|
|
21
|
-
* California, Berkeley and its contributors.
|
|
22
|
-
* 4. Neither the name of the University nor the names of its contributors
|
|
23
|
-
* may be used to endorse or promote products derived from this software
|
|
24
|
-
* without specific prior written permission.
|
|
25
|
-
*
|
|
26
|
-
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
27
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
28
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
29
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
30
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
31
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
32
|
-
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
33
|
-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
34
|
-
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
35
|
-
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
36
|
-
* SUCH DAMAGE.
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
#ifndef lib_pcap_can_socketcan_h
|
|
40
|
-
#define lib_pcap_can_socketcan_h
|
|
41
|
-
|
|
42
|
-
#include <pcap/pcap-inttypes.h>
|
|
43
|
-
|
|
44
|
-
/*
|
|
45
|
-
* SocketCAN header, as per Documentation/networking/can.txt in the
|
|
46
|
-
* Linux source.
|
|
47
|
-
*/
|
|
48
|
-
typedef struct {
|
|
49
|
-
uint32_t can_id;
|
|
50
|
-
uint8_t payload_length;
|
|
51
|
-
uint8_t pad;
|
|
52
|
-
uint8_t reserved1;
|
|
53
|
-
uint8_t reserved2;
|
|
54
|
-
} pcap_can_socketcan_hdr;
|
|
55
|
-
|
|
56
|
-
#endif
|
|
1
|
+
/*-
|
|
2
|
+
* Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
|
|
3
|
+
* The Regents of the University of California. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This code is derived from the Stanford/CMU enet packet filter,
|
|
6
|
+
* (net/enet.c) distributed as part of 4.3BSD, and code contributed
|
|
7
|
+
* to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
|
|
8
|
+
* Berkeley Laboratory.
|
|
9
|
+
*
|
|
10
|
+
* Redistribution and use in source and binary forms, with or without
|
|
11
|
+
* modification, are permitted provided that the following conditions
|
|
12
|
+
* are met:
|
|
13
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
14
|
+
* notice, this list of conditions and the following disclaimer.
|
|
15
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
16
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
17
|
+
* documentation and/or other materials provided with the distribution.
|
|
18
|
+
* 3. All advertising materials mentioning features or use of this software
|
|
19
|
+
* must display the following acknowledgement:
|
|
20
|
+
* This product includes software developed by the University of
|
|
21
|
+
* California, Berkeley and its contributors.
|
|
22
|
+
* 4. Neither the name of the University nor the names of its contributors
|
|
23
|
+
* may be used to endorse or promote products derived from this software
|
|
24
|
+
* without specific prior written permission.
|
|
25
|
+
*
|
|
26
|
+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
27
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
28
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
29
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
30
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
31
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
32
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
33
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
34
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
35
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
36
|
+
* SUCH DAMAGE.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
#ifndef lib_pcap_can_socketcan_h
|
|
40
|
+
#define lib_pcap_can_socketcan_h
|
|
41
|
+
|
|
42
|
+
#include <pcap/pcap-inttypes.h>
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* SocketCAN header, as per Documentation/networking/can.txt in the
|
|
46
|
+
* Linux source.
|
|
47
|
+
*/
|
|
48
|
+
typedef struct {
|
|
49
|
+
uint32_t can_id;
|
|
50
|
+
uint8_t payload_length;
|
|
51
|
+
uint8_t pad;
|
|
52
|
+
uint8_t reserved1;
|
|
53
|
+
uint8_t reserved2;
|
|
54
|
+
} pcap_can_socketcan_hdr;
|
|
55
|
+
|
|
56
|
+
#endif
|
|
@@ -1,163 +1,163 @@
|
|
|
1
|
-
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
|
2
|
-
/*
|
|
3
|
-
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
|
4
|
-
* The Regents of the University of California. All rights reserved.
|
|
5
|
-
*
|
|
6
|
-
* Redistribution and use in source and binary forms, with or without
|
|
7
|
-
* modification, are permitted provided that the following conditions
|
|
8
|
-
* are met:
|
|
9
|
-
* 1. Redistributions of source code must retain the above copyright
|
|
10
|
-
* notice, this list of conditions and the following disclaimer.
|
|
11
|
-
* 2. Redistributions in binary form must reproduce the above copyright
|
|
12
|
-
* notice, this list of conditions and the following disclaimer in the
|
|
13
|
-
* documentation and/or other materials provided with the distribution.
|
|
14
|
-
* 3. All advertising materials mentioning features or use of this software
|
|
15
|
-
* must display the following acknowledgement:
|
|
16
|
-
* This product includes software developed by the Computer Systems
|
|
17
|
-
* Engineering Group at Lawrence Berkeley Laboratory.
|
|
18
|
-
* 4. Neither the name of the University nor of the Laboratory may be used
|
|
19
|
-
* to endorse or promote products derived from this software without
|
|
20
|
-
* specific prior written permission.
|
|
21
|
-
*
|
|
22
|
-
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
23
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
24
|
-
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
25
|
-
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
26
|
-
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
27
|
-
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
28
|
-
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
29
|
-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
30
|
-
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
31
|
-
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
32
|
-
* SUCH DAMAGE.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
#ifndef lib_pcap_compiler_tests_h
|
|
36
|
-
#define lib_pcap_compiler_tests_h
|
|
37
|
-
|
|
38
|
-
/*
|
|
39
|
-
* This was introduced by Clang:
|
|
40
|
-
*
|
|
41
|
-
* https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
|
|
42
|
-
*
|
|
43
|
-
* in some version (which version?); it has been picked up by GCC 5.0.
|
|
44
|
-
*/
|
|
45
|
-
#ifndef __has_attribute
|
|
46
|
-
/*
|
|
47
|
-
* It's a macro, so you can check whether it's defined to check
|
|
48
|
-
* whether it's supported.
|
|
49
|
-
*
|
|
50
|
-
* If it's not, define it to always return 0, so that we move on to
|
|
51
|
-
* the fallback checks.
|
|
52
|
-
*/
|
|
53
|
-
#define __has_attribute(x) 0
|
|
54
|
-
#endif
|
|
55
|
-
|
|
56
|
-
/*
|
|
57
|
-
* Note that the C90 spec's "6.8.1 Conditional inclusion" and the
|
|
58
|
-
* C99 spec's and C11 spec's "6.10.1 Conditional inclusion" say:
|
|
59
|
-
*
|
|
60
|
-
* Prior to evaluation, macro invocations in the list of preprocessing
|
|
61
|
-
* tokens that will become the controlling constant expression are
|
|
62
|
-
* replaced (except for those macro names modified by the defined unary
|
|
63
|
-
* operator), just as in normal text. If the token "defined" is
|
|
64
|
-
* generated as a result of this replacement process or use of the
|
|
65
|
-
* "defined" unary operator does not match one of the two specified
|
|
66
|
-
* forms prior to macro replacement, the behavior is undefined.
|
|
67
|
-
*
|
|
68
|
-
* so you shouldn't use defined() in a #define that's used in #if or
|
|
69
|
-
* #elif. Some versions of Clang, for example, will warn about this.
|
|
70
|
-
*
|
|
71
|
-
* Instead, we check whether the pre-defined macros for particular
|
|
72
|
-
* compilers are defined and, if not, define the "is this version XXX
|
|
73
|
-
* or a later version of this compiler" macros as 0.
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
/*
|
|
77
|
-
* Check whether this is GCC major.minor or a later release, or some
|
|
78
|
-
* compiler that claims to be "just like GCC" of that version or a
|
|
79
|
-
* later release.
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
#if ! defined(__GNUC__)
|
|
83
|
-
#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0
|
|
84
|
-
#else
|
|
85
|
-
#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \
|
|
86
|
-
(__GNUC__ > (major) || \
|
|
87
|
-
(__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
|
|
88
|
-
#endif
|
|
89
|
-
|
|
90
|
-
/*
|
|
91
|
-
* Check whether this is Clang major.minor or a later release.
|
|
92
|
-
*/
|
|
93
|
-
|
|
94
|
-
#if !defined(__clang__)
|
|
95
|
-
#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0
|
|
96
|
-
#else
|
|
97
|
-
#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) \
|
|
98
|
-
(__clang_major__ > (major) || \
|
|
99
|
-
(__clang_major__ == (major) && __clang_minor__ >= (minor)))
|
|
100
|
-
#endif
|
|
101
|
-
|
|
102
|
-
/*
|
|
103
|
-
* Check whether this is Sun C/SunPro C/Oracle Studio major.minor
|
|
104
|
-
* or a later release.
|
|
105
|
-
*
|
|
106
|
-
* The version number in __SUNPRO_C is encoded in hex BCD, with the
|
|
107
|
-
* uppermost hex digit being the major version number, the next
|
|
108
|
-
* one or two hex digits being the minor version number, and
|
|
109
|
-
* the last digit being the patch version.
|
|
110
|
-
*
|
|
111
|
-
* It represents the *compiler* version, not the product version;
|
|
112
|
-
* see
|
|
113
|
-
*
|
|
114
|
-
* https://sourceforge.net/p/predef/wiki/Compilers/
|
|
115
|
-
*
|
|
116
|
-
* for a partial mapping, which we assume continues for later
|
|
117
|
-
* 12.x product releases.
|
|
118
|
-
*/
|
|
119
|
-
|
|
120
|
-
#if ! defined(__SUNPRO_C)
|
|
121
|
-
#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0
|
|
122
|
-
#else
|
|
123
|
-
#define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \
|
|
124
|
-
(((minor) >= 10) ? \
|
|
125
|
-
(((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \
|
|
126
|
-
(((major) << 8) | ((minor) << 4)))
|
|
127
|
-
#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \
|
|
128
|
-
(__SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD((major), (minor)))
|
|
129
|
-
#endif
|
|
130
|
-
|
|
131
|
-
/*
|
|
132
|
-
* Check whether this is IBM XL C major.minor or a later release.
|
|
133
|
-
*
|
|
134
|
-
* The version number in __xlC__ has the major version in the
|
|
135
|
-
* upper 8 bits and the minor version in the lower 8 bits.
|
|
136
|
-
*/
|
|
137
|
-
|
|
138
|
-
#if ! defined(__xlC__)
|
|
139
|
-
#define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0
|
|
140
|
-
#else
|
|
141
|
-
#define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \
|
|
142
|
-
(__xlC__ >= (((major) << 8) | (minor)))
|
|
143
|
-
#endif
|
|
144
|
-
|
|
145
|
-
/*
|
|
146
|
-
* Check whether this is HP aC++/HP C major.minor or a later release.
|
|
147
|
-
*
|
|
148
|
-
* The version number in __HP_aCC is encoded in zero-padded decimal BCD,
|
|
149
|
-
* with the "A." stripped off, the uppermost two decimal digits being
|
|
150
|
-
* the major version number, the next two decimal digits being the minor
|
|
151
|
-
* version number, and the last two decimal digits being the patch version.
|
|
152
|
-
* (Strip off the A., remove the . between the major and minor version
|
|
153
|
-
* number, and add two digits of patch.)
|
|
154
|
-
*/
|
|
155
|
-
|
|
156
|
-
#if ! defined(__HP_aCC)
|
|
157
|
-
#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0
|
|
158
|
-
#else
|
|
159
|
-
#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \
|
|
160
|
-
(__HP_aCC >= ((major)*10000 + (minor)*100))
|
|
161
|
-
#endif
|
|
162
|
-
|
|
163
|
-
#endif /* lib_pcap_compiler_tests_h */
|
|
1
|
+
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 1993, 1994, 1995, 1996, 1997
|
|
4
|
+
* The Regents of the University of California. All rights reserved.
|
|
5
|
+
*
|
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
|
7
|
+
* modification, are permitted provided that the following conditions
|
|
8
|
+
* are met:
|
|
9
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
10
|
+
* notice, this list of conditions and the following disclaimer.
|
|
11
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
12
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
13
|
+
* documentation and/or other materials provided with the distribution.
|
|
14
|
+
* 3. All advertising materials mentioning features or use of this software
|
|
15
|
+
* must display the following acknowledgement:
|
|
16
|
+
* This product includes software developed by the Computer Systems
|
|
17
|
+
* Engineering Group at Lawrence Berkeley Laboratory.
|
|
18
|
+
* 4. Neither the name of the University nor of the Laboratory may be used
|
|
19
|
+
* to endorse or promote products derived from this software without
|
|
20
|
+
* specific prior written permission.
|
|
21
|
+
*
|
|
22
|
+
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
23
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
24
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
25
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
26
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
27
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
28
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
29
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
30
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
31
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
32
|
+
* SUCH DAMAGE.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
#ifndef lib_pcap_compiler_tests_h
|
|
36
|
+
#define lib_pcap_compiler_tests_h
|
|
37
|
+
|
|
38
|
+
/*
|
|
39
|
+
* This was introduced by Clang:
|
|
40
|
+
*
|
|
41
|
+
* https://clang.llvm.org/docs/LanguageExtensions.html#has-attribute
|
|
42
|
+
*
|
|
43
|
+
* in some version (which version?); it has been picked up by GCC 5.0.
|
|
44
|
+
*/
|
|
45
|
+
#ifndef __has_attribute
|
|
46
|
+
/*
|
|
47
|
+
* It's a macro, so you can check whether it's defined to check
|
|
48
|
+
* whether it's supported.
|
|
49
|
+
*
|
|
50
|
+
* If it's not, define it to always return 0, so that we move on to
|
|
51
|
+
* the fallback checks.
|
|
52
|
+
*/
|
|
53
|
+
#define __has_attribute(x) 0
|
|
54
|
+
#endif
|
|
55
|
+
|
|
56
|
+
/*
|
|
57
|
+
* Note that the C90 spec's "6.8.1 Conditional inclusion" and the
|
|
58
|
+
* C99 spec's and C11 spec's "6.10.1 Conditional inclusion" say:
|
|
59
|
+
*
|
|
60
|
+
* Prior to evaluation, macro invocations in the list of preprocessing
|
|
61
|
+
* tokens that will become the controlling constant expression are
|
|
62
|
+
* replaced (except for those macro names modified by the defined unary
|
|
63
|
+
* operator), just as in normal text. If the token "defined" is
|
|
64
|
+
* generated as a result of this replacement process or use of the
|
|
65
|
+
* "defined" unary operator does not match one of the two specified
|
|
66
|
+
* forms prior to macro replacement, the behavior is undefined.
|
|
67
|
+
*
|
|
68
|
+
* so you shouldn't use defined() in a #define that's used in #if or
|
|
69
|
+
* #elif. Some versions of Clang, for example, will warn about this.
|
|
70
|
+
*
|
|
71
|
+
* Instead, we check whether the pre-defined macros for particular
|
|
72
|
+
* compilers are defined and, if not, define the "is this version XXX
|
|
73
|
+
* or a later version of this compiler" macros as 0.
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
* Check whether this is GCC major.minor or a later release, or some
|
|
78
|
+
* compiler that claims to be "just like GCC" of that version or a
|
|
79
|
+
* later release.
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
#if ! defined(__GNUC__)
|
|
83
|
+
#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) 0
|
|
84
|
+
#else
|
|
85
|
+
#define PCAP_IS_AT_LEAST_GNUC_VERSION(major, minor) \
|
|
86
|
+
(__GNUC__ > (major) || \
|
|
87
|
+
(__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
|
|
88
|
+
#endif
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
* Check whether this is Clang major.minor or a later release.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
#if !defined(__clang__)
|
|
95
|
+
#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) 0
|
|
96
|
+
#else
|
|
97
|
+
#define PCAP_IS_AT_LEAST_CLANG_VERSION(major, minor) \
|
|
98
|
+
(__clang_major__ > (major) || \
|
|
99
|
+
(__clang_major__ == (major) && __clang_minor__ >= (minor)))
|
|
100
|
+
#endif
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
* Check whether this is Sun C/SunPro C/Oracle Studio major.minor
|
|
104
|
+
* or a later release.
|
|
105
|
+
*
|
|
106
|
+
* The version number in __SUNPRO_C is encoded in hex BCD, with the
|
|
107
|
+
* uppermost hex digit being the major version number, the next
|
|
108
|
+
* one or two hex digits being the minor version number, and
|
|
109
|
+
* the last digit being the patch version.
|
|
110
|
+
*
|
|
111
|
+
* It represents the *compiler* version, not the product version;
|
|
112
|
+
* see
|
|
113
|
+
*
|
|
114
|
+
* https://sourceforge.net/p/predef/wiki/Compilers/
|
|
115
|
+
*
|
|
116
|
+
* for a partial mapping, which we assume continues for later
|
|
117
|
+
* 12.x product releases.
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
#if ! defined(__SUNPRO_C)
|
|
121
|
+
#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) 0
|
|
122
|
+
#else
|
|
123
|
+
#define PCAP_SUNPRO_VERSION_TO_BCD(major, minor) \
|
|
124
|
+
(((minor) >= 10) ? \
|
|
125
|
+
(((major) << 12) | (((minor)/10) << 8) | (((minor)%10) << 4)) : \
|
|
126
|
+
(((major) << 8) | ((minor) << 4)))
|
|
127
|
+
#define PCAP_IS_AT_LEAST_SUNC_VERSION(major,minor) \
|
|
128
|
+
(__SUNPRO_C >= PCAP_SUNPRO_VERSION_TO_BCD((major), (minor)))
|
|
129
|
+
#endif
|
|
130
|
+
|
|
131
|
+
/*
|
|
132
|
+
* Check whether this is IBM XL C major.minor or a later release.
|
|
133
|
+
*
|
|
134
|
+
* The version number in __xlC__ has the major version in the
|
|
135
|
+
* upper 8 bits and the minor version in the lower 8 bits.
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
#if ! defined(__xlC__)
|
|
139
|
+
#define PCAP_IS_AT_LEAST_XL_C_VERSION(major,minor) 0
|
|
140
|
+
#else
|
|
141
|
+
#define PCAP_IS_AT_LEAST_XL_C_VERSION(major, minor) \
|
|
142
|
+
(__xlC__ >= (((major) << 8) | (minor)))
|
|
143
|
+
#endif
|
|
144
|
+
|
|
145
|
+
/*
|
|
146
|
+
* Check whether this is HP aC++/HP C major.minor or a later release.
|
|
147
|
+
*
|
|
148
|
+
* The version number in __HP_aCC is encoded in zero-padded decimal BCD,
|
|
149
|
+
* with the "A." stripped off, the uppermost two decimal digits being
|
|
150
|
+
* the major version number, the next two decimal digits being the minor
|
|
151
|
+
* version number, and the last two decimal digits being the patch version.
|
|
152
|
+
* (Strip off the A., remove the . between the major and minor version
|
|
153
|
+
* number, and add two digits of patch.)
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
#if ! defined(__HP_aCC)
|
|
157
|
+
#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) 0
|
|
158
|
+
#else
|
|
159
|
+
#define PCAP_IS_AT_LEAST_HP_C_VERSION(major,minor) \
|
|
160
|
+
(__HP_aCC >= ((major)*10000 + (minor)*100))
|
|
161
|
+
#endif
|
|
162
|
+
|
|
163
|
+
#endif /* lib_pcap_compiler_tests_h */
|