pub struct MacsecHeader {
pub ptype: MacsecPType,
pub endstation_id: bool,
pub scb: bool,
pub an: MacsecAn,
pub short_len: MacsecShortLen,
pub packet_nr: u32,
pub sci: Option<u64>,
}
Expand description
MACsec SecTag header (present at the start of a packet capsuled with MACsec).
Fields§
§ptype: MacsecPType
Payload type (contains encryption, modification flag as well as the next ether type if available)
endstation_id: bool
End station identifier (TCI.ES flag).
scb: bool
Ethernet passive optical network broadcast flag.
an: MacsecAn
Association number (identifies SAs).
short_len: MacsecShortLen
Short length with reserved bits.
packet_nr: u32
Packet number.
sci: Option<u64>
Secure channel identifier.
Implementations§
Source§impl MacsecHeader
impl MacsecHeader
Sourcepub const MAX_LEN: usize = 16usize
pub const MAX_LEN: usize = 16usize
Maximum length of an MacSec header (including ether type of payload) in bytes/octets.
Sourcepub fn encrypted(&self) -> bool
pub fn encrypted(&self) -> bool
Encryption flag, which indicates whether the user data is encrypted (true = encrypted, TCI.E flag).
Sourcepub fn userdata_changed(&self) -> bool
pub fn userdata_changed(&self) -> bool
Flag for change text, set if the user data is modified.
Sourcepub fn next_ether_type(&self) -> Option<EtherType>
pub fn next_ether_type(&self) -> Option<EtherType>
Ether type of the data following the mac sec tag.
Sourcepub fn from_slice(slice: &[u8]) -> Result<MacsecHeader, HeaderSliceError>
pub fn from_slice(slice: &[u8]) -> Result<MacsecHeader, HeaderSliceError>
Try creating a MacsecHeaderSlice
from a slice containing the
MACsec header & next ether type.
Sourcepub fn to_bytes(&self) -> ArrayVec<u8, { MacsecHeader::MAX_LEN }>
pub fn to_bytes(&self) -> ArrayVec<u8, { MacsecHeader::MAX_LEN }>
Serialize the mac sec header.
Sourcepub fn read<T: Read + Sized>(
reader: &mut T,
) -> Result<MacsecHeader, HeaderReadError>
Available on crate feature std
only.
pub fn read<T: Read + Sized>( reader: &mut T, ) -> Result<MacsecHeader, HeaderReadError>
std
only.Try reading a MACsec header from the position of the reader.
Sourcepub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), Error>
Available on crate feature std
only.
pub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), Error>
std
only.Writes a given MACsec header to the current position (SecTag & next ether type if available).
Sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Length of the MACsec header (SecTag + next ether type if available).
Sourcepub fn expected_payload_len(&self) -> Option<usize>
pub fn expected_payload_len(&self) -> Option<usize>
Returns the required length of the payload (data after header + next_ether_type if present) if possible.
If the length cannot be determined (short_len
is zero or less then
2
when ptype
Unmodified
) None
is returned.
Sourcepub fn set_payload_len(&mut self, payload_len: usize)
pub fn set_payload_len(&mut self, payload_len: usize)
Set the short_len
field based on the given payload byte len
(payload len excluding the ether_type if ptype
Unmodified
)
based on the current ptype
.
Trait Implementations§
Source§impl Clone for MacsecHeader
impl Clone for MacsecHeader
Source§fn clone(&self) -> MacsecHeader
fn clone(&self) -> MacsecHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more