add winpcap 4.0.2 from url http://www.winpcap.org/
[natblaster.git] / winpcap / dox / libpcap / incs / pcap.h
blobdb764052b78d674b3bec8a9fb8c63b3fa4482a89
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.
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.
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.
34 * @(#) $Header: /usr/cvsroot_private/winpcap/dox/libpcap/incs/pcap.h,v 1.5 2005/11/30 21:48:23 gianlucav Exp $ (LBL)
38 /** @defgroup wpcap_def Definitions
39 * @ingroup wpcap
40 * Definitions for wpcap.dll
41 * @{
44 #ifndef lib_pcap_h
45 #define lib_pcap_h
47 #include <pcap-stdinc.h>
48 #include <net/bpf.h>
50 #include <stdio.h>
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
56 #define PCAP_VERSION_MAJOR 2 ///< Major libpcap dump file version.
57 #define PCAP_VERSION_MINOR 4 ///< Minor libpcap dump file version.
59 #define PCAP_ERRBUF_SIZE 256 ///< Size to use when allocating the buffer that contains the libpcap errors.
61 /*!
62 * Compatibility for systems that have a bpf.h that
63 * predates the bpf typedefs for 64-bit support.
65 #if BPF_RELEASE - 0 < 199406
66 typedef int bpf_int32; ///< 32-bit integer
67 typedef u_int bpf_u_int32; ///< 32-bit unsigned integer
68 #endif
70 typedef struct pcap pcap_t; ///< Descriptor of an open capture instance. This structure is \b opaque to the user, that handles its content through the functions provided by wpcap.dll.
71 typedef struct pcap_dumper pcap_dumper_t; ///< libpcap savefile descriptor.
72 typedef struct pcap_if pcap_if_t; ///< Item in a list of interfaces, see pcap_if
73 typedef struct pcap_addr pcap_addr_t; ///< Representation of an interface address, see pcap_addr
75 /*! \brief Header of a libpcap dump file.
77 * The first record in the file contains saved values for some
78 * of the flags used in the printout phases of tcpdump.
79 * Many fields here are 32 bit ints so compilers won't insert unwanted
80 * padding; these files need to be interchangeable across architectures.
82 * Do not change the layout of this structure, in any way (this includes
83 * changes that only affect the length of fields in this structure).
85 * Also, do not change the interpretation of any of the members of this
86 * structure, in any way (this includes using values other than
87 * LINKTYPE_ values, as defined in "savefile.c", in the "linktype"
88 * field).
90 * Instead:
92 * introduce a new structure for the new format, if the layout
93 * of the structure changed;
95 * send mail to "tcpdump-workers@tcpdump.org", requesting a new
96 * magic number for your new capture file format, and, when
97 * you get the new magic number, put it in "savefile.c";
99 * use that magic number for save files with the changed file
100 * header;
102 * make the code in "savefile.c" capable of reading files with
103 * the old file header as well as files with the new file header
104 * (using the magic number to determine the header format).
106 * Then supply the changes to "patches@tcpdump.org", so that future
107 * versions of libpcap and programs that use it (such as tcpdump) will
108 * be able to read your new capture file format.
110 struct pcap_file_header {
111 bpf_u_int32 magic;
112 u_short version_major; ///< Libpcap major version.
113 u_short version_minor; ///< Libpcap minor version.
114 bpf_int32 thiszone; ///< gmt to local correction
115 bpf_u_int32 sigfigs; ///< accuracy of timestamps
116 bpf_u_int32 snaplen; ///< max length saved portion of each pkt
117 bpf_u_int32 linktype; ///< data link type (LINKTYPE_*)
120 /*! \brief Header of a packet in the dump file.
122 * Each packet in the dump file is prepended with this generic header.
123 * This gets around the problem of different headers for different
124 * packet interfaces.
126 struct pcap_pkthdr {
127 struct timeval ts; ///< time stamp
128 bpf_u_int32 caplen; ///< length of portion present
129 bpf_u_int32 len; ///< length this packet (off wire)
132 /*! \brief Structure that keeps statistical values on an interface.
134 * As returned by the pcap_stats()
136 struct pcap_stat {
137 u_int ps_recv; ///< number of packets transited on the network
138 u_int ps_drop; ///< number of packets dropped by the driver
139 u_int ps_ifdrop; ///< drops by interface, not yet supported
140 #ifdef WIN32
141 u_int bs_capt; ///< <b>Win32 specific.</b> number of packets captured, i.e number of packets that are accepted by the filter, that find place in the kernel buffer and therefore that actually reach the application. For backward compatibility, pcap_stats() does not fill this member, so use pcap_stats_ex() to get it.
142 #endif /* WIN32 */
145 /*! \brief
146 * Item in a list of interfaces, used by pcap_findalldevs().
148 struct pcap_if {
149 struct pcap_if *next; ///< if not NULL, a pointer to the next element in the list; NULL for the last element of the list
150 char *name; ///< a pointer to a string giving a name for the device to pass to pcap_open_live()
151 char *description; ///< if not NULL, a pointer to a string giving a human-readable description of the device
152 struct pcap_addr *addresses; ///< a pointer to the first element of a list of addresses for the interface
153 u_int flags; ///< PCAP_IF_ interface flags. Currently the only possible flag is \b PCAP_IF_LOOPBACK, that is set if the interface is a loopback interface.
156 #define PCAP_IF_LOOPBACK 0x00000001 ///< interface is loopback
158 /*! \brief
159 * Representation of an interface address, used by pcap_findalldevs().
161 struct pcap_addr {
162 struct pcap_addr *next; ///< if not NULL, a pointer to the next element in the list; NULL for the last element of the list
163 struct sockaddr *addr; ///< a pointer to a struct sockaddr containing an address
164 struct sockaddr *netmask; ///< if not NULL, a pointer to a struct sockaddr that contains the netmask corresponding to the address pointed to by addr.
165 struct sockaddr *broadaddr; ///< if not NULL, a pointer to a struct sockaddr that contains the broadcast address correĀ­ sponding to the address pointed to by addr; may be null if the interface doesn't support broadcasts
166 struct sockaddr *dstaddr; ///< if not NULL, a pointer to a struct sockaddr that contains the destination address correĀ­ sponding to the address pointed to by addr; may be null if the interface isn't a point- to-point interface
169 #if defined(WIN32)
172 #define MODE_CAPT 0 ///< Capture mode, to be used when calling pcap_setmode()
173 #define MODE_STAT 1 ///< Statistical mode, to be used when calling pcap_setmode()
175 #endif /* WIN32 */
177 #ifdef __cplusplus
179 #endif
181 #endif
184 * @}