Watt-32 tcp/ip  2.2 dev-rel.10
pcpkt.h
Go to the documentation of this file.
1 
3 #ifndef _w32_PCPKT_H
4 #define _w32_PCPKT_H
5 
6 #ifndef _w32_PCQUEUE_H
7 #include "pcqueue.h"
8 #endif
9 
10 #ifndef _w32_PCSED_H
11 #include "pcsed.h"
12 #endif
13 
14 
15 #if defined(WIN32)
16  #define PKTDRVR_STR "WinPcap"
17 #else
18  #define PKTDRVR_STR "PKTDRVR"
19 #endif
20 
21 /*
22  * Common stuff for PKTDRVR and Windows interfaces
23  */
24 #if defined(USE_DEBUG)
25  #define ASSERT_PKT_INF(rc) do { \
26  if (!_pkt_inf) { \
27  (*_printf) ("%s (%u): " \
28  "_pkt_inf == NULL\n", \
29  __FILE__, __LINE__); \
30  return (rc); \
31  } \
32  } while (0)
33 #else
34  #define ASSERT_PKT_INF(rc) do { \
35  if (!_pkt_inf) \
36  return (rc); \
37  } while (0)
38 #endif
39 
40 extern WORD _pktdevclass;
41 extern WORD _pkt_ip_ofs;
42 extern BOOL _pktserial;
43 extern char _pktdrvrname[];
44 extern int _pkt_rxmode;
45 extern int _pkt_rxmode0;
46 extern int _pkt_forced_rxmode;
47 extern int _pkt_errno;
54 #if defined(WIN32)
55 
56 #include "winpkt.h"
57 
58 #else /* rest of file */
59 
60 /* Basic PD Functions.
61  */
62 #define PD_DRIVER_INFO 0x01FF
63 #define PD_ACCESS 0x0200
64 #define PD_RELEASE 0x0300
65 #define PD_SEND 0x0400
66 #define PD_TERMINATE 0x0500
67 #define PD_GET_ADDRESS 0x0600
68 #define PD_RESET 0x0700
69 
70 /* Extended PD Functions (1.09+)
71  */
72 #define PD_GET_PARAM 0x0A00
73 #define PD_ASY_SEND_109 0x0B00
74 #define PD_ASY_SEND 0x0C00
75 #define PD_ASY_DROP 0x0D00
76 #define PD_SET_RCV 0x1400
77 #define PD_GET_RCV 0x1500
78 #define PD_SET_MULTI 0x1600
79 #define PD_GET_MULTI 0x1700
80 #define PD_GET_STATS 0x1800
81 #define PD_SET_ADDR 0x1900
82 #define PD_RAW_SEND 0x1A00
83 #define PD_RAW_FLUSH 0x1B00
84 #define PD_RAW_GET 0x1C00
85 #define PD_SIGNAL 0x1D00
86 #define PD_GET_STRUCT 0x1E00
87 #define PD_GET_VJSTATS 0x8100
89 /* Packet-Driver Error Returns.
90  */
91 #define PDERR_BAD_HANDLE 1
92 #define PDERR_NO_CLASS 2
93 #define PDERR_NO_TYPE 3
94 #define PDERR_NO_NUMBER 4
95 #define PDERR_BAD_TYPE 5
96 #define PDERR_NO_MULTICAST 6
97 #define PDERR_CANT_TERMINATE 7
98 #define PDERR_BAD_MODE 8
99 #define PDERR_NO_SPACE 9
100 #define PDERR_TYPE_INUSE 10
101 #define PDERR_BAD_COMMAND 11
102 #define PDERR_CANT_SEND 12
103 #define PDERR_CANT_SET 13
104 #define PDERR_BAD_ADDRESS 14
105 #define PDERR_CANT_RESET 15
106 #define PDERR_BASIC_DVR 16
107 
115  };
116 
117 extern BYTE _pktdevlevel;
119 #if defined(USE_MULTICAST)
120  extern int pkt_get_multicast_list (mac_address *listbuf, int *len);
121  extern int pkt_set_multicast_list (const void *listbuf, int len);
122 #endif
123 
124 #include <sys/pack_on.h> /* cstate, slcompress etc. must be packed */
125 
126 /*\struct cstate
127  *
128  * Statistics returned from DOS-PPP.
129  *
130  * "state" data for each active tcp conversation on the wire. This is
131  * basically a copy of the entire IP/TCP header from the last packet
132  * we saw from the conversation together with a small identifier
133  * the transmit & receive ends of the line use to locate saved header.
134  */
135 struct cstate {
136  BYTE cs_this; /* connection id number (xmit) */
137  WORD cs_next; /* next in ring (xmit) */
138  in_Header cs_ip; /* ip/tcp hdr from most recent packet */
139  tcp_Header cs_tcp;
140  BYTE cs_ipopt[40];
141  BYTE cs_tcpopt[40];
142  };
143 
144 /*\struct slcompress
145  *
146  * Serial line compression statistics.
147  */
148 struct slcompress {
149  WORD cstate_ptr_tstate; /* transmit connection states (DOSPPP is small model) */
150  WORD cstate_ptr_rstate; /* receive connection states */
151 
152  BYTE tslot_limit; /* highest transmit slot id (0-l) */
153  BYTE rslot_limit; /* highest receive slot id (0-l) */
154 
155  BYTE xmit_oldest; /* oldest xmit in ring */
156  BYTE xmit_current; /* most recent xmit id */
157  BYTE recv_current; /* most recent rcvd id */
158  BYTE flags;
159 
160  DWORD sls_o_nontcp; /* outbound non-TCP packets */
161  DWORD sls_o_tcp; /* outbound TCP packets */
162  DWORD sls_o_uncompressed; /* outbound uncompressed packets */
163  DWORD sls_o_compressed; /* outbound compressed packets */
164  DWORD sls_o_searches; /* searches for connection state */
165  DWORD sls_o_misses; /* times couldn't find conn. state */
166 
167  DWORD sls_i_uncompressed; /* inbound uncompressed packets */
168  DWORD sls_i_compressed; /* inbound compressed packets */
169  DWORD sls_i_error; /* inbound error packets */
170  DWORD sls_i_tossed; /* inbound packets tossed because of error */
171 
172  DWORD sls_i_runt; /* inbound packets too short */
173  DWORD sls_i_badcheck; /* inbound IP-packets with chksum error */
174  };
175 
176 extern int pkt_get_vjstats (struct slcompress *vjstats);
177 extern int pkt_get_cstate (struct cstate *cs, WORD cstate_ofs);
178 
179 
180 /*\struct async_iocb
181  *
182  * I/O structure for asynchronous transmit function (v1.11, AH = 12)
183  * (not used)
184  */
185 struct async_iocb {
186  DWORD buffer; /* Pointer to xmit buffer */
187  WORD length; /* Length of buffer */
188  BYTE flagbits; /* Flag bits */
189  BYTE code; /* Error code */
190  DWORD xmit_func; /* Transmitter upcall */
191  char reserved[4]; /* Future gather-write data */
192  char private[8]; /* Driver's private data */
193  };
194 
195 #define ASY_DONE 1 /* packet driver is done with this iocb */
196 #define ASY_UPCALL 2 /* requests an upcall when the buffer is re-usable */
197 
198 /*\struct pkt_info
199  *
200  * Placeholder for vital data accessed on packet-driver upcall.
201  *
202  * Keep it gathered to simplify locking memory at `_pkt_inf'.
203  * For DOS4GW targets; this structure \b MUST match same structure
204  * in \b asmpkt4.asm.
205  */
206 struct pkt_info {
207  WORD rm_sel, rm_seg, rm_ofs; /* real selector, segment, ofs */
208  WORD dos_ds; /* copy of _dos_ds */
209  WORD use_near_ptr; /* near-pointers enabled */
210  WORD handle; /* Packet-driver handle */
211  WORD is_serial; /* duplicated from _pktserial */
212  WORD pkt_ip_ofs; /* store length of MAC-header */
213  WORD pkt_type_ofs; /* offset to MAC-type */
214  struct pkt_ringbuf pkt_queue; /* Ring-struct for enqueueing */
215 
216 #if !defined(USE_FAST_PKT)
217  /* USE_FAST_PKT uses a single rx_buf in pcpkt2.c
218  */
219  struct pkt_rx_element rx_buf [RX_BUFS];
220 #endif
221  };
222 
223 extern struct pkt_info *_pkt_inf;
224 
225 #include <sys/pack_off.h> /* restore default packing */
226 
227 /*
228  * sizeof(*_pkt_inf), __LARGE__
229  * 3*2 = 6
230  * 16 = 16
231  * 5*1524 = 7620
232  * = 7642
233  *
234  * sizeof(*_pkt_inf), DOS4GW
235  * 3*2 = 6
236  * 26 = 26
237  * 20*(14+1500+10) = 30480
238  * = 30512
239  */
240 
241 #if (DOSX & (DOS4GW|X32VM|DJGPP))
242  extern void *pkt_tx_buf (void);
243 #endif
244 
245 #if defined(USE_FAST_PKT)
246  extern int pkt_append_recv (const void *tx, unsigned len);
247  extern int pkt_buffers_used (void);
248  extern int pkt_test_upcall (void);
249  extern void pkt_dump_real_mem(void);
250 
251  extern struct pkt_rx_element *pkt_poll_recv (void);
252 #endif
253 
254 
255 #define ROUND_UP32(sz) (4 * (((sz) + 3) / 4))
256 
257 #if (DOSX & DJGPP)
258  extern void __dj_movedata (void); /* called by __movedata() */
259  extern void __movedata (unsigned src_sel, unsigned src_ofs,
260  unsigned dst_sel, unsigned dst_ofs,
261  size_t bytes);
262 
263  #define DOSMEMGET(ofs,len,buf) __movedata (_pkt_inf->dos_ds, \
264  (unsigned)(ofs), \
265  (unsigned)_my_ds(), \
266  (unsigned)(buf), \
267  len)
268  #define DOSMEMGETL(ofs,d32,buf) _movedatal (_pkt_inf->dos_ds, \
269  (unsigned)(ofs), \
270  (unsigned)_my_ds(), \
271  (unsigned)(buf), \
272  d32)
273  #define DOSMEMPUT(buf,len,ofs) __movedata ((unsigned)_my_ds(), \
274  (unsigned)(buf), \
275  _pkt_inf->dos_ds, \
276  (unsigned)(ofs), \
277  len)
278  #define DOSMEMPUTL(buf,d32,ofs) _movedatal ((unsigned)_my_ds(), \
279  (unsigned)(buf), \
280  _pkt_inf->dos_ds, \
281  (unsigned)(ofs), \
282  d32)
283 
284  #define DOSMEMCLR(ofs,len) \
285  do { \
286  int i = ROUND_UP32 (len) - 4; \
287  _farsetsel (_dos_ds); /* FS=dos DS */ \
288  for ( ; i >= 0; i -= 4) \
289  _farnspokel (ofs+i, 0L); \
290  } while (0)
291 
292 #endif /* (DOSX & DJGPP) */
293 #endif /* WIN32 */
294 #endif
295 
Definition: pcpkt.h:135
WORD _pkt_ip_ofs
Offset from MAC-header to IP-header.
Definition: pcpkt.c:52
int pkt_get_multicast_list(mac_address *listbuf, int *len)
Gets the current list of multicast addresses from the PKTDRVR.
Definition: pcpkt.c:2037
struct pkt_info * _pkt_inf
module data that will be locked
Definition: pcpkt.c:64
int pkt_set_multicast_list(const void *listbuf, int len)
Sets the list of multicast addresses for which the PKTDRVR is responsible.
Definition: pcpkt.c:2084
WORD _pktdevclass
Driver class; <tcp.h> for values.
Definition: pcpkt.c:51
DIRECT + broadcast packets.
Definition: pcpkt.h:111
char _pktdrvrname[]
Name of PKDRVR.
Definition: pcpkt.c:62
ReceiveModes
Definition: pcpkt.h:108
void * pkt_tx_buf(void)
Return address of DOS memory Tx-buffer.
Definition: pcpkt.c:302
int _pkt_errno
Last PKTDRVR error code.
Definition: pcpkt.c:58
int _pkt_rxmode0
Startup receive mode.
Definition: pcpkt.c:57
BOOL _pktserial
Driver is a serial (SLIP/PPP) driver.
Definition: pcpkt.c:54
Definition: zinftree.h:24
BROADCAST + all multicast.
Definition: pcpkt.h:113
int _pkt_rxmode
Current PKTDRVR/WinPcap Rx-mode.
Definition: pcpkt.c:56
receive all packets on network
Definition: pcpkt.h:114
int _pkt_forced_rxmode
Forced Rx-mode via WATTCP.CFG.
Definition: pcpkt.c:61
BYTE _pktdevlevel
Device level.
Definition: pcpkt.c:55
receive only to this interface
Definition: pcpkt.h:110
Placeholder for vital data accessed by capture thread.
Definition: pcpkt.h:206
turn off receiver
Definition: pcpkt.h:109
BROADCAST + limited multicast.
Definition: pcpkt.h:112