Skip to content

Commit d8dcac5

Browse files
committed
Add ethernet lengths and types, and header
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 <[email protected]>
1 parent bc22545 commit d8dcac5

File tree

2 files changed

+436
-0
lines changed

2 files changed

+436
-0
lines changed

Diff for: rust/kernel/net.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use crate::{bindings, str::CStr, to_result, ARef, AlwaysRefCounted, Error, Result};
1010
use core::{cell::UnsafeCell, ptr::NonNull};
1111

12+
pub mod ethernet;
1213
#[cfg(CONFIG_NETFILTER)]
1314
pub mod filter;
1415

0 commit comments

Comments
 (0)