Skip to content

Commit

Permalink
Merge pull request #619 from reticulis/sll2
Browse files Browse the repository at this point in the history
Add LINKTYPE_LINUX_SLL2 support and fix link to SLL
  • Loading branch information
mrmonday committed Jul 19, 2023
2 parents 12636de + 15bc024 commit 391b133
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pnet_packet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ pub mod tcp;
pub mod udp;
pub mod usbpcap;
pub mod vlan;
pub mod sll;
pub mod sll2;

pub mod util;
4 changes: 2 additions & 2 deletions pnet_packet/src/sll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use alloc::vec::Vec;

use ethernet::EtherType;
use super::ethernet::EtherType;
use pnet_macros::packet;
use pnet_macros_support::types::*
use pnet_macros_support::types::*;

// ref: https://wiki.wireshark.org/SLL
// ref: https://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL.html
Expand Down
38 changes: 38 additions & 0 deletions pnet_packet/src/sll2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//! A Linux cooked-mode capture v2 (LINKTYPE_LINUX_SLL2) packet abstraction.
// ref: https://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL2.html

use alloc::vec::Vec;

use pnet_macros::packet;
use pnet_macros_support::types::*;

use super::ethernet::EtherType;

/// Represents an SLL2 packet (LINKTYPE_LINUX_SLL2).
#[packet]
pub struct SLL2 {
#[construct_with(u16)]
pub protocol_type: EtherType,

#[construct_with(u16)]
pub reserverd: u16be,

Check warning on line 18 in pnet_packet/src/sll2.rs

View workflow job for this annotation

GitHub Actions / spell-check

"reserverd" should be "reserved".

#[construct_with(u32)]
pub interface_index: u32be,

#[construct_with(u16)]
pub arphrd_type: u16be,

#[construct_with(u8)]
pub packet_type: u8,

#[construct_with(u8)]
pub link_layer_address_length: u8,

#[construct_with(u8, u8, u8, u8, u8, u8, u8, u8)]
#[length = "8"]
pub link_layer_address: Vec<u8>,

#[payload]
pub payload: Vec<u8>
}

0 comments on commit 391b133

Please sign in to comment.