Skip to content

Commit

Permalink
Switch to Dead phase if LCP gets terminated by the peer.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Aug 29, 2023
1 parent 8667375 commit e5dc10a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ppp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub struct Status {

pub(crate) struct PPP<'a> {
phase: Phase,
opening: bool,
pub(crate) lcp: OptionFsm<LCP>,
pub(crate) pap: PAP<'a>,
pub(crate) ipv4cp: OptionFsm<IPv4CP>,
Expand All @@ -56,6 +57,7 @@ impl<'a> PPP<'a> {
pub fn new(config: Config<'a>) -> Self {
Self {
phase: Phase::Dead,
opening: false,
lcp: OptionFsm::new(LCP::new()),
pap: PAP::new(config.username, config.password),
ipv4cp: OptionFsm::new(IPv4CP::new()),
Expand All @@ -77,6 +79,7 @@ impl<'a> PPP<'a> {
match self.phase {
Phase::Dead => {
self.phase = Phase::Establish;
self.opening = true;
Ok(())
}
_ => Err(crate::InvalidStateError),
Expand Down Expand Up @@ -104,6 +107,7 @@ impl<'a> PPP<'a> {
Phase::Establish => {
if self.lcp.state() == State::Closed {
tx(self.lcp.open());
self.opening = false;
}

if self.lcp.state() == State::Opened {
Expand Down Expand Up @@ -144,6 +148,10 @@ impl<'a> PPP<'a> {
Phase::Open => {}
}

if self.lcp.state() == State::Closed && !self.opening {
self.phase = Phase::Dead
}

if old_phase != self.phase {
info!("PPP link phase {:?} -> {:?}", old_phase, self.phase);
}
Expand Down

0 comments on commit e5dc10a

Please sign in to comment.