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