1146768Ssam/* 2146768Ssam * Internal details for libpcap on DOS. 3146768Ssam * 32-bit targets: djgpp, Pharlap or DOS4GW. 4146768Ssam * 5214518Srpaulo * @(#) $Header: /tcpdump/master/libpcap/pcap-dos.h,v 1.1 2004-12-18 08:52:10 guy Exp $ (LBL) 6146768Ssam */ 7146768Ssam 8146768Ssam#ifndef __PCAP_DOS_H 9146768Ssam#define __PCAP_DOS_H 10146768Ssam 11146768Ssam#ifdef __DJGPP__ 12146768Ssam#include <pc.h> /* simple non-conio kbhit */ 13146768Ssam#else 14146768Ssam#include <conio.h> 15146768Ssam#endif 16146768Ssam 17146768Ssamtypedef int BOOL; 18146768Ssamtypedef unsigned char BYTE; 19146768Ssamtypedef unsigned short WORD; 20146768Ssamtypedef unsigned long DWORD; 21146768Ssamtypedef BYTE ETHER[6]; 22146768Ssam 23146768Ssam#define ETH_ALEN sizeof(ETHER) /* Ether address length */ 24146768Ssam#define ETH_HLEN (2*ETH_ALEN+2) /* Ether header length */ 25146768Ssam#define ETH_MTU 1500 26146768Ssam#define ETH_MIN 60 27146768Ssam#define ETH_MAX (ETH_MTU+ETH_HLEN) 28146768Ssam 29146768Ssam#ifndef TRUE 30146768Ssam #define TRUE 1 31146768Ssam #define FALSE 0 32146768Ssam#endif 33146768Ssam 34146768Ssam#define PHARLAP 1 35146768Ssam#define DJGPP 2 36146768Ssam#define DOS4GW 4 37146768Ssam 38146768Ssam#ifdef __DJGPP__ 39146768Ssam #undef DOSX 40146768Ssam #define DOSX DJGPP 41146768Ssam#endif 42146768Ssam 43146768Ssam#ifdef __WATCOMC__ 44146768Ssam #undef DOSX 45146768Ssam #define DOSX DOS4GW 46146768Ssam#endif 47146768Ssam 48146768Ssam#ifdef __HIGHC__ 49146768Ssam #include <pharlap.h> 50146768Ssam #undef DOSX 51146768Ssam #define DOSX PHARLAP 52146768Ssam #define inline 53146768Ssam#else 54146768Ssam typedef unsigned int UINT; 55146768Ssam#endif 56146768Ssam 57146768Ssam 58146768Ssam#if defined(__GNUC__) || defined(__HIGHC__) 59146768Ssam typedef unsigned long long uint64; 60146768Ssam typedef unsigned long long QWORD; 61146768Ssam#endif 62146768Ssam 63146768Ssam#if defined(__WATCOMC__) 64146768Ssam typedef unsigned __int64 uint64; 65146768Ssam typedef unsigned __int64 QWORD; 66146768Ssam#endif 67146768Ssam 68146768Ssam#define ARGSUSED(x) (void) x 69146768Ssam 70146768Ssam#if defined (__SMALL__) || defined(__LARGE__) 71146768Ssam #define DOSX 0 72146768Ssam 73146768Ssam#elif !defined(DOSX) 74146768Ssam #error DOSX not defined; 1 = PharLap, 2 = djgpp, 4 = DOS4GW 75146768Ssam#endif 76146768Ssam 77146768Ssam#ifdef __HIGHC__ 78146768Ssam#define min(a,b) _min(a,b) 79146768Ssam#define max(a,b) _max(a,b) 80146768Ssam#endif 81146768Ssam 82146768Ssam#ifndef min 83146768Ssam#define min(a,b) ((a) < (b) ? (a) : (b)) 84146768Ssam#endif 85146768Ssam 86146768Ssam#ifndef max 87146768Ssam#define max(a,b) ((a) < (b) ? (b) : (a)) 88146768Ssam#endif 89146768Ssam 90146768Ssam#if !defined(_U_) && defined(__GNUC__) 91146768Ssam#define _U_ __attribute__((unused)) 92146768Ssam#endif 93146768Ssam 94146768Ssam#ifndef _U_ 95146768Ssam#define _U_ 96146768Ssam#endif 97146768Ssam 98146768Ssam#if defined(USE_32BIT_DRIVERS) 99146768Ssam #include "msdos/pm_drvr/lock.h" 100146768Ssam 101146768Ssam #ifndef RECEIVE_QUEUE_SIZE 102146768Ssam #define RECEIVE_QUEUE_SIZE 60 103146768Ssam #endif 104146768Ssam 105146768Ssam #ifndef RECEIVE_BUF_SIZE 106146768Ssam #define RECEIVE_BUF_SIZE (ETH_MAX+20) 107146768Ssam #endif 108146768Ssam 109146768Ssam extern struct device el2_dev LOCKED_VAR; /* 3Com EtherLink II */ 110146768Ssam extern struct device el3_dev LOCKED_VAR; /* EtherLink III */ 111146768Ssam extern struct device tc59_dev LOCKED_VAR; /* 3Com Vortex Card (?) */ 112146768Ssam extern struct device tc515_dev LOCKED_VAR; 113146768Ssam extern struct device tc90x_dev LOCKED_VAR; 114146768Ssam extern struct device tc90bcx_dev LOCKED_VAR; 115146768Ssam extern struct device wd_dev LOCKED_VAR; 116146768Ssam extern struct device ne_dev LOCKED_VAR; 117146768Ssam extern struct device acct_dev LOCKED_VAR; 118146768Ssam extern struct device cs89_dev LOCKED_VAR; 119146768Ssam extern struct device rtl8139_dev LOCKED_VAR; 120146768Ssam 121146768Ssam struct rx_ringbuf { 122146768Ssam volatile int in_index; /* queue index head */ 123146768Ssam int out_index; /* queue index tail */ 124146768Ssam int elem_size; /* size of each element */ 125146768Ssam int num_elem; /* number of elements */ 126146768Ssam char *buf_start; /* start of buffer pool */ 127146768Ssam }; 128146768Ssam 129146768Ssam struct rx_elem { 130146768Ssam DWORD size; /* size copied to this element */ 131146768Ssam BYTE data[ETH_MAX+10]; /* add some margin. data[0] should be */ 132146768Ssam }; /* dword aligned */ 133146768Ssam 134146768Ssam extern BYTE *get_rxbuf (int len) LOCKED_FUNC; 135146768Ssam extern int peek_rxbuf (BYTE **buf); 136146768Ssam extern int release_rxbuf (BYTE *buf); 137146768Ssam 138146768Ssam#else 139146768Ssam #define LOCKED_VAR 140146768Ssam #define LOCKED_FUNC 141146768Ssam 142146768Ssam struct device { 143146768Ssam const char *name; 144146768Ssam const char *long_name; 145146768Ssam DWORD base_addr; /* device I/O address */ 146146768Ssam int irq; /* device IRQ number */ 147146768Ssam int dma; /* DMA channel */ 148146768Ssam DWORD mem_start; /* shared mem start */ 149146768Ssam DWORD mem_end; /* shared mem end */ 150146768Ssam DWORD rmem_start; /* shmem "recv" start */ 151146768Ssam DWORD rmem_end; /* shared "recv" end */ 152146768Ssam 153146768Ssam struct device *next; /* next device in list */ 154146768Ssam 155146768Ssam /* interface service routines */ 156146768Ssam int (*probe)(struct device *dev); 157146768Ssam int (*open) (struct device *dev); 158146768Ssam void (*close)(struct device *dev); 159146768Ssam int (*xmit) (struct device *dev, const void *buf, int len); 160146768Ssam void *(*get_stats)(struct device *dev); 161146768Ssam void (*set_multicast_list)(struct device *dev); 162146768Ssam 163146768Ssam /* driver-to-pcap receive buffer routines */ 164146768Ssam int (*copy_rx_buf) (BYTE *buf, int max); /* rx-copy (pktdrvr only) */ 165146768Ssam BYTE *(*get_rx_buf) (int len); /* rx-buf fetch/enqueue */ 166146768Ssam int (*peek_rx_buf) (BYTE **buf); /* rx-non-copy at queue */ 167146768Ssam int (*release_rx_buf) (BYTE *buf); /* release after peek */ 168146768Ssam 169146768Ssam WORD flags; /* Low-level status flags. */ 170146768Ssam void *priv; /* private data */ 171146768Ssam }; 172146768Ssam 173146768Ssam /* 174146768Ssam * Network device statistics 175146768Ssam */ 176146768Ssam typedef struct net_device_stats { 177146768Ssam DWORD rx_packets; /* total packets received */ 178146768Ssam DWORD tx_packets; /* total packets transmitted */ 179146768Ssam DWORD rx_bytes; /* total bytes received */ 180146768Ssam DWORD tx_bytes; /* total bytes transmitted */ 181146768Ssam DWORD rx_errors; /* bad packets received */ 182146768Ssam DWORD tx_errors; /* packet transmit problems */ 183146768Ssam DWORD rx_dropped; /* no space in Rx buffers */ 184146768Ssam DWORD tx_dropped; /* no space available for Tx */ 185146768Ssam DWORD multicast; /* multicast packets received */ 186146768Ssam 187146768Ssam /* detailed rx_errors: */ 188146768Ssam DWORD rx_length_errors; 189146768Ssam DWORD rx_over_errors; /* recv'r overrun error */ 190146768Ssam DWORD rx_osize_errors; /* recv'r over-size error */ 191146768Ssam DWORD rx_crc_errors; /* recv'd pkt with crc error */ 192146768Ssam DWORD rx_frame_errors; /* recv'd frame alignment error */ 193146768Ssam DWORD rx_fifo_errors; /* recv'r fifo overrun */ 194146768Ssam DWORD rx_missed_errors; /* recv'r missed packet */ 195146768Ssam 196146768Ssam /* detailed tx_errors */ 197146768Ssam DWORD tx_aborted_errors; 198146768Ssam DWORD tx_carrier_errors; 199146768Ssam DWORD tx_fifo_errors; 200146768Ssam DWORD tx_heartbeat_errors; 201146768Ssam DWORD tx_window_errors; 202146768Ssam DWORD tx_collisions; 203146768Ssam DWORD tx_jabbers; 204146768Ssam } NET_STATS; 205146768Ssam#endif 206146768Ssam 207146768Ssamextern struct device *active_dev LOCKED_VAR; 208146768Ssamextern const struct device *dev_base LOCKED_VAR; 209146768Ssamextern struct device *probed_dev; 210146768Ssam 211146768Ssamextern int pcap_pkt_debug; 212146768Ssam 213146768Ssamextern void _w32_os_yield (void); /* Watt-32's misc.c */ 214146768Ssam 215146768Ssam#ifdef NDEBUG 216146768Ssam #define PCAP_ASSERT(x) ((void)0) 217146768Ssam 218146768Ssam#else 219146768Ssam void pcap_assert (const char *what, const char *file, unsigned line); 220146768Ssam 221146768Ssam #define PCAP_ASSERT(x) do { \ 222146768Ssam if (!(x)) \ 223146768Ssam pcap_assert (#x, __FILE__, __LINE__); \ 224146768Ssam } while (0) 225146768Ssam#endif 226146768Ssam 227146768Ssam#endif /* __PCAP_DOS_H */ 228