summaryrefslogtreecommitdiff
path: root/src/protocol/vlan.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/protocol/vlan.rs')
-rw-r--r--src/protocol/vlan.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/protocol/vlan.rs b/src/protocol/vlan.rs
index 7533e41..17a82e1 100644
--- a/src/protocol/vlan.rs
+++ b/src/protocol/vlan.rs
@@ -1,5 +1,5 @@
use crate::protocol::codec::Decode;
-use crate::protocol::ethernet::EtherType;
+use crate::protocol::ethernet::EthType;
use nom::bits;
use nom::error::Error;
use nom::sequence;
@@ -10,15 +10,15 @@ use nom::IResult;
******************************************************************************/
#[derive(Clone, Debug, PartialEq, Eq)]
-pub struct VlanHeader {
+pub struct VLANHeader {
// A 3 bit number which refers to the IEEE 802.1p class of service and maps to the frame priority level.
pub priority_code_point: u8,
// Indicate that the frame may be dropped under the presence of congestion.
pub drop_eligible_indicator: bool,
// 12 bits vland identifier.
pub vlan_identifier: u16,
- // "Tag protocol identifier": Type id of content after this header. Refer to the "EtherType" for a list of possible supported values.
- pub ether_type: EtherType,
+ // "Tag protocol identifier": Type id of content after this header. Refer to the "EthType" for a list of possible supported values.
+ pub ether_type: EthType,
}
/******************************************************************************
@@ -33,15 +33,15 @@ fn bit_decode(input: &[u8]) -> IResult<&[u8], (u8, u8, u16)> {
)))(input)
}
-impl Decode for VlanHeader {
- type Iterm = VlanHeader;
- fn decode(input: &[u8]) -> IResult<&[u8], VlanHeader> {
+impl Decode for VLANHeader {
+ type Iterm = VLANHeader;
+ fn decode(input: &[u8]) -> IResult<&[u8], VLANHeader> {
let (input, (priority_code_point, drop_eligible_indicator, vlan_identifier)) =
bit_decode(input)?;
- let (input, ether_type) = EtherType::decode(input)?;
+ let (input, ether_type) = EthType::decode(input)?;
Ok((
input,
- VlanHeader {
+ VLANHeader {
priority_code_point,
drop_eligible_indicator: drop_eligible_indicator == 1,
vlan_identifier,
@@ -57,9 +57,9 @@ impl Decode for VlanHeader {
#[cfg(test)]
mod tests {
- use super::VlanHeader;
+ use super::VLANHeader;
use crate::protocol::codec::Decode;
- use crate::protocol::ethernet::EtherType;
+ use crate::protocol::ethernet::EthType;
const LAST_SLICE: &'static [u8] = &[0xff];
#[test]
@@ -73,17 +73,17 @@ mod tests {
*/
let bytes = [0x00, 0x20, 0x08, 0x00, 0xff /* Payload */];
- let expectation = VlanHeader {
+ let expectation = VLANHeader {
priority_code_point: 0,
drop_eligible_indicator: false,
vlan_identifier: 32,
- ether_type: EtherType::IPv4,
+ ether_type: EthType::IPv4,
};
- assert_eq!(VlanHeader::decode(&bytes), Ok((LAST_SLICE, expectation)));
+ assert_eq!(VLANHeader::decode(&bytes), Ok((LAST_SLICE, expectation)));
// example
- let result = VlanHeader::decode(&bytes);
+ let result = VLANHeader::decode(&bytes);
if let Ok((payload, header)) = result {
println!("return: {:?}, payload: {}", header, payload.len());
} else {