1 /*
2  * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)
3  * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California)
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of the Politecnico di Torino, CACE Technologies
16  * nor the names of its contributors may be used to endorse or promote
17  * products derived from this software without specific prior written
18  * permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 
35 #ifndef __WIN32_EXTENSIONS_H__
36     #define __WIN32_EXTENSIONS_H__
37 
38     #ifdef __cplusplus
39     extern "C" {
40     #endif
41 
42 /* Definitions */
43 
44 /*!
45  * \brief A queue of raw packets that will be sent to the network with pcap_sendqueue_transmit().
46  */
47     struct pcap_send_queue
48     {
49         u_int maxlen;  /*/< Maximum size of the the queue, in bytes. This variable contains the size of the buffer field. */
50         u_int len;     /*/< Current size of the queue, in bytes. */
51         char * buffer; /*/< Buffer containing the packets to be sent. */
52     };
53 
54     typedef struct pcap_send_queue      pcap_send_queue;
55 
56 /*!
57  * \brief This typedef is a support for the pcap_get_airpcap_handle() function
58  */
59     #if !defined( AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_ )
60         #define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_
61         typedef struct _AirpcapHandle   * PAirpcapHandle;
62     #endif
63 
64     #define     BPF_MEM_EX_IMM            0xc0
65     #define     BPF_MEM_EX_IND            0xe0
66 
67 /*used for ST*/
68     #define     BPF_MEM_EX                0xc0
69     #define     BPF_TME                   0x08
70 
71     #define     BPF_LOOKUP                0x90
72     #define     BPF_EXECUTE               0xa0
73     #define     BPF_INIT                  0xb0
74     #define     BPF_VALIDATE              0xc0
75     #define     BPF_SET_ACTIVE            0xd0
76     #define     BPF_RESET                 0xe0
77     #define     BPF_SET_MEMORY            0x80
78     #define     BPF_GET_REGISTER_VALUE    0x70
79     #define     BPF_SET_REGISTER_VALUE    0x60
80     #define     BPF_SET_WORKING           0x50
81     #define     BPF_SET_ACTIVE_READ       0x40
82     #define     BPF_SET_AUTODELETION      0x30
83     #define     BPF_SEPARATION            0xff
84 
85 /* Prototypes */
86     pcap_send_queue * pcap_sendqueue_alloc( u_int memsize );
87 
88     void pcap_sendqueue_destroy( pcap_send_queue * queue );
89 
90     int pcap_sendqueue_queue( pcap_send_queue * queue,
91                               const struct pcap_pkthdr * pkt_header,
92                               const u_char * pkt_data );
93 
94     u_int pcap_sendqueue_transmit( pcap_t * p,
95                                    pcap_send_queue * queue,
96                                    int sync );
97 
98     HANDLE pcap_getevent( pcap_t * p );
99 
100     struct pcap_stat * pcap_stats_ex( pcap_t * p,
101                                       int * pcap_stat_size );
102 
103     int pcap_setuserbuffer( pcap_t * p,
104                             int size );
105 
106     int pcap_live_dump( pcap_t * p,
107                         char * filename,
108                         int maxsize,
109                         int maxpacks );
110 
111     int pcap_live_dump_ended( pcap_t * p,
112                               int sync );
113 
114     int pcap_offline_filter( struct bpf_program * prog,
115                              const struct pcap_pkthdr * header,
116                              const u_char * pkt_data );
117 
118     int pcap_start_oem( char * err_str,
119                         int flags );
120 
121     PAirpcapHandle pcap_get_airpcap_handle( pcap_t * p );
122 
123     #ifdef __cplusplus
124 }
125     #endif
126 
127 #endif //__WIN32_EXTENSIONS_H__
128