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
use libc::{c_uint, c_char, c_int, time_t, c_uchar, timeval};
use super::constants::PFRingChunkType;
pub enum PFRing{}
#[repr(C)]
pub struct PFRingPacketHeader {
pub ts: timeval,
pub caplen: u32,
pub len: u32,
extended_hdr: [u8; 512]
}
#[repr(C)]
pub struct PFRingCardSettings{
pub max_packet_size: u32,
pub rx_ring_slots: u32,
pub tx_ring_slots: u32,
}
#[repr(C)]
pub struct PFRingStat{
pub recv: u64,
pub drop: u64,
pub shunt: u64
}
#[repr(C)]
pub struct PFRingChunkInfo{
pub length: u32,
pub chunk_type: PFRingChunkType,
}
#[repr(C)]
pub struct PFRingBpfProgram {
bf_len: c_uint,
bf_insns: * const ()
}
#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub struct BusId {
pub slot: c_int,
pub bus: c_int,
pub device: c_int,
pub function: c_int
}
#[derive(Debug)]
#[repr(C)]
pub struct PFRingInterface {
pub name: * const c_char,
pub system_name: * const c_char,
pub module: * const c_char,
pub sn: * const c_char,
pub mac: [c_char; 6],
pub bus_id: BusId,
pub status: c_int,
pub license: c_int,
pub license_expiration: time_t,
pub next: * const PFRingInterface
}
#[repr(C)]
pub struct PFRingModuleInfo {
pub name: c_int,
pub open: unsafe extern "C" fn (* const PFRing) -> c_int,
pub findalldevs : unsafe extern "C" fn () -> * const PFRingInterface
}
#[repr(C)]
pub struct ThirdpartyFunc {
pub name: * const c_char,
pub ptr: unsafe extern "C" fn() -> ()
}
#[repr(C)]
pub struct PFRingStats{
recv: u64,
drop: u64,
shunt: u64
}
#[repr(C)]
pub enum PacketDirection {
RxAndTx = 0,
RxOnly,
TxOnly
}
pub type PFRingProcessPacket = unsafe extern "C" fn(h: * const PFRingPacketHeader, p: * const c_uchar, user_bytes: * const c_uchar);
#[repr(C)]
pub enum ChunkType{
PCapChunk = 0,
PCapNsecChunk,
PCapngNsecChunk,
UnknownChunkType
}
#[repr(C)]
pub struct ChunkInfo{
pub length: u32,
pub chunk_type: ChunkType
}