Main Page Modules Data Structures File List Data Fields Globals Related Pages

# pcap-remote.h

Go to the documentation of this file.

    00001 /*
    00002  * Copyright (c) 2002 - 2003
    00003  * NetGroup, Politecnico di Torino (Italy)
    00004  * All rights reserved.
    00005  *
    00006  * Redistribution and use in source and binary forms, with or without
    00007  * modification, are permitted provided that the following conditions
    00008  * are met:
    00009  *
    00010  * 1. Redistributions of source code must retain the above copyright
    00011  * notice, this list of conditions and the following disclaimer.
    00012  * 2. Redistributions in binary form must reproduce the above copyright
    00013  * notice, this list of conditions and the following disclaimer in the
    00014  * documentation and/or other materials provided with the distribution.
    00015  * 3. Neither the name of the Politecnico di Torino nor the names of its
    00016  * contributors may be used to endorse or promote products derived from
    00017  * this software without specific prior written permission.
    00018  *
    00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    00020  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    00022  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    00023  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    00024  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00025  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    00026  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    00027  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    00028  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    00029  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00030  *
    00031  */
    00032
    00033 #ifndef __PCAP_REMOTE_H__
    00034 #define __PCAP_REMOTE_H__
    00035
    00036 #include "pcap.h"
    00037
    00038
    00071 /*********************************************************
    00072  *                                                       *
    00073  * General definitions / typedefs for the RPCAP protocol *
    00074  *                                                       *
    00075  *********************************************************/
    00076
    00077 // All the following structures and typedef belongs to the Private Documentation
    00082 #define RPCAP_DEFAULT_NETPORT "2002"
    00084 #define RPCAP_DEFAULT_NETPORT_ACTIVE "2003"
    00085 #define RPCAP_DEFAULT_NETADDR ""
    00086 #define RPCAP_VERSION 0
    00087 #define RPCAP_TIMEOUT_INIT 90
    00088 #define RPCAP_TIMEOUT_RUNTIME 180
    00089 #define RPCAP_ACTIVE_WAIT 30
    00090 #define RPCAP_SUSPEND_WRONGAUTH 1
    00096 #define RPCAP_NETBUF_SIZE 64000
    00097
    00098
    00106 #define RPCAP_HOSTLIST_SEP " ,;\n\r"
    00107
    00108
    00109
    00110
    00111 // WARNING: These could need to be changed on other platforms
    00112 typedef unsigned char uint8;
    00113 typedef unsigned short uint16;
    00114 typedef unsigned int uint32;
    00115 typedef int int32;
    00116
    00117
    00118
    00119
    00130 struct activehosts
    00131 {
    00132     struct sockaddr_storage host;
    00133     SOCKET sockctrl;
    00134     struct activehosts *next;
    00135 };
    00136
    00137
    00138 /*********************************************************
    00139  *                                                       *
    00140  * Protocol messages formats                             *
    00141  *                                                       *
    00142  *********************************************************/
    00143 // WARNING Take care you compiler does not insert padding for better alignments into these structs
    00144
    00145
    00147 struct rpcap_header
    00148 {
    00149     uint8 ver;
    00150     uint8 type;
    00151     uint16 value;
    00152     uint32 plen;
    00153 };
    00154
    00155
    00157 struct rpcap_findalldevs_if
    00158 {
    00159     uint16 namelen;
    00160     uint16 desclen;
    00161     uint32 flags;
    00162     uint16 naddr;
    00163     uint16 dummy;
    00164 };
    00165
    00166
    00168 struct rpcap_findalldevs_ifaddr
    00169 {
    00170     struct sockaddr_storage addr;
    00171     struct sockaddr_storage netmask;
    00172     struct sockaddr_storage broadaddr;
    00173     struct sockaddr_storage dstaddr;
    00174 };
    00175
    00176
    00177
    00183 struct rpcap_openreply
    00184 {
    00185     int32 linktype;
    00186     int32 tzoff;
    00187 };
    00188
    00189
    00190
    00192 struct rpcap_startcapreq
    00193 {
    00194     uint32 snaplen;
    00195     uint32 read_timeout;
    00196     uint16 flags;
    00197     uint16 portdata;
    00198 };
    00199
    00200
    00202 struct rpcap_startcapreply
    00203 {
    00204     int32 bufsize;
    00205     uint16 portdata;
    00206     uint16 dummy;
    00207 };
    00208
    00209
    00216 struct rpcap_pkthdr
    00217 {
    00218     uint32 timestamp_sec;
    00219     uint32 timestamp_usec;
    00220     uint32 caplen;
    00221     uint32 len;
    00222     uint32 npkt;
    00223 };
    00224
    00225
    00227 struct rpcap_filter
    00228 {
    00229     uint16 filtertype;
    00230     uint16 dummy;
    00231     uint32 nitems;
    00232 };
    00233
    00234
    00236 struct rpcap_filterbpf_insn
    00237 {
    00238     uint16 code;
    00239     uint8 jt;
    00240     uint8 jf;
    00241     int32 k;
    00242 };
    00243
    00244
    00246 struct rpcap_auth
    00247 {
    00248     uint16 type;
    00249     uint16 dummy;
    00250     uint16 slen1;
    00251     uint16 slen2;
    00252 };
    00253
    00254
    00256 struct rpcap_stats
    00257 {
    00258     uint32 ifrecv;
    00259     uint32 ifdrop;
    00260     uint32 krnldrop;
    00261     uint32 svrcapt;
    00262 };
    00263
    00264
    00265
    00266 // Messages field coding
    00267 #define RPCAP_MSG_ERROR 1
    00268 #define RPCAP_MSG_FINDALLIF_REQ 2
    00269 #define RPCAP_MSG_OPEN_REQ 3
    00270 #define RPCAP_MSG_STARTCAP_REQ 4
    00271 #define RPCAP_MSG_UPDATEFILTER_REQ 5
    00272 #define RPCAP_MSG_CLOSE 6
    00273 #define RPCAP_MSG_PACKET 7
    00274 #define RPCAP_MSG_AUTH_REQ 8
    00275 #define RPCAP_MSG_STATS_REQ 9
    00276 #define RPCAP_MSG_ENDCAP_REQ 10
    00278 #define RPCAP_MSG_FINDALLIF_REPLY   (128+RPCAP_MSG_FINDALLIF_REQ)
    00279 #define RPCAP_MSG_OPEN_REPLY        (128+RPCAP_MSG_OPEN_REQ)
    00280 #define RPCAP_MSG_STARTCAP_REPLY    (128+RPCAP_MSG_STARTCAP_REQ)
    00281 #define RPCAP_MSG_UPDATEFILTER_REPLY (128+RPCAP_MSG_UPDATEFILTER_REQ)
    00282 #define RPCAP_MSG_AUTH_REPLY        (128+RPCAP_MSG_AUTH_REQ)
    00283 #define RPCAP_MSG_STATS_REPLY       (128+RPCAP_MSG_STATS_REQ)
    00284 #define RPCAP_MSG_ENDCAP_REPLY      (128+RPCAP_MSG_ENDCAP_REQ)
    00286 #define RPCAP_STARTCAPREQ_FLAG_PROMISC 1
    00287 #define RPCAP_STARTCAPREQ_FLAG_DGRAM 2
    00288 #define RPCAP_STARTCAPREQ_FLAG_SERVEROPEN 4
    00289 #define RPCAP_STARTCAPREQ_FLAG_INBOUND 8
    00290 #define RPCAP_STARTCAPREQ_FLAG_OUTBOUND 16
    00293 #define RPCAP_UPDATEFILTER_BPF 1
    00296 // Network error codes
    00297 #define PCAP_ERR_NETW 1
    00298 #define PCAP_ERR_INITTIMEOUT 2
    00299 #define PCAP_ERR_AUTH 3
    00300 #define PCAP_ERR_FINDALLIF 4
    00301 #define PCAP_ERR_NOREMOTEIF 5
    00302 #define PCAP_ERR_OPEN 6
    00303 #define PCAP_ERR_UPDATEFILTER 7
    00304 #define PCAP_ERR_GETSTATS 8
    00305 #define PCAP_ERR_READEX 9
    00306 #define PCAP_ERR_HOSTNOAUTH 10
    00307 #define PCAP_ERR_REMOTEACCEPT 11
    00308 #define PCAP_ERR_STARTCAPTURE 12
    00309 #define PCAP_ERR_ENDCAPTURE 13
    00310 #define PCAP_ERR_RUNTIMETIMEOUT 14       // end of private documentation
    00314
    00315
    00316
    00317
    00318
    00319
    00320 /*********************************************************
    00321  *                                                       *
    00322  * Exported funtion prototypes                           *
    00323  *                                                       *
    00324  *********************************************************/
    00325 pcap_t *pcap_opensource_remote(const char *source, struct pcap_rmtauth *auth, char *errbuf);
    00326 int pcap_startcapture_remote(pcap_t *fp);
    00327
    00328 int pcap_read_nocb_remote(pcap_t *p, struct pcap_pkthdr **pkt_header, u_char **pkt_data);
    00329 int pcap_read_remote(pcap_t *p, int cnt, pcap_handler callback, u_char *user);
    00330 int pcap_updatefilter_remote(pcap_t *fp, struct bpf_program *prog);
    00331 int pcap_setfilter_remote(pcap_t *fp, struct bpf_program *prog);
    00332 int pcap_stats_remote(pcap_t *p, struct pcap_stat *ps);
    00333 struct pcap_stat *pcap_stats_ex_remote(pcap_t *p);
    00334 void pcap_close_remote(pcap_t *p);
    00335
    00336 void rpcap_createhdr(struct rpcap_header *header, uint8 type, uint16 value, uint32 length);
    00337 int rpcap_deseraddr(struct sockaddr_storage *sockaddrin, struct sockaddr_storage **sockaddrout, char *errbuf);
    00338 int rpcap_checkmsg(char *errbuf, SOCKET sock, struct rpcap_header *header, uint8 first, ...);
    00339 int rpcap_senderror(SOCKET sock, char *error, unsigned short errcode, char *errbuf);
    00340 int rpcap_sendauth(SOCKET sock, struct pcap_rmtauth *auth, char *errbuf);
    00341
    00342 int rpcap_remoteact_getsock(const char *host, char *errbuf);
    00343
    00344 void pthread_suspend(int msec);
    00345
    00346 #endif
    00347

documentation. Copyright (c) 2002-2003 Politecnico di Torino. All rights reserved.