diff options
Diffstat (limited to 'src/protocol/grev0.rs')
| -rw-r--r-- | src/protocol/grev0.rs | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/protocol/grev0.rs b/src/protocol/grev0.rs index fd368b9..8ef5a20 100644 --- a/src/protocol/grev0.rs +++ b/src/protocol/grev0.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::bytes; use nom::error::Error; @@ -49,7 +49,7 @@ pub struct SourceRouteEntry { } #[derive(Clone, Debug, PartialEq, Eq)] -pub struct Grev0Header { +pub struct GREv0Header { pub flag_checksum: bool, pub flag_routing: bool, pub flag_key: bool, @@ -58,7 +58,7 @@ pub struct Grev0Header { pub recursion_control: u8, pub flags: u8, pub version: u8, - pub protocol_type: EtherType, + pub protocol_type: EthType, pub checksum: Option<u16>, pub offset: Option<u16>, pub key: Option<u32>, @@ -93,9 +93,9 @@ fn source_route_entry_decode(input: &[u8]) -> IResult<&[u8], SourceRouteEntry> { )) } -impl Decode for Grev0Header { - type Iterm = Grev0Header; - fn decode(input: &[u8]) -> IResult<&[u8], Grev0Header> { +impl Decode for GREv0Header { + type Iterm = GREv0Header; + fn decode(input: &[u8]) -> IResult<&[u8], GREv0Header> { let ( input, ( @@ -126,7 +126,7 @@ impl Decode for Grev0Header { ))); } - let (input, protocol_type) = EtherType::decode(input)?; + let (input, protocol_type) = EthType::decode(input)?; let (input, checksum) = match (flag_checksum, flag_routing) { (0, 0) => (input, None), (_, _) => number::streaming::be_u16(input).map(|(i, l)| (i, Some(l)))?, @@ -163,7 +163,7 @@ impl Decode for Grev0Header { Ok(( input, - Grev0Header { + GREv0Header { flag_checksum: flag_checksum == 1, flag_routing: flag_routing == 1, flag_key: flag_key == 1, @@ -189,10 +189,10 @@ impl Decode for Grev0Header { #[cfg(test)] mod tests { - use super::Grev0Header; + use super::GREv0Header; use super::SourceRouteEntry; use crate::protocol::codec::Decode; - use crate::protocol::ethernet::EtherType; + use crate::protocol::ethernet::EthType; const LAST_SLICE: &'static [u8] = &[0xff]; #[test] @@ -217,7 +217,7 @@ mod tests { 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x84, 0xff, /* Payload */ ]; - let expectation = Grev0Header { + let expectation = GREv0Header { flag_checksum: false, flag_routing: false, flag_key: true, @@ -226,7 +226,7 @@ mod tests { recursion_control: 0, flags: 0, version: 0, - protocol_type: EtherType::IPv4, + protocol_type: EthType::IPv4, checksum: None, offset: None, key: Some(0x384), @@ -234,10 +234,10 @@ mod tests { routing: None, }; - assert_eq!(Grev0Header::decode(&bytes), Ok((LAST_SLICE, expectation))); + assert_eq!(GREv0Header::decode(&bytes), Ok((LAST_SLICE, expectation))); // example - let result = Grev0Header::decode(&bytes); + let result = GREv0Header::decode(&bytes); if let Ok((payload, header)) = result { println!("return: {:?}, payload: {}", header, payload.len()); } else { @@ -286,7 +286,7 @@ mod tests { 0x00, 0x00, 0x00, 0x00, 0xff, /* Payload */ ]; - let expectation = Grev0Header { + let expectation = GREv0Header { flag_checksum: true, flag_routing: true, flag_key: false, @@ -295,7 +295,7 @@ mod tests { recursion_control: 0, flags: 0, version: 0, - protocol_type: EtherType::IPv4, + protocol_type: EthType::IPv4, checksum: Some(0x0000), offset: Some(44), key: None, @@ -321,10 +321,10 @@ mod tests { ]), }; - assert_eq!(Grev0Header::decode(&bytes), Ok((LAST_SLICE, expectation))); + assert_eq!(GREv0Header::decode(&bytes), Ok((LAST_SLICE, expectation))); // example - let result = Grev0Header::decode(&bytes); + let result = GREv0Header::decode(&bytes); if let Ok((payload, header)) = result { println!("return: {:?}, payload: {}", header, payload.len()); } else { |
