Skip to content

Commit

Permalink
Add ethernet lengths and types, and header
Browse files Browse the repository at this point in the history
This patch adds a module to the `net` module of `kernel` that provides
enumerations with constants for ethernet lengths (address length, type
length, etc), as well as the enumeration of all protocols currently
understood by the network stack. The latter are represented as 16-bit
integers in memory to simplify conversion to and from the types read
directly from Ethernet II frames. This patch also contains a conversion
from/to `u16`.

The `ethernet` module also contains a `Header` abstraction that just
wraps around `struct ethhdr` defined in the UAPI. There is a simple
builder function implemented as well as getters for src/dst address, and
protocol number.

Signed-off-by: Amélie Gonzalez <lymkwi@vulpinecitrus.info>
  • Loading branch information
Lymkwi committed Jun 13, 2023
1 parent bc22545 commit d8dcac5
Show file tree
Hide file tree
Showing 2 changed files with 436 additions and 0 deletions.
1 change: 1 addition & 0 deletions rust/kernel/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use crate::{bindings, str::CStr, to_result, ARef, AlwaysRefCounted, Error, Result};
use core::{cell::UnsafeCell, ptr::NonNull};

pub mod ethernet;
#[cfg(CONFIG_NETFILTER)]
pub mod filter;

Expand Down
Loading

0 comments on commit d8dcac5

Please sign in to comment.