Struct etherparse::IpNumber

source ·
pub struct IpNumber(pub u8);
Expand description

Identifiers for the next_header field in ipv6 headers and protocol field in ipv4 headers.

You can access the underlying u8 value by using .0 and any u8 can be converted to an IpNumber:

use etherparse::IpNumber;

assert_eq!(IpNumber::TCP.0, 6);
assert_eq!(IpNumber::TCP, IpNumber(6));

// convert to IpNumber using the from & into trait
let ip_num: IpNumber = 6.into();
assert_eq!(IpNumber::TCP, ip_num);

// convert to u8 using the from & into trait
let num: u8 = IpNumber::TCP.into();
assert_eq!(6, num);

The constants are also defined in the ip_number module so they can be used without the need to write IpNumber:: in front of them:

use etherparse::{ip_number::TCP, IpNumber};

assert_eq!(TCP, IpNumber::TCP);

The list original values were copied from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml

Tuple Fields§

§0: u8

Implementations§

source§

impl IpNumber

source

pub const IPV6_HEADER_HOP_BY_HOP: IpNumber = _

IPv6 Hop-by-Hop Option [RFC8200]

source

pub const ICMP: IpNumber = _

Internet Control Message [RFC792]

source

pub const IGMP: IpNumber = _

Internet Group Management [RFC1112]

source

pub const GGP: IpNumber = _

Gateway-to-Gateway [RFC823]

source

pub const IPV4: IpNumber = _

IPv4 encapsulation [RFC2003]

source

pub const STREAM: IpNumber = _

Stream [RFC1190] [RFC1819]

source

pub const TCP: IpNumber = _

Transmission Control [RFC793]

source

pub const CBT: IpNumber = _

CBT [Tony_Ballardie]

source

pub const EGP: IpNumber = _

Exterior Gateway Protocol [RFC888] [David_Mills]

source

pub const IGP: IpNumber = _

any private interior gateway (used by Cisco for their IGRP) [Internet_Assigned_Numbers_Authority]

source

pub const BBN_RCC_MON: IpNumber = _

BBN RCC Monitoring [Steve_Chipman]

source

pub const NVP_II: IpNumber = _

Network Voice Protocol [RFC741][Steve_Casner]

source

pub const PUP: IpNumber = _

PUP

source

pub const ARGUS: IpNumber = _

ARGUS (deprecated) [Robert_W_Scheifler]

source

pub const EMCON: IpNumber = _

EMCON [mystery contact]

source

pub const XNET: IpNumber = _

Cross Net Debugger [Haverty, J., “XNET Formats for Internet Protocol Version 4”, IEN 158, October 1980.][Jack_Haverty]

source

pub const CHAOS: IpNumber = _

Chaos [J_Noel_Chiappa]

source

pub const UDP: IpNumber = _

User Datagram [RFC768][Jon_Postel]

source

pub const MUX: IpNumber = _

Multiplexing [Cohen, D. and J. Postel, “Multiplexing Protocol”, IEN 90, USC/Information Sciences Institute, May 1979.][Jon_Postel]

source

pub const DCN_MEAS: IpNumber = _

DCN Measurement Subsystems [David_Mills]

source

pub const HMP: IpNumber = _

Host Monitoring [RFC869][Bob_Hinden]

source

pub const PRM: IpNumber = _

Packet Radio Measurement [Zaw_Sing_Su]

source

pub const XNS_IDP: IpNumber = _

XEROX NS IDP

source

pub const TRUNK1: IpNumber = _

Trunk-1 [Barry_Boehm]

source

pub const TRUNK2: IpNumber = _

Trunk-2 [Barry_Boehm]

source

pub const LEAF1: IpNumber = _

Leaf-1 [Barry_Boehm]

source

pub const LEAF2: IpNumber = _

Leaf-2 [Barry_Boehm]

source

pub const RDP: IpNumber = _

Reliable Data Protocol [RFC908] [Bob_Hinden]

source

pub const IRTP: IpNumber = _

Internet Reliable Transaction [RFC938] [Trudy_Miller]

source

pub const ISO_TP4: IpNumber = _

ISO Transport Protocol Class 4 [RFC905] [mystery contact]

source

pub const NET_BLT: IpNumber = _

Bulk Data Transfer Protocol [RFC969] [David_Clark]

source

pub const MFE_NSP: IpNumber = _

MFE Network Services Protocol [Shuttleworth, B., “A Documentary of MFENet, a National Computer Network”, UCRL-52317, Lawrence Livermore Labs, Livermore, California, June 1977.] [Barry_Howard]

source

pub const MERIT_INP: IpNumber = _

MERIT Internodal Protocol [Hans_Werner_Braun]

source

pub const DCCP: IpNumber = _

Datagram Congestion Control Protocol [RFC4340]

source

pub const THIRD_PARTY_CONNECT_PROTOCOL: IpNumber = _

Third Party Connect Protocol [Stuart_A_Friedberg]

source

pub const IDPR: IpNumber = _

Inter-Domain Policy Routing Protocol [Martha_Steenstrup]

source

pub const XTP: IpNumber = _

XTP [Greg_Chesson]

source

pub const DDP: IpNumber = _

Datagram Delivery Protocol [Wesley_Craig]

source

pub const IDPR_CMTP: IpNumber = _

IDPR Control Message Transport Proto [Martha_Steenstrup]

source

pub const TP_PLUS_PLUS: IpNumber = _

TP++ Transport Protocol [Dirk_Fromhein]

source

pub const IL: IpNumber = _

IL Transport Protocol [Dave_Presotto]

source

pub const IPV6: IpNumber = _

IPv6 encapsulation [RFC2473]

source

pub const SDRP: IpNumber = _

Source Demand Routing Protocol [Deborah_Estrin]

source

pub const IPV6_ROUTE_HEADER: IpNumber = _

Routing Header for IPv6 [Steve_Deering]

source

pub const IPV6_FRAGMENTATION_HEADER: IpNumber = _

Fragment Header for IPv6 [Steve_Deering]

source

pub const IDRP: IpNumber = _

Inter-Domain Routing Protocol [Sue_Hares]

source

pub const RSVP: IpNumber = _

Reservation Protocol [RFC2205][RFC3209][Bob_Braden]

source

pub const GRE: IpNumber = _

Generic Routing Encapsulation [RFC2784][Tony_Li]

source

pub const DSR: IpNumber = _

Dynamic Source Routing Protocol [RFC4728]

source

pub const BNA: IpNumber = _

BNA [Gary Salamon]

source

pub const ENCAPSULATING_SECURITY_PAYLOAD: IpNumber = _

Encapsulating Security Payload [RFC4303]

source

pub const AUTHENTICATION_HEADER: IpNumber = _

Authentication Header [RFC4302]

source

pub const INLSP: IpNumber = _

Integrated Net Layer Security TUBA [K_Robert_Glenn]

source

pub const SWIPE: IpNumber = _

IP with Encryption (deprecated) [John_Ioannidis]

source

pub const NARP: IpNumber = _

NBMA Address Resolution Protocol [RFC1735]

source

pub const MOBILE: IpNumber = _

IP Mobility [Charlie_Perkins]

source

pub const TLSP: IpNumber = _

Transport Layer Security Protocol using Kryptonet key management [Christer_Oberg]

source

pub const SKIP: IpNumber = _

SKIP [Tom_Markson]

source

pub const IPV6_ICMP: IpNumber = _

ICMP for IPv6 [RFC8200]

source

pub const IPV6_NO_NEXT_HEADER: IpNumber = _

No Next Header for IPv6 [RFC8200]

source

pub const IPV6_DESTINATION_OPTIONS: IpNumber = _

Destination Options for IPv6 [RFC8200]

source

pub const ANY_HOST_INTERNAL_PROTOCOL: IpNumber = _

any host internal protocol [Internet_Assigned_Numbers_Authority]

source

pub const CFTP: IpNumber = _

CFTP [Forsdick, H., “CFTP”, Network Message, Bolt Beranek and Newman, January 1982.][Harry_Forsdick]

source

pub const ANY_LOCAL_NETWORK: IpNumber = _

any local network [Internet_Assigned_Numbers_Authority]

source

pub const SAT_EXPAK: IpNumber = _

SATNET and Backroom EXPAK [Steven_Blumenthal]

source

pub const KRYTOLAN: IpNumber = _

Kryptolan [Paul Liu]

source

pub const RVD: IpNumber = _

MIT Remote Virtual Disk Protocol [Michael_Greenwald]

source

pub const IPPC: IpNumber = _

Internet Pluribus Packet Core [Steven_Blumenthal]

source

pub const ANY_DISTRIBUTED_FILE_SYSTEM: IpNumber = _

any distributed file system [Internet_Assigned_Numbers_Authority]

source

pub const SAT_MON: IpNumber = _

SATNET Monitoring [Steven_Blumenthal]

source

pub const VISA: IpNumber = _

VISA Protocol [Gene_Tsudik]

source

pub const IPCV: IpNumber = _

Internet Packet Core Utility [Steven_Blumenthal]

source

pub const CPNX: IpNumber = _

Computer Protocol Network Executive [David Mittnacht]

source

pub const CPHB: IpNumber = _

Computer Protocol Heart Beat [David Mittnacht]

source

pub const WSN: IpNumber = _

Wang Span Network [Victor Dafoulas]

source

pub const PVP: IpNumber = _

Packet Video Protocol [Steve_Casner]

source

pub const BR_SAT_MON: IpNumber = _

Backroom SATNET Monitoring [Steven_Blumenthal]

source

pub const SUN_ND: IpNumber = _

SUN ND PROTOCOL-Temporary [William_Melohn]

source

pub const WB_MON: IpNumber = _

WIDEBAND Monitoring [Steven_Blumenthal]

source

pub const WB_EXPAK: IpNumber = _

WIDEBAND EXPAK [Steven_Blumenthal]

source

pub const ISO_IP: IpNumber = _

ISO Internet Protocol [Marshall_T_Rose]

source

pub const VMTP: IpNumber = _

VMTP [Dave_Cheriton]

source

pub const SECURE_VMTP: IpNumber = _

SECURE-VMTP [Dave_Cheriton]

source

pub const VINES: IpNumber = _

VINES [Brian Horn]

source

pub const TTP_OR_IPTM: IpNumber = _

Transaction Transport Protocol or Internet Protocol Traffic Manager [Jim_Stevens]

source

pub const NSFNET_IGP: IpNumber = _

NSFNET-IGP [Hans_Werner_Braun]

source

pub const DGP: IpNumber = _

Dissimilar Gateway Protocol [M/A-COM Government Systems, “Dissimilar Gateway Protocol Specification, Draft Version”, Contract no. CS901145, November 16, 1987.][Mike_Little]

source

pub const TCF: IpNumber = _

TCF [Guillermo_A_Loyola]

source

pub const EIGRP: IpNumber = _

EIGRP [RFC7868]

source

pub const OSPFIGP: IpNumber = _

OSPFIGP [RFC1583][RFC2328][RFC5340][John_Moy]

source

pub const SPRITE_RPC: IpNumber = _

Sprite RPC Protocol [Welch, B., “The Sprite Remote Procedure Call System”, Technical Report, UCB/Computer Science Dept., 86/302, University of California at Berkeley, June 1986.][Bruce Willins]

source

pub const LARP: IpNumber = _

Locus Address Resolution Protocol [Brian Horn]

source

pub const MTP: IpNumber = _

Multicast Transport Protocol [Susie_Armstrong]

source

pub const AX25: IpNumber = _

AX.25 Frames [Brian_Kantor]

source

pub const IPIP: IpNumber = _

IP-within-IP Encapsulation Protocol [John_Ioannidis]

source

pub const MICP: IpNumber = _

Mobile Internetworking Control Pro. (deprecated) [John_Ioannidis]

source

pub const SCC_SP: IpNumber = _

Semaphore Communications Sec. Pro. [Howard_Hart]

source

pub const ETHER_IP: IpNumber = _

Ethernet-within-IP Encapsulation [RFC3378]

source

pub const ENCAP: IpNumber = _

Encapsulation Header [RFC1241][Robert_Woodburn]

source

pub const GMTP: IpNumber = _

GMTP [[RXB5]]

source

pub const IFMP: IpNumber = _

Ipsilon Flow Management Protocol [Bob_Hinden][November 1995, 1997.]

source

pub const PNNI: IpNumber = _

PNNI over IP [Ross_Callon]

source

pub const PIM: IpNumber = _

Protocol Independent Multicast [RFC7761][Dino_Farinacci]

source

pub const ARIS: IpNumber = _

ARIS [Nancy_Feldman]

source

pub const SCPS: IpNumber = _

SCPS [Robert_Durst]

source

pub const QNX: IpNumber = _

QNX [Michael_Hunter]

source

pub const ACTIVE_NETWORKS: IpNumber = _

Active Networks [Bob_Braden]

source

pub const IP_COMP: IpNumber = _

IP Payload Compression Protocol [RFC2393]

source

pub const SITRA_NETWORKS_PROTOCOL: IpNumber = _

Sitara Networks Protocol [Manickam_R_Sridhar]

source

pub const COMPAQ_PEER: IpNumber = _

Compaq Peer Protocol [Victor_Volpe]

source

pub const IPX_IN_IP: IpNumber = _

IPX in IP [CJ_Lee]

source

pub const VRRP: IpNumber = _

Virtual Router Redundancy Protocol [RFC5798]

source

pub const PGM: IpNumber = _

PGM Reliable Transport Protocol [Tony_Speakman]

source

pub const ANY_ZERO_HOP_PROTOCOL: IpNumber = _

any 0-hop protocol [Internet_Assigned_Numbers_Authority]

source

pub const LAYER2_TUNNELING_PROTOCOL: IpNumber = _

Layer Two Tunneling Protocol [RFC3931][Bernard_Aboba]

source

pub const DDX: IpNumber = _

D-II Data Exchange (DDX) [John_Worley]

source

pub const IATP: IpNumber = _

Interactive Agent Transfer Protocol [John_Murphy]

source

pub const STP: IpNumber = _

Schedule Transfer Protocol [Jean_Michel_Pittet]

source

pub const SRP: IpNumber = _

SpectraLink Radio Protocol [Mark_Hamilton]

source

pub const UTI: IpNumber = _

UTI [Peter_Lothberg]

source

pub const SIMPLE_MESSAGE_PROTOCOL: IpNumber = _

Simple Message Protocol [Leif_Ekblad]

source

pub const SM: IpNumber = _

Simple Multicast Protocol (deprecated) [Jon_Crowcroft][draft-perlman-simple-multicast]

source

pub const PTP: IpNumber = _

Performance Transparency Protocol [Michael_Welzl]

source

pub const ISIS_OVER_IPV4: IpNumber = _

ISIS over IPv4 [Tony_Przygienda]

source

pub const FIRE: IpNumber = _

FIRE [Criag_Partridge]

source

pub const CRTP: IpNumber = _

Combat Radio Transport Protocol [Robert_Sautter]

source

pub const CRUDP: IpNumber = _

Combat Radio User Datagram [Robert_Sautter]

source

pub const SSCOPMCE: IpNumber = _

SSCOPMCE [Kurt_Waber]

source

pub const IPLT: IpNumber = _

IPLT [[Hollbach]]

source

pub const SPS: IpNumber = _

Secure Packet Shield [Bill_McIntosh]

source

pub const PIPE: IpNumber = _

Private IP Encapsulation within IP [Bernhard_Petri]

source

pub const SCTP: IpNumber = _

Stream Control Transmission Protocol [Randall_R_Stewart]

source

pub const FC: IpNumber = _

Fibre Channel [Murali_Rajagopal][RFC6172]

source

pub const RSVP_E2E_IGNORE: IpNumber = _

RSVP-E2E-IGNORE [RFC3175]

source

pub const MOBILITY_HEADER: IpNumber = _

MobilityHeader [RFC6275]

source

pub const UDP_LITE: IpNumber = _

UDPLite [RFC3828]

source

pub const MPLS_IN_IP: IpNumber = _

source

pub const MANET: IpNumber = _

MANET Protocols [RFC5498]

source

pub const HIP: IpNumber = _

Host Identity Protocol [RFC7401]

source

pub const SHIM6: IpNumber = _

Shim6 Protocol [RFC5533]

source

pub const WESP: IpNumber = _

Wrapped Encapsulating Security Payload [RFC5840]

source

pub const ROHC: IpNumber = _

Robust Header Compression [RFC5858]

source

pub const EXPERIMENTAL_AND_TESTING_0: IpNumber = _

Use for experimentation and testing

source

pub const EXPERIMENTAL_AND_TESTING_1: IpNumber = _

Use for experimentation and testing

source§

impl IpNumber

source

pub fn is_ipv6_ext_header_value(self) -> bool

Returns true if the given number is the internet number of an IPV6 extension header.

source

pub fn keyword_str(self) -> Option<&'static str>

Returns the “keyword” string if known. Usually this is the abbreviation of the protocol.

§Example
use etherparse::IpNumber;

assert_eq!(IpNumber::UDP.keyword_str(), Some("UDP"));

// Unassigned values return None
assert_eq!(IpNumber(145).keyword_str(), None);
§Data Source

The strings were copied from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml on 2023-04-11.

source

pub fn protocol_str(self) -> Option<&'static str>

Returns the “protocol” string if known. Usually this the non abbreviated name of the protocol.

§Example
use etherparse::IpNumber;

assert_eq!(IpNumber::UDP.protocol_str(), Some("User Datagram"));

// Unassigned values return None
assert_eq!(IpNumber(145).protocol_str(), None);
§Data Source

The string was copied from https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml on 2023-04-11.

Trait Implementations§

source§

impl Clone for IpNumber

source§

fn clone(&self) -> IpNumber

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for IpNumber

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for IpNumber

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<IpNumber> for u8

source§

fn from(val: IpNumber) -> Self

Converts to this type from the input type.
source§

impl From<u8> for IpNumber

source§

fn from(val: u8) -> Self

Converts to this type from the input type.
source§

impl Hash for IpNumber

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for IpNumber

source§

fn cmp(&self, other: &IpNumber) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for IpNumber

source§

fn eq(&self, other: &IpNumber) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for IpNumber

source§

fn partial_cmp(&self, other: &IpNumber) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for IpNumber

source§

impl Eq for IpNumber

source§

impl StructuralPartialEq for IpNumber

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.