mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-28 18:18:55 +00:00
Within Firezone's Rust codebase, we use the `etherparse` crate extensively to parse network packets. To provide a more ergonomic API, this is all encapsulated in our `ip-packet` crate. For #7518, we need to write an eBPF kernel that parses and manipulates network packets. Etherparse itself doesn't provide any facilities to manipulate network packets. That is an open feature request: https://github.com/JulianSchmid/etherparse/issues/9. For the packet manipulation that we are doing in `connlib`, we already wrote certain extensions to the `etherparse` crate but today, those are all within the `ip-packet` crate. In order to reuse that within the eBPF kernel, we cannot just depend on `ip-packet` directly because eBPF is a no-std and no-alloc environment, thus no crate in the dependency tree is allowed to depend on Rust's std-lib. `etherparse` itself actually has an `std` feature flag that we can turn off. Introducing the same in `ip-packet` would require a lot of conditional-compilation gates using `#[cfg]`. it is much easier to just introduce a new crate that houses all our in-house extensions to `etherparse`. Eventually, we can hopefully upstream those which is another motivator to separate this out.
22 lines
601 B
Rust
22 lines
601 B
Rust
//! Extension crate for `etherparse` that provides mutable slices for headers.
|
|
//!
|
|
//! To be eventually upstreamed to `etherparse`.
|
|
|
|
#![cfg_attr(not(test), no_std)]
|
|
#![cfg_attr(test, allow(clippy::unwrap_used))]
|
|
|
|
mod icmpv4_header_slice_mut;
|
|
mod icmpv6_header_slice_mut;
|
|
mod ipv4_header_slice_mut;
|
|
mod ipv6_header_slice_mut;
|
|
mod slice_utils;
|
|
mod tcp_header_slice_mut;
|
|
mod udp_header_slice_mut;
|
|
|
|
pub use icmpv4_header_slice_mut::*;
|
|
pub use icmpv6_header_slice_mut::*;
|
|
pub use ipv4_header_slice_mut::*;
|
|
pub use ipv6_header_slice_mut::*;
|
|
pub use tcp_header_slice_mut::*;
|
|
pub use udp_header_slice_mut::*;
|