pub struct L2tpLayer {
pub index: LayerIndex,
}Expand description
L2TP layer — a zero-copy view into a packet buffer.
Fields§
§index: LayerIndexImplementations§
Source§impl L2tpLayer
impl L2tpLayer
Sourcepub fn new(index: LayerIndex) -> Self
pub fn new(index: LayerIndex) -> Self
Create a new L2TP layer from a layer index.
Sourcepub fn flags_word(&self, buf: &[u8]) -> Result<u16, FieldError>
pub fn flags_word(&self, buf: &[u8]) -> Result<u16, FieldError>
Read the 2-byte flags+version word.
Sourcepub fn flags(&self, buf: &[u8]) -> Result<u16, FieldError>
pub fn flags(&self, buf: &[u8]) -> Result<u16, FieldError>
Get the raw flags byte (high byte of the flags word, bits 0-7).
Sourcepub fn version(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn version(&self, buf: &[u8]) -> Result<u8, FieldError>
Get the version nibble (bits 12-15 of the flags word; should be 2).
Sourcepub fn msg_type(&self, buf: &[u8]) -> Result<u8, FieldError>
pub fn msg_type(&self, buf: &[u8]) -> Result<u8, FieldError>
Get message type: 0 = data, 1 = control (T bit, bit 15 of word).
Sourcepub fn is_control(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn is_control(&self, buf: &[u8]) -> Result<bool, FieldError>
Returns true if the T (type) bit is set (control message).
Sourcepub fn has_length(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn has_length(&self, buf: &[u8]) -> Result<bool, FieldError>
Returns true if the L (length) bit is set, meaning Length field is present.
Sourcepub fn has_sequence(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn has_sequence(&self, buf: &[u8]) -> Result<bool, FieldError>
Returns true if the S (sequence) bit is set, meaning Ns and Nr are present.
Sourcepub fn has_offset(&self, buf: &[u8]) -> Result<bool, FieldError>
pub fn has_offset(&self, buf: &[u8]) -> Result<bool, FieldError>
Returns true if the O (offset) bit is set, meaning Offset fields are present.
Sourcepub fn length(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
pub fn length(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
Get the optional Length field (present when L bit is set).
Sourcepub fn set_tunnel_id(
&self,
buf: &mut [u8],
value: u16,
) -> Result<(), FieldError>
pub fn set_tunnel_id( &self, buf: &mut [u8], value: u16, ) -> Result<(), FieldError>
Set the Tunnel ID field.
Sourcepub fn session_id(&self, buf: &[u8]) -> Result<u16, FieldError>
pub fn session_id(&self, buf: &[u8]) -> Result<u16, FieldError>
Get the Session ID field.
Sourcepub fn set_session_id(
&self,
buf: &mut [u8],
value: u16,
) -> Result<(), FieldError>
pub fn set_session_id( &self, buf: &mut [u8], value: u16, ) -> Result<(), FieldError>
Set the Session ID field.
Sourcepub fn ns(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
pub fn ns(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
Get the Ns (send sequence number) field if S bit is set.
Sourcepub fn nr(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
pub fn nr(&self, buf: &[u8]) -> Result<Option<u16>, FieldError>
Get the Nr (receive sequence number) field if S bit is set.
Sourcepub fn field_names() -> &'static [&'static str]
pub fn field_names() -> &'static [&'static str]
Get the field names for this layer.
Sourcepub fn get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
pub fn get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Get a field value by name.
Sourcepub fn set_field(
&self,
buf: &mut [u8],
name: &str,
value: FieldValue,
) -> Option<Result<(), FieldError>>
pub fn set_field( &self, buf: &mut [u8], name: &str, value: FieldValue, ) -> Option<Result<(), FieldError>>
Set a field value by name.
Trait Implementations§
Source§impl Layer for L2tpLayer
impl Layer for L2tpLayer
Source§fn header_len(&self, data: &[u8]) -> usize
fn header_len(&self, data: &[u8]) -> usize
Source§fn field_names(&self) -> &'static [&'static str]
fn field_names(&self) -> &'static [&'static str]
Source§impl LayerDispatch for L2tpLayer
impl LayerDispatch for L2tpLayer
Source§fn dispatch_kind(&self) -> LayerKind
fn dispatch_kind(&self) -> LayerKind
Source§fn dispatch_index(&self) -> &LayerIndex
fn dispatch_index(&self) -> &LayerIndex
Source§fn dispatch_summary(&self, buf: &[u8]) -> String
fn dispatch_summary(&self, buf: &[u8]) -> String
Source§fn dispatch_header_len(&self, buf: &[u8]) -> usize
fn dispatch_header_len(&self, buf: &[u8]) -> usize
Source§fn dispatch_field_names(&self) -> &'static [&'static str]
fn dispatch_field_names(&self) -> &'static [&'static str]
Source§fn dispatch_get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
fn dispatch_get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Source§fn dispatch_set_field(
&self,
buf: &mut [u8],
name: &str,
value: FieldValue,
) -> Option<Result<(), FieldError>>
fn dispatch_set_field( &self, buf: &mut [u8], name: &str, value: FieldValue, ) -> Option<Result<(), FieldError>>
Auto Trait Implementations§
impl Freeze for L2tpLayer
impl RefUnwindSafe for L2tpLayer
impl Send for L2tpLayer
impl Sync for L2tpLayer
impl Unpin for L2tpLayer
impl UnsafeUnpin for L2tpLayer
impl UnwindSafe for L2tpLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more