Struct 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 duplicate 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,

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

impl PartialEq for IpNumber

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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

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

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

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

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

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>,

Source§

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.