From 2bd66b9a04be8a63d7ee0be2d633ead183fa7e76 Mon Sep 17 00:00:00 2001 From: gennyble Date: Sat, 17 May 2025 09:53:23 -0500 Subject: initial commit; meow --- src/ethertype.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/ethertype.rs (limited to 'src/ethertype.rs') diff --git a/src/ethertype.rs b/src/ethertype.rs new file mode 100644 index 0000000..0d728f3 --- /dev/null +++ b/src/ethertype.rs @@ -0,0 +1,20 @@ +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum EtherType { + /// The frame type is IEEE 802.3 and this is it's length + Length(u16), + IPv4, + IPv6, + Unknown(u16), +} + +impl EtherType { + //TODO: check ethertype is correct + pub fn new(n: u16) -> Self { + match n { + n if n <= 1500 => Self::Length(n), + 0x0800 => Self::IPv4, + 0x86DD => Self::IPv6, + n => Self::Unknown(n), + } + } +} -- cgit 1.4.1-3-g733a5