Blame view

Network/libpcap-1.9.0/pcap-dos.h 6.7 KB
fee2cbd6   amoreau   ajout des librairies
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
  /*
   * Internal details for libpcap on DOS.
   * 32-bit targets: djgpp, Pharlap or DOS4GW.
   */
  
  #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 */