1extern crate libc;
4#[cfg(windows)] extern crate winapi;
5pub use libc::FILE;
6#[cfg(unix)] pub use libc::{sockaddr, timeval};
7#[cfg(windows)] pub use winapi::shared::ws2def::SOCKADDR as sockaddr;
8#[cfg(windows)] pub use winapi::um::winsock2::timeval;
9
10pub const PCAP_VERSION_MAJOR: u32 = 2;
11pub const PCAP_VERSION_MINOR: u32 = 4;
12pub const PCAP_ERRBUF_SIZE: u32 = 256;
13pub const PCAP_IF_LOOPBACK: u32 = 1;
14pub const PCAP_IF_UP: u32 = 2;
15pub const PCAP_IF_RUNNING: u32 = 4;
16pub const PCAP_ERROR: i32 = -1;
17pub const PCAP_ERROR_BREAK: i32 = -2;
18pub const PCAP_ERROR_NOT_ACTIVATED: i32 = -3;
19pub const PCAP_ERROR_ACTIVATED: i32 = -4;
20pub const PCAP_ERROR_NO_SUCH_DEVICE: i32 = -5;
21pub const PCAP_ERROR_RFMON_NOTSUP: i32 = -6;
22pub const PCAP_ERROR_NOT_RFMON: i32 = -7;
23pub const PCAP_ERROR_PERM_DENIED: i32 = -8;
24pub const PCAP_ERROR_IFACE_NOT_UP: i32 = -9;
25pub const PCAP_ERROR_CANTSET_TSTAMP_TYPE: i32 = -10;
26pub const PCAP_ERROR_PROMISC_PERM_DENIED: i32 = -11;
27pub const PCAP_ERROR_TSTAMP_PRECISION_NOTSUP: i32 = -12;
28pub const PCAP_WARNING: u32 = 1;
29pub const PCAP_WARNING_PROMISC_NOTSUP: u32 = 2;
30pub const PCAP_WARNING_TSTAMP_TYPE_NOTSUP: u32 = 3;
31pub const PCAP_NETMASK_UNKNOWN: u32 = 4294967295;
32pub const PCAP_TSTAMP_HOST: u32 = 0;
33pub const PCAP_TSTAMP_HOST_LOWPREC: u32 = 1;
34pub const PCAP_TSTAMP_HOST_HIPREC: u32 = 2;
35pub const PCAP_TSTAMP_ADAPTER: u32 = 3;
36pub const PCAP_TSTAMP_ADAPTER_UNSYNCED: u32 = 4;
37pub const PCAP_TSTAMP_PRECISION_MICRO: u32 = 0;
38pub const PCAP_TSTAMP_PRECISION_NANO: u32 = 1;
39pub type u_char = libc::c_uchar;
40pub type u_short = libc::c_ushort;
41pub type u_int = libc::c_uint;
42pub type bpf_int32 = libc::c_int;
43pub type bpf_u_int32 = u_int;
44#[repr(C)]
45#[derive(Debug, Copy, Clone)]
46pub struct bpf_program {
47 pub bf_len: u_int,
48 pub bf_insns: *mut bpf_insn,
49}
50#[repr(C)]
51#[derive(Debug, Copy, Clone)]
52pub struct bpf_insn {
53 pub code: u_short,
54 pub jt: u_char,
55 pub jf: u_char,
56 pub k: bpf_u_int32,
57}
58#[repr(C)]
59#[derive(Debug, Copy, Clone)]
60pub struct pcap {
61 _unused: [u8; 0],
62}
63pub type pcap_t = pcap;
64#[repr(C)]
65#[derive(Debug, Copy, Clone)]
66pub struct pcap_dumper {
67 _unused: [u8; 0],
68}
69pub type pcap_dumper_t = pcap_dumper;
70pub type pcap_if_t = pcap_if;
71pub type pcap_addr_t = pcap_addr;
72#[repr(C)]
73#[derive(Debug, Copy, Clone)]
74pub struct pcap_file_header {
75 pub magic: bpf_u_int32,
76 pub version_major: u_short,
77 pub version_minor: u_short,
78 pub thiszone: bpf_int32,
79 pub sigfigs: bpf_u_int32,
80 pub snaplen: bpf_u_int32,
81 pub linktype: bpf_u_int32,
82}
83pub const pcap_direction_t_PCAP_D_INOUT: pcap_direction_t = 0;
84pub const pcap_direction_t_PCAP_D_IN: pcap_direction_t = 1;
85pub const pcap_direction_t_PCAP_D_OUT: pcap_direction_t = 2;
86pub type pcap_direction_t = u32;
87#[repr(C)]
88pub struct pcap_pkthdr {
89 pub ts: timeval,
90 pub caplen: bpf_u_int32,
91 pub len: bpf_u_int32,
92 pub comment: [libc::c_char; 256usize],
93}
94#[repr(C)]
95#[derive(Debug, Copy, Clone)]
96pub struct pcap_stat {
97 pub ps_recv: u_int,
98 pub ps_drop: u_int,
99 pub ps_ifdrop: u_int,
100}
101#[repr(C)]
102#[derive(Debug, Copy, Clone)]
103pub struct pcap_if {
104 pub next: *mut pcap_if,
105 pub name: *mut libc::c_char,
106 pub description: *mut libc::c_char,
107 pub addresses: *mut pcap_addr,
108 pub flags: bpf_u_int32,
109}
110#[repr(C)]
111#[derive(Debug, Copy, Clone)]
112pub struct pcap_addr {
113 pub next: *mut pcap_addr,
114 pub addr: *mut sockaddr,
115 pub netmask: *mut sockaddr,
116 pub broadaddr: *mut sockaddr,
117 pub dstaddr: *mut sockaddr,
118}
119pub type pcap_handler = ::std::option::Option<
120 unsafe extern "C" fn(arg1: *mut u_char, arg2: *const pcap_pkthdr, arg3: *const u_char),
121>;
122extern "C" {
123 pub fn pcap_lookupdev(arg1: *mut libc::c_char) -> *mut libc::c_char;
124}
125extern "C" {
126 pub fn pcap_lookupnet(
127 arg1: *const libc::c_char,
128 arg2: *mut bpf_u_int32,
129 arg3: *mut bpf_u_int32,
130 arg4: *mut libc::c_char,
131 ) -> libc::c_int;
132}
133extern "C" {
134 pub fn pcap_create(arg1: *const libc::c_char, arg2: *mut libc::c_char) -> *mut pcap_t;
135}
136extern "C" {
137 pub fn pcap_set_snaplen(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
138}
139extern "C" {
140 pub fn pcap_set_promisc(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
141}
142extern "C" {
143 pub fn pcap_can_set_rfmon(arg1: *mut pcap_t) -> libc::c_int;
144}
145extern "C" {
146 pub fn pcap_set_rfmon(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
147}
148extern "C" {
149 pub fn pcap_set_timeout(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
150}
151extern "C" {
152 pub fn pcap_set_tstamp_type(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
153}
154extern "C" {
155 pub fn pcap_set_immediate_mode(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
156}
157extern "C" {
158 pub fn pcap_set_buffer_size(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
159}
160extern "C" {
161 pub fn pcap_set_tstamp_precision(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
162}
163extern "C" {
164 pub fn pcap_get_tstamp_precision(arg1: *mut pcap_t) -> libc::c_int;
165}
166extern "C" {
167 pub fn pcap_activate(arg1: *mut pcap_t) -> libc::c_int;
168}
169extern "C" {
170 pub fn pcap_apple_set_exthdr(p: *mut pcap_t, arg1: libc::c_int) -> libc::c_int;
171}
172extern "C" {
173 pub fn pcap_list_tstamp_types(arg1: *mut pcap_t, arg2: *mut *mut libc::c_int) -> libc::c_int;
174}
175extern "C" {
176 pub fn pcap_free_tstamp_types(arg1: *mut libc::c_int);
177}
178extern "C" {
179 pub fn pcap_tstamp_type_name_to_val(arg1: *const libc::c_char) -> libc::c_int;
180}
181extern "C" {
182 pub fn pcap_tstamp_type_val_to_name(arg1: libc::c_int) -> *const libc::c_char;
183}
184extern "C" {
185 pub fn pcap_tstamp_type_val_to_description(arg1: libc::c_int) -> *const libc::c_char;
186}
187extern "C" {
188 pub fn pcap_open_live(
189 arg1: *const libc::c_char,
190 arg2: libc::c_int,
191 arg3: libc::c_int,
192 arg4: libc::c_int,
193 arg5: *mut libc::c_char,
194 ) -> *mut pcap_t;
195}
196extern "C" {
197 pub fn pcap_open_dead(arg1: libc::c_int, arg2: libc::c_int) -> *mut pcap_t;
198}
199extern "C" {
200 pub fn pcap_open_dead_with_tstamp_precision(
201 arg1: libc::c_int,
202 arg2: libc::c_int,
203 arg3: u_int,
204 ) -> *mut pcap_t;
205}
206extern "C" {
207 pub fn pcap_open_offline_with_tstamp_precision(
208 arg1: *const libc::c_char,
209 arg2: u_int,
210 arg3: *mut libc::c_char,
211 ) -> *mut pcap_t;
212}
213extern "C" {
214 pub fn pcap_open_offline(arg1: *const libc::c_char, arg2: *mut libc::c_char) -> *mut pcap_t;
215}
216extern "C" {
217 pub fn pcap_fopen_offline_with_tstamp_precision(
218 arg1: *mut FILE,
219 arg2: u_int,
220 arg3: *mut libc::c_char,
221 ) -> *mut pcap_t;
222}
223extern "C" {
224 pub fn pcap_fopen_offline(arg1: *mut FILE, arg2: *mut libc::c_char) -> *mut pcap_t;
225}
226extern "C" {
227 pub fn pcap_close(arg1: *mut pcap_t);
228}
229extern "C" {
230 pub fn pcap_loop(
231 arg1: *mut pcap_t,
232 arg2: libc::c_int,
233 arg3: pcap_handler,
234 arg4: *mut u_char,
235 ) -> libc::c_int;
236}
237extern "C" {
238 pub fn pcap_dispatch(
239 arg1: *mut pcap_t,
240 arg2: libc::c_int,
241 arg3: pcap_handler,
242 arg4: *mut u_char,
243 ) -> libc::c_int;
244}
245extern "C" {
246 pub fn pcap_next(arg1: *mut pcap_t, arg2: *mut pcap_pkthdr) -> *const u_char;
247}
248extern "C" {
249 pub fn pcap_next_ex(
250 arg1: *mut pcap_t,
251 arg2: *mut *mut pcap_pkthdr,
252 arg3: *mut *const u_char,
253 ) -> libc::c_int;
254}
255extern "C" {
256 pub fn pcap_breakloop(arg1: *mut pcap_t);
257}
258extern "C" {
259 pub fn pcap_stats(arg1: *mut pcap_t, arg2: *mut pcap_stat) -> libc::c_int;
260}
261extern "C" {
262 pub fn pcap_setfilter(arg1: *mut pcap_t, arg2: *mut bpf_program) -> libc::c_int;
263}
264extern "C" {
265 pub fn pcap_setdirection(arg1: *mut pcap_t, arg2: pcap_direction_t) -> libc::c_int;
266}
267extern "C" {
268 pub fn pcap_getnonblock(arg1: *mut pcap_t, arg2: *mut libc::c_char) -> libc::c_int;
269}
270extern "C" {
271 pub fn pcap_setnonblock(
272 arg1: *mut pcap_t,
273 arg2: libc::c_int,
274 arg3: *mut libc::c_char,
275 ) -> libc::c_int;
276}
277extern "C" {
278 pub fn pcap_inject(arg1: *mut pcap_t, arg2: *const libc::c_void, arg3: usize) -> libc::c_int;
279}
280extern "C" {
281 pub fn pcap_sendpacket(
282 arg1: *mut pcap_t,
283 arg2: *const u_char,
284 arg3: libc::c_int,
285 ) -> libc::c_int;
286}
287extern "C" {
288 pub fn pcap_statustostr(arg1: libc::c_int) -> *const libc::c_char;
289}
290extern "C" {
291 pub fn pcap_strerror(arg1: libc::c_int) -> *const libc::c_char;
292}
293extern "C" {
294 pub fn pcap_geterr(arg1: *mut pcap_t) -> *mut libc::c_char;
295}
296extern "C" {
297 pub fn pcap_perror(arg1: *mut pcap_t, arg2: *const libc::c_char);
298}
299extern "C" {
300 pub fn pcap_compile(
301 arg1: *mut pcap_t,
302 arg2: *mut bpf_program,
303 arg3: *const libc::c_char,
304 arg4: libc::c_int,
305 arg5: bpf_u_int32,
306 ) -> libc::c_int;
307}
308extern "C" {
309 pub fn pcap_compile_nopcap(
310 arg1: libc::c_int,
311 arg2: libc::c_int,
312 arg3: *mut bpf_program,
313 arg4: *const libc::c_char,
314 arg5: libc::c_int,
315 arg6: bpf_u_int32,
316 ) -> libc::c_int;
317}
318extern "C" {
319 pub fn pcap_freecode(arg1: *mut bpf_program);
320}
321extern "C" {
322 pub fn pcap_offline_filter(
323 arg1: *const bpf_program,
324 arg2: *const pcap_pkthdr,
325 arg3: *const u_char,
326 ) -> libc::c_int;
327}
328extern "C" {
329 pub fn pcap_datalink(arg1: *mut pcap_t) -> libc::c_int;
330}
331extern "C" {
332 pub fn pcap_datalink_ext(arg1: *mut pcap_t) -> libc::c_int;
333}
334extern "C" {
335 pub fn pcap_list_datalinks(arg1: *mut pcap_t, arg2: *mut *mut libc::c_int) -> libc::c_int;
336}
337extern "C" {
338 pub fn pcap_set_datalink(arg1: *mut pcap_t, arg2: libc::c_int) -> libc::c_int;
339}
340extern "C" {
341 pub fn pcap_free_datalinks(arg1: *mut libc::c_int);
342}
343extern "C" {
344 pub fn pcap_datalink_name_to_val(arg1: *const libc::c_char) -> libc::c_int;
345}
346extern "C" {
347 pub fn pcap_datalink_val_to_name(arg1: libc::c_int) -> *const libc::c_char;
348}
349extern "C" {
350 pub fn pcap_datalink_val_to_description(arg1: libc::c_int) -> *const libc::c_char;
351}
352extern "C" {
353 pub fn pcap_snapshot(arg1: *mut pcap_t) -> libc::c_int;
354}
355extern "C" {
356 pub fn pcap_is_swapped(arg1: *mut pcap_t) -> libc::c_int;
357}
358extern "C" {
359 pub fn pcap_major_version(arg1: *mut pcap_t) -> libc::c_int;
360}
361extern "C" {
362 pub fn pcap_minor_version(arg1: *mut pcap_t) -> libc::c_int;
363}
364extern "C" {
365 pub fn pcap_file(arg1: *mut pcap_t) -> *mut FILE;
366}
367extern "C" {
368 pub fn pcap_fileno(arg1: *mut pcap_t) -> libc::c_int;
369}
370extern "C" {
371 pub fn pcap_dump_open(arg1: *mut pcap_t, arg2: *const libc::c_char) -> *mut pcap_dumper_t;
372}
373extern "C" {
374 pub fn pcap_dump_fopen(arg1: *mut pcap_t, fp: *mut FILE) -> *mut pcap_dumper_t;
375}
376extern "C" {
377 pub fn pcap_dump_open_append(
378 arg1: *mut pcap_t,
379 arg2: *const libc::c_char,
380 ) -> *mut pcap_dumper_t;
381}
382extern "C" {
383 pub fn pcap_dump_file(arg1: *mut pcap_dumper_t) -> *mut FILE;
384}
385extern "C" {
386 pub fn pcap_dump_ftell(arg1: *mut pcap_dumper_t) -> libc::c_long;
387}
388extern "C" {
389 pub fn pcap_dump_flush(arg1: *mut pcap_dumper_t) -> libc::c_int;
390}
391extern "C" {
392 pub fn pcap_dump_close(arg1: *mut pcap_dumper_t);
393}
394extern "C" {
395 pub fn pcap_dump(arg1: *mut u_char, arg2: *const pcap_pkthdr, arg3: *const u_char);
396}
397extern "C" {
398 pub fn pcap_findalldevs(arg1: *mut *mut pcap_if_t, arg2: *mut libc::c_char) -> libc::c_int;
399}
400extern "C" {
401 pub fn pcap_freealldevs(arg1: *mut pcap_if_t);
402}
403extern "C" {
404 pub fn pcap_lib_version() -> *const libc::c_char;
405}
406extern "C" {
407 pub fn pcap_get_selectable_fd(arg1: *mut pcap_t) -> libc::c_int;
408}
409extern "C" {
410 pub fn pcap_get_selectable_fd_list(
411 arg1: *mut pcap_t,
412 arg2: *mut *mut libc::c_int,
413 ) -> libc::c_int;
414}
415extern "C" {
416 pub fn pcap_free_selectable_fd_list(arg1: *mut libc::c_int);
417}