1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00
freebsd/contrib/libpcap/pcap-dos.h

228 lines
6.8 KiB
C
Raw Normal View History

/*
* Internal details for libpcap on DOS.
* 32-bit targets: djgpp, Pharlap or DOS4GW.
*
Update libpcap to 1.1.1. Changes: Thu. April 1, 2010. guy@alum.mit.edu. Summary for 1.1.1 libpcap release Update CHANGES to reflect more of the changes in 1.1.0. Fix build on RHEL5. Fix shared library build on AIX. Thu. March 11, 2010. ken@netfunctional.ca/guy@alum.mit.edu. Summary for 1.1.0 libpcap release Add SocketCAN capture support Add Myricom SNF API support Update Endace DAG and ERF support Add support for shared libraries on Solaris, HP-UX, and AIX Build, install, and un-install shared libraries by default; don't build/install shared libraries on platforms we don't support Fix building from a directory other than the source directory Fix compiler warnings and builds on some platforms Update config.guess and config.sub Support monitor mode on mac80211 devices on Linux Fix USB memory-mapped capturing on Linux; it requires a new DLT_ value On Linux, scan /sys/class/net for devices if we have it; scan it, or /proc/net/dev if we don't have /sys/class/net, even if we have getifaddrs(), as it'll find interfaces with no addresses Add limited support for reading pcap-ng files Fix BPF driver-loading error handling on AIX Support getting the full-length interface description on FreeBSD In the lexical analyzer, free up any addrinfo structure we got back from getaddrinfo(). Add support for BPF and libdlpi in OpenSolaris (and SXCE) Hyphenate "link-layer" everywhere Add /sys/kernel/debug/usb/usbmon to the list of usbmon locations In pcap_read_linux_mmap(), if there are no frames available, call poll() even if we're in non-blocking mode, so we pick up errors, and check for the errors in question. Note that poll() works on BPF devices is Snow Leopard If an ENXIO or ENETDOWN is received, it may mean the device has gone away. Deal with it. For BPF, raise the default capture buffer size to from 32k to 512k Support ps_ifdrop on Linux Added a bunch of #ifdef directives to make wpcap.dll (WinPcap) compile under cygwin. Changes to Linux mmapped captures. Fix bug where create_ring would fail for particular snaplen and buffer size combinations Update pcap-config so that it handles libpcap requiring additional libraries Add workaround for threadsafeness on Windows Add missing mapping for DLT_ENC <-> LINKTYPE_ENC DLT: Add DLT_CAN_SOCKETCAN DLT: Add Solaris ipnet Don't check for DLT_IPNET if it's not defined Add link-layer types for Fibre Channel FC-2 Add link-layer types for Wireless HART Add link-layer types for AOS Add link-layer types for DECT Autoconf fixes (AIX, HP-UX, OSF/1, Tru64 cleanups) Install headers unconditionally, and include vlan.h/bluetooth.h if enabled Autoconf fixes+cleanup Support enabling/disabling bluetooth (--{en,dis}able-bluetooth) Support disabling SITA support (--without-sita) Return -1 on failure to create packet ring (if supported but creation failed) Fix handling of 'any' device, so that it can be opened, and no longer attempt to open it in Monitor mode Add support for snapshot length for USB Memory-Mapped Interface Fix configure and build on recent Linux kernels Fix memory-mapped Linux capture to support pcap_next() and pcap_next_ex() Fixes for Linux USB capture DLT: Add DLT_LINUX_EVDEV DLT: Add DLT_GSMTAP_UM DLT: Add DLT_GSMTAP_ABIS
2010-10-28 16:22:13 +00:00
* @(#) $Header: /tcpdump/master/libpcap/pcap-dos.h,v 1.1 2004-12-18 08:52:10 guy Exp $ (LBL)
*/
#ifndef __PCAP_DOS_H
#define __PCAP_DOS_H
#ifdef __DJGPP__
#include <pc.h> /* simple non-conio kbhit */
#else
#include <conio.h>
#endif
typedef int BOOL;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef BYTE ETHER[6];
#define ETH_ALEN sizeof(ETHER) /* Ether address length */
#define ETH_HLEN (2*ETH_ALEN+2) /* Ether header length */
#define ETH_MTU 1500
#define ETH_MIN 60
#define ETH_MAX (ETH_MTU+ETH_HLEN)
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#define PHARLAP 1
#define DJGPP 2
#define DOS4GW 4
#ifdef __DJGPP__
#undef DOSX
#define DOSX DJGPP
#endif
#ifdef __WATCOMC__
#undef DOSX
#define DOSX DOS4GW
#endif
#ifdef __HIGHC__
#include <pharlap.h>
#undef DOSX
#define DOSX PHARLAP
#define inline
#else
typedef unsigned int UINT;
#endif
#if defined(__GNUC__) || defined(__HIGHC__)
typedef unsigned long long uint64;
typedef unsigned long long QWORD;
#endif
#if defined(__WATCOMC__)
typedef unsigned __int64 uint64;
typedef unsigned __int64 QWORD;
#endif
#define ARGSUSED(x) (void) x
#if defined (__SMALL__) || defined(__LARGE__)
#define DOSX 0
#elif !defined(DOSX)
#error DOSX not defined; 1 = PharLap, 2 = djgpp, 4 = DOS4GW
#endif
#ifdef __HIGHC__
#define min(a,b) _min(a,b)
#define max(a,b) _max(a,b)
#endif
#ifndef min
#define min(a,b) ((a) < (b) ? (a) : (b))
#endif
#ifndef max
#define max(a,b) ((a) < (b) ? (b) : (a))
#endif
#if !defined(_U_) && defined(__GNUC__)
#define _U_ __attribute__((unused))
#endif
#ifndef _U_
#define _U_
#endif
#if defined(USE_32BIT_DRIVERS)
#include "msdos/pm_drvr/lock.h"
#ifndef RECEIVE_QUEUE_SIZE
#define RECEIVE_QUEUE_SIZE 60
#endif
#ifndef RECEIVE_BUF_SIZE
#define RECEIVE_BUF_SIZE (ETH_MAX+20)
#endif
extern struct device el2_dev LOCKED_VAR; /* 3Com EtherLink II */
extern struct device el3_dev LOCKED_VAR; /* EtherLink III */
extern struct device tc59_dev LOCKED_VAR; /* 3Com Vortex Card (?) */
extern struct device tc515_dev LOCKED_VAR;
extern struct device tc90x_dev LOCKED_VAR;
extern struct device tc90bcx_dev LOCKED_VAR;
extern struct device wd_dev LOCKED_VAR;
extern struct device ne_dev LOCKED_VAR;
extern struct device acct_dev LOCKED_VAR;
extern struct device cs89_dev LOCKED_VAR;
extern struct device rtl8139_dev LOCKED_VAR;
struct rx_ringbuf {
volatile int in_index; /* queue index head */
int out_index; /* queue index tail */
int elem_size; /* size of each element */
int num_elem; /* number of elements */
char *buf_start; /* start of buffer pool */
};
struct rx_elem {
DWORD size; /* size copied to this element */
BYTE data[ETH_MAX+10]; /* add some margin. data[0] should be */
}; /* dword aligned */
extern BYTE *get_rxbuf (int len) LOCKED_FUNC;
extern int peek_rxbuf (BYTE **buf);
extern int release_rxbuf (BYTE *buf);
#else
#define LOCKED_VAR
#define LOCKED_FUNC
struct device {
const char *name;
const char *long_name;
DWORD base_addr; /* device I/O address */
int irq; /* device IRQ number */
int dma; /* DMA channel */
DWORD mem_start; /* shared mem start */
DWORD mem_end; /* shared mem end */
DWORD rmem_start; /* shmem "recv" start */
DWORD rmem_end; /* shared "recv" end */
struct device *next; /* next device in list */
/* interface service routines */
int (*probe)(struct device *dev);
int (*open) (struct device *dev);
void (*close)(struct device *dev);
int (*xmit) (struct device *dev, const void *buf, int len);
void *(*get_stats)(struct device *dev);
void (*set_multicast_list)(struct device *dev);
/* driver-to-pcap receive buffer routines */
int (*copy_rx_buf) (BYTE *buf, int max); /* rx-copy (pktdrvr only) */
BYTE *(*get_rx_buf) (int len); /* rx-buf fetch/enqueue */
int (*peek_rx_buf) (BYTE **buf); /* rx-non-copy at queue */
int (*release_rx_buf) (BYTE *buf); /* release after peek */
WORD flags; /* Low-level status flags. */
void *priv; /* private data */
};
/*
* Network device statistics
*/
typedef struct net_device_stats {
DWORD rx_packets; /* total packets received */
DWORD tx_packets; /* total packets transmitted */
DWORD rx_bytes; /* total bytes received */
DWORD tx_bytes; /* total bytes transmitted */
DWORD rx_errors; /* bad packets received */
DWORD tx_errors; /* packet transmit problems */
DWORD rx_dropped; /* no space in Rx buffers */
DWORD tx_dropped; /* no space available for Tx */
DWORD multicast; /* multicast packets received */
/* detailed rx_errors: */
DWORD rx_length_errors;
DWORD rx_over_errors; /* recv'r overrun error */
DWORD rx_osize_errors; /* recv'r over-size error */
DWORD rx_crc_errors; /* recv'd pkt with crc error */
DWORD rx_frame_errors; /* recv'd frame alignment error */
DWORD rx_fifo_errors; /* recv'r fifo overrun */
DWORD rx_missed_errors; /* recv'r missed packet */
/* detailed tx_errors */
DWORD tx_aborted_errors;
DWORD tx_carrier_errors;
DWORD tx_fifo_errors;
DWORD tx_heartbeat_errors;
DWORD tx_window_errors;
DWORD tx_collisions;
DWORD tx_jabbers;
} NET_STATS;
#endif
extern struct device *active_dev LOCKED_VAR;
extern const struct device *dev_base LOCKED_VAR;
extern struct device *probed_dev;
extern int pcap_pkt_debug;
extern void _w32_os_yield (void); /* Watt-32's misc.c */
#ifdef NDEBUG
#define PCAP_ASSERT(x) ((void)0)
#else
void pcap_assert (const char *what, const char *file, unsigned line);
#define PCAP_ASSERT(x) do { \
if (!(x)) \
pcap_assert (#x, __FILE__, __LINE__); \
} while (0)
#endif
#endif /* __PCAP_DOS_H */