1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-11 02:09:03 +00:00

Windoze just about working

This commit is contained in:
fyodor
2005-08-09 04:20:34 +00:00
parent bdf2caa2a4
commit a33bfd5f26
10 changed files with 299 additions and 1451 deletions

View File

@@ -1,4 +1,4 @@
/* @(#) $Header$ (LBL) */ /* @(#) $Header: /tcpdump/master/libpcap/Win32/Include/Gnuc.h,v 1.1 2002/08/01 08:33:05 risso Exp $ (LBL) */
/* Define __P() macro, if necessary */ /* Define __P() macro, if necessary */

File diff suppressed because it is too large Load Diff

View File

@@ -120,7 +120,8 @@ typedef struct NetType
The program will be injected in the kernel by the PacketSetBPF() function and applied to every incoming packet. The program will be injected in the kernel by the PacketSetBPF() function and applied to every incoming packet.
*/ */
struct bpf_program { struct bpf_program
{
UINT bf_len; ///< Indicates the number of instructions of the program, i.e. the number of struct bpf_insn that will follow. UINT bf_len; ///< Indicates the number of instructions of the program, i.e. the number of struct bpf_insn that will follow.
struct bpf_insn *bf_insns; ///< A pointer to the first instruction of the program. struct bpf_insn *bf_insns; ///< A pointer to the first instruction of the program.
}; };
@@ -130,7 +131,8 @@ struct bpf_program {
bpf_insn contains a single instruction for the BPF register-machine. It is used to send a filter program to the driver. bpf_insn contains a single instruction for the BPF register-machine. It is used to send a filter program to the driver.
*/ */
struct bpf_insn { struct bpf_insn
{
USHORT code; ///< Instruction type and addressing mode. USHORT code; ///< Instruction type and addressing mode.
UCHAR jt; ///< Jump if true UCHAR jt; ///< Jump if true
UCHAR jf; ///< Jump if false UCHAR jf; ///< Jump if false
@@ -142,7 +144,8 @@ struct bpf_insn {
It is used by packet.dll to return statistics about a capture session. It is used by packet.dll to return statistics about a capture session.
*/ */
struct bpf_stat { struct bpf_stat
{
UINT bs_recv; ///< Number of packets that the driver received from the network adapter UINT bs_recv; ///< Number of packets that the driver received from the network adapter
///< from the beginning of the current capture. This value includes the packets ///< from the beginning of the current capture. This value includes the packets
///< lost by the driver. ///< lost by the driver.
@@ -159,7 +162,8 @@ struct bpf_stat {
This structure defines the header associated with every packet delivered to the application. This structure defines the header associated with every packet delivered to the application.
*/ */
struct bpf_hdr { struct bpf_hdr
{
struct timeval bh_tstamp; ///< The timestamp associated with the captured packet. struct timeval bh_tstamp; ///< The timestamp associated with the captured packet.
///< It is stored in a TimeVal structure. ///< It is stored in a TimeVal structure.
UINT bh_caplen; ///< Length of captured portion. The captured portion <b>can be different</b> UINT bh_caplen; ///< Length of captured portion. The captured portion <b>can be different</b>
@@ -220,6 +224,8 @@ typedef WAN_ADAPTER *PWAN_ADAPTER; ///< Describes an opened wan (dialup, VPN...)
#define INFO_FLAG_NDISWAN_ADAPTER 1 ///< Flag for ADAPTER_INFO: this is a NdisWan adapter #define INFO_FLAG_NDISWAN_ADAPTER 1 ///< Flag for ADAPTER_INFO: this is a NdisWan adapter
#define INFO_FLAG_DAG_CARD 2 ///< Flag for ADAPTER_INFO: this is a DAG card #define INFO_FLAG_DAG_CARD 2 ///< Flag for ADAPTER_INFO: this is a DAG card
#define INFO_FLAG_DAG_FILE 6 ///< Flag for ADAPTER_INFO: this is a DAG file #define INFO_FLAG_DAG_FILE 6 ///< Flag for ADAPTER_INFO: this is a DAG file
#define INFO_FLAG_DONT_EXPORT 8 ///< Flag for ADAPTER_INFO: when this flag is set, the adapter will not be listed or openend by winpcap. This allows to prevent exporting broken network adapters, like for example FireWire ones.
/*! /*!
\brief Contains comprehensive information about a network adapter. \brief Contains comprehensive information about a network adapter.
@@ -363,12 +369,17 @@ extern "C" {
* @} * @}
*/ */
// The following is used to check the adapter name in PacketOpenAdapterNPF and prevent
// opening of firewire adapters
#define FIREWIRE_SUBSTR L"1394"
void PacketPopulateAdaptersInfoList(); void PacketPopulateAdaptersInfoList();
PWCHAR SChar2WChar(PCHAR string); PWCHAR SChar2WChar(PCHAR string);
PCHAR WChar2SChar(PWCHAR string); PCHAR WChar2SChar(PWCHAR string);
BOOL PacketGetFileVersion(LPTSTR FileName, PCHAR VersionBuff, UINT VersionBuffLen); BOOL PacketGetFileVersion(LPTSTR FileName, PCHAR VersionBuff, UINT VersionBuffLen);
PADAPTER_INFO PacketFindAdInfo(PCHAR AdapterName); PADAPTER_INFO PacketFindAdInfo(PCHAR AdapterName);
BOOLEAN PacketUpdateAdInfo(PCHAR AdapterName); BOOLEAN PacketUpdateAdInfo(PCHAR AdapterName);
BOOLEAN IsFireWire(TCHAR *AdapterDesc);
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -83,4 +83,53 @@ typedef signed short int32_t;
#endif /* HAVE_U_INT32_T */ #endif /* HAVE_U_INT32_T */
#ifndef HAVE_U_INT64_T
#if SIZEOF_LONG_LONG == 8
typedef unsigned long long u_int64_t;
#elif defined(_MSC_EXTENSIONS)
typedef unsigned _int64 u_int64_t;
#elif SIZEOF_INT == 8
typedef unsigned int u_int64_t;
#elif SIZEOF_LONG == 8
typedef unsigned long u_int64_t;
#elif SIZEOF_SHORT == 8
typedef unsigned short u_int64_t;
#else /* XXX */
#error "there's no appropriate type for u_int64_t"
#endif
#endif /* HAVE_U_INT64_T */
#ifndef PRId64
#ifdef _MSC_EXTENSIONS
#define PRId64 "I64d"
#else /* _MSC_EXTENSIONS */
#define PRId64 "lld"
#endif /* _MSC_EXTENSIONS */
#endif /* PRId64 */
#ifndef PRIo64
#ifdef _MSC_EXTENSIONS
#define PRIo64 "I64o"
#else /* _MSC_EXTENSIONS */
#define PRIo64 "llo"
#endif /* _MSC_EXTENSIONS */
#endif /* PRIo64 */
#ifndef PRIx64
#ifdef _MSC_EXTENSIONS
#define PRIx64 "I64x"
#else /* _MSC_EXTENSIONS */
#define PRIx64 "llx"
#endif /* _MSC_EXTENSIONS */
#endif /* PRIx64 */
#ifndef PRIu64
#ifdef _MSC_EXTENSIONS
#define PRIu64 "I64u"
#else /* _MSC_EXTENSIONS */
#define PRIu64 "llu"
#endif /* _MSC_EXTENSIONS */
#endif /* PRIu64 */
#endif /* _BITTYPES_H */ #endif /* _BITTYPES_H */

View File

@@ -18,7 +18,7 @@
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* *
* @(#) $Header$ (LBL) * @(#) $Header: /tcpdump/master/libpcap/Win32/Include/ip6_misc.h,v 1.4 2004/07/06 23:45:29 risso Exp $ (LBL)
*/ */
/* /*
@@ -58,8 +58,12 @@ struct in6_addr
#endif /* __MINGW32__ */ #endif /* __MINGW32__ */
#ifdef __MINGW32__ #if (defined WIN32) || (defined __MINGW32__)
typedef unsigned short sa_family_t; typedef unsigned short sa_family_t;
#endif
#ifdef __MINGW32__
#define __SOCKADDR_COMMON(sa_prefix) \ #define __SOCKADDR_COMMON(sa_prefix) \
sa_family_t sa_prefix##family sa_family_t sa_prefix##family

View File

@@ -37,7 +37,7 @@
* *
* @(#)bpf.h 7.1 (Berkeley) 5/7/91 * @(#)bpf.h 7.1 (Berkeley) 5/7/91
* *
* @(#) $Header$ (LBL) * @(#) $Header: /tcpdump/master/libpcap/pcap-bpf.h,v 1.34.2.5 2005/05/27 23:33:00 guy Exp $ (LBL)
*/ */
/* /*
@@ -60,8 +60,13 @@ extern "C" {
/* BSD style release date */ /* BSD style release date */
#define BPF_RELEASE 199606 #define BPF_RELEASE 199606
#ifdef MSDOS /* must be 32-bit */
typedef long bpf_int32;
typedef unsigned long bpf_u_int32;
#else
typedef int bpf_int32; typedef int bpf_int32;
typedef u_int bpf_u_int32; typedef u_int bpf_u_int32;
#endif
/* /*
* Alignment macros. BPF_WORDALIGN rounds up to the next * Alignment macros. BPF_WORDALIGN rounds up to the next
@@ -121,7 +126,7 @@ struct bpf_version {
* These are the types that are the same on all platforms, and that * These are the types that are the same on all platforms, and that
* have been defined by <net/bpf.h> for ages. * have been defined by <net/bpf.h> for ages.
*/ */
#define DLT_NULL 0 /* no link-layer encapsulation */ #define DLT_NULL 0 /* BSD loopback encapsulation */
#define DLT_EN10MB 1 /* Ethernet (10Mb) */ #define DLT_EN10MB 1 /* Ethernet (10Mb) */
#define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */ #define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */
#define DLT_AX25 3 /* Amateur Radio AX.25 */ #define DLT_AX25 3 /* Amateur Radio AX.25 */
@@ -142,7 +147,7 @@ struct bpf_version {
* XXX - DLT_ATM_RFC1483 is 13 in BSD/OS, and DLT_RAW is 14 in BSD/OS, * XXX - DLT_ATM_RFC1483 is 13 in BSD/OS, and DLT_RAW is 14 in BSD/OS,
* but I don't know what the right #define is for BSD/OS. * but I don't know what the right #define is for BSD/OS.
*/ */
#define DLT_ATM_RFC1483 11 /* LLC/SNAP encapsulated atm */ #define DLT_ATM_RFC1483 11 /* LLC-encapsulated ATM */
#ifdef __OpenBSD__ #ifdef __OpenBSD__
#define DLT_RAW 14 /* raw IP */ #define DLT_RAW 14 /* raw IP */
@@ -174,6 +179,12 @@ struct bpf_version {
#define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */ #define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */
/*
* Apparently Redback uses this for its SmartEdge 400/800. I hope
* nobody else decided to use it, too.
*/
#define DLT_REDBACK_SMARTEDGE 32
/* /*
* These values are defined by NetBSD; other platforms should refrain from * These values are defined by NetBSD; other platforms should refrain from
* using them for other purposes, so that NetBSD savefiles with link * using them for other purposes, so that NetBSD savefiles with link
@@ -350,10 +361,11 @@ struct bpf_version {
#define DLT_AURORA 126 /* Xilinx Aurora link layer */ #define DLT_AURORA 126 /* Xilinx Aurora link layer */
/* /*
* BSD header for 802.11 plus a number of bits of link-layer information * Header for 802.11 plus a number of bits of link-layer information
* including radio information. * including radio information, used by some recent BSD drivers as
* well as the madwifi Atheros driver for Linux.
*/ */
#define DLT_IEEE802_11_RADIO 127 /* 802.11 plus BSD radio header */ #define DLT_IEEE802_11_RADIO 127 /* 802.11 plus radiotap radio header */
/* /*
* Reserved for the TZSP encapsulation, as per request from * Reserved for the TZSP encapsulation, as per request from
@@ -411,11 +423,16 @@ struct bpf_version {
#define DLT_APPLE_IP_OVER_IEEE1394 138 #define DLT_APPLE_IP_OVER_IEEE1394 138
/* /*
* 139 through 142 are reserved for SS7. * Various SS7 encapsulations, as per a request from Jeff Morriss
* <jeff.morriss[AT]ulticom.com> and subsequent discussions.
*/ */
#define DLT_MTP2_WITH_PHDR 139 /* pseudo-header with various info, followed by MTP2 */
#define DLT_MTP2 140 /* MTP2, without pseudo-header */
#define DLT_MTP3 141 /* MTP3, without pseudo-header or MTP2 */
#define DLT_SCCP 142 /* SCCP, without pseudo-header or MTP2 or MTP3 */
/* /*
* Reserved for DOCSIS MAC frames. * DOCSIS MAC frames.
*/ */
#define DLT_DOCSIS 143 #define DLT_DOCSIS 143
@@ -491,8 +508,8 @@ struct bpf_version {
* *
* http://www.shaftnet.org/~pizza/software/capturefrm.txt * http://www.shaftnet.org/~pizza/software/capturefrm.txt
* *
* but could and arguably should also be used by non-AVS Linux * but it might be used by some non-AVS drivers now or in the
* 802.11 drivers; that may happen in the future. * future.
*/ */
#define DLT_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */ #define DLT_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */
@@ -504,6 +521,78 @@ struct bpf_version {
*/ */
#define DLT_JUNIPER_MONITOR 164 #define DLT_JUNIPER_MONITOR 164
/*
* Reserved for BACnet MS/TP.
*/
#define DLT_BACNET_MS_TP 165
/*
* Another PPP variant as per request from Karsten Keil <kkeil@suse.de>.
*
* This is used in some OSes to allow a kernel socket filter to distinguish
* between incoming and outgoing packets, on a socket intended to
* supply pppd with outgoing packets so it can do dial-on-demand and
* hangup-on-lack-of-demand; incoming packets are filtered out so they
* don't cause pppd to hold the connection up (you don't want random
* input packets such as port scans, packets from old lost connections,
* etc. to force the connection to stay up).
*
* The first byte of the PPP header (0xff03) is modified to accomodate
* the direction - 0x00 = IN, 0x01 = OUT.
*/
#define DLT_PPP_PPPD 166
/*
* Names for backwards compatibility with older versions of some PPP
* software; new software should use DLT_PPP_PPPD.
*/
#define DLT_PPP_WITH_DIRECTION DLT_PPP_PPPD
#define DLT_LINUX_PPP_WITHDIRECTION DLT_PPP_PPPD
/*
* Juniper-private data link type, as per request from
* Hannes Gredler <hannes@juniper.net>. The DLT_s are used
* for passing on chassis-internal metainformation such as
* QOS profiles, cookies, etc..
*/
#define DLT_JUNIPER_PPPOE 167
#define DLT_JUNIPER_PPPOE_ATM 168
#define DLT_GPRS_LLC 169 /* GPRS LLC */
#define DLT_GPF_T 170 /* GPF-T (ITU-T G.7041/Y.1303) */
#define DLT_GPF_F 171 /* GPF-F (ITU-T G.7041/Y.1303) */
/*
* Requested by Oolan Zimmer <oz@gcom.com> for use in Gcom's T1/E1 line
* monitoring equipment.
*/
#define DLT_GCOM_T1E1 172
#define DLT_GCOM_SERIAL 173
/*
* Juniper-private data link type, as per request from
* Hannes Gredler <hannes@juniper.net>. The DLT_ is used
* for internal communication to Physical Interface Cards (PIC)
*/
#define DLT_JUNIPER_PIC_PEER 174
/*
* Link types requested by Gregor Maier <gregor@endace.com> of Endace
* Measurement Systems. They add an ERF header (see
* http://www.endace.com/support/EndaceRecordFormat.pdf) in front of
* the link-layer header.
*/
#define DLT_ERF_ETH 175 /* Ethernet */
#define DLT_ERF_POS 176 /* Packet-over-SONET */
/*
* Requested by Daniele Orlandi <daniele@orlandi.com> for raw LAPD
* for vISDN (http://www.orlandi.com/visdn/). Its link-layer header
* includes additional information before the LAPD header, so it's
* not necessarily a generic LAPD header.
*/
#define DLT_LINUX_LAPD 177
/* /*
* The instruction encodings. * The instruction encodings.
*/ */

View File

@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#) $Header$ (LBL) * @(#) $Header: /tcpdump/master/libpcap/pcap-int.h,v 1.68.2.6 2005/07/07 06:56:04 guy Exp $ (LBL)
*/ */
#ifndef pcap_int_h #ifndef pcap_int_h
@@ -46,6 +46,11 @@ extern "C" {
#include <packet32.h> #include <packet32.h>
#endif /* WIN32 */ #endif /* WIN32 */
#ifdef MSDOS
#include <fcntl.h>
#include <io.h>
#endif
/* /*
* Savefile * Savefile
*/ */
@@ -74,23 +79,33 @@ struct pcap_md {
u_long TotDrops; /* count of dropped packets */ u_long TotDrops; /* count of dropped packets */
long TotMissed; /* missed by i/f during this run */ long TotMissed; /* missed by i/f during this run */
long OrigMissed; /* missed by i/f before this run */ long OrigMissed; /* missed by i/f before this run */
char *device; /* device name */
#ifdef linux #ifdef linux
int sock_packet; /* using Linux 2.0 compatible interface */ int sock_packet; /* using Linux 2.0 compatible interface */
int timeout; /* timeout specified to pcap_open_live */ int timeout; /* timeout specified to pcap_open_live */
int clear_promisc; /* must clear promiscuous mode when we close */ int clear_promisc; /* must clear promiscuous mode when we close */
int cooked; /* using SOCK_DGRAM rather than SOCK_RAW */ int cooked; /* using SOCK_DGRAM rather than SOCK_RAW */
int ifindex; /* interface index of device we're bound to */
int lo_ifindex; /* interface index of the loopback device */ int lo_ifindex; /* interface index of the loopback device */
char *device; /* device name */
struct pcap *next; /* list of open promiscuous sock_packet pcaps */ struct pcap *next; /* list of open promiscuous sock_packet pcaps */
#endif #endif
#ifdef HAVE_DAG_API #ifdef HAVE_DAG_API
#ifdef HAVE_DAG_STREAMS_API
u_char *dag_mem_bottom; /* DAG card current memory bottom pointer */
u_char *dag_mem_top; /* DAG card current memory top pointer */
#else
void *dag_mem_base; /* DAG card memory base address */ void *dag_mem_base; /* DAG card memory base address */
u_int dag_mem_bottom; /* DAG card current memory bottom pointer */ u_int dag_mem_bottom; /* DAG card current memory bottom offset */
u_int dag_mem_top; /* DAG card current memory top pointer */ u_int dag_mem_top; /* DAG card current memory top offset */
#endif /* HAVE_DAG_STREAMS_API */
int dag_fcs_bits; /* Number of checksum bits from link layer */ int dag_fcs_bits; /* Number of checksum bits from link layer */
int dag_offset_flags; /* Flags to pass to dag_offset(). */ int dag_offset_flags; /* Flags to pass to dag_offset(). */
#endif int dag_stream; /* DAG stream number */
int dag_timeout; /* timeout specified to pcap_open_live.
* Same as in linux above, introduce
* generally? */
#endif /* HAVE_DAG_API */
#ifdef HAVE_REMOTE #ifdef HAVE_REMOTE
/*! /*!
@@ -124,6 +139,14 @@ struct pcap_md {
#endif /* HAVE_REMOTE */ #endif /* HAVE_REMOTE */
}; };
/*
* 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
* Tru64 UNIX, and NetBSD pad to make everything line up on a nice boundary.
*/
#if defined(ultrix) || defined(__osf__) || (defined(__NetBSD__) && __NetBSD_Version__ > 106000000)
#define PCAP_FDDIPAD 3
#endif
struct pcap { struct pcap {
#ifdef WIN32 #ifdef WIN32
ADAPTER *adapter; ADAPTER *adapter;
@@ -133,6 +156,7 @@ struct pcap {
#else #else
int fd; int fd;
int selectable_fd; int selectable_fd;
int send_fd;
#endif /* WIN32 */ #endif /* WIN32 */
int snapshot; int snapshot;
int linktype; int linktype;
@@ -141,6 +165,15 @@ struct pcap {
int break_loop; /* flag set to force break from packet-reading loop */ int break_loop; /* flag set to force break from packet-reading loop */
#ifdef PCAP_FDDIPAD
int fddipad;
#endif
#ifdef MSDOS
int inter_packet_wait; /* offline: wait between packets */
void (*wait_proc)(void); /* call proc while waiting */
#endif
struct pcap_sf sf; struct pcap_sf sf;
struct pcap_md md; struct pcap_md md;
@@ -157,11 +190,16 @@ struct pcap {
*/ */
u_char *pkt; u_char *pkt;
/* We're accepting only packets in this direction/these directions. */
pcap_direction_t direction;
/* /*
* Methods. * Methods.
*/ */
int (*read_op)(pcap_t *, int cnt, pcap_handler, u_char *); int (*read_op)(pcap_t *, int cnt, pcap_handler, u_char *);
int (*inject_op)(pcap_t *, const void *, size_t);
int (*setfilter_op)(pcap_t *, struct bpf_program *); int (*setfilter_op)(pcap_t *, struct bpf_program *);
int (*setdirection_op)(pcap_t *, pcap_direction_t);
int (*set_datalink_op)(pcap_t *, int); int (*set_datalink_op)(pcap_t *, int);
int (*getnonblock_op)(pcap_t *, char *); int (*getnonblock_op)(pcap_t *, char *);
int (*setnonblock_op)(pcap_t *, int, char *); int (*setnonblock_op)(pcap_t *, int, char *);
@@ -175,7 +213,7 @@ struct pcap {
char errbuf[PCAP_ERRBUF_SIZE + 1]; char errbuf[PCAP_ERRBUF_SIZE + 1];
int dlt_count; int dlt_count;
int *dlt_list; u_int *dlt_list;
struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */ struct pcap_pkthdr pcap_header; /* This is needed for the pcap_next_ex() to work */
@@ -268,15 +306,6 @@ int yylex(void);
int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *); int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *); int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
/*
* 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
* Tru64 UNIX, and NetBSD pad to make everything line up on a nice boundary.
*/
#if defined(ultrix) || defined(__osf__) || defined(__NetBSD__)
#define PCAP_FDDIPAD 3
#endif
#ifndef HAVE_STRLCPY #ifndef HAVE_STRLCPY
#define strlcpy(x, y, z) \ #define strlcpy(x, y, z) \
(strncpy((x), (y), (z)), \ (strncpy((x), (y), (z)), \
@@ -299,11 +328,13 @@ extern int vsnprintf (char *, size_t, const char *, va_list ap);
/* /*
* Routines that most pcap implementations can use for non-blocking mode. * Routines that most pcap implementations can use for non-blocking mode.
*/ */
#ifndef WIN32 #if !defined(WIN32) && !defined(MSDOS)
int pcap_getnonblock_fd(pcap_t *, char *); int pcap_getnonblock_fd(pcap_t *, char *);
int pcap_setnonblock_fd(pcap_t *p, int, char *); int pcap_setnonblock_fd(pcap_t *p, int, char *);
#endif #endif
void pcap_close_common(pcap_t *);
/* /*
* Internal interfaces for "pcap_findalldevs()". * Internal interfaces for "pcap_findalldevs()".
* *
@@ -314,10 +345,10 @@ int pcap_setnonblock_fd(pcap_t *p, int, char *);
* "pcap_add_if()" adds an interface to the list of interfaces. * "pcap_add_if()" adds an interface to the list of interfaces.
*/ */
int pcap_platform_finddevs(pcap_if_t **, char *); int pcap_platform_finddevs(pcap_if_t **, char *);
int add_addr_to_iflist(pcap_if_t **, char *, u_int, struct sockaddr *, int add_addr_to_iflist(pcap_if_t **, const char *, u_int, struct sockaddr *,
size_t, struct sockaddr *, size_t, struct sockaddr *, size_t, size_t, struct sockaddr *, size_t, struct sockaddr *, size_t,
struct sockaddr *, size_t, char *); struct sockaddr *, size_t, char *);
int pcap_add_if(pcap_if_t **, char *, u_int, const char *, char *); int pcap_add_if(pcap_if_t **, const char *, u_int, const char *, char *);
struct sockaddr *dup_sockaddr(struct sockaddr *, size_t); struct sockaddr *dup_sockaddr(struct sockaddr *, size_t);
int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int, int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int,
const char *, char *); const char *, char *);
@@ -326,9 +357,6 @@ int add_or_find_if(pcap_if_t **, pcap_if_t **, const char *, u_int,
char *pcap_win32strerror(void); char *pcap_win32strerror(void);
#endif #endif
/* XXX */
extern int pcap_fddipad;
int install_bpf_program(pcap_t *, struct bpf_program *); int install_bpf_program(pcap_t *, struct bpf_program *);
int pcap_strcasecmp(const char *, const char *); int pcap_strcasecmp(const char *, const char *);

View File

@@ -33,6 +33,10 @@
#define SIZEOF_CHAR 1 #define SIZEOF_CHAR 1
#define SIZEOF_SHORT 2 #define SIZEOF_SHORT 2
#define SIZEOF_INT 4 #define SIZEOF_INT 4
#ifndef _MSC_EXTENSIONS
#define SIZEOF_LONG_LONG 8
#endif
/* /*
* Avoids a compiler warning in case this was already defined * Avoids a compiler warning in case this was already defined

View File

@@ -31,18 +31,21 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#) $Header$ (LBL) * @(#) $Header: /tcpdump/master/libpcap/pcap.h,v 1.52.2.5 2005/07/07 02:04:36 guy Exp $ (LBL)
*/ */
#ifndef lib_pcap_h #ifndef lib_pcap_h
#define lib_pcap_h #define lib_pcap_h
#ifdef WIN32 #if defined(WIN32)
#include <pcap-stdinc.h> #include <pcap-stdinc.h>
#else /* WIN32 */ #elif defined(MSDOS)
#include <sys/types.h>
#include <sys/socket.h> /* u_int, u_char etc. */
#else /* UN*X */
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#endif /* WIN32 */ #endif /* WIN32/MSDOS/UN*X */
#ifndef PCAP_DONT_INCLUDE_PCAP_BPF_H #ifndef PCAP_DONT_INCLUDE_PCAP_BPF_H
#include <pcap-bpf.h> #include <pcap-bpf.h>
@@ -130,6 +133,12 @@ struct pcap_file_header {
bpf_u_int32 linktype; /* data link type (LINKTYPE_*) */ bpf_u_int32 linktype; /* data link type (LINKTYPE_*) */
}; };
typedef enum {
PCAP_D_INOUT = 0,
PCAP_D_IN,
PCAP_D_OUT
} pcap_direction_t;
/* /*
* Each packet in the dump file is prepended with this generic header. * Each packet in the dump file is prepended with this generic header.
* This gets around the problem of different headers for different * This gets around the problem of different headers for different
@@ -155,6 +164,39 @@ struct pcap_stat {
#endif /* HAVE_REMOTE */ #endif /* HAVE_REMOTE */
}; };
#ifdef MSDOS
/*
* As returned by the pcap_stats_ex()
*/
struct pcap_stat_ex {
u_long rx_packets; /* total packets received */
u_long tx_packets; /* total packets transmitted */
u_long rx_bytes; /* total bytes received */
u_long tx_bytes; /* total bytes transmitted */
u_long rx_errors; /* bad packets received */
u_long tx_errors; /* packet transmit problems */
u_long rx_dropped; /* no space in Rx buffers */
u_long tx_dropped; /* no space available for Tx */
u_long multicast; /* multicast packets received */
u_long collisions;
/* detailed rx_errors: */
u_long rx_length_errors;
u_long rx_over_errors; /* receiver ring buff overflow */
u_long rx_crc_errors; /* recv'd pkt with crc error */
u_long rx_frame_errors; /* recv'd frame alignment error */
u_long rx_fifo_errors; /* recv'r fifo overrun */
u_long rx_missed_errors; /* recv'r missed packet */
/* detailed tx_errors */
u_long tx_aborted_errors;
u_long tx_carrier_errors;
u_long tx_fifo_errors;
u_long tx_heartbeat_errors;
u_long tx_window_errors;
};
#endif
/* /*
* Item in a list of interfaces. * Item in a list of interfaces.
*/ */
@@ -187,6 +229,7 @@ int pcap_lookupnet(const char *, bpf_u_int32 *, bpf_u_int32 *, char *);
pcap_t *pcap_open_live(const char *, int, int, int, char *); pcap_t *pcap_open_live(const char *, int, int, int, char *);
pcap_t *pcap_open_dead(int, int); pcap_t *pcap_open_dead(int, int);
pcap_t *pcap_open_offline(const char *, char *); pcap_t *pcap_open_offline(const char *, char *);
pcap_t *pcap_fopen_offline(FILE *, char *);
void pcap_close(pcap_t *); void pcap_close(pcap_t *);
int pcap_loop(pcap_t *, int, pcap_handler, u_char *); int pcap_loop(pcap_t *, int, pcap_handler, u_char *);
int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *); int pcap_dispatch(pcap_t *, int, pcap_handler, u_char *);
@@ -196,9 +239,12 @@ int pcap_next_ex(pcap_t *, struct pcap_pkthdr **, const u_char **);
void pcap_breakloop(pcap_t *); void pcap_breakloop(pcap_t *);
int pcap_stats(pcap_t *, struct pcap_stat *); int pcap_stats(pcap_t *, struct pcap_stat *);
int pcap_setfilter(pcap_t *, struct bpf_program *); int pcap_setfilter(pcap_t *, struct bpf_program *);
int pcap_setdirection(pcap_t *, pcap_direction_t);
int pcap_getnonblock(pcap_t *, char *); int pcap_getnonblock(pcap_t *, char *);
int pcap_setnonblock(pcap_t *, int, char *); int pcap_setnonblock(pcap_t *, int, char *);
void pcap_perror(pcap_t *, char *); void pcap_perror(pcap_t *, char *);
int pcap_inject(pcap_t *, const void *, size_t);
int pcap_sendpacket(pcap_t *, const u_char *, int);
char *pcap_strerror(int); char *pcap_strerror(int);
char *pcap_geterr(pcap_t *); char *pcap_geterr(pcap_t *);
int pcap_compile(pcap_t *, struct bpf_program *, char *, int, int pcap_compile(pcap_t *, struct bpf_program *, char *, int,
@@ -222,10 +268,12 @@ FILE *pcap_file(pcap_t *);
int pcap_fileno(pcap_t *); int pcap_fileno(pcap_t *);
pcap_dumper_t *pcap_dump_open(pcap_t *, const char *); pcap_dumper_t *pcap_dump_open(pcap_t *, const char *);
pcap_dumper_t *pcap_dump_fopen(pcap_t *, FILE *fp);
FILE *pcap_dump_file(pcap_dumper_t *);
long pcap_dump_ftell(pcap_dumper_t *);
int pcap_dump_flush(pcap_dumper_t *); int pcap_dump_flush(pcap_dumper_t *);
void pcap_dump_close(pcap_dumper_t *); void pcap_dump_close(pcap_dumper_t *);
void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *); void pcap_dump(u_char *, const struct pcap_pkthdr *, const u_char *);
FILE *pcap_dump_file(pcap_dumper_t *);
int pcap_findalldevs(pcap_if_t **, char *); int pcap_findalldevs(pcap_if_t **, char *);
void pcap_freealldevs(pcap_if_t *); void pcap_freealldevs(pcap_if_t *);
@@ -238,40 +286,50 @@ int bpf_validate(struct bpf_insn *f, int len);
char *bpf_image(struct bpf_insn *, int); char *bpf_image(struct bpf_insn *, int);
void bpf_dump(struct bpf_program *, int); void bpf_dump(struct bpf_program *, int);
#ifdef WIN32 #if defined(WIN32)
/* /*
* Win32 definitions * Win32 definitions
*/ */
int pcap_setbuff(pcap_t *p, int dim); int pcap_setbuff(pcap_t *p, int dim);
int pcap_setmode(pcap_t *p, int mode); int pcap_setmode(pcap_t *p, int mode);
int pcap_sendpacket(pcap_t *p, u_char *buf, int size);
int pcap_setmintocopy(pcap_t *p, int size); int pcap_setmintocopy(pcap_t *p, int size);
#ifdef WPCAP #ifdef WPCAP
/* Include file with the wpcap-specific extensions */ /* Include file with the wpcap-specific extensions */
#include <Win32-Extensions.h> #include <Win32-Extensions.h>
#endif #endif /* WPCAP */
#define MODE_CAPT 0 #define MODE_CAPT 0
#define MODE_STAT 1 #define MODE_STAT 1
#define MODE_MON 2 #define MODE_MON 2
#else #elif defined(MSDOS)
/*
* MS-DOS definitions
*/
int pcap_stats_ex (pcap_t *, struct pcap_stat_ex *);
void pcap_set_wait (pcap_t *p, void (*yield)(void), int wait);
u_long pcap_mac_packets (void);
#else /* UN*X */
/* /*
* UN*X definitions * UN*X definitions
*/ */
int pcap_get_selectable_fd(pcap_t *); int pcap_get_selectable_fd(pcap_t *);
#endif /* WIN32 */ #endif /* WIN32/MSDOS/UN*X */
#ifdef HAVE_REMOTE #ifdef HAVE_REMOTE
/* Includes most of the public stuff that is needed for the remote capture */ /* Includes most of the public stuff that is needed for the remote capture */
#include "remote-ext.h" #include "remote-ext.h"
#endif /* HAVE_REMOTE */ #endif /* HAVE_REMOTE */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -41,6 +41,9 @@
#pragma once #pragma once
#endif #endif
#ifdef __cplusplus
extern "C" {
#endif
/*! /*!
\file remote-ext.h \file remote-ext.h
@@ -399,8 +402,6 @@ struct pcap_samp *pcap_setsampling(pcap_t *p);
/** \name Remote Capture functions /** \name Remote Capture functions
This section lists the functions that are specific for remote capture.
*/ */
//\{ //\{
SOCKET pcap_remoteact_accept(const char *address, const char *port, const char *hostlist, char *connectinghost, struct pcap_rmtauth *auth, char *errbuf); SOCKET pcap_remoteact_accept(const char *address, const char *port, const char *hostlist, char *connectinghost, struct pcap_rmtauth *auth, char *errbuf);
@@ -410,6 +411,10 @@ void pcap_remoteact_cleanup();
//\} //\}
// End of remote capture functions // End of remote capture functions
#ifdef __cplusplus
}
#endif
#endif #endif