Watt-32 tcp/ip  2.2 dev-rel.10
winpkt.h
Go to the documentation of this file.
1 
5 #ifndef _w32_WINPKT_H
6 #define _w32_WINPKT_H
7 
8 #if !defined(_w32_PCPKT_H)
9 #error Include this file inside or after pcpkt.h only.
10 #endif
11 
17 #define PDERR_GEN_FAIL -1
18 #define PDERR_NO_DRIVER -2
19 #define PDERR_NO_CLASS -3
20 #define PDERR_NO_MULTICAST -4
21 #define PDERR_NO_SPACE -5
22 
24  RXMODE_OFF = 0x00,
25  RXMODE_DIRECT = 0x01,
31  /* we have no use for the other NDIS_PACKET_TYPE defs */
32  };
33 
34 /* NPF defaults to mode 0 after openening adapter.
35  */
36 #define RXMODE_DEFAULT (RXMODE_DIRECT | RXMODE_BROADCAST)
37 
38 extern struct pkt_rx_element *pkt_poll_recv (void);
39 
40 #if defined(USE_MULTICAST)
41  extern int pkt_get_multicast_list (mac_address *listbuf, int *len);
42  extern int pkt_set_multicast_list (const void *listbuf, int len);
43 #endif
44 
45 typedef BOOL (*func_init) (void);
46 typedef void *(*func_open) (const char *name, ...);
47 typedef BOOL (*func_close) (void *a);
48 typedef UINT (*func_send) (const void *a, const void *buf, UINT buf_len); /* returns length of buf sent */
49 typedef BOOL (*func_get_mac) (const void *a, const void *mac);
50 typedef BOOL (*func_get_stats) (const void *a, struct PktStats *stats, struct PktStats *total);
51 typedef BOOL (*func_get_if_stat) (const void *a, BOOL *up);
52 typedef BOOL (*func_get_if_type) (const void *a, WORD *type);
53 typedef BOOL (*func_get_if_mtu) (const void *a, DWORD *Mbit_s);
54 typedef BOOL (*func_get_if_speed)(const void *a, DWORD *Mbit_s);
55 typedef BOOL (*func_get_descr) (const void *a, char *descr, size_t max);
56 typedef const char *(*func_get_drv_ver) (void);
57 
58 /* This func-ptr is used in 'winpcap_recv_thread()' outside of the
59  * critical region. Hence we force a 'cdecl' on MSVC since registers
60  * doesn't always seems to be preserved across thread-switches.
61  * See '\note' in 'winpcap_recv_thread()' docs.
62  */
63 typedef UINT (MS_CDECL *func_recv) (const void *a, void *buf, UINT buf_len); /* returns length of buf received */
64 
69 struct pkt_info {
70  const void *adapter_info; /* opaque ADAPTER_INFO object (WinPcap only) */
71  const void *adapter; /* opaque ADAPTER or SwsVpktUsr object */
72  void *npf_buf; /* WinPcap: buffer for ReadFile() */
73  int npf_buf_size; /* WinPcap: size of above buffer */
74  HANDLE recv_thread; /* WinPcap: thread for capturing */
75  WORD pkt_ip_ofs; /* store length of MAC-header */
76  WORD pkt_type_ofs; /* offset to MAC-type */
77  volatile BOOL stop_thread; /* signal thread to stop */
78  volatile BOOL thread_stopped; /* did it stop gracefully? */
79 
80  const char *api_name; /* "WinPcap", "AirPcap", "SwsVpkt" etc. */
81  const char *sys_drvr_name; /* "NPF.sys", "airpcap.sys", "SwsVpkt.sys" etc. */
82 
83  /* Function pointers to transmit(), recv() etc. Depending
84  * on the type of low-level driver we use (NPF/SwsVpkt/AirPcap/WanPacket).
85  */
86  func_init init_op;
87  func_open open_op;
88  func_close close_op;
89  func_send send_op;
90  func_recv recv_op;
91  func_get_mac get_mac_op;
92  func_get_stats get_stats_op;
93  func_get_if_stat get_if_stat_op;
94  func_get_if_type get_if_type_op;
95  func_get_if_mtu get_if_mtu_op;
96  func_get_if_speed get_if_speed_op;
97  func_get_descr get_descr_op;
98  func_get_drv_ver get_drv_ver_op;
99 
100  const char *error; /* Last error (NULL if none) */
101  struct pkt_ringbuf pkt_queue; /* Ring-struct for enqueueing */
102  struct pkt_rx_element rx_buf [RX_BUFS]; /* the receive buffer */
103  };
104 
105 extern char _pktdrvr_descr[];
106 
107 extern struct pkt_info *_pkt_inf;
108 
109 extern const char *winpkt_trace_func;
110 extern const char *winpkt_trace_file;
111 extern UINT winpkt_trace_line;
112 extern UINT winpkt_trace_level;
113 
114 #if defined(USE_DEBUG)
115  #define WINPKT_TRACE(args) do { \
116  winpkt_trace_file = __FILE__; \
117  winpkt_trace_line = __LINE__; \
118  winpkt_trace args ; \
119  } while (0)
120 
121  extern void winpkt_trace (const char *fmt, ...) ATTR_PRINTF (1,2);
122  extern void winpkt_trace_fclose (void);
123 
124 #else
125  #define WINPKT_TRACE(args) ((void)0)
126 #endif /* USE_DEBUG */
127 
128 #endif /* _w32_WINPKT_H */
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
NDIS_PACKET_TYPE_ALL_LOCAL (direct+bc+mc1)
Definition: winpkt.h:30
NDIS_PACKET_TYPE_ALL_MULTICAST.
Definition: winpkt.h:27
NDIS_PACKET_TYPE_BROADCAST.
Definition: winpkt.h:28
ReceiveModes
Definition: pcpkt.h:108
NDIS_PACKET_TYPE_MULTICAST.
Definition: winpkt.h:26
struct pkt_info * _pkt_inf
module data that will be locked
Definition: pcpkt.c:64
NDIS_PACKET_TYPE_PROMISCUOUS.
Definition: winpkt.h:29
Definition: tcp.h:778
possible to turn off?
Definition: winpkt.h:24
int pkt_get_multicast_list(mac_address *listbuf, int *len)
Gets the current list of multicast addresses from the PKTDRVR.
Definition: pcpkt.c:2037
Placeholder for vital data accessed by capture thread.
Definition: pcpkt.h:206
NDIS_PACKET_TYPE_DIRECTED.
Definition: winpkt.h:25