xref: /aosp_15_r20/external/libpcap/pcap-rpcap-int.h (revision 8b26181f966a6af5cf6981a6f474313de533bb28)
1*8b26181fSAndroid Build Coastguard Worker /*
2*8b26181fSAndroid Build Coastguard Worker  * Copyright (c) 2002 - 2005 NetGroup, Politecnico di Torino (Italy)
3*8b26181fSAndroid Build Coastguard Worker  * Copyright (c) 2005 - 2008 CACE Technologies, Davis (California)
4*8b26181fSAndroid Build Coastguard Worker  * All rights reserved.
5*8b26181fSAndroid Build Coastguard Worker  *
6*8b26181fSAndroid Build Coastguard Worker  * Redistribution and use in source and binary forms, with or without
7*8b26181fSAndroid Build Coastguard Worker  * modification, are permitted provided that the following conditions
8*8b26181fSAndroid Build Coastguard Worker  * are met:
9*8b26181fSAndroid Build Coastguard Worker  *
10*8b26181fSAndroid Build Coastguard Worker  * 1. Redistributions of source code must retain the above copyright
11*8b26181fSAndroid Build Coastguard Worker  * notice, this list of conditions and the following disclaimer.
12*8b26181fSAndroid Build Coastguard Worker  * 2. Redistributions in binary form must reproduce the above copyright
13*8b26181fSAndroid Build Coastguard Worker  * notice, this list of conditions and the following disclaimer in the
14*8b26181fSAndroid Build Coastguard Worker  * documentation and/or other materials provided with the distribution.
15*8b26181fSAndroid Build Coastguard Worker  * 3. Neither the name of the Politecnico di Torino, CACE Technologies
16*8b26181fSAndroid Build Coastguard Worker  * nor the names of its contributors may be used to endorse or promote
17*8b26181fSAndroid Build Coastguard Worker  * products derived from this software without specific prior written
18*8b26181fSAndroid Build Coastguard Worker  * permission.
19*8b26181fSAndroid Build Coastguard Worker  *
20*8b26181fSAndroid Build Coastguard Worker  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21*8b26181fSAndroid Build Coastguard Worker  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22*8b26181fSAndroid Build Coastguard Worker  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23*8b26181fSAndroid Build Coastguard Worker  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24*8b26181fSAndroid Build Coastguard Worker  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25*8b26181fSAndroid Build Coastguard Worker  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26*8b26181fSAndroid Build Coastguard Worker  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27*8b26181fSAndroid Build Coastguard Worker  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28*8b26181fSAndroid Build Coastguard Worker  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29*8b26181fSAndroid Build Coastguard Worker  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30*8b26181fSAndroid Build Coastguard Worker  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31*8b26181fSAndroid Build Coastguard Worker  *
32*8b26181fSAndroid Build Coastguard Worker  */
33*8b26181fSAndroid Build Coastguard Worker 
34*8b26181fSAndroid Build Coastguard Worker #ifndef __PCAP_RPCAP_INT_H__
35*8b26181fSAndroid Build Coastguard Worker #define __PCAP_RPCAP_INT_H__
36*8b26181fSAndroid Build Coastguard Worker 
37*8b26181fSAndroid Build Coastguard Worker #include "pcap.h"
38*8b26181fSAndroid Build Coastguard Worker #include "sockutils.h"	/* Needed for some structures (like SOCKET, sockaddr_in) which are used here */
39*8b26181fSAndroid Build Coastguard Worker 
40*8b26181fSAndroid Build Coastguard Worker /*
41*8b26181fSAndroid Build Coastguard Worker  * \file pcap-rpcap-int.h
42*8b26181fSAndroid Build Coastguard Worker  *
43*8b26181fSAndroid Build Coastguard Worker  * This file keeps all the definitions used by the RPCAP client and server,
44*8b26181fSAndroid Build Coastguard Worker  * other than the protocol definitions.
45*8b26181fSAndroid Build Coastguard Worker  *
46*8b26181fSAndroid Build Coastguard Worker  * \warning All the RPCAP functions that are allowed to return a buffer containing
47*8b26181fSAndroid Build Coastguard Worker  * the error description can return max PCAP_ERRBUF_SIZE characters.
48*8b26181fSAndroid Build Coastguard Worker  * However there is no guarantees that the string will be zero-terminated.
49*8b26181fSAndroid Build Coastguard Worker  * Best practice is to define the errbuf variable as a char of size 'PCAP_ERRBUF_SIZE+1'
50*8b26181fSAndroid Build Coastguard Worker  * and to insert manually the termination char at the end of the buffer. This will
51*8b26181fSAndroid Build Coastguard Worker  * guarantee that no buffer overflows occur even if we use the printf() to show
52*8b26181fSAndroid Build Coastguard Worker  * the error on the screen.
53*8b26181fSAndroid Build Coastguard Worker  */
54*8b26181fSAndroid Build Coastguard Worker 
55*8b26181fSAndroid Build Coastguard Worker /*********************************************************
56*8b26181fSAndroid Build Coastguard Worker  *                                                       *
57*8b26181fSAndroid Build Coastguard Worker  * General definitions / typedefs for the RPCAP protocol *
58*8b26181fSAndroid Build Coastguard Worker  *                                                       *
59*8b26181fSAndroid Build Coastguard Worker  *********************************************************/
60*8b26181fSAndroid Build Coastguard Worker 
61*8b26181fSAndroid Build Coastguard Worker /*
62*8b26181fSAndroid Build Coastguard Worker  * \brief Buffer used by socket functions to send-receive packets.
63*8b26181fSAndroid Build Coastguard Worker  * In case you plan to have messages larger than this value, you have to increase it.
64*8b26181fSAndroid Build Coastguard Worker  */
65*8b26181fSAndroid Build Coastguard Worker #define RPCAP_NETBUF_SIZE 64000
66*8b26181fSAndroid Build Coastguard Worker 
67*8b26181fSAndroid Build Coastguard Worker /*********************************************************
68*8b26181fSAndroid Build Coastguard Worker  *                                                       *
69*8b26181fSAndroid Build Coastguard Worker  * Exported function prototypes                          *
70*8b26181fSAndroid Build Coastguard Worker  *                                                       *
71*8b26181fSAndroid Build Coastguard Worker  *********************************************************/
72*8b26181fSAndroid Build Coastguard Worker void rpcap_createhdr(struct rpcap_header *header, uint8 type, uint16 value, uint32 length);
73*8b26181fSAndroid Build Coastguard Worker int rpcap_senderror(SOCKET sock, char *error, unsigned short errcode, char *errbuf);
74*8b26181fSAndroid Build Coastguard Worker 
75*8b26181fSAndroid Build Coastguard Worker #endif
76