]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_IoT_Libraries/task_pool/WinPCap/remote-ext.h
9f54d6974cdf7c556c553c6183c594cf51260c0e
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_IoT_Libraries / task_pool / WinPCap / remote-ext.h
1 /*\r
2  * Copyright (c) 2002 - 2003\r
3  * NetGroup, Politecnico di Torino (Italy)\r
4  * All rights reserved.\r
5  * \r
6  * Redistribution and use in source and binary forms, with or without \r
7  * modification, are permitted provided that the following conditions \r
8  * are met:\r
9  * \r
10  * 1. Redistributions of source code must retain the above copyright \r
11  * notice, this list of conditions and the following disclaimer.\r
12  * 2. Redistributions in binary form must reproduce the above copyright \r
13  * notice, this list of conditions and the following disclaimer in the \r
14  * documentation and/or other materials provided with the distribution. \r
15  * 3. Neither the name of the Politecnico di Torino nor the names of its \r
16  * contributors may be used to endorse or promote products derived from \r
17  * this software without specific prior written permission. \r
18  * \r
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \r
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT \r
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR \r
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT \r
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, \r
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT \r
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, \r
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY \r
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE \r
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
30  * \r
31  */\r
32 \r
33 \r
34 #ifndef __REMOTE_EXT_H__\r
35 #define __REMOTE_EXT_H__\r
36 \r
37 \r
38 #ifndef HAVE_REMOTE\r
39 #error Please do not include this file directly. Just define HAVE_REMOTE and then include pcap.h\r
40 #endif\r
41 \r
42 // Definition for Microsoft Visual Studio\r
43 #if _MSC_VER > 1000\r
44 #pragma once\r
45 #endif\r
46 \r
47 #ifdef __cplusplus\r
48 extern "C" {\r
49 #endif\r
50 \r
51 /*!\r
52         \file remote-ext.h\r
53 \r
54         The goal of this file it to include most of the new definitions that should be\r
55         placed into the pcap.h file.\r
56 \r
57         It includes all new definitions (structures and functions like pcap_open().\r
58     Some of the functions are not really a remote feature, but, right now, \r
59         they are placed here.\r
60 */\r
61 \r
62 \r
63 \r
64 // All this stuff is public\r
65 /*! \addtogroup remote_struct\r
66         \{\r
67 */\r
68 \r
69 \r
70 \r
71 \r
72 /*!\r
73         \brief Defines the maximum buffer size in which address, port, interface names are kept.\r
74 \r
75         In case the adapter name or such is larger than this value, it is truncated.\r
76         This is not used by the user; however it must be aware that an hostname / interface\r
77         name longer than this value will be truncated.\r
78 */\r
79 #define PCAP_BUF_SIZE 1024\r
80 \r
81 \r
82 /*! \addtogroup remote_source_ID\r
83         \{\r
84 */\r
85 \r
86 \r
87 /*!\r
88         \brief Internal representation of the type of source in use (file, \r
89         remote/local interface).\r
90 \r
91         This indicates a file, i.e. the user want to open a capture from a local file.\r
92 */\r
93 #define PCAP_SRC_FILE 2\r
94 /*!\r
95         \brief Internal representation of the type of source in use (file, \r
96         remote/local interface).\r
97 \r
98         This indicates a local interface, i.e. the user want to open a capture from \r
99         a local interface. This does not involve the RPCAP protocol.\r
100 */\r
101 #define PCAP_SRC_IFLOCAL 3\r
102 /*!\r
103         \brief Internal representation of the type of source in use (file, \r
104         remote/local interface).\r
105 \r
106         This indicates a remote interface, i.e. the user want to open a capture from \r
107         an interface on a remote host. This does involve the RPCAP protocol.\r
108 */\r
109 #define PCAP_SRC_IFREMOTE 4\r
110 \r
111 /*!\r
112         \}\r
113 */\r
114 \r
115 \r
116 \r
117 /*! \addtogroup remote_source_string\r
118 \r
119         The formats allowed by the pcap_open() are the following:\r
120         - file://path_and_filename [opens a local file]\r
121         - rpcap://devicename [opens the selected device devices available on the local host, without using the RPCAP protocol]\r
122         - rpcap://host/devicename [opens the selected device available on a remote host]\r
123         - rpcap://host:port/devicename [opens the selected device available on a remote host, using a non-standard port for RPCAP]\r
124         - adaptername [to open a local adapter; kept for compability, but it is strongly discouraged]\r
125         - (NULL) [to open the first local adapter; kept for compability, but it is strongly discouraged]\r
126 \r
127         The formats allowed by the pcap_findalldevs_ex() are the following:\r
128         - file://folder/ [lists all the files in the given folder]\r
129         - rpcap:// [lists all local adapters]\r
130         - rpcap://host:port/ [lists the devices available on a remote host]\r
131 \r
132         Referring to the 'host' and 'port' paramters, they can be either numeric or literal. Since\r
133         IPv6 is fully supported, these are the allowed formats:\r
134 \r
135         - host (literal): e.g. host.foo.bar\r
136         - host (numeric IPv4): e.g. 10.11.12.13\r
137         - host (numeric IPv4, IPv6 style): e.g. [10.11.12.13]\r
138         - host (numeric IPv6): e.g. [1:2:3::4]\r
139         - port: can be either numeric (e.g. '80') or literal (e.g. 'http')\r
140 \r
141         Here you find some allowed examples:\r
142         - rpcap://host.foo.bar/devicename [everything literal, no port number]\r
143         - rpcap://host.foo.bar:1234/devicename [everything literal, with port number]\r
144         - rpcap://10.11.12.13/devicename [IPv4 numeric, no port number]\r
145         - rpcap://10.11.12.13:1234/devicename [IPv4 numeric, with port number]\r
146         - rpcap://[10.11.12.13]:1234/devicename [IPv4 numeric with IPv6 format, with port number]\r
147         - rpcap://[1:2:3::4]/devicename [IPv6 numeric, no port number]\r
148         - rpcap://[1:2:3::4]:1234/devicename [IPv6 numeric, with port number]\r
149         - rpcap://[1:2:3::4]:http/devicename [IPv6 numeric, with literal port number]\r
150         \r
151         \{\r
152 */\r
153 \r
154 \r
155 /*!\r
156         \brief String that will be used to determine the type of source in use (file,\r
157         remote/local interface).\r
158 \r
159         This string will be prepended to the interface name in order to create a string\r
160         that contains all the information required to open the source.\r
161 \r
162         This string indicates that the user wants to open a capture from a local file.\r
163 */\r
164 #define PCAP_SRC_FILE_STRING "file://"\r
165 /*!\r
166         \brief String that will be used to determine the type of source in use (file,\r
167         remote/local interface).\r
168 \r
169         This string will be prepended to the interface name in order to create a string\r
170         that contains all the information required to open the source.\r
171 \r
172         This string indicates that the user wants to open a capture from a network interface.\r
173         This string does not necessarily involve the use of the RPCAP protocol. If the\r
174         interface required resides on the local host, the RPCAP protocol is not involved\r
175         and the local functions are used.\r
176 */\r
177 #define PCAP_SRC_IF_STRING "rpcap://"\r
178 \r
179 /*!\r
180         \}\r
181 */\r
182 \r
183 \r
184 \r
185 \r
186 \r
187 /*!\r
188         \addtogroup remote_open_flags\r
189         \{\r
190 */\r
191 \r
192 /*!\r
193         \brief Defines if the adapter has to go in promiscuous mode.\r
194 \r
195         It is '1' if you have to open the adapter in promiscuous mode, '0' otherwise.\r
196         Note that even if this parameter is false, the interface could well be in promiscuous\r
197         mode for some other reason (for example because another capture process with \r
198         promiscuous mode enabled is currently using that interface).\r
199         On on Linux systems with 2.2 or later kernels (that have the "any" device), this\r
200         flag does not work on the "any" device; if an argument of "any" is supplied,\r
201         the 'promisc' flag is ignored.\r
202 */\r
203 #define PCAP_OPENFLAG_PROMISCUOUS               1\r
204 \r
205 /*!\r
206         \brief Defines if the data trasfer (in case of a remote\r
207         capture) has to be done with UDP protocol.\r
208 \r
209         If it is '1' if you want a UDP data connection, '0' if you want\r
210         a TCP data connection; control connection is always TCP-based.\r
211         A UDP connection is much lighter, but it does not guarantee that all\r
212         the captured packets arrive to the client workstation. Moreover, \r
213         it could be harmful in case of network congestion.\r
214         This flag is meaningless if the source is not a remote interface.\r
215         In that case, it is simply ignored.\r
216 */\r
217 #define PCAP_OPENFLAG_DATATX_UDP                        2\r
218 \r
219 \r
220 /*!\r
221         \brief Defines if the remote probe will capture its own generated traffic.\r
222 \r
223         In case the remote probe uses the same interface to capture traffic and to send\r
224         data back to the caller, the captured traffic includes the RPCAP traffic as well.\r
225         If this flag is turned on, the RPCAP traffic is excluded from the capture, so that\r
226         the trace returned back to the collector is does not include this traffic.\r
227 */\r
228 #define PCAP_OPENFLAG_NOCAPTURE_RPCAP   4\r
229 \r
230 /*!\r
231         \brief Defines if the local adapter will capture its own generated traffic.\r
232 \r
233         This flag tells the underlying capture driver to drop the packets that were sent by itself. \r
234         This is usefult when building applications like bridges, that should ignore the traffic\r
235         they just sent.\r
236 */\r
237 #define PCAP_OPENFLAG_NOCAPTURE_LOCAL   8\r
238 \r
239 /*!\r
240         \brief This flag configures the adapter for maximum responsiveness.\r
241 \r
242         In presence of a large value for nbytes, WinPcap waits for the arrival of several packets before \r
243         copying the data to the user. This guarantees a low number of system calls, i.e. lower processor usage, \r
244         i.e. better performance, which is good for applications like sniffers. If the user sets the \r
245         PCAP_OPENFLAG_MAX_RESPONSIVENESS flag, the capture driver will copy the packets as soon as the application \r
246         is ready to receive them. This is suggested for real time applications (like, for example, a bridge) \r
247         that need the best responsiveness.*/\r
248 #define PCAP_OPENFLAG_MAX_RESPONSIVENESS        16\r
249 \r
250 /*!\r
251         \}\r
252 */\r
253 \r
254 \r
255 /*!\r
256         \addtogroup remote_samp_methods\r
257         \{\r
258 */\r
259 \r
260 /*!\r
261         \brief No sampling has to be done on the current capture.\r
262 \r
263         In this case, no sampling algorithms are applied to the current capture.\r
264 */\r
265 #define PCAP_SAMP_NOSAMP        0\r
266 \r
267 /*!\r
268         \brief It defines that only 1 out of N packets must be returned to the user.\r
269 \r
270         In this case, the 'value' field of the 'pcap_samp' structure indicates the\r
271         number of packets (minus 1) that must be discarded before one packet got accepted.\r
272         In other words, if 'value = 10', the first packet is returned to the caller, while\r
273         the following 9 are discarded.\r
274 */\r
275 #define PCAP_SAMP_1_EVERY_N     1\r
276 \r
277 /*!\r
278         \brief It defines that we have to return 1 packet every N milliseconds.\r
279 \r
280         In this case, the 'value' field of the 'pcap_samp' structure indicates the 'waiting\r
281         time' in milliseconds before one packet got accepted.\r
282         In other words, if 'value = 10', the first packet is returned to the caller; the next \r
283         returned one will be the first packet that arrives when 10ms have elapsed. \r
284 */\r
285 #define PCAP_SAMP_FIRST_AFTER_N_MS 2\r
286 \r
287 /*!\r
288         \}\r
289 */\r
290 \r
291 \r
292 /*!\r
293         \addtogroup remote_auth_methods\r
294         \{\r
295 */\r
296 \r
297 /*!\r
298         \brief It defines the NULL authentication.\r
299 \r
300         This value has to be used within the 'type' member of the pcap_rmtauth structure.\r
301         The 'NULL' authentication has to be equal to 'zero', so that old applications\r
302         can just put every field of struct pcap_rmtauth to zero, and it does work.\r
303 */\r
304 #define RPCAP_RMTAUTH_NULL 0\r
305 /*!\r
306         \brief It defines the username/password authentication.\r
307 \r
308         With this type of authentication, the RPCAP protocol will use the username/\r
309         password provided to authenticate the user on the remote machine. If the\r
310         authentication is successful (and the user has the right to open network devices)\r
311         the RPCAP connection will continue; otherwise it will be dropped.\r
312 \r
313         This value has to be used within the 'type' member of the pcap_rmtauth structure.\r
314 */\r
315 #define RPCAP_RMTAUTH_PWD 1\r
316 \r
317 /*!\r
318         \}\r
319 */\r
320 \r
321 \r
322 \r
323 \r
324 /*!\r
325 \r
326         \brief This structure keeps the information needed to autheticate\r
327         the user on a remote machine.\r
328         \r
329         The remote machine can either grant or refuse the access according \r
330         to the information provided.\r
331         In case the NULL authentication is required, both 'username' and\r
332         'password' can be NULL pointers.\r
333         \r
334         This structure is meaningless if the source is not a remote interface;\r
335         in that case, the functions which requires such a structure can accept\r
336         a NULL pointer as well.\r
337 */\r
338 struct pcap_rmtauth\r
339 {\r
340         /*!\r
341                 \brief Type of the authentication required.\r
342 \r
343                 In order to provide maximum flexibility, we can support different types\r
344                 of authentication based on the value of this 'type' variable. The currently \r
345                 supported authentication methods are defined into the\r
346                 \link remote_auth_methods Remote Authentication Methods Section\endlink.\r
347 \r
348         */\r
349         int type;\r
350         /*!\r
351                 \brief Zero-terminated string containing the username that has to be \r
352                 used on the remote machine for authentication.\r
353                 \r
354                 This field is meaningless in case of the RPCAP_RMTAUTH_NULL authentication\r
355                 and it can be NULL.\r
356         */\r
357         char *username;\r
358         /*!\r
359                 \brief Zero-terminated string containing the password that has to be \r
360                 used on the remote machine for authentication.\r
361                 \r
362                 This field is meaningless in case of the RPCAP_RMTAUTH_NULL authentication\r
363                 and it can be NULL.\r
364         */\r
365         char *password;\r
366 };\r
367 \r
368 \r
369 /*!\r
370         \brief This structure defines the information related to sampling.\r
371 \r
372         In case the sampling is requested, the capturing device should read\r
373         only a subset of the packets coming from the source. The returned packets depend\r
374         on the sampling parameters.\r
375 \r
376         \warning The sampling process is applied <strong>after</strong> the filtering process.\r
377         In other words, packets are filtered first, then the sampling process selects a\r
378         subset of the 'filtered' packets and it returns them to the caller.\r
379 */\r
380 struct pcap_samp\r
381 {\r
382         /*!\r
383                 Method used for sampling. Currently, the supported methods are listed in the\r
384                 \link remote_samp_methods Sampling Methods Section\endlink.\r
385         */\r
386         int method;\r
387 \r
388         /*!\r
389                 This value depends on the sampling method defined. For its meaning, please check\r
390                 at the \link remote_samp_methods Sampling Methods Section\endlink.\r
391         */\r
392         int value;\r
393 };\r
394 \r
395 \r
396 \r
397 \r
398 //! Maximum lenght of an host name (needed for the RPCAP active mode)\r
399 #define RPCAP_HOSTLIST_SIZE 1024\r
400 \r
401 \r
402 /*!\r
403         \}\r
404 */ // end of public documentation\r
405 \r
406 \r
407 // Exported functions\r
408 \r
409 \r
410 \r
411 /** \name New WinPcap functions\r
412 \r
413         This section lists the new functions that are able to help considerably in writing\r
414         WinPcap programs because of their easiness of use.\r
415  */\r
416 //\{\r
417 pcap_t *pcap_open(const char *source, int snaplen, int flags, int read_timeout, struct pcap_rmtauth *auth, char *errbuf);\r
418 int pcap_createsrcstr(char *source, int type, const char *host, const char *port, const char *name, char *errbuf);\r
419 int pcap_parsesrcstr(const char *source, int *type, char *host, char *port, char *name, char *errbuf);\r
420 int pcap_findalldevs_ex(char *source, struct pcap_rmtauth *auth, pcap_if_t **alldevs, char *errbuf);\r
421 struct pcap_samp *pcap_setsampling(pcap_t *p);\r
422 \r
423 //\}\r
424 // End of new winpcap functions\r
425 \r
426 \r
427 \r
428 /** \name Remote Capture functions\r
429  */\r
430 //\{ \r
431 SOCKET pcap_remoteact_accept(const char *address, const char *port, const char *hostlist, char *connectinghost, struct pcap_rmtauth *auth, char *errbuf);\r
432 int pcap_remoteact_list(char *hostlist, char sep, int size, char *errbuf);\r
433 int pcap_remoteact_close(const char *host, char *errbuf);\r
434 void pcap_remoteact_cleanup();\r
435 //\}\r
436 // End of remote capture functions\r
437 \r
438 #ifdef __cplusplus\r
439 }\r
440 #endif\r
441 \r
442 \r
443 #endif\r
444 \r