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
//! push-packet is a high-level, extensible packet routing library built on eBPF with aya. It is
//! intended to be a simple, yet flexible foundation for traffic analysis applications and
//! network-stack bypass.
//!
//! # Example: Tap into a network interface, and copy all packets to userspace.
//! ```no_run
//! # use push_packet::{Tap, rules::{Rule, Action}};
//! # fn main() -> Result<(), push_packet::Error> {
//! let mut tap = Tap::builder("wlp3s0")
//! .rule(Rule::source_cidr("0.0.0.0/0").action(Action::Copy { take: None }))
//! .build()?;
//!
//! let mut rx = tap.copy_receiver()?;
//! while let Ok(event) = rx.recv() {
//! println!("Received packet of length {}", event.packet_len());
//! }
//! # Ok(())
//! # }
//! ```
//! # Example: Tap into an interface, add and remove rules dynamically.
//! ```no_run
//! # use push_packet::{Tap, rules::{Rule, Action, Protocol}, CopyConfig};
//! # fn main() -> Result<(), push_packet::Error> {
//! let mut tap = Tap::builder("wlp3s0")
//! // Set force_enabled on the copy config so we can use copy rules later.
//! .copy_config(CopyConfig::default().force_enabled())
//! .build()?;
//!
//! // call add_rule to get a RuleId
//! let drop_rule_id = tap.add_rule(
//! Rule::protocol(Protocol::Tcp)
//! .source_cidr("127.0.0.1")
//! .source_port(3000..4000)
//! .action(Action::Drop),
//! )?;
//!
//! // [traffic dropped]
//!
//! // Remove a rule with RuleId
//! tap.remove_rule(drop_rule_id)?;
//!
//! // Read some traffic instead
//! tap.add_rule(
//! Rule::source_cidr("127.0.0.1")
//! .source_port(3001)
//! .action(Action::COPY_ALL),
//! )?;
//!
//! let mut rx = tap.copy_receiver()?;
//! while let Ok(event) = rx.recv() {
//! println!("Received packet of length {}", event.packet_len());
//! }
//!
//! # Ok(())
//! # }
//! ```
pub use ChannelError;
pub use Error;
pub use Interface;
pub use Loader;
pub use FrameKind;
pub use RuleError;
pub use ;