Expand description
§Internet
A networking library providing codecs, in-place parsing and mutation.
§Architecture
§Mappings: In-Place Parsing and Mutation
Access protocol fields directly on the underlying buffer with zero allocations:
use internet::ietf::udp::{HeaderMapping, Port};
// Parse in-place
let udp = HeaderMapping::new(&[0xaa, 0xaa, 0xbb, 0xbb, 0x66, 0x66, 0x00, 0x00]);
let src_port = udp.read_source_port();
let dst_port = udp.read_destination_port();
println!("{src_port:#?}, {dst_port:#?}");
// Mutate in-place
let udp_mut_bytes = &mut [0xaa, 0xaa, 0xbb, 0xbb, 0x66, 0x66, 0x00, 0x00];
let mut udp = HeaderMapping::new(udp_mut_bytes);
udp.write_source_port(Port::from(443)).unwrap();§Codecs: Type-Safe Serialization and Deserialization
High-level protocol types with encode/decode methods:
use internet::ietf::tls1_3::{Alert, AlertDescription};
use internet::{Codec, Cursor};
// Decode from buffer
let mut alert = Alert::decode(&mut Cursor::new(&[0x02, 0xA]), ()).unwrap();
alert.description = AlertDescription::DecodeError;
println!("{alert:#?}");
// Encode to buffer
let mut writer = Cursor::new(vec![]);
alert.encode(&mut writer, ()).unwrap();§Scope
This library provides zero-copy, type-safe implementations of dozens of internet protocols across all network layers:
- Layer 2 (Data Link): Ethernet, VLAN, ARP
- Layer 3 (Network): IPv4, IPv6, ICMPv4/6, IGMP (v1-3), NDP, MLD (v1/2), SLAAC
- Layer 4 (Transport): TCP, UDP, QUIC (v1/2)
- Layer 5-7 (Application): HTTP/1.1, HTTP/2, HTTP/3, TLS (1.0-1.3), DHCPv4/6
Future releases will expand coverage to hundreds of protocols including BGP, DNS, SMTP, and 3GPP mobile standards.
§Modules
egpp— 3GPP mobile protocols (LTE, 5G, etc.)ieee— IEEE family (Ethernet, VLAN, Wi-Fi, etc.)ietf— IETF protocols (IP, TCP, UDP, HTTP, TLS, etc.)
§Core Traits
Buf,BufMut— Buffer traits for zero-copy operationsCodec— Trait for type-safe encoding/decodingCursor— Cursor wrapper for buffer operations
§Design Goals
- Zero-copy: Parse packets without allocations
- Type-safe: Compile-time guarantees on protocol structure
- Comprehensive: Cover the entire internet protocol stack
- Extensible: Easy to add new protocols following the same pattern
§Status
This library is under active development. Currently implements 30+ protocols with more being added regularly.
Unstable API — Breaking changes expected until 1.0.0.
Then more standards and protocols we met — then more ideas we got. Then more areas we explore — then more name spaces and conflicts we got. Then more goals we set — then more scales we got. Then more time we lived — then more times we changed.
Modules§
- egpp
- 3GPP: Mobile telecommunication protocols
- ieee
- IEEE: Data link and physical layer protocols
- ietf
- IETF: End-to-end routing, transport, and application protocols
Structs§
- Cursor
- A stateful wrapper for sequential reading and writing in a buffer.
Enums§
- BufError
- Errors that can occur during buffer read or write operations.
Traits§
- Buf
- Read-only memory abstraction supporting random-access reads.
- BufMut
- Mutable memory abstraction supporting random-access writes.
- Codec
- A
Codectrait provides encoding and decoding.