--- /dev/null
+/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */\r
+/*\r
+ * Copyright (c) 1993, 1994, 1995, 1996, 1997\r
+ * The Regents of the University of California. All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ * notice, this list of conditions and the following disclaimer.\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
+ * 3. All advertising materials mentioning features or use of this software\r
+ * must display the following acknowledgement:\r
+ * This product includes software developed by the Computer Systems\r
+ * Engineering Group at Lawrence Berkeley Laboratory.\r
+ * 4. Neither the name of the University nor of the Laboratory may be used\r
+ * to endorse or promote products derived from this software without\r
+ * specific prior written permission.\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND\r
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE\r
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r
+ * SUCH DAMAGE.\r
+ *\r
+ * @(#) $Header: /tcpdump/master/libpcap/pcap/pcap.h,v 1.4.2.11 2008-10-06 15:38:39 gianluca Exp $ (LBL)\r
+ */\r
+\r
+#ifndef lib_pcap_pcap_h\r
+#define lib_pcap_pcap_h\r
+\r
+#if defined(WIN32)\r
+ #include <pcap-stdinc.h>\r
+#elif defined(MSDOS)\r
+ #include <sys/types.h>\r
+ #include <sys/socket.h> /* u_int, u_char etc. */\r
+#else /* UN*X */\r
+ #include <sys/types.h>\r
+ #include <sys/time.h>\r
+#endif /* WIN32/MSDOS/UN*X */\r
+\r
+#ifndef PCAP_DONT_INCLUDE_PCAP_BPF_H\r
+#include <pcap/bpf.h>\r
+#endif\r
+\r
+#include <stdio.h>\r
+\r
+#ifdef HAVE_REMOTE\r
+ // We have to define the SOCKET here, although it has been defined in sockutils.h\r
+ // This is to avoid the distribution of the 'sockutils.h' file around\r
+ // (for example in the WinPcap developer's pack)\r
+ #ifndef SOCKET\r
+ #ifdef WIN32\r
+ #define SOCKET unsigned int\r
+ #else\r
+ #define SOCKET int\r
+ #endif\r
+ #endif\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#define PCAP_VERSION_MAJOR 2\r
+#define PCAP_VERSION_MINOR 4\r
+\r
+#define PCAP_ERRBUF_SIZE 256\r
+\r
+/*\r
+ * Compatibility for systems that have a bpf.h that\r
+ * predates the bpf typedefs for 64-bit support.\r
+ */\r
+#if BPF_RELEASE - 0 < 199406\r
+typedef int bpf_int32;\r
+typedef u_int bpf_u_int32;\r
+#endif\r
+\r
+typedef struct pcap pcap_t;\r
+typedef struct pcap_dumper pcap_dumper_t;\r
+typedef struct pcap_if pcap_if_t;\r
+typedef struct pcap_addr pcap_addr_t;\r
+\r
+/*\r
+ * The first record in the file contains saved values for some\r
+ * of the flags used in the printout phases of tcpdump.\r
+ * Many fields here are 32 bit ints so compilers won't insert unwanted\r
+ * padding; these files need to be interchangeable across architectures.\r
+ *\r
+ * Do not change the layout of this structure, in any way (this includes\r
+ * changes that only affect the length of fields in this structure).\r
+ *\r
+ * Also, do not change the interpretation of any of the members of this\r
+ * structure, in any way (this includes using values other than\r
+ * LINKTYPE_ values, as defined in "savefile.c", in the "linktype"\r
+ * field).\r
+ *\r
+ * Instead:\r
+ *\r
+ * introduce a new structure for the new format, if the layout\r
+ * of the structure changed;\r
+ *\r
+ * send mail to "tcpdump-workers@lists.tcpdump.org", requesting\r
+ * a new magic number for your new capture file format, and, when\r
+ * you get the new magic number, put it in "savefile.c";\r
+ *\r
+ * use that magic number for save files with the changed file\r
+ * header;\r
+ *\r
+ * make the code in "savefile.c" capable of reading files with\r
+ * the old file header as well as files with the new file header\r
+ * (using the magic number to determine the header format).\r
+ *\r
+ * Then supply the changes as a patch at\r
+ *\r
+ * http://sourceforge.net/projects/libpcap/\r
+ *\r
+ * so that future versions of libpcap and programs that use it (such as\r
+ * tcpdump) will be able to read your new capture file format.\r
+ */\r
+struct pcap_file_header {\r
+ bpf_u_int32 magic;\r
+ u_short version_major;\r
+ u_short version_minor;\r
+ bpf_int32 thiszone; /* gmt to local correction */\r
+ bpf_u_int32 sigfigs; /* accuracy of timestamps */\r
+ bpf_u_int32 snaplen; /* max length saved portion of each pkt */\r
+ bpf_u_int32 linktype; /* data link type (LINKTYPE_*) */\r
+};\r
+\r
+/*\r
+ * Macros for the value returned by pcap_datalink_ext().\r
+ * \r
+ * If LT_FCS_LENGTH_PRESENT(x) is true, the LT_FCS_LENGTH(x) macro\r
+ * gives the FCS length of packets in the capture.\r
+ */\r
+#define LT_FCS_LENGTH_PRESENT(x) ((x) & 0x04000000)\r
+#define LT_FCS_LENGTH(x) (((x) & 0xF0000000) >> 28)\r
+#define LT_FCS_DATALINK_EXT(x) ((((x) & 0xF) << 28) | 0x04000000)\r
+\r
+typedef enum {\r
+ PCAP_D_INOUT = 0,\r
+ PCAP_D_IN,\r
+ PCAP_D_OUT\r
+} pcap_direction_t;\r
+\r
+/*\r
+ * Generic per-packet information, as supplied by libpcap.\r
+ *\r
+ * The time stamp can and should be a "struct timeval", regardless of\r
+ * whether your system supports 32-bit tv_sec in "struct timeval",\r
+ * 64-bit tv_sec in "struct timeval", or both if it supports both 32-bit\r
+ * and 64-bit applications. The on-disk format of savefiles uses 32-bit\r
+ * tv_sec (and tv_usec); this structure is irrelevant to that. 32-bit\r
+ * and 64-bit versions of libpcap, even if they're on the same platform,\r
+ * should supply the appropriate version of "struct timeval", even if\r
+ * that's not what the underlying packet capture mechanism supplies.\r
+ */\r
+struct pcap_pkthdr {\r
+ struct timeval ts; /* time stamp */\r
+ bpf_u_int32 caplen; /* length of portion present */\r
+ bpf_u_int32 len; /* length this packet (off wire) */\r
+};\r
+\r
+/*\r
+ * As returned by the pcap_stats()\r
+ */\r
+struct pcap_stat {\r
+ u_int ps_recv; /* number of packets received */\r
+ u_int ps_drop; /* number of packets dropped */\r
+ u_int ps_ifdrop; /* drops by interface XXX not yet supported */\r
+#ifdef HAVE_REMOTE\r
+ u_int ps_capt; /* number of packets that are received by the application; please get rid off the Win32 ifdef */\r
+ u_int ps_sent; /* number of packets sent by the server on the network */\r
+ u_int ps_netdrop; /* number of packets lost on the network */\r
+#endif /* HAVE_REMOTE */\r
+};\r
+\r
+#ifdef MSDOS\r
+/*\r
+ * As returned by the pcap_stats_ex()\r
+ */\r
+struct pcap_stat_ex {\r
+ u_long rx_packets; /* total packets received */\r
+ u_long tx_packets; /* total packets transmitted */\r
+ u_long rx_bytes; /* total bytes received */\r
+ u_long tx_bytes; /* total bytes transmitted */\r
+ u_long rx_errors; /* bad packets received */\r
+ u_long tx_errors; /* packet transmit problems */\r
+ u_long rx_dropped; /* no space in Rx buffers */\r
+ u_long tx_dropped; /* no space available for Tx */\r
+ u_long multicast; /* multicast packets received */\r
+ u_long collisions;\r
+\r
+ /* detailed rx_errors: */\r
+ u_long rx_length_errors;\r
+ u_long rx_over_errors; /* receiver ring buff overflow */\r
+ u_long rx_crc_errors; /* recv'd pkt with crc error */\r
+ u_long rx_frame_errors; /* recv'd frame alignment error */\r
+ u_long rx_fifo_errors; /* recv'r fifo overrun */\r
+ u_long rx_missed_errors; /* recv'r missed packet */\r
+\r
+ /* detailed tx_errors */\r
+ u_long tx_aborted_errors;\r
+ u_long tx_carrier_errors;\r
+ u_long tx_fifo_errors;\r
+ u_long tx_heartbeat_errors;\r
+ u_long tx_window_errors;\r
+ };\r
+#endif\r
+\r
+/*\r
+ * Item in a list of interfaces.\r
+ */\r
+struct pcap_if {\r
+ struct pcap_if *next;\r
+ char *name; /* name to hand to "pcap_open_live()" */\r
+ char *description; /* textual description of interface, or NULL */\r
+ struct pcap_addr *addresses;\r
+ bpf_u_int32 flags; /* PCAP_IF_ interface flags */\r
+};\r
+\r
+#define PCAP_IF_LOOPBACK 0x00000001 /* interface is loopback */\r
+\r
+/*\r
+ * Representation of an interface address.\r
+ */\r
+struct pcap_addr {\r
+ struct pcap_addr *next;\r
+ struct sockaddr *addr; /* address */\r
+ struct sockaddr *netmask; /* netmask for that address */\r
+ struct sockaddr *broadaddr; /* broadcast address for that address */\r
+ struct sockaddr *dstaddr; /* P2P destination address for that address */\r
+};\r
+\r
+typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,\r
+ const u_char *);\r
+\r
+/*\r
+ * Error codes for the pcap API.\r
+ * These will all be negative, so you can check for the success or\r
+ * failure of a call that returns these codes by checking for a\r
+ * negative value.\r
+ */\r
+#define PCAP_ERROR -1 /* generic error code */\r
+#define PCAP_ERROR_BREAK -2 /* loop terminated by pcap_breakloop */\r
+#define PCAP_ERROR_NOT_ACTIVATED -3 /* the capture needs to be activated */\r
+#define PCAP_ERROR_ACTIVATED -4 /* the operation can't be performed on already activated captures */\r
+#define PCAP_ERROR_NO_SUCH_DEVICE -5 /* no such device exists */\r
+#define PCAP_ERROR_RFMON_NOTSUP -6 /* this device doesn't support rfmon (monitor) mode */\r
+#define PCAP_ERROR_NOT_RFMON -7 /* operation supported only in monitor mode */\r
+#define PCAP_ERROR_PERM_DENIED -8 /* no permission to open the device */\r
+#define PCAP_ERROR_IFACE_NOT_UP -9 /* interface isn't up */\r
+\r
+/*\r
+ * Warning codes for the pcap API.\r
+ * These will all be positive and non-zero, so they won't look like\r
+ * errors.\r
+ */\r
+#define PCAP_WARNING 1 /* generic warning code */\r
+#define PCAP_WARNING_PROMISC_NOTSUP 2 /* this device doesn't support promiscuous mode */\r
+\r
+char *pcap_lookupdev(char *);\r
+int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);\r
+\r
+pcap_t *pcap_create(const char *, char *);\r
+int pcap_set_snaplen(pcap_t *, int);\r
+int pcap_set_promisc(pcap_t *, int);\r
+int pcap_can_set_rfmon(pcap_t *);\r
+int pcap_set_rfmon(pcap_t *, int);\r
+int pcap_set_timeout(pcap_t *, int);\r
+int pcap_set_buffer_size(pcap_t *, int);\r
+int pcap_activate(pcap_t *);\r
+\r
+pcap_t *pcap_open_live(const char *, int, int, int, char *);\r
+pcap_t *pcap_open_dead(int, int);\r
+pcap_t *pcap_open_offline(const char *, char *);\r
+#if defined(WIN32)\r
+pcap_t *pcap_hopen_offline(intptr_t, char *);\r
+#if !defined(LIBPCAP_EXPORTS)\r
+#define pcap_fopen_offline(f,b) \\r
+ pcap_hopen_offline(_get_osfhandle(_fileno(f)), b)\r
+#else /*LIBPCAP_EXPORTS*/\r
+static pcap_t *pcap_fopen_offline(FILE *, char *);\r
+#endif\r
+#else /*WIN32*/\r
+pcap_t *pcap_fopen_offline(FILE *, char *);\r
+#endif /*WIN32*/\r
+\r
+void pcap_close(pcap_t *);\r
+int pcap_loop(pcap_t *, int, pcap_handler, u_char *);\r
+int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *);\r
+const u_char*\r
+ pcap_next(pcap_t *, struct pcap_pkthdr *);\r
+int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **);\r
+void pcap_breakloop(pcap_t *);\r
+int pcap_stats(pcap_t *, struct pcap_stat *);\r
+int pcap_setfilter(pcap_t *, struct bpf_program *);\r
+int pcap_setdirection(pcap_t *, pcap_direction_t);\r
+int pcap_getnonblock(pcap_t *, char *);\r
+int pcap_setnonblock(pcap_t *, int, char *);\r
+int pcap_inject(pcap_t *, const void *, size_t);\r
+int pcap_sendpacket(pcap_t *, const u_char *, int);\r
+const char *pcap_statustostr(int);\r
+const char *pcap_strerror(int);\r
+char *pcap_geterr(pcap_t *);\r
+void pcap_perror(pcap_t *, char *);\r
+int pcap_compile(pcap_t *, struct bpf_program *, const char *, int,\r
+ bpf_u_int32);\r
+int pcap_compile_nopcap(int, int, struct bpf_program *,\r
+ const char *, int, bpf_u_int32);\r
+void pcap_freecode(struct bpf_program *);\r
+int pcap_offline_filter(struct bpf_program *, const struct pcap_pkthdr *,\r
+ const u_char *);\r
+int pcap_datalink(pcap_t *);\r
+int pcap_datalink_ext(pcap_t *);\r
+int pcap_list_datalinks(pcap_t *, int **);\r
+int pcap_set_datalink(pcap_t *, int);\r
+void pcap_free_datalinks(int *);\r
+int pcap_datalink_name_to_val(const char *);\r
+const char *pcap_datalink_val_to_name(int);\r
+const char *pcap_datalink_val_to_description(int);\r
+int pcap_snapshot(pcap_t *);\r
+int pcap_is_swapped(pcap_t *);\r
+int pcap_major_version(pcap_t *);\r
+int pcap_minor_version(pcap_t *);\r
+\r
+/* XXX */\r
+FILE *pcap_file(pcap_t *);\r
+int pcap_fileno(pcap_t *);\r
+\r
+pcap_dumper_t *pcap_dump_open(pcap_t *, const char *);\r
+pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp);\r
+FILE *pcap_dump_file(pcap_dumper_t *);\r
+long pcap_dump_ftell(pcap_dumper_t *);\r
+int pcap_dump_flush(pcap_dumper_t *);\r
+void pcap_dump_close(pcap_dumper_t *);\r
+void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *);\r
+\r
+int pcap_findalldevs(pcap_if_t **, char *);\r
+void pcap_freealldevs(pcap_if_t *);\r
+\r
+const char *pcap_lib_version(void);\r
+\r
+/* XXX this guy lives in the bpf tree */\r
+u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);\r
+int bpf_validate(const struct bpf_insn *f, int len);\r
+char *bpf_image(const struct bpf_insn *, int);\r
+void bpf_dump(const struct bpf_program *, int);\r
+\r
+#if defined(WIN32)\r
+\r
+/*\r
+ * Win32 definitions\r
+ */\r
+\r
+int pcap_setbuff(pcap_t *p, int dim);\r
+int pcap_setmode(pcap_t *p, int mode);\r
+int pcap_setmintocopy(pcap_t *p, int size);\r
+\r
+#ifdef WPCAP\r
+/* Include file with the wpcap-specific extensions */\r
+#include <Win32-Extensions.h>\r
+#endif /* WPCAP */\r
+\r
+#define MODE_CAPT 0\r
+#define MODE_STAT 1\r
+#define MODE_MON 2\r
+\r
+#elif defined(MSDOS)\r
+\r
+/*\r
+ * MS-DOS definitions\r
+ */\r
+\r
+int pcap_stats_ex (pcap_t *, struct pcap_stat_ex *);\r
+void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait);\r
+u_long pcap_mac_packets (void);\r
+\r
+#else /* UN*X */\r
+\r
+/*\r
+ * UN*X definitions\r
+ */\r
+\r
+int pcap_get_selectable_fd(pcap_t *);\r
+\r
+#endif /* WIN32/MSDOS/UN*X */\r
+\r
+#ifdef HAVE_REMOTE\r
+/* Includes most of the public stuff that is needed for the remote capture */\r
+#include <remote-ext.h>\r
+#endif /* HAVE_REMOTE */\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif\r