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.