aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-07-26 19:26:20 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-07-26 19:26:20 +0200
commit5f78e8220404294ebbb4de91c2a09640f21aac14 (patch)
tree05dea3d569665d76488541db64da447e1ec29056 /src/lib.rs
parent5468e5281d47f4d95cb1214482e8dd1296d824dd (diff)
add IPCP Configure-Request serialization test
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 216bc12..818b937 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -32,6 +32,8 @@ pub use types::*;
mod tests {
use super::{de::Deserialize, ser::Serialize, *};
+ use std::net::Ipv4Addr;
+
use ppproperly_macros::{Deserialize, Serialize};
#[test]
@@ -1269,4 +1271,56 @@ mod tests {
);
Ok(())
}
+
+ #[test]
+ fn test_serialize_ipcp_configure_request() -> Result<()> {
+ let configure_request = PppoePkt::new_ppp(
+ [0x00, 0x00, 0x5e, 0x00, 0x53, 0x02].into(),
+ [0x00, 0x00, 0x5e, 0x00, 0x53, 0x01].into(),
+ 1,
+ PppPkt::new_ipcp(IpcpPkt::new_configure_request(
+ 0x41,
+ vec![IpcpOpt::IpAddr(Ipv4Addr::new(198, 51, 100, 1).into()).into()],
+ )),
+ );
+
+ let mut buf = Vec::new();
+ configure_request.serialize(&mut buf)?;
+
+ assert_eq!(
+ &buf,
+ &[
+ 0x00, 0x00, 0x5e, 0x00, 0x53, 0x02, 0x00, 0x00, 0x5e, 0x00, 0x53, 0x01, 0x88, 0x64,
+ 0x11, 0x00, 0x00, 0x01, 0x00, 0x0c, 0x80, 0x21, 0x01, 0x41, 0x00, 0x0a, 0x03, 0x06,
+ 0xc6, 0x33, 0x64, 0x01
+ ]
+ );
+ Ok(())
+ }
+
+ #[test]
+ fn test_deserialize_ipcp_configure_request() -> Result<()> {
+ let mut configure_request = PppoePkt::default();
+
+ let buf = [
+ 0x00, 0x00, 0x5e, 0x00, 0x53, 0x02, 0x00, 0x00, 0x5e, 0x00, 0x53, 0x01, 0x88, 0x64,
+ 0x11, 0x00, 0x00, 0x01, 0x00, 0x0c, 0x80, 0x21, 0x01, 0x41, 0x00, 0x0a, 0x03, 0x06,
+ 0xc6, 0x33, 0x64, 0x01,
+ ];
+ configure_request.deserialize(&mut buf.as_ref())?;
+
+ assert_eq!(
+ configure_request,
+ PppoePkt::new_ppp(
+ [0x00, 0x00, 0x5e, 0x00, 0x53, 0x02].into(),
+ [0x00, 0x00, 0x5e, 0x00, 0x53, 0x01].into(),
+ 1,
+ PppPkt::new_ipcp(IpcpPkt::new_configure_request(
+ 0x41,
+ vec![IpcpOpt::IpAddr(Ipv4Addr::new(198, 51, 100, 1).into()).into()]
+ ))
+ )
+ );
+ Ok(())
+ }
}