diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-07-30 10:18:04 +0200 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-07-30 10:18:04 +0200 |
commit | bb38811c966d366e3dda177706dbbbc1dde67c91 (patch) | |
tree | 7810318f0ca293d4f7039a8965a9a00ada8e1c51 | |
parent | 07e04d42496f41873dae456c9dcf5669ecffa687 (diff) |
ignore packets for other sessions, including PADTs
-rw-r--r-- | src/main.rs | 16 | ||||
-rw-r--r-- | src/state.rs | 2 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 7ef8b33..2c9f822 100644 --- a/src/main.rs +++ b/src/main.rs @@ -136,7 +136,7 @@ fn connect(interface: &str) -> Result<()> { println!(" -> [{}] padr {}/{}", remote_mac, attempt, MAX_ATTEMPTS); *pppoe_state = Pppoe::Request(remote_mac, ac_cookie.to_owned(), attempt + 1); } - Pppoe::Active(_) => {} + Pppoe::Active(..) => {} Pppoe::Err => { return Err(recv_disc .join() @@ -170,11 +170,19 @@ fn recv_discovery( continue; } } - Pppoe::Active(remote_mac) => { + Pppoe::Active(remote_mac, session_id) => { if pkt.src_mac != remote_mac { println!(" <- [{}] unexpected mac, pkt: {:?}", pkt.src_mac, pkt); continue; } + + if pkt.session_id != session_id { + println!( + " <- [{}] wrong session id {}, pkt: {:?}", + pkt.src_mac, pkt.session_id, pkt + ); + continue; + } } _ => {} } @@ -249,7 +257,7 @@ fn recv_discovery( } }); - *state = Pppoe::Active(pkt.src_mac); + *state = Pppoe::Active(pkt.src_mac, pkt.session_id); println!(" <- [{}] pads, session id: {}", pkt.src_mac, pkt.session_id); } else { println!( @@ -272,7 +280,7 @@ fn recv_discovery( .unwrap_or(String::new()); let mut state = state.lock().expect("pppoe state mutex is poisoned"); - if let Pppoe::Active(_) = *state { + if let Pppoe::Active(..) = *state { *state = Pppoe::Init; } diff --git a/src/state.rs b/src/state.rs index e300e20..7919255 100644 --- a/src/state.rs +++ b/src/state.rs @@ -5,7 +5,7 @@ pub enum Pppoe { #[default] Init, Request(MacAddr, Option<Vec<u8>>, usize), - Active(MacAddr), + Active(MacAddr, u16), Err, } |