libpcap  1.10.1
About: libpcap is a packet filter library used by tools like tcpdump.
  Fossies Dox: libpcap-1.10.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pcap-dos.h
Go to the documentation of this file.
1 /*
2  * Internal details for libpcap on DOS.
3  * 32-bit targets: djgpp, Pharlap or DOS4GW.
4  */
5 
6 #ifndef __PCAP_DOS_H
7 #define __PCAP_DOS_H
8 
9 #ifdef __DJGPP__
10 #include <pc.h> /* simple non-conio kbhit */
11 #else
12 #include <conio.h>
13 #endif
14 
15 typedef int BOOL;
16 typedef unsigned char BYTE;
17 typedef unsigned short WORD;
18 typedef unsigned long DWORD;
19 typedef BYTE ETHER[6];
20 
21 #define ETH_ALEN sizeof(ETHER) /* Ether address length */
22 #define ETH_HLEN (2*ETH_ALEN+2) /* Ether header length */
23 #define ETH_MTU 1500
24 #define ETH_MIN 60
25 #define ETH_MAX (ETH_MTU+ETH_HLEN)
26 
27 #ifndef TRUE
28  #define TRUE 1
29  #define FALSE 0
30 #endif
31 
32 #define PHARLAP 1
33 #define DJGPP 2
34 #define DOS4GW 4
35 
36 #ifdef __DJGPP__
37  #undef DOSX
38  #define DOSX DJGPP
39 #endif
40 
41 #ifdef __WATCOMC__
42  #undef DOSX
43  #define DOSX DOS4GW
44 #endif
45 
46 #ifdef __HIGHC__
47  #include <pharlap.h>
48  #undef DOSX
49  #define DOSX PHARLAP
50  #define inline
51 #else
52  typedef unsigned int UINT;
53 #endif
54 
55 
56 #if defined(__GNUC__) || defined(__HIGHC__)
57  typedef unsigned long long uint64;
58  typedef unsigned long long QWORD;
59 #endif
60 
61 #if defined(__WATCOMC__)
62  typedef unsigned __int64 uint64;
63  typedef unsigned __int64 QWORD;
64 #endif
65 
66 #define ARGSUSED(x) (void) x
67 
68 #if defined (__SMALL__) || defined(__LARGE__)
69  #define DOSX 0
70 
71 #elif !defined(DOSX)
72  #error DOSX not defined; 1 = PharLap, 2 = djgpp, 4 = DOS4GW
73 #endif
74 
75 #ifdef __HIGHC__
76 #define min(a,b) _min(a,b)
77 #define max(a,b) _max(a,b)
78 #endif
79 
80 #ifndef min
81 #define min(a,b) ((a) < (b) ? (a) : (b))
82 #endif
83 
84 #ifndef max
85 #define max(a,b) ((a) < (b) ? (b) : (a))
86 #endif
87 
88 #if !defined(_U_) && defined(__GNUC__)
89 #define _U_ __attribute__((unused))
90 #endif
91 
92 #ifndef _U_
93 #define _U_
94 #endif
95 
96 #if defined(USE_32BIT_DRIVERS)
97  #include "msdos/pm_drvr/lock.h"
98 
99  #ifndef RECEIVE_QUEUE_SIZE
100  #define RECEIVE_QUEUE_SIZE 60
101  #endif
102 
103  #ifndef RECEIVE_BUF_SIZE
104  #define RECEIVE_BUF_SIZE (ETH_MAX+20)
105  #endif
106 
107  extern struct device el2_dev LOCKED_VAR; /* 3Com EtherLink II */
108  extern struct device el3_dev LOCKED_VAR; /* EtherLink III */
109  extern struct device tc59_dev LOCKED_VAR; /* 3Com Vortex Card (?) */
110  extern struct device tc515_dev LOCKED_VAR;
111  extern struct device tc90x_dev LOCKED_VAR;
112  extern struct device tc90bcx_dev LOCKED_VAR;
113  extern struct device wd_dev LOCKED_VAR;
114  extern struct device ne_dev LOCKED_VAR;
115  extern struct device acct_dev LOCKED_VAR;
116  extern struct device cs89_dev LOCKED_VAR;
117  extern struct device rtl8139_dev LOCKED_VAR;
118 
119  struct rx_ringbuf {
120  volatile int in_index; /* queue index head */
121  int out_index; /* queue index tail */
122  int elem_size; /* size of each element */
123  int num_elem; /* number of elements */
124  char *buf_start; /* start of buffer pool */
125  };
126 
127  struct rx_elem {
128  DWORD size; /* size copied to this element */
129  BYTE data[ETH_MAX+10]; /* add some margin. data[0] should be */
130  }; /* dword aligned */
131 
132  extern BYTE *get_rxbuf (int len) LOCKED_FUNC;
133  extern int peek_rxbuf (BYTE **buf);
134  extern int release_rxbuf (BYTE *buf);
135 
136 #else
137  #define LOCKED_VAR
138  #define LOCKED_FUNC
139 
140  struct device {
141  const char *name;
142  const char *long_name;
143  DWORD base_addr; /* device I/O address */
144  int irq; /* device IRQ number */
145  int dma; /* DMA channel */
146  DWORD mem_start; /* shared mem start */
147  DWORD mem_end; /* shared mem end */
148  DWORD rmem_start; /* shmem "recv" start */
149  DWORD rmem_end; /* shared "recv" end */
150 
151  struct device *next; /* next device in list */
152 
153  /* interface service routines */
154  int (*probe)(struct device *dev);
155  int (*open) (struct device *dev);
156  void (*close)(struct device *dev);
157  int (*xmit) (struct device *dev, const void *buf, int len);
158  void *(*get_stats)(struct device *dev);
159  void (*set_multicast_list)(struct device *dev);
160 
161  /* driver-to-pcap receive buffer routines */
162  int (*copy_rx_buf) (BYTE *buf, int max); /* rx-copy (pktdrvr only) */
163  BYTE *(*get_rx_buf) (int len); /* rx-buf fetch/enqueue */
164  int (*peek_rx_buf) (BYTE **buf); /* rx-non-copy at queue */
165  int (*release_rx_buf) (BYTE *buf); /* release after peek */
166 
167  WORD flags; /* Low-level status flags. */
168  void *priv; /* private data */
169  };
170 
171  /*
172  * Network device statistics
173  */
174  typedef struct net_device_stats {
175  DWORD rx_packets; /* total packets received */
176  DWORD tx_packets; /* total packets transmitted */
177  DWORD rx_bytes; /* total bytes received */
178  DWORD tx_bytes; /* total bytes transmitted */
179  DWORD rx_errors; /* bad packets received */
180  DWORD tx_errors; /* packet transmit problems */
181  DWORD rx_dropped; /* no space in Rx buffers */
182  DWORD tx_dropped; /* no space available for Tx */
183  DWORD multicast; /* multicast packets received */
184 
185  /* detailed rx_errors: */
187  DWORD rx_over_errors; /* recv'r overrun error */
188  DWORD rx_osize_errors; /* recv'r over-size error */
189  DWORD rx_crc_errors; /* recv'd pkt with crc error */
190  DWORD rx_frame_errors; /* recv'd frame alignment error */
191  DWORD rx_fifo_errors; /* recv'r fifo overrun */
192  DWORD rx_missed_errors; /* recv'r missed packet */
193 
194  /* detailed tx_errors */
203 #endif
204 
205 extern struct device *active_dev LOCKED_VAR;
206 extern const struct device *dev_base LOCKED_VAR;
207 extern struct device *probed_dev;
208 
209 extern int pcap_pkt_debug;
210 
211 extern void _w32_os_yield (void); /* Watt-32's misc.c */
212 
213 #ifdef NDEBUG
214  #define PCAP_ASSERT(x) ((void)0)
215 
216 #else
217  void pcap_assert (const char *what, const char *file, unsigned line);
218 
219  #define PCAP_ASSERT(x) do { \
220  if (!(x)) \
221  pcap_assert (#x, __FILE__, __LINE__); \
222  } while (0)
223 #endif
224 
225 #endif /* __PCAP_DOS_H */
struct net_device_stats NET_STATS
int BOOL
Definition: pcap-dos.h:15
struct device * probed_dev
Definition: pcap-dos.c:1095
unsigned short WORD
Definition: pcap-dos.h:17
struct device * active_dev
Definition: pcap-dos.c:1094
unsigned int UINT
Definition: pcap-dos.h:52
void pcap_assert(const char *what, const char *file, unsigned line)
Definition: pcap-dos.c:625
unsigned char BYTE
Definition: pcap-dos.h:16
#define ETH_MAX
Definition: pcap-dos.h:25
#define LOCKED_VAR
Definition: pcap-dos.h:137
BYTE ETHER[6]
Definition: pcap-dos.h:19
const struct device * dev_base
Definition: pcap-dos.c:1096
unsigned long DWORD
Definition: pcap-dos.h:18
#define LOCKED_FUNC
Definition: pcap-dos.h:138
int pcap_pkt_debug
Definition: pcap-dos.c:1101
void _w32_os_yield(void)
#define max(a, b)
Definition: pcap-dos.h:85
void(* close)(struct device *dev)
Definition: pcap-dos.h:156
DWORD rmem_end
Definition: pcap-dos.h:149
int irq
Definition: pcap-dos.h:144
void(* set_multicast_list)(struct device *dev)
Definition: pcap-dos.h:159
int(* copy_rx_buf)(BYTE *buf, int max)
Definition: pcap-dos.h:162
const char * name
Definition: pcap-dos.h:141
WORD flags
Definition: pcap-dos.h:167
int(* peek_rx_buf)(BYTE **buf)
Definition: pcap-dos.h:164
void * priv
Definition: pcap-dos.h:168
DWORD mem_end
Definition: pcap-dos.h:147
DWORD mem_start
Definition: pcap-dos.h:146
DWORD rmem_start
Definition: pcap-dos.h:148
const char * long_name
Definition: pcap-dos.h:142
int(* release_rx_buf)(BYTE *buf)
Definition: pcap-dos.h:165
int dma
Definition: pcap-dos.h:145
int(* open)(struct device *dev)
Definition: pcap-dos.h:155
int(* xmit)(struct device *dev, const void *buf, int len)
Definition: pcap-dos.h:157
int(* probe)(struct device *dev)
Definition: pcap-dos.h:154
struct device * next
Definition: pcap-dos.h:151
DWORD base_addr
Definition: pcap-dos.h:143
DWORD rx_fifo_errors
Definition: pcap-dos.h:191
DWORD rx_packets
Definition: pcap-dos.h:175
DWORD rx_missed_errors
Definition: pcap-dos.h:192
DWORD tx_fifo_errors
Definition: pcap-dos.h:197
DWORD tx_jabbers
Definition: pcap-dos.h:201
DWORD rx_crc_errors
Definition: pcap-dos.h:189
DWORD tx_dropped
Definition: pcap-dos.h:182
DWORD tx_aborted_errors
Definition: pcap-dos.h:195
DWORD rx_frame_errors
Definition: pcap-dos.h:190
DWORD tx_window_errors
Definition: pcap-dos.h:199
DWORD tx_collisions
Definition: pcap-dos.h:200
DWORD rx_length_errors
Definition: pcap-dos.h:186
DWORD tx_heartbeat_errors
Definition: pcap-dos.h:198
DWORD tx_packets
Definition: pcap-dos.h:176
DWORD tx_carrier_errors
Definition: pcap-dos.h:196
DWORD rx_over_errors
Definition: pcap-dos.h:187
DWORD rx_osize_errors
Definition: pcap-dos.h:188
DWORD rx_dropped
Definition: pcap-dos.h:181