diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-07-26 19:29:10 +0200 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-07-26 19:29:10 +0200 |
commit | dd274b404c848c594b85541b6ab3a6fbd54b22e0 (patch) | |
tree | d115553e85ef254b2debc9160c402dd0be438fee /src | |
parent | 5f78e8220404294ebbb4de91c2a09640f21aac14 (diff) |
add IPCP Configure-Ack (de)serialization tests
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 52 |
1 files changed, 52 insertions, 0 deletions
@@ -1323,4 +1323,56 @@ mod tests { ); Ok(()) } + + #[test] + fn test_serialize_ipcp_configure_ack() -> Result<()> { + let configure_ack = PppoePkt::new_ppp( + [0x00, 0x00, 0x5e, 0x00, 0x53, 0x01].into(), + [0x00, 0x00, 0x5e, 0x00, 0x53, 0x02].into(), + 1, + PppPkt::new_ipcp(IpcpPkt::new_configure_ack( + 0x41, + vec![IpcpOpt::IpAddr(Ipv4Addr::new(198, 51, 100, 1).into()).into()], + )), + ); + + let mut buf = Vec::new(); + configure_ack.serialize(&mut buf)?; + + assert_eq!( + &buf, + &[ + 0x00, 0x00, 0x5e, 0x00, 0x53, 0x01, 0x00, 0x00, 0x5e, 0x00, 0x53, 0x02, 0x88, 0x64, + 0x11, 0x00, 0x00, 0x01, 0x00, 0x0c, 0x80, 0x21, 0x02, 0x41, 0x00, 0x0a, 0x03, 0x06, + 0xc6, 0x33, 0x64, 0x01 + ] + ); + Ok(()) + } + + #[test] + fn test_deserialize_ipcp_configure_ack() -> Result<()> { + let mut configure_ack = PppoePkt::default(); + + let buf = [ + 0x00, 0x00, 0x5e, 0x00, 0x53, 0x01, 0x00, 0x00, 0x5e, 0x00, 0x53, 0x02, 0x88, 0x64, + 0x11, 0x00, 0x00, 0x01, 0x00, 0x0c, 0x80, 0x21, 0x02, 0x41, 0x00, 0x0a, 0x03, 0x06, + 0xc6, 0x33, 0x64, 0x01, + ]; + configure_ack.deserialize(&mut buf.as_ref())?; + + assert_eq!( + configure_ack, + PppoePkt::new_ppp( + [0x00, 0x00, 0x5e, 0x00, 0x53, 0x01].into(), + [0x00, 0x00, 0x5e, 0x00, 0x53, 0x02].into(), + 1, + PppPkt::new_ipcp(IpcpPkt::new_configure_ack( + 0x41, + vec![IpcpOpt::IpAddr(Ipv4Addr::new(198, 51, 100, 1).into()).into()] + )) + ) + ); + Ok(()) + } } |