diff options
Diffstat (limited to 'pcap')
-rw-r--r-- | pcap/bluetooth.h | 9 | ||||
-rw-r--r-- | pcap/can_socketcan.h | 12 | ||||
-rw-r--r-- | pcap/dlt.h | 16 | ||||
-rw-r--r-- | pcap/nflog.h | 28 | ||||
-rw-r--r-- | pcap/pcap-inttypes.h | 122 | ||||
-rw-r--r-- | pcap/sll.h | 12 | ||||
-rw-r--r-- | pcap/usb.h | 54 | ||||
-rw-r--r-- | pcap/vlan.h | 6 |
8 files changed, 196 insertions, 63 deletions
diff --git a/pcap/bluetooth.h b/pcap/bluetooth.h index c5f378ab..15dc5a82 100644 --- a/pcap/bluetooth.h +++ b/pcap/bluetooth.h @@ -34,12 +34,14 @@ #ifndef lib_pcap_bluetooth_h #define lib_pcap_bluetooth_h +#include <pcap/pcap-inttypes.h> + /* * Header prepended libpcap to each bluetooth h4 frame, * fields are in network byte order */ typedef struct _pcap_bluetooth_h4_header { - u_int32_t direction; /* if first bit is set direction is incoming */ + uint32_t direction; /* if first bit is set direction is incoming */ } pcap_bluetooth_h4_header; /* @@ -47,9 +49,8 @@ typedef struct _pcap_bluetooth_h4_header { * fields are in network byte order */ typedef struct _pcap_bluetooth_linux_monitor_header { - u_int16_t adapter_id; - u_int16_t opcode; + uint16_t adapter_id; + uint16_t opcode; } pcap_bluetooth_linux_monitor_header; - #endif diff --git a/pcap/can_socketcan.h b/pcap/can_socketcan.h index 68d2a131..332d9ff5 100644 --- a/pcap/can_socketcan.h +++ b/pcap/can_socketcan.h @@ -39,16 +39,18 @@ #ifndef lib_pcap_can_socketcan_h #define lib_pcap_can_socketcan_h +#include <pcap/pcap-inttypes.h> + /* * SocketCAN header, as per Documentation/networking/can.txt in the * Linux source. */ typedef struct { - u_int32_t can_id; - u_int8_t payload_length; - u_int8_t pad; - u_int8_t reserved1; - u_int8_t reserved2; + uint32_t can_id; + uint8_t payload_length; + uint8_t pad; + uint8_t reserved1; + uint8_t reserved2; } pcap_can_socketcan_hdr; #endif @@ -946,14 +946,14 @@ * the pseudo-header is: * * struct dl_ipnetinfo { - * u_int8_t dli_version; - * u_int8_t dli_family; - * u_int16_t dli_htype; - * u_int32_t dli_pktlen; - * u_int32_t dli_ifindex; - * u_int32_t dli_grifindex; - * u_int32_t dli_zsrc; - * u_int32_t dli_zdst; + * uint8_t dli_version; + * uint8_t dli_family; + * uint16_t dli_htype; + * uint32_t dli_pktlen; + * uint32_t dli_ifindex; + * uint32_t dli_grifindex; + * uint32_t dli_zsrc; + * uint32_t dli_zdst; * }; * * dli_version is 2 for the current version of the pseudo-header. diff --git a/pcap/nflog.h b/pcap/nflog.h index a3867cdd..29a71d2d 100644 --- a/pcap/nflog.h +++ b/pcap/nflog.h @@ -28,6 +28,8 @@ #ifndef lib_pcap_nflog_h #define lib_pcap_nflog_h +#include <pcap/pcap-inttypes.h> + /* * Structure of an NFLOG header and TLV parts, as described at * http://www.tcpdump.org/linktypes/LINKTYPE_NFLOG.html @@ -40,32 +42,32 @@ * data, etc.). */ typedef struct nflog_hdr { - u_int8_t nflog_family; /* address family */ - u_int8_t nflog_version; /* version */ - u_int16_t nflog_rid; /* resource ID */ + uint8_t nflog_family; /* address family */ + uint8_t nflog_version; /* version */ + uint16_t nflog_rid; /* resource ID */ } nflog_hdr_t; typedef struct nflog_tlv { - u_int16_t tlv_length; /* tlv length */ - u_int16_t tlv_type; /* tlv type */ + uint16_t tlv_length; /* tlv length */ + uint16_t tlv_type; /* tlv type */ /* value follows this */ } nflog_tlv_t; typedef struct nflog_packet_hdr { - u_int16_t hw_protocol; /* hw protocol */ - u_int8_t hook; /* netfilter hook */ - u_int8_t pad; /* padding to 32 bits */ + uint16_t hw_protocol; /* hw protocol */ + uint8_t hook; /* netfilter hook */ + uint8_t pad; /* padding to 32 bits */ } nflog_packet_hdr_t; typedef struct nflog_hwaddr { - u_int16_t hw_addrlen; /* address length */ - u_int16_t pad; /* padding to 32-bit boundary */ - u_int8_t hw_addr[8]; /* address, up to 8 bytes */ + uint16_t hw_addrlen; /* address length */ + uint16_t pad; /* padding to 32-bit boundary */ + uint8_t hw_addr[8]; /* address, up to 8 bytes */ } nflog_hwaddr_t; typedef struct nflog_timestamp { - u_int64_t sec; - u_int64_t usec; + uint64_t sec; + uint64_t usec; } nflog_timestamp_t; /* diff --git a/pcap/pcap-inttypes.h b/pcap/pcap-inttypes.h new file mode 100644 index 00000000..58d8c18c --- /dev/null +++ b/pcap/pcap-inttypes.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy) + * Copyright (c) 2005 - 2009 CACE Technologies, Inc. Davis (California) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Politecnico di Torino nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef pcap_pcap_inttypes_h +#define pcap_pcap_inttypes_h + +/* + * Get the integer types and PRi[doux]64 values from C99 <inttypes.h> + * defined, by hook or by crook. + */ +#if defined(_MSC_VER) + /* + * Compiler is MSVC. + */ + #if _MSC_VER >= 1800 + /* + * VS 2013 or newer; we have <inttypes.h>. + */ + #include <inttypes.h> + + #define uint8_t uint8_t + #define uint16_t uint16_t + #define uint32_t uint32_t + #define uint64_t uint64_t + #else + /* + * Earlier VS; we have to define this stuff ourselves. + */ + typedef unsigned char uint8_t; + typedef signed char int8_t; + typedef unsigned short uint16_t; + typedef signed short int16_t; + typedef unsigned int uint32_t; + typedef signed int int32_t; + #ifdef _MSC_EXTENSIONS + typedef unsigned _int64 uint64_t; + typedef _int64 int64_t; + #else /* _MSC_EXTENSIONS */ + typedef unsigned long long uint64_t; + typedef long long int64_t; + #endif + #endif + + /* + * These may be defined by <inttypes.h>. + * + * XXX - for MSVC, we always want the _MSC_EXTENSIONS versions. + * What about other compilers? If, as the MinGW Web site says MinGW + * does, the other compilers just use Microsoft's run-time library, + * then they should probably use the _MSC_EXTENSIONS even if the + * compiler doesn't define _MSC_EXTENSIONS. + * + * XXX - we currently aren't using any of these, but this allows + * their use in the future. + */ + #ifndef PRId64 + #ifdef _MSC_EXTENSIONS + #define PRId64 "I64d" + #else + #define PRId64 "lld" + #endif + #endif /* PRId64 */ + + #ifndef PRIo64 + #ifdef _MSC_EXTENSIONS + #define PRIo64 "I64o" + #else + #define PRIo64 "llo" + #endif + #endif /* PRIo64 */ + + #ifndef PRIx64 + #ifdef _MSC_EXTENSIONS + #define PRIx64 "I64x" + #else + #define PRIx64 "llx" + #endif + #endif + + #ifndef PRIu64 + #ifdef _MSC_EXTENSIONS + #define PRIu64 "I64u" + #else + #define PRIu64 "llu" + #endif + #endif +#elif defined(__MINGW32__) || !defined(_WIN32) + /* + * Compiler is MinGW or target is UN*X or MS-DOS. Just use + * <inttypes.h>. + */ + #include <inttypes.h> +#endif + +#endif /* pcap/pcap-inttypes.h */ @@ -80,12 +80,14 @@ #define SLL_HDR_LEN 16 /* total header length */ #define SLL_ADDRLEN 8 /* length of address field */ +#include <pcap/pcap-inttypes.h> + struct sll_header { - u_int16_t sll_pkttype; /* packet type */ - u_int16_t sll_hatype; /* link-layer address type */ - u_int16_t sll_halen; /* link-layer address length */ - u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */ - u_int16_t sll_protocol; /* protocol */ + uint16_t sll_pkttype; /* packet type */ + uint16_t sll_hatype; /* link-layer address type */ + uint16_t sll_halen; /* link-layer address length */ + uint8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */ + uint16_t sll_protocol; /* protocol */ }; /* @@ -34,6 +34,8 @@ #ifndef lib_pcap_usb_h #define lib_pcap_usb_h +#include <pcap/pcap-inttypes.h> + /* * possible transfer mode */ @@ -55,11 +57,11 @@ * Appears at the front of each Control S-type packet in DLT_USB captures. */ typedef struct _usb_setup { - u_int8_t bmRequestType; - u_int8_t bRequest; - u_int16_t wValue; - u_int16_t wIndex; - u_int16_t wLength; + uint8_t bmRequestType; + uint8_t bRequest; + uint16_t wValue; + uint16_t wIndex; + uint16_t wLength; } pcap_usb_setup; /* @@ -75,19 +77,19 @@ typedef struct _iso_rec { * Appears at the front of each packet in DLT_USB_LINUX captures. */ typedef struct _usb_header { - u_int64_t id; - u_int8_t event_type; - u_int8_t transfer_type; - u_int8_t endpoint_number; - u_int8_t device_address; - u_int16_t bus_id; + uint64_t id; + uint8_t event_type; + uint8_t transfer_type; + uint8_t endpoint_number; + uint8_t device_address; + uint16_t bus_id; char setup_flag;/*if !=0 the urb setup header is not present*/ char data_flag; /*if !=0 no urb data is present*/ int64_t ts_sec; int32_t ts_usec; int32_t status; - u_int32_t urb_len; - u_int32_t data_len; /* amount of urb data really present in this event*/ + uint32_t urb_len; + uint32_t data_len; /* amount of urb data really present in this event*/ pcap_usb_setup setup; } pcap_usb_header; @@ -100,27 +102,27 @@ typedef struct _usb_header { * Appears at the front of each packet in DLT_USB_LINUX_MMAPPED captures. */ typedef struct _usb_header_mmapped { - u_int64_t id; - u_int8_t event_type; - u_int8_t transfer_type; - u_int8_t endpoint_number; - u_int8_t device_address; - u_int16_t bus_id; + uint64_t id; + uint8_t event_type; + uint8_t transfer_type; + uint8_t endpoint_number; + uint8_t device_address; + uint16_t bus_id; char setup_flag;/*if !=0 the urb setup header is not present*/ char data_flag; /*if !=0 no urb data is present*/ int64_t ts_sec; int32_t ts_usec; int32_t status; - u_int32_t urb_len; - u_int32_t data_len; /* amount of urb data really present in this event*/ + uint32_t urb_len; + uint32_t data_len; /* amount of urb data really present in this event*/ union { pcap_usb_setup setup; iso_rec iso; } s; int32_t interval; /* for Interrupt and Isochronous events */ int32_t start_frame; /* for Isochronous events */ - u_int32_t xfer_flags; /* copy of URB's transfer flags */ - u_int32_t ndesc; /* number of isochronous descriptors */ + uint32_t xfer_flags; /* copy of URB's transfer flags */ + uint32_t ndesc; /* number of isochronous descriptors */ } pcap_usb_header_mmapped; /* @@ -133,9 +135,9 @@ typedef struct _usb_header_mmapped { */ typedef struct _usb_isodesc { int32_t status; - u_int32_t offset; - u_int32_t len; - u_int8_t pad[4]; + uint32_t offset; + uint32_t len; + uint8_t pad[4]; } usb_isodesc; #endif diff --git a/pcap/vlan.h b/pcap/vlan.h index 021f6129..b29dd73c 100644 --- a/pcap/vlan.h +++ b/pcap/vlan.h @@ -34,9 +34,11 @@ #ifndef lib_pcap_vlan_h #define lib_pcap_vlan_h +#include <pcap/pcap-inttypes.h> + struct vlan_tag { - u_int16_t vlan_tpid; /* ETH_P_8021Q */ - u_int16_t vlan_tci; /* VLAN TCI */ + uint16_t vlan_tpid; /* ETH_P_8021Q */ + uint16_t vlan_tci; /* VLAN TCI */ }; #define VLAN_TAG_LEN 4 |