pcap-int.h (109841) | pcap-int.h (127667) |
---|---|
1/* 2 * Copyright (c) 1994, 1995, 1996 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * | 1/* 2 * Copyright (c) 1994, 1995, 1996 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * |
33 * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.33 2001/08/24 07:46:52 guy Exp $ (LBL) 34 * 35 * $FreeBSD: head/contrib/libpcap/pcap-int.h 109841 2003-01-26 01:21:53Z fenner $ | 33 * $FreeBSD: head/contrib/libpcap/pcap-int.h 127667 2004-03-31 09:15:09Z bms $ 34 * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.55.2.4 2003/12/15 01:42:24 guy Exp $ (LBL) |
36 */ 37 38#ifndef pcap_int_h 39#define pcap_int_h 40 41#ifdef __cplusplus 42extern "C" { 43#endif 44 45#include <pcap.h> 46 | 35 */ 36 37#ifndef pcap_int_h 38#define pcap_int_h 39 40#ifdef __cplusplus 41extern "C" { 42#endif 43 44#include <pcap.h> 45 |
46#ifdef WIN32 47#include <packet32.h> 48#endif /* WIN32 */ 49 |
|
47/* 48 * Savefile 49 */ | 50/* 51 * Savefile 52 */ |
53typedef enum { 54 NOT_SWAPPED, 55 SWAPPED, 56 MAYBE_SWAPPED 57} swapped_type_t; 58 |
|
50struct pcap_sf { 51 FILE *rfile; 52 int swapped; 53 int hdrsize; | 59struct pcap_sf { 60 FILE *rfile; 61 int swapped; 62 int hdrsize; |
63 swapped_type_t lengths_swapped; |
|
54 int version_major; 55 int version_minor; 56 u_char *base; 57}; 58 59struct pcap_md { 60 struct pcap_stat stat; 61 /*XXX*/ --- 4 unchanged lines hidden (view full) --- 66 long TotMissed; /* missed by i/f during this run */ 67 long OrigMissed; /* missed by i/f before this run */ 68#ifdef linux 69 int sock_packet; /* using Linux 2.0 compatible interface */ 70 int timeout; /* timeout specified to pcap_open_live */ 71 int clear_promisc; /* must clear promiscuous mode when we close */ 72 int cooked; /* using SOCK_DGRAM rather than SOCK_RAW */ 73 int lo_ifindex; /* interface index of the loopback device */ | 64 int version_major; 65 int version_minor; 66 u_char *base; 67}; 68 69struct pcap_md { 70 struct pcap_stat stat; 71 /*XXX*/ --- 4 unchanged lines hidden (view full) --- 76 long TotMissed; /* missed by i/f during this run */ 77 long OrigMissed; /* missed by i/f before this run */ 78#ifdef linux 79 int sock_packet; /* using Linux 2.0 compatible interface */ 80 int timeout; /* timeout specified to pcap_open_live */ 81 int clear_promisc; /* must clear promiscuous mode when we close */ 82 int cooked; /* using SOCK_DGRAM rather than SOCK_RAW */ 83 int lo_ifindex; /* interface index of the loopback device */ |
74 char *device; /* device name */ | 84 char *device; /* device name */ |
75 struct pcap *next; /* list of open promiscuous sock_packet pcaps */ 76#endif | 85 struct pcap *next; /* list of open promiscuous sock_packet pcaps */ 86#endif |
87 88#ifdef HAVE_DAG_API 89 void *dag_mem_base; /* DAG card memory base address */ 90 u_int dag_mem_bottom; /* DAG card current memory bottom pointer */ 91 u_int dag_mem_top; /* DAG card current memory top pointer */ 92 int dag_fcs_bits; /* Number of checksum bits from link layer */ 93 int dag_offset_flags; /* Flags to pass to dag_offset(). */ 94#endif |
|
77}; 78 79struct pcap { | 95}; 96 97struct pcap { |
98#ifdef WIN32 99 ADAPTER *adapter; 100 LPPACKET Packet; 101 int timeout; 102 int nonblock; 103#else |
|
80 int fd; | 104 int fd; |
105 int selectable_fd; 106#endif /* WIN32 */ |
|
81 int snapshot; 82 int linktype; 83 int tzoff; /* timezone offset */ 84 int offset; /* offset for proper alignment */ 85 | 107 int snapshot; 108 int linktype; 109 int tzoff; /* timezone offset */ 110 int offset; /* offset for proper alignment */ 111 |
112 int break_loop; /* flag set to force break from packet-reading loop */ 113 |
|
86 struct pcap_sf sf; 87 struct pcap_md md; 88 89 /* 90 * Read buffer. 91 */ 92 int bufsize; 93 u_char *buffer; 94 u_char *bp; 95 int cc; 96 97 /* 98 * Place holder for pcap_next(). 99 */ 100 u_char *pkt; 101 | 114 struct pcap_sf sf; 115 struct pcap_md md; 116 117 /* 118 * Read buffer. 119 */ 120 int bufsize; 121 u_char *buffer; 122 u_char *bp; 123 int cc; 124 125 /* 126 * Place holder for pcap_next(). 127 */ 128 u_char *pkt; 129 |
102 | |
103 /* | 130 /* |
131 * Methods. 132 */ 133 int (*read_op)(pcap_t *, int cnt, pcap_handler, u_char *); 134 int (*setfilter_op)(pcap_t *, struct bpf_program *); 135 int (*set_datalink_op)(pcap_t *, int); 136 int (*getnonblock_op)(pcap_t *, char *); 137 int (*setnonblock_op)(pcap_t *, int, char *); 138 int (*stats_op)(pcap_t *, struct pcap_stat *); 139 void (*close_op)(pcap_t *); 140 141 /* |
|
104 * Placeholder for filter code if bpf not in kernel. 105 */ 106 struct bpf_program fcode; 107 | 142 * Placeholder for filter code if bpf not in kernel. 143 */ 144 struct bpf_program fcode; 145 |
108 char errbuf[PCAP_ERRBUF_SIZE]; | 146 char errbuf[PCAP_ERRBUF_SIZE + 1]; |
109 int dlt_count; 110 int *dlt_list; | 147 int dlt_count; 148 int *dlt_list; |
149 150 struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */ |
|
111}; 112 113/* 114 * This is a timeval as stored in disk in a dumpfile. 115 * It has to use the same types everywhere, independent of the actual 116 * `struct timeval' 117 */ 118 --- 58 unchanged lines hidden (view full) --- 177#ifndef min 178#define min(a, b) ((a) > (b) ? (b) : (a)) 179#endif 180 181/* XXX should these be in pcap.h? */ 182int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *); 183int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *); 184 | 151}; 152 153/* 154 * This is a timeval as stored in disk in a dumpfile. 155 * It has to use the same types everywhere, independent of the actual 156 * `struct timeval' 157 */ 158 --- 58 unchanged lines hidden (view full) --- 217#ifndef min 218#define min(a, b) ((a) > (b) ? (b) : (a)) 219#endif 220 221/* XXX should these be in pcap.h? */ 222int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *); 223int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *); 224 |
225 |
|
185/* 186 * Ultrix, DEC OSF/1^H^H^H^H^H^H^H^H^HDigital UNIX^H^H^H^H^H^H^H^H^H^H^H^H 187 * Tru64 UNIX, and NetBSD pad to make everything line up on a nice boundary. 188 */ 189#if defined(ultrix) || defined(__osf__) || defined(__NetBSD__) 190#define PCAP_FDDIPAD 3 191#endif 192 193#ifndef HAVE_STRLCPY 194#define strlcpy(x, y, z) \ 195 (strncpy((x), (y), (z)), \ 196 ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \ 197 strlen((y))) 198#endif 199 | 226/* 227 * Ultrix, DEC OSF/1^H^H^H^H^H^H^H^H^HDigital UNIX^H^H^H^H^H^H^H^H^H^H^H^H 228 * Tru64 UNIX, and NetBSD pad to make everything line up on a nice boundary. 229 */ 230#if defined(ultrix) || defined(__osf__) || defined(__NetBSD__) 231#define PCAP_FDDIPAD 3 232#endif 233 234#ifndef HAVE_STRLCPY 235#define strlcpy(x, y, z) \ 236 (strncpy((x), (y), (z)), \ 237 ((z) <= 0 ? 0 : ((x)[(z) - 1] = '\0')), \ 238 strlen((y))) 239#endif 240 |
200#ifdef linux 201void pcap_close_linux(pcap_t *); | 241#include <stdarg.h> 242 243#if !defined(HAVE_SNPRINTF) 244#define snprintf pcap_snprintf 245extern int snprintf (char *, size_t, const char *, ...); |
202#endif 203 | 246#endif 247 |
248#if !defined(HAVE_VSNPRINTF) 249#define vsnprintf pcap_vsnprintf 250extern int vsnprintf (char *, size_t, const char *, va_list ap); 251#endif 252 253/* 254 * Routines that most pcap implementations can use for non-blocking mode. 255 */ 256#ifndef WIN32 257int pcap_getnonblock_fd(pcap_t *, char *); 258int pcap_setnonblock_fd(pcap_t *p, int, char *); 259#endif 260 261/* 262 * Internal interfaces for "pcap_findalldevs()". 263 * 264 * "pcap_platform_finddevs()" is a platform-dependent routine to 265 * add devices not found by the "standard" mechanisms (SIOCGIFCONF, 266 * "getifaddrs()", etc.. 267 * 268 * "pcap_add_if()" adds an interface to the list of interfaces. 269 */ 270int pcap_platform_finddevs(pcap_if_t **, char *); 271int add_addr_to_iflist(pcap_if_t **, char *, u_int, struct sockaddr *, 272 size_t, struct sockaddr *, size_t, struct sockaddr *, size_t, 273 struct sockaddr *, size_t, char *); 274int pcap_add_if(pcap_if_t **, char *, u_int, const char *, char *); 275struct sockaddr *dup_sockaddr(struct sockaddr *, size_t); 276int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int, 277 const char *, char *); 278 279#ifdef WIN32 280char *pcap_win32strerror(void); 281#endif 282 |
|
204/* XXX */ 205extern int pcap_fddipad; 206 207int install_bpf_program(pcap_t *, struct bpf_program *); 208 | 283/* XXX */ 284extern int pcap_fddipad; 285 286int install_bpf_program(pcap_t *, struct bpf_program *); 287 |
288int pcap_strcasecmp(const char *, const char *); 289 |
|
209#ifdef __cplusplus 210} 211#endif 212 213#endif | 290#ifdef __cplusplus 291} 292#endif 293 294#endif |