diff --git a/src/displays/transport/mod.rs b/src/displays/transport/mod.rs
index 43c71ae..3270287 100644
--- a/src/displays/transport/mod.rs
+++ b/src/displays/transport/mod.rs
@@ -29,46 +29,161 @@ impl<'a> fmt::Display for Transport<'a> {
impl fmt::Display for TransportProtocol {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let protocol_str = match self {
- // IPv6 extension headers
- TransportProtocol::HopByHop => "IPv6 Hop-by-Hop",
- TransportProtocol::Routing => "IPv6 Routing Header",
- TransportProtocol::Fragment => "IPv6 Fragment Header",
- TransportProtocol::DestinationOptions => "IPv6 Destination Options",
- TransportProtocol::Mobility => "IPv6 Mobility Header",
- TransportProtocol::NoNextHeader => "No Next Header",
-
- // Transport protocols
+ TransportProtocol::Hopopt => "IPv6 Hop-by-Hop",
+ TransportProtocol::Ipv6Route => "IPv6 Routing Header",
+ TransportProtocol::Ipv6Frag => "IPv6 Fragment Header",
+ TransportProtocol::Ipv6Opts => "IPv6 Destination Options",
+ TransportProtocol::MobilityHeader => "IPv6 Mobility Header",
+ TransportProtocol::Ipv6NoNxt => "No Next Header",
TransportProtocol::Tcp => "TCP",
TransportProtocol::Udp => "UDP",
TransportProtocol::Icmp => "ICMP",
- TransportProtocol::IcmpV6 => "ICMPv6",
+ TransportProtocol::Ipv6Icmp => "ICMPv6",
TransportProtocol::Igmp => "IGMP",
TransportProtocol::Pim => "PIM",
- TransportProtocol::PimV2 => "PIMv2",
TransportProtocol::Vrrp => "VRRP",
-
- // Routing
TransportProtocol::Egp => "EGP",
- TransportProtocol::Igrp => "IGRP",
- TransportProtocol::Ospf => "OSPF",
+ TransportProtocol::Ospfigp => "OSPFIGP",
TransportProtocol::Eigrp => "EIGRP",
-
- // Tunneling
TransportProtocol::Gre => "GRE",
- TransportProtocol::IpInIp => "IP-in-IP",
-
- // Security
+ TransportProtocol::Ipip => "IP-in-IP",
TransportProtocol::Ah => "AH",
TransportProtocol::Esp => "ESP",
-
- // Others
TransportProtocol::Rdp => "RDP",
TransportProtocol::Dccp => "DCCP",
TransportProtocol::Rsvp => "RSVP",
TransportProtocol::Sctp => "SCTP",
-
- // Fallback
- TransportProtocol::Unknown => "Unknown",
+ TransportProtocol::Ipv4 => "IPv4",
+ TransportProtocol::St => "ST",
+ TransportProtocol::Cbt => "CBT",
+ TransportProtocol::Igp => "IGP",
+ TransportProtocol::BbnRccMon => "BBN-RCC-MON",
+ TransportProtocol::NvpIi => "NVP-II",
+ TransportProtocol::Pup => "PUP",
+ TransportProtocol::Argus => "ARGUS",
+ TransportProtocol::Emcon => "EMCON",
+ TransportProtocol::Xnet => "XNET",
+ TransportProtocol::Chaos => "CHAOS",
+ TransportProtocol::Mux => "MUX",
+ TransportProtocol::DcnMeas => "DCN-MEAS",
+ TransportProtocol::Hmp => "HMP",
+ TransportProtocol::Prm => "PRM",
+ TransportProtocol::XnsIdp => "XNS-IDP",
+ TransportProtocol::Trunk1 => "TRUNK-1",
+ TransportProtocol::Trunk2 => "TRUNK-2",
+ TransportProtocol::Leaf1 => "LEAF-1",
+ TransportProtocol::Leaf2 => "LEAF-2",
+ TransportProtocol::Irtp => "IRTP",
+ TransportProtocol::IsoTp4 => "ISO-TP4",
+ TransportProtocol::Netblt => "NETBLT",
+ TransportProtocol::MfeNsp => "MFE-NSP",
+ TransportProtocol::MeritInp => "MERIT-INP",
+ TransportProtocol::ThreePc => "3PC",
+ TransportProtocol::Idpr => "IDPR",
+ TransportProtocol::Xtp => "XTP",
+ TransportProtocol::Ddp => "DDP",
+ TransportProtocol::IdprCmtp => "IDPR-CMTP",
+ TransportProtocol::TpPlusPlus => "TP++",
+ TransportProtocol::Il => "IL",
+ TransportProtocol::Ipv6 => "IPv6",
+ TransportProtocol::Sdrp => "SDRP",
+ TransportProtocol::Idrp => "IDRP",
+ TransportProtocol::Dsr => "DSR",
+ TransportProtocol::Bna => "BNA",
+ TransportProtocol::INlsp => "INLSP",
+ TransportProtocol::Swipe => "SWIPE",
+ TransportProtocol::Narp => "NARP",
+ TransportProtocol::MinIpv4 => "MIN-IPv4",
+ TransportProtocol::Tlsp => "TLSP",
+ TransportProtocol::Skip => "SKIP",
+ TransportProtocol::AnyHostInternalProtocol => "ANY-HOST-INTERNAL-PROTOCOL",
+ TransportProtocol::Cftp => "CFTP",
+ TransportProtocol::AnyLocalNetwork => "ANY-LOCAL-NETWORK",
+ TransportProtocol::SatExpak => "SAT-EXPAK",
+ TransportProtocol::Kryptolan => "KRYPTOLAN",
+ TransportProtocol::Rvd => "RVD",
+ TransportProtocol::Ippc => "IPPC",
+ TransportProtocol::AnyDistributedFileSystem => "ANY-DISTRIBUTED-FILE-SYSTEM",
+ TransportProtocol::SatMon => "SAT-MON",
+ TransportProtocol::Visa => "VISA",
+ TransportProtocol::Ipcv => "IPCV",
+ TransportProtocol::Cpnx => "CPNX",
+ TransportProtocol::Cphb => "CPHB",
+ TransportProtocol::Wsn => "WSN",
+ TransportProtocol::Pvp => "PVP",
+ TransportProtocol::BrSatMon => "BR-SAT-MON",
+ TransportProtocol::SunNd => "SUN-ND",
+ TransportProtocol::WbMon => "WB-MON",
+ TransportProtocol::WbExpak => "WB-EXPAK",
+ TransportProtocol::IsoIp => "ISO-IP",
+ TransportProtocol::Vmtp => "VMTP",
+ TransportProtocol::SecureVmtp => "SECURE-VMTP",
+ TransportProtocol::Vines => "VINES",
+ TransportProtocol::Iptm => "IPTM",
+ TransportProtocol::NsfnetIgp => "NSFNET-IGP",
+ TransportProtocol::Dgp => "DGP",
+ TransportProtocol::Tcf => "TCF",
+ TransportProtocol::SpriteRpc => "SPRITE-RPC",
+ TransportProtocol::Larp => "LARP",
+ TransportProtocol::Mtp => "MTP",
+ TransportProtocol::Ax25 => "AX.25",
+ TransportProtocol::Micp => "MICP",
+ TransportProtocol::SccSp => "SCC-SP",
+ TransportProtocol::Etherip => "ETHERIP",
+ TransportProtocol::Encap => "ENCAP",
+ TransportProtocol::AnyPrivateEncryptionScheme => "ANY-PRIVATE-ENCRYPTION-Scheme",
+ TransportProtocol::Gmtp => "GMTP",
+ TransportProtocol::Ifmp => "IFMP",
+ TransportProtocol::Pnni => "PNNI",
+ TransportProtocol::Aris => "ARIS",
+ TransportProtocol::Scps => "SCPS",
+ TransportProtocol::Qnx => "QNX",
+ TransportProtocol::AN => "AN",
+ TransportProtocol::Ipcomp => "IPCOMP",
+ TransportProtocol::Snp => "SNP",
+ TransportProtocol::CompaqPeer => "COMPAQ-PEER",
+ TransportProtocol::IpxInIp => "IPX-IN-IP",
+ TransportProtocol::Pgm => "PGM",
+ TransportProtocol::Any0HopProtocol => "ANY-0-HOP-PROTOCOL",
+ TransportProtocol::L2tp => "L2TP",
+ TransportProtocol::Ddx => "DDX",
+ TransportProtocol::Iatp => "IATP",
+ TransportProtocol::Stp => "STP",
+ TransportProtocol::Srp => "SRP",
+ TransportProtocol::Uti => "UTI",
+ TransportProtocol::Smp => "SMP",
+ TransportProtocol::Sm => "SM",
+ TransportProtocol::Ptp => "PTP",
+ TransportProtocol::IsisOverIpv4 => "ISIS-OVER-IPV4",
+ TransportProtocol::Fire => "FIRE",
+ TransportProtocol::Crtp => "CRTP",
+ TransportProtocol::Crudp => "CRUDP",
+ TransportProtocol::Sscopmce => "SSCOPMCE",
+ TransportProtocol::Iplt => "IPLT",
+ TransportProtocol::Sps => "SPS",
+ TransportProtocol::Pipe => "PIPE",
+ TransportProtocol::Fc => "FC",
+ TransportProtocol::RsvpE2eIgnore => "RSVP-E2E-IGNORE",
+ TransportProtocol::Udplite => "UDPLITE",
+ TransportProtocol::MplsInIp => "MPLS-IN-IP",
+ TransportProtocol::Manet => "MANET",
+ TransportProtocol::Hip => "HIP",
+ TransportProtocol::Shim6 => "SHIM6",
+ TransportProtocol::Wesp => "WESP",
+ TransportProtocol::Rohc => "ROHC",
+ TransportProtocol::Ethernet => "ETHERNET",
+ TransportProtocol::Aggfrag => "AGGFRAG",
+ TransportProtocol::Nsh => "NSH",
+ TransportProtocol::Homa => "HOMA",
+ TransportProtocol::BitEmu => "BIT-EMU",
+ TransportProtocol::Experimentation253 => "EXPERIMENTATION-253",
+ TransportProtocol::Experimentation254 => "EXPERIMENTATION-254",
+ TransportProtocol::Reserved255 => "RESERVED-255",
+ TransportProtocol::Unknown(value) => {
+ write!(f, "Unknown ({})", value)?;
+ return Ok(());
+ }
+ TransportProtocol::Ggp => "GGP",
};
write!(f, "{protocol_str}")
}
diff --git a/src/parse/internet/mod.rs b/src/parse/internet/mod.rs
index 47a89d4..8e17793 100644
--- a/src/parse/internet/mod.rs
+++ b/src/parse/internet/mod.rs
@@ -87,8 +87,10 @@ impl<'a> TryFrom<&'a [u8]> for Internet<'a> {
}
Err(InternetError::UnsupportedProtocol)
}
+
}
+
// impl<'a> Internet<'a> {
// pub fn to_transport(&self) -> Option<Transport<'a>> {
// let protocol = match self.payload_protocol.as_deref()? {
diff --git a/src/parse/internet/protocols/ipv4.rs b/src/parse/internet/protocols/ipv4.rs
index 2a9114a..040ec33 100644
--- a/src/parse/internet/protocols/ipv4.rs
+++ b/src/parse/internet/protocols/ipv4.rs
@@ -169,6 +169,8 @@ impl<'a> TryFrom<&'a [u8]> for Ipv4Packet<'a> {
}
}
+
+
#[cfg(test)]
mod tests {
use super::*;
diff --git a/src/parse/mod.rs b/src/parse/mod.rs
index 82cc275..dd3ecbe 100644
--- a/src/parse/mod.rs
+++ b/src/parse/mod.rs
@@ -1,7 +1,27 @@
-// Copyright (c) 2025 Cyprien Avico avicocyprien@yahoo.com
-//
-// Licensed under the MIT License <LICENSE-MIT or http://opensource.org/licenses/MIT>.
-// This file may not be copied, modified, or distributed except according to those terms.
+//! PacketFlow – Unified network packet parsing abstraction
+//!
+//! This module provides the [`PacketFlow`] structure, which represents a
+//! fully parsed network packet across multiple layers:
+//!
+//! - Data Link (L2)
+//! - Internet (L3)
+//! - Transport (L4)
+//! - Application (L7, best-effort)
+//!
+//! The parsing model is **layered and progressive**: each layer is parsed
+//! from the payload of the previous one. Unsupported protocols do **not**
+//! cause a hard failure and are represented as `None`, allowing partial
+//! decoding of real-world traffic.
+//!
+//! ## Design goals
+//!
+//! - Deterministic, allocation-free parsing using `&[u8]` references
+//! - Clear separation between protocol layers
+//! - Robust handling of unknown or unsupported protocols
+//! - Suitable for network auditing, traffic analysis and post-capture inspection
+//!
+//! This module does **not** perform stream reassembly or session tracking.
+//! It expects a complete packet buffer (e.g. from PCAP capture).
use application::Application;
use internet::Internet;
@@ -20,17 +40,49 @@ pub mod application;
pub mod data_link;
pub mod internet;
pub mod transport;
-// You can determine either a full raw packet that will return a PacketParsed struct composed of data link network transportand application layers.
-// Or if you need to, you can put your payload in a determine application try from. detemines function are not dependants.
+/// A fully or partially parsed network packet flow.
+///
+/// `PacketFlow` represents a packet parsed across protocol layers.
+/// Each layer is optional except for the data link layer, which is mandatory.
+///
+/// Unsupported or unrecognized protocols do **not** fail parsing and instead
+/// result in `None` for the corresponding layer.
+///
+/// The structure borrows from the original packet buffer (`&[u8]`) and is
+/// therefore zero-copy.
+///
+/// ## Layer mapping
+///
+/// | Field | OSI Layer | Description |
+/// |--------------|-----------|-------------------------------------|
+/// | `data_link` | L2 | Ethernet / VLAN / etc. |
+/// | `internet` | L3 | IPv4 / IPv6 (optional) |
+/// | `transport` | L4 | TCP / UDP / ICMP (optional) |
+/// | `application`| L7 | Best-effort application decoding |
+///
+/// ## Error handling
+///
+/// Parsing stops only on **structural errors**. Unsupported protocols are
+/// handled gracefully.
+///
+/// This behavior makes `PacketFlow` suitable for offline analysis, auditing,
+/// and security-oriented tooling.
#[derive(Debug, Clone, Serialize, Eq)]
pub struct PacketFlow<'a> {
+ /// Data link layer (mandatory).
#[serde(flatten)]
pub data_link: DataLink<'a>,
+
+ /// Internet layer (optional).
#[serde(flatten)]
pub internet: Option<Internet<'a>>,
+
+ /// Transport layer (optional).
#[serde(flatten)]
pub transport: Option<Transport<'a>>,
+
+ /// Application layer (optional, best-effort).
#[serde(flatten)]
pub application: Option<Application>,
}
@@ -38,23 +90,37 @@ pub struct PacketFlow<'a> {
impl<'a> TryFrom<&'a [u8]> for PacketFlow<'a> {
type Error = ParsedPacketError;
+ /// Attempts to parse a raw packet buffer into a [`PacketFlow`].
+ ///
+ /// Parsing proceeds layer by layer:
+ ///
+ /// 1. Data Link
+ /// 2. Internet (if supported)
+ /// 3. Transport (if supported)
+ /// 4. Application (best-effort)
+ ///
+ /// Unsupported protocols do not cause an error and simply stop further
+ /// decoding.
+ ///
+ /// # Errors
+ ///
+ /// Returns an error only when a layer is structurally invalid or malformed.
fn try_from(packets: &'a [u8]) -> Result<Self, Self::Error> {
let data_link = DataLink::try_from(packets)?;
let mut internet = match Internet::try_from(data_link.payload) {
Ok(internet) => Some(internet),
Err(InternetError::UnsupportedProtocol) => None,
- Err(e) => return Err(e.into()), // ex : DataLinkError etc.
+ Err(e) => return Err(e.into()),
};
- // Étape 4 : Transport
let transport = match internet.as_mut() {
Some(internet) => match Transport::try_from(internet.payload) {
Ok(transport) => Some(transport),
Err(TransportError::UnsupportedProtocol) => {
internet
.payload_protocol
- .take() // Option<TransportProtocol> -> Option<TransportProtocol> (move)
+ .take()
.map(TransportProtocol::to_transport)
}
Err(e) => return Err(e.into()),
@@ -62,8 +128,6 @@ impl<'a> TryFrom<&'a [u8]> for PacketFlow<'a> {
None => None,
};
- // Étape 5 : Application
- // handle when transport is None then application is None
let application = match &transport {
Some(t) => match t.payload {
Some(p) => Application::try_from(p).ok(),
@@ -102,6 +166,11 @@ impl<'a> Hash for PacketFlow<'a> {
}
impl<'a> PacketFlow<'a> {
+ /// Converts this borrowed [`PacketFlow`] into an owned version.
+ ///
+ /// This performs the necessary allocations to detach from the original
+ /// packet buffer and is suitable for storage, serialization or cross-thread
+ /// usage.
pub fn to_owned(&self) -> PacketFlowOwned {
PacketFlowOwned::from(self.clone())
}
diff --git a/src/parse/transport/protocols/mod.rs b/src/parse/transport/protocols/mod.rs
index acb8363..33133ef 100644
--- a/src/parse/transport/protocols/mod.rs
+++ b/src/parse/transport/protocols/mod.rs
@@ -6,92 +6,474 @@ pub mod tcp;
pub mod udp;
/// Represents transport protocols AND IPv6 extension headers
-#[derive(Debug, Clone, Serialize, Hash, PartialEq, Eq)]
+#[derive(Debug, Clone, Copy, Serialize, Hash, PartialEq, Eq)]
pub enum TransportProtocol {
- // IPv6 Extension Headers
- HopByHop, // 0
- Routing, // 43
- Fragment, // 44
- DestinationOptions, // 60
- Mobility, // 135
- NoNextHeader, // 59
-
- // Core transport protocols
- Tcp,
- Udp,
+ // 0
+ Hopopt,
+ // 1
Icmp,
- IcmpV6,
+ // 2
Igmp,
- Pim,
- PimV2,
- Vrrp,
-
- // Routing protocols
+ // 3
+ Ggp,
+ // 4
+ Ipv4,
+ // 5
+ St,
+ // 6
+ Tcp,
+ // 7
+ Cbt,
+ // 8
Egp,
- Igrp,
- Ospf,
- Eigrp,
-
- // Tunneling protocols
- Gre,
- IpInIp,
-
- // Security protocols
- Ah,
- Esp,
-
- // Other protocols
+ // 9
+ Igp,
+ // 10
+ BbnRccMon,
+ // 11
+ NvpIi,
+ // 12
+ Pup,
+ // 13
+ Argus,
+ // 14
+ Emcon,
+ // 15
+ Xnet,
+ // 16
+ Chaos,
+ // 17
+ Udp,
+ // 18
+ Mux,
+ // 19
+ DcnMeas,
+ // 20
+ Hmp,
+ // 21
+ Prm,
+ // 22
+ XnsIdp,
+ // 23
+ Trunk1,
+ // 24
+ Trunk2,
+ // 25
+ Leaf1,
+ // 26
+ Leaf2,
+ // 27
Rdp,
+ // 28
+ Irtp,
+ // 29
+ IsoTp4,
+ // 30
+ Netblt,
+ // 31
+ MfeNsp,
+ // 32
+ MeritInp,
+ // 33
Dccp,
+ // 34
+ ThreePc,
+ // 35
+ Idpr,
+ // 36
+ Xtp,
+ // 37
+ Ddp,
+ // 38
+ IdprCmtp,
+ // 39
+ TpPlusPlus,
+ // 40
+ Il,
+ // 41
+ Ipv6,
+ // 42
+ Sdrp,
+ // 43
+ Ipv6Route,
+ // 44
+ Ipv6Frag,
+ // 45
+ Idrp,
+ // 46
Rsvp,
+ // 47
+ Gre,
+ // 48
+ Dsr,
+ // 49
+ Bna,
+ // 50
+ Esp,
+ // 51
+ Ah,
+ // 52
+ INlsp,
+ // 53
+ Swipe,
+ // 54
+ Narp,
+ // 55
+ MinIpv4,
+ // 56
+ Tlsp,
+ // 57
+ Skip,
+ // 58
+ Ipv6Icmp,
+ // 59
+ Ipv6NoNxt,
+ // 60
+ Ipv6Opts,
+ // 61
+ AnyHostInternalProtocol,
+ // 62
+ Cftp,
+ // 63
+ AnyLocalNetwork,
+ // 64
+ SatExpak,
+ // 65
+ Kryptolan,
+ // 66
+ Rvd,
+ // 67
+ Ippc,
+ // 68
+ AnyDistributedFileSystem,
+ // 69
+ SatMon,
+ // 70
+ Visa,
+ // 71
+ Ipcv,
+ // 72
+ Cpnx,
+ // 73
+ Cphb,
+ // 74
+ Wsn,
+ // 75
+ Pvp,
+ // 76
+ BrSatMon,
+ // 77
+ SunNd,
+ // 78
+ WbMon,
+ // 79
+ WbExpak,
+ // 80
+ IsoIp,
+ // 81
+ Vmtp,
+ // 82
+ SecureVmtp,
+ // 83
+ Vines,
+ // 84
+ Iptm,
+ // 85
+ NsfnetIgp,
+ // 86
+ Dgp,
+ // 87
+ Tcf,
+ // 88
+ Eigrp,
+ // 89
+ Ospfigp,
+ // 90
+ SpriteRpc,
+ // 91
+ Larp,
+ // 92
+ Mtp,
+ // 93
+ Ax25,
+ // 94
+ Ipip,
+ // 95
+ Micp,
+ // 96
+ SccSp,
+ // 97
+ Etherip,
+ // 98
+ Encap,
+ // 99
+ AnyPrivateEncryptionScheme,
+ // 100
+ Gmtp,
+ // 101
+ Ifmp,
+ // 102
+ Pnni,
+ // 103
+ Pim, // PIM (la version se déduit ensuite dans le payload)
+ // 104
+ Aris,
+ // 105
+ Scps,
+ // 106
+ Qnx,
+ // 107
+ AN, // Active Networks
+ // 108
+ Ipcomp,
+ // 109
+ Snp,
+ // 110
+ CompaqPeer,
+ // 111
+ IpxInIp,
+ // 112
+ Vrrp,
+ // 113
+ Pgm,
+ // 114
+ Any0HopProtocol,
+ // 115
+ L2tp,
+ // 116
+ Ddx,
+ // 117
+ Iatp,
+ // 118
+ Stp,
+ // 119
+ Srp,
+ // 120
+ Uti,
+ // 121
+ Smp,
+ // 122
+ Sm,
+ // 123
+ Ptp,
+ // 124
+ IsisOverIpv4,
+ // 125
+ Fire,
+ // 126
+ Crtp,
+ // 127
+ Crudp,
+ // 128
+ Sscopmce,
+ // 129
+ Iplt,
+ // 130
+ Sps,
+ // 131
+ Pipe,
+ // 132
Sctp,
+ // 133
+ Fc,
+ // 134
+ RsvpE2eIgnore,
+ // 135
+ MobilityHeader,
+ // 136
+ Udplite,
+ // 137
+ MplsInIp,
+ // 138
+ Manet,
+ // 139
+ Hip,
+ // 140
+ Shim6,
+ // 141
+ Wesp,
+ // 142
+ Rohc,
+ // 143
+ Ethernet,
+ // 144
+ Aggfrag,
+ // 145
+ Nsh,
+ // 146
+ Homa,
+ // 147
+ BitEmu,
+
+ // 253
+ Experimentation253,
+ // 254
+ Experimentation254,
+ // 255
+ Reserved255,
- // Fallback
- Unknown,
+ /// Anything else (including 148-252 currently unassigned)
+ Unknown(u8),
}
impl TransportProtocol {
+ /// Converts an IANA protocol number / IPv6 next-header number
/// Converts an IANA protocol number / IPv6 next-header number
pub fn from_u8(value: u8) -> Self {
+ use TransportProtocol::*;
match value {
- // IPv6 extension headers
- 0 => TransportProtocol::HopByHop,
- 43 => TransportProtocol::Routing,
- 44 => TransportProtocol::Fragment,
- 59 => TransportProtocol::NoNextHeader,
- 60 => TransportProtocol::DestinationOptions,
- 135 => TransportProtocol::Mobility,
-
- // Core transport protocols
- 1 => TransportProtocol::Icmp,
- 2 => TransportProtocol::Igmp,
- 6 => TransportProtocol::Tcp,
- 17 => TransportProtocol::Udp,
- 58 => TransportProtocol::IcmpV6,
- 103 => TransportProtocol::PimV2,
- 112 => TransportProtocol::Vrrp,
-
- // Routing protocols
- 8 => TransportProtocol::Egp,
- 9 => TransportProtocol::Igrp,
- 89 => TransportProtocol::Ospf,
- 88 => TransportProtocol::Eigrp,
-
- // Tunneling
- 47 => TransportProtocol::Gre,
- 4 => TransportProtocol::IpInIp,
-
- // Security
- 50 => TransportProtocol::Esp,
- 51 => TransportProtocol::Ah,
-
- // Other protocols
- 27 => TransportProtocol::Rdp,
- 33 => TransportProtocol::Dccp,
- 46 => TransportProtocol::Rsvp,
- 132 => TransportProtocol::Sctp,
-
- _ => TransportProtocol::Unknown,
+ 0 => Hopopt,
+ 1 => Icmp,
+ 2 => Igmp,
+ 3 => Ggp,
+ 4 => Ipv4,
+ 5 => St,
+ 6 => Tcp,
+ 7 => Cbt,
+ 8 => Egp,
+ 9 => Igp,
+ 10 => BbnRccMon,
+ 11 => NvpIi,
+ 12 => Pup,
+ 13 => Argus,
+ 14 => Emcon,
+ 15 => Xnet,
+ 16 => Chaos,
+ 17 => Udp,
+ 18 => Mux,
+ 19 => DcnMeas,
+ 20 => Hmp,
+ 21 => Prm,
+ 22 => XnsIdp,
+ 23 => Trunk1,
+ 24 => Trunk2,
+ 25 => Leaf1,
+ 26 => Leaf2,
+ 27 => Rdp,
+ 28 => Irtp,
+ 29 => IsoTp4,
+ 30 => Netblt,
+ 31 => MfeNsp,
+ 32 => MeritInp,
+ 33 => Dccp,
+ 34 => ThreePc,
+ 35 => Idpr,
+ 36 => Xtp,
+ 37 => Ddp,
+ 38 => IdprCmtp,
+ 39 => TpPlusPlus,
+ 40 => Il,
+ 41 => Ipv6,
+ 42 => Sdrp,
+ 43 => Ipv6Route,
+ 44 => Ipv6Frag,
+ 45 => Idrp,
+ 46 => Rsvp,
+ 47 => Gre,
+ 48 => Dsr,
+ 49 => Bna,
+ 50 => Esp,
+ 51 => Ah,
+ 52 => INlsp,
+ 53 => Swipe,
+ 54 => Narp,
+ 55 => MinIpv4,
+ 56 => Tlsp,
+ 57 => Skip,
+ 58 => Ipv6Icmp,
+ 59 => Ipv6NoNxt,
+ 60 => Ipv6Opts,
+ 61 => AnyHostInternalProtocol,
+ 62 => Cftp,
+ 63 => AnyLocalNetwork,
+ 64 => SatExpak,
+ 65 => Kryptolan,
+ 66 => Rvd,
+ 67 => Ippc,
+ 68 => AnyDistributedFileSystem,
+ 69 => SatMon,
+ 70 => Visa,
+ 71 => Ipcv,
+ 72 => Cpnx,
+ 73 => Cphb,
+ 74 => Wsn,
+ 75 => Pvp,
+ 76 => BrSatMon,
+ 77 => SunNd,
+ 78 => WbMon,
+ 79 => WbExpak,
+ 80 => IsoIp,
+ 81 => Vmtp,
+ 82 => SecureVmtp,
+ 83 => Vines,
+ 84 => Iptm,
+ 85 => NsfnetIgp,
+ 86 => Dgp,
+ 87 => Tcf,
+ 88 => Eigrp,
+ 89 => Ospfigp,
+ 90 => SpriteRpc,
+ 91 => Larp,
+ 92 => Mtp,
+ 93 => Ax25,
+ 94 => Ipip,
+ 95 => Micp,
+ 96 => SccSp,
+ 97 => Etherip,
+ 98 => Encap,
+ 99 => AnyPrivateEncryptionScheme,
+ 100 => Gmtp,
+ 101 => Ifmp,
+ 102 => Pnni,
+ 103 => Pim,
+ 104 => Aris,
+ 105 => Scps,
+ 106 => Qnx,
+ 107 => AN,
+ 108 => Ipcomp,
+ 109 => Snp,
+ 110 => CompaqPeer,
+ 111 => IpxInIp,
+ 112 => Vrrp,
+ 113 => Pgm,
+ 114 => Any0HopProtocol,
+ 115 => L2tp,
+ 116 => Ddx,
+ 117 => Iatp,
+ 118 => Stp,
+ 119 => Srp,
+ 120 => Uti,
+ 121 => Smp,
+ 122 => Sm,
+ 123 => Ptp,
+ 124 => IsisOverIpv4,
+ 125 => Fire,
+ 126 => Crtp,
+ 127 => Crudp,
+ 128 => Sscopmce,
+ 129 => Iplt,
+ 130 => Sps,
+ 131 => Pipe,
+ 132 => Sctp,
+ 133 => Fc,
+ 134 => RsvpE2eIgnore,
+ 135 => MobilityHeader,
+ 136 => Udplite,
+ 137 => MplsInIp,
+ 138 => Manet,
+ 139 => Hip,
+ 140 => Shim6,
+ 141 => Wesp,
+ 142 => Rohc,
+ 143 => Ethernet,
+ 144 => Aggfrag,
+ 145 => Nsh,
+ 146 => Homa,
+ 147 => BitEmu,
+ 253 => Experimentation253,
+ 254 => Experimentation254,
+ 255 => Reserved255,
+ _ => Unknown(value),
}
}
pub fn to_transport(self) -> Transport<'static> {
@@ -126,7 +508,7 @@ mod tests {
));
assert!(matches!(
TransportProtocol::from_u8(58),
- TransportProtocol::IcmpV6
+ TransportProtocol::Ipv6Icmp
));
assert!(matches!(
TransportProtocol::from_u8(47),
@@ -140,32 +522,32 @@ mod tests {
// IPv6 extension tests
assert!(matches!(
TransportProtocol::from_u8(0),
- TransportProtocol::HopByHop
+ TransportProtocol::Hopopt
));
assert!(matches!(
TransportProtocol::from_u8(43),
- TransportProtocol::Routing
+ TransportProtocol::Ipv6Route
));
assert!(matches!(
TransportProtocol::from_u8(44),
- TransportProtocol::Fragment
+ TransportProtocol::Ipv6Frag
));
assert!(matches!(
TransportProtocol::from_u8(59),
- TransportProtocol::NoNextHeader
+ TransportProtocol::Ipv6NoNxt
));
assert!(matches!(
TransportProtocol::from_u8(60),
- TransportProtocol::DestinationOptions
+ TransportProtocol::Ipv6Opts
));
assert!(matches!(
TransportProtocol::from_u8(135),
- TransportProtocol::Mobility
+ TransportProtocol::MobilityHeader
));
assert!(matches!(
TransportProtocol::from_u8(255),
- TransportProtocol::Unknown
+ TransportProtocol::Reserved255
));
}
}