]>
The Tcpdump Group git mirrors - tcpslice/blob - tcpslice.h
2 * Copyright (c) 1993, 1995
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
25 #include "compiler-tests.h"
30 * If we're compiling with Visual Studio, make sure we have at least
31 * VS 2015 or later, so we have sufficient C99 support.
33 * XXX - verify that we have at least C99 support on UN*Xes?
35 * What about MinGW or various DOS toolchains? We're currently assuming
36 * sufficient C99 support there.
40 * Make sure we have VS 2015 or later.
43 #error "Building tcpslice requires VS 2015 or later"
48 * Get the C99 types, and the PRI[doux]64 format strings, defined.
50 #ifdef HAVE_PCAP_PCAP_INTTYPES_H
52 * We have pcap/pcap-inttypes.h; use that, as it'll do all the
53 * work, and won't cause problems if a file includes this file
54 * and later includes a pcap header file that also includes
55 * pcap/pcap-inttypes.h.
57 #include <pcap/pcap-inttypes.h>
60 * OK, we don't have pcap/pcap-inttypes.h, so we'll have to
61 * do the work ourselves, but at least we don't have to
62 * worry about other headers including it and causing
67 * Include <inttypes.h> to get the integer types and PRI[doux]64 values
70 * If the compiler is MSVC, we require VS 2015 or newer, so we
71 * have <inttypes.h> - and support for %zu in the formatted
74 * If the compiler is MinGW, we assume we have <inttypes.h> - and
75 * support for %zu in the formatted printing functions.
77 * If the target is UN*X, we assume we have a C99-or-later development
78 * environment, and thus have <inttypes.h> - and support for %zu in
79 * the formatted printing functions.
81 * If the target is MS-DOS, we assume we have <inttypes.h> - and support
82 * for %zu in the formatted printing functions.
88 * Suppress definition of intN_t in bittypes.h, which might be included
89 * by <pcap/pcap.h> in older versions of WinPcap.
90 * (Yes, HAVE_U_INTn_T, as the definition guards are UN*X-oriented.)
93 #define HAVE_U_INT16_T
94 #define HAVE_U_INT32_T
95 #define HAVE_U_INT64_T
97 #endif /* HAVE_PCAP_PCAP_INTTYPES_H */
100 #include <sys/types.h>
101 #include <sys/time.h>
104 #define IS_LEAP_YEAR(year) \
105 ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
108 * OpenBSD libpcap compensation: in struct pcap_pkthdr "ts" instead of struct
109 * timeval uses struct bpf_timeval, which declares members with the same names
110 * and a different type, which is a 32-bit unsigned, whilst on 64-bit systems
111 * struct timeval uses a 64-bit integer type.
113 #define TIMEVAL_FROM_PKTHDR_TS(dst, src) { \
114 (dst).tv_sec = (src).tv_sec; \
115 (dst).tv_usec = (src).tv_usec; \
118 extern const int days_in_month
[];
119 time_t gwtm2secs( const struct tm
*tm
);
121 int sf_find_end( struct pcap
*p
, const struct timeval
*first_timestamp
,
122 struct timeval
*last_timestamp
);
123 int sf_timestamp_less_than( const struct timeval
*t1
, const struct timeval
*t2
);
124 int sf_find_packet( struct pcap
*p
,
125 struct timeval
*min_time
, int64_t min_pos
,
126 struct timeval
*max_time
, int64_t max_pos
,
127 const struct timeval
*desired_time
);
129 int fseek64(FILE *p
, const int64_t offset
, const int whence
);
130 int64_t ftell64(FILE *p
);
131 extern char *timestamp_to_string(const struct timeval
*timestamp
);
133 void error(const char *fmt
, ...);
134 void warning(const char *fmt
, ...);
136 extern pcap_dumper_t
*global_dumper
;
137 #endif /* TCPSLICE_H */