1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/* automatically generated by rust-bindgen */

extern crate libc;
#[cfg(windows)] extern crate winapi;
pub use libc::FILE;
#[cfg(unix)] pub use libc::{sockaddr, timeval};
#[cfg(windows)] pub use winapi::shared::ws2def::SOCKADDR as sockaddr;
#[cfg(windows)] pub use winapi::um::winsock2::timeval;

pub const PCAP_VERSION_MAJOR: u32 = 2;
pub const PCAP_VERSION_MINOR: u32 = 4;
pub const PCAP_ERRBUF_SIZE: u32 = 256;
pub const PCAP_IF_LOOPBACK: u32 = 1;
pub const PCAP_IF_UP: u32 = 2;
pub const PCAP_IF_RUNNING: u32 = 4;
pub const PCAP_ERROR: i32 = -1;
pub const PCAP_ERROR_BREAK: i32 = -2;
pub const PCAP_ERROR_NOT_ACTIVATED: i32 = -3;
pub const PCAP_ERROR_ACTIVATED: i32 = -4;
pub const PCAP_ERROR_NO_SUCH_DEVICE: i32 = -5;
pub const PCAP_ERROR_RFMON_NOTSUP: i32 = -6;
pub const PCAP_ERROR_NOT_RFMON: i32 = -7;
pub const PCAP_ERROR_PERM_DENIED: i32 = -8;
pub const PCAP_ERROR_IFACE_NOT_UP: i32 = -9;
pub const PCAP_ERROR_CANTSET_TSTAMP_TYPE: i32 = -10;
pub const PCAP_ERROR_PROMISC_PERM_DENIED: i32 = -11;
pub const PCAP_ERROR_TSTAMP_PRECISION_NOTSUP: i32 = -12;
pub const PCAP_WARNING: u32 = 1;
pub const PCAP_WARNING_PROMISC_NOTSUP: u32 = 2;
pub const PCAP_WARNING_TSTAMP_TYPE_NOTSUP: u32 = 3;
pub const PCAP_NETMASK_UNKNOWN: u32 = 4294967295;
pub const PCAP_TSTAMP_HOST: u32 = 0;
pub const PCAP_TSTAMP_HOST_LOWPREC: u32 = 1;
pub const PCAP_TSTAMP_HOST_HIPREC: u32 = 2;
pub const PCAP_TSTAMP_ADAPTER: u32 = 3;
pub const PCAP_TSTAMP_ADAPTER_UNSYNCED: u32 = 4;
pub const PCAP_TSTAMP_PRECISION_MICRO: u32 = 0;
pub const PCAP_TSTAMP_PRECISION_NANO: u32 = 1;
pub type u_char = libc::c_uchar;
pub type u_short = libc::c_ushort;
pub type u_int = libc::c_uint;
pub type bpf_int32 = libc::c_int;
pub type bpf_u_int32 = u_int;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct bpf_program {
    pub bf_len: u_int,
    pub bf_insns: *mut bpf_insn,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct bpf_insn {
    pub code: u_short,
    pub jt: u_char,
    pub jf: u_char,
    pub k: bpf_u_int32,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct pcap {
    _unused: [u8; 0],
}
pub type pcap_t = pcap;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct pcap_dumper {
    _unused: [u8; 0],
}
pub type pcap_dumper_t = pcap_dumper;
pub type pcap_if_t = pcap_if;
pub type pcap_addr_t = pcap_addr;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct pcap_file_header {
    pub magic: bpf_u_int32,
    pub version_major: u_short,
    pub version_minor: u_short,
    pub thiszone: bpf_int32,
    pub sigfigs: bpf_u_int32,
    pub snaplen: bpf_u_int32,
    pub linktype: bpf_u_int32,
}
pub const pcap_direction_t_PCAP_D_INOUT: pcap_direction_t = 0;
pub const pcap_direction_t_PCAP_D_IN: pcap_direction_t = 1;
pub const pcap_direction_t_PCAP_D_OUT: pcap_direction_t = 2;
pub type pcap_direction_t = u32;
#[repr(C)]
pub struct pcap_pkthdr {
    pub ts: timeval,
    pub caplen: bpf_u_int32,
    pub len: bpf_u_int32,
    pub comment: [libc::c_char; 256usize],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct pcap_stat {
    pub ps_recv: u_int,
    pub ps_drop: u_int,
    pub ps_ifdrop: u_int,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct pcap_if {
    pub next: *mut pcap_if,
    pub name: *mut libc::c_char,
    pub description: *mut libc::c_char,
    pub addresses: *mut pcap_addr,
    pub flags: bpf_u_int32,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct pcap_addr {
    pub next: *mut pcap_addr,
    pub addr: *mut sockaddr,
    pub netmask: *mut sockaddr,
    pub broadaddr: *mut sockaddr,
    pub dstaddr: *mut sockaddr,
}
pub type pcap_handler = ::std::option::Option<
    unsafe extern "C" fn(arg1: *mut u_char, arg2: *const pcap_pkthdr, arg3: *const u_char),
>;
extern "C" {
    pub fn pcap_lookupdev(arg1: *mut libc::c_char) -> *mut libc::c_char;
}
extern "C" {
    pub fn pcap_lookupnet(
        arg1: *const libc::c_char,
        arg2: *mut bpf_u_int32,
        arg3: *mut bpf_u_int32,
        arg4: *mut libc::c_char,
    ) -> libc::c_int;
}
extern "C" {
    pub fn pcap_create(arg1: *const libc::c_char, arg2: *mut libc::c_char) -> *mut pcap_t;
}
extern "C" {
    pub fn pcap_set_snaplen(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
}
extern "C" {
    pub fn pcap_set_promisc(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
}
extern "C" {
    pub fn pcap_can_set_rfmon(arg1: *mut pcap_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_set_rfmon(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
}
extern "C" {
    pub fn pcap_set_timeout(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
}
extern "C" {
    pub fn pcap_set_tstamp_type(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
}
extern "C" {
    pub fn pcap_set_immediate_mode(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
}
extern "C" {
    pub fn pcap_set_buffer_size(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
}
extern "C" {
    pub fn pcap_set_tstamp_precision(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
}
extern "C" {
    pub fn pcap_get_tstamp_precision(arg1: *mut pcap_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_activate(arg1: *mut pcap_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_apple_set_exthdr(p: *mut pcap_t, arg1: libc::c_int) -> libc::c_int;
}
extern "C" {
    pub fn pcap_list_tstamp_types(arg1: *mut pcap_t, arg2: *mut *mut libc::c_int) -> libc::c_int;
}
extern "C" {
    pub fn pcap_free_tstamp_types(arg1: *mut libc::c_int);
}
extern "C" {
    pub fn pcap_tstamp_type_name_to_val(arg1: *const libc::c_char) -> libc::c_int;
}
extern "C" {
    pub fn pcap_tstamp_type_val_to_name(arg1: libc::c_int) -> *const libc::c_char;
}
extern "C" {
    pub fn pcap_tstamp_type_val_to_description(arg1: libc::c_int) -> *const libc::c_char;
}
extern "C" {
    pub fn pcap_open_live(
        arg1: *const libc::c_char,
        arg2: libc::c_int,
        arg3: libc::c_int,
        arg4: libc::c_int,
        arg5: *mut libc::c_char,
    ) -> *mut pcap_t;
}
extern "C" {
    pub fn pcap_open_dead(arg1: libc::c_int, arg2: libc::c_int) -> *mut pcap_t;
}
extern "C" {
    pub fn pcap_open_dead_with_tstamp_precision(
        arg1: libc::c_int,
        arg2: libc::c_int,
        arg3: u_int,
    ) -> *mut pcap_t;
}
extern "C" {
    pub fn pcap_open_offline_with_tstamp_precision(
        arg1: *const libc::c_char,
        arg2: u_int,
        arg3: *mut libc::c_char,
    ) -> *mut pcap_t;
}
extern "C" {
    pub fn pcap_open_offline(arg1: *const libc::c_char, arg2: *mut libc::c_char) -> *mut pcap_t;
}
extern "C" {
    pub fn pcap_fopen_offline_with_tstamp_precision(
        arg1: *mut FILE,
        arg2: u_int,
        arg3: *mut libc::c_char,
    ) -> *mut pcap_t;
}
extern "C" {
    pub fn pcap_fopen_offline(arg1: *mut FILE, arg2: *mut libc::c_char) -> *mut pcap_t;
}
extern "C" {
    pub fn pcap_close(arg1: *mut pcap_t);
}
extern "C" {
    pub fn pcap_loop(
        arg1: *mut pcap_t,
        arg2: libc::c_int,
        arg3: pcap_handler,
        arg4: *mut u_char,
    ) -> libc::c_int;
}
extern "C" {
    pub fn pcap_dispatch(
        arg1: *mut pcap_t,
        arg2: libc::c_int,
        arg3: pcap_handler,
        arg4: *mut u_char,
    ) -> libc::c_int;
}
extern "C" {
    pub fn pcap_next(arg1: *mut pcap_t, arg2: *mut pcap_pkthdr) -> *const u_char;
}
extern "C" {
    pub fn pcap_next_ex(
        arg1: *mut pcap_t,
        arg2: *mut *mut pcap_pkthdr,
        arg3: *mut *const u_char,
    ) -> libc::c_int;
}
extern "C" {
    pub fn pcap_breakloop(arg1: *mut pcap_t);
}
extern "C" {
    pub fn pcap_stats(arg1: *mut pcap_t, arg2: *mut pcap_stat) -> libc::c_int;
}
extern "C" {
    pub fn pcap_setfilter(arg1: *mut pcap_t, arg2: *mut bpf_program) -> libc::c_int;
}
extern "C" {
    pub fn pcap_setdirection(arg1: *mut pcap_t, arg2: pcap_direction_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_getnonblock(arg1: *mut pcap_t, arg2: *mut libc::c_char) -> libc::c_int;
}
extern "C" {
    pub fn pcap_setnonblock(
        arg1: *mut pcap_t,
        arg2: libc::c_int,
        arg3: *mut libc::c_char,
    ) -> libc::c_int;
}
extern "C" {
    pub fn pcap_inject(arg1: *mut pcap_t, arg2: *const libc::c_void, arg3: usize) -> libc::c_int;
}
extern "C" {
    pub fn pcap_sendpacket(
        arg1: *mut pcap_t,
        arg2: *const u_char,
        arg3: libc::c_int,
    ) -> libc::c_int;
}
extern "C" {
    pub fn pcap_statustostr(arg1: libc::c_int) -> *const libc::c_char;
}
extern "C" {
    pub fn pcap_strerror(arg1: libc::c_int) -> *const libc::c_char;
}
extern "C" {
    pub fn pcap_geterr(arg1: *mut pcap_t) -> *mut libc::c_char;
}
extern "C" {
    pub fn pcap_perror(arg1: *mut pcap_t, arg2: *const libc::c_char);
}
extern "C" {
    pub fn pcap_compile(
        arg1: *mut pcap_t,
        arg2: *mut bpf_program,
        arg3: *const libc::c_char,
        arg4: libc::c_int,
        arg5: bpf_u_int32,
    ) -> libc::c_int;
}
extern "C" {
    pub fn pcap_compile_nopcap(
        arg1: libc::c_int,
        arg2: libc::c_int,
        arg3: *mut bpf_program,
        arg4: *const libc::c_char,
        arg5: libc::c_int,
        arg6: bpf_u_int32,
    ) -> libc::c_int;
}
extern "C" {
    pub fn pcap_freecode(arg1: *mut bpf_program);
}
extern "C" {
    pub fn pcap_offline_filter(
        arg1: *const bpf_program,
        arg2: *const pcap_pkthdr,
        arg3: *const u_char,
    ) -> libc::c_int;
}
extern "C" {
    pub fn pcap_datalink(arg1: *mut pcap_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_datalink_ext(arg1: *mut pcap_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_list_datalinks(arg1: *mut pcap_t, arg2: *mut *mut libc::c_int) -> libc::c_int;
}
extern "C" {
    pub fn pcap_set_datalink(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
}
extern "C" {
    pub fn pcap_free_datalinks(arg1: *mut libc::c_int);
}
extern "C" {
    pub fn pcap_datalink_name_to_val(arg1: *const libc::c_char) -> libc::c_int;
}
extern "C" {
    pub fn pcap_datalink_val_to_name(arg1: libc::c_int) -> *const libc::c_char;
}
extern "C" {
    pub fn pcap_datalink_val_to_description(arg1: libc::c_int) -> *const libc::c_char;
}
extern "C" {
    pub fn pcap_snapshot(arg1: *mut pcap_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_is_swapped(arg1: *mut pcap_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_major_version(arg1: *mut pcap_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_minor_version(arg1: *mut pcap_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_file(arg1: *mut pcap_t) -> *mut FILE;
}
extern "C" {
    pub fn pcap_fileno(arg1: *mut pcap_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_dump_open(arg1: *mut pcap_t, arg2: *const libc::c_char) -> *mut pcap_dumper_t;
}
extern "C" {
    pub fn pcap_dump_fopen(arg1: *mut pcap_t, fp: *mut FILE) -> *mut pcap_dumper_t;
}
extern "C" {
    pub fn pcap_dump_open_append(
        arg1: *mut pcap_t,
        arg2: *const libc::c_char,
    ) -> *mut pcap_dumper_t;
}
extern "C" {
    pub fn pcap_dump_file(arg1: *mut pcap_dumper_t) -> *mut FILE;
}
extern "C" {
    pub fn pcap_dump_ftell(arg1: *mut pcap_dumper_t) -> libc::c_long;
}
extern "C" {
    pub fn pcap_dump_flush(arg1: *mut pcap_dumper_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_dump_close(arg1: *mut pcap_dumper_t);
}
extern "C" {
    pub fn pcap_dump(arg1: *mut u_char, arg2: *const pcap_pkthdr, arg3: *const u_char);
}
extern "C" {
    pub fn pcap_findalldevs(arg1: *mut *mut pcap_if_t, arg2: *mut libc::c_char) -> libc::c_int;
}
extern "C" {
    pub fn pcap_freealldevs(arg1: *mut pcap_if_t);
}
extern "C" {
    pub fn pcap_lib_version() -> *const libc::c_char;
}
extern "C" {
    pub fn pcap_get_selectable_fd(arg1: *mut pcap_t) -> libc::c_int;
}
extern "C" {
    pub fn pcap_get_selectable_fd_list(
        arg1: *mut pcap_t,
        arg2: *mut *mut libc::c_int,
    ) -> libc::c_int;
}
extern "C" {
    pub fn pcap_free_selectable_fd_list(arg1: *mut libc::c_int);
}