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
//! Rust bindings for Linux AF_PACKET (raw) sockets
//! > Packet sockets are used to receive or send raw packets at the device
//! > driver (OSI Layer 2) level. They allow the user to implement
//! > protocol modules in user space on top of the physical layer.
//! -- [packet(7)](http://man7.org/linux/man-pages/man7/packet.7.html)
/// Async wrapper for use with `futures` or `async-std`
///
/// Example usage:
/// ```
/// use afpacket::async_std::RawPacketStream;
/// use futures_lite::{future, AsyncReadExt};
/// use nom::HexDisplay;
///
/// fn main() {
/// future::block_on(async {
/// let mut ps = RawPacketStream::new().unwrap();
/// loop {
/// let mut buf = [0u8; 1500];
/// ps.read(&mut buf).await.unwrap();
/// println!("{}", buf.to_hex(24));
/// }
/// })
/// }
/// ```
/// Async wrapper for use with `tokio`
///
/// Example usage:
/// ```
/// use afpacket::tokio::RawPacketStream;
/// use nom::HexDisplay;
///
/// fn main() {
/// future::block_on(async {
/// let mut ps = RawPacketStream::new().unwrap();
/// loop {
/// let mut buf = [0u8; 1500];
/// ps.read(&mut buf).await.unwrap();
/// println!("{}", buf.to_hex(24));
/// }
/// })
/// }
/// ```
/// The bindings
///
/// Example usage:
/// ```
/// use afpacket::sync::RawPacketStream;
/// use nom::HexDisplay;
///
/// fn main() {
/// let mut ps = RawPacketStream::new().unwrap();
/// loop {
/// let mut buf = [0u8; 1500];
/// ps.read(&mut buf).unwrap();
/// println!("{}", buf.to_hex(24));
/// }
/// }
/// ```