From 975f2f23c0256f192838a5a5cd995faa9ad88f34 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 30 Aug 2023 01:04:43 +0200 Subject: [PATCH] net-ppp: return error when PPP link gets terminated by the peer. --- embassy-net-ppp/Cargo.toml | 2 +- embassy-net-ppp/src/lib.rs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/embassy-net-ppp/Cargo.toml b/embassy-net-ppp/Cargo.toml index b2874c683..191577b5c 100644 --- a/embassy-net-ppp/Cargo.toml +++ b/embassy-net-ppp/Cargo.toml @@ -18,7 +18,7 @@ log = { version = "0.4.14", optional = true } embedded-io-async = { version = "0.5.0" } embassy-net-driver-channel = { version = "0.1.0", path = "../embassy-net-driver-channel" } embassy-futures = { version = "0.1.0", path = "../embassy-futures" } -ppproto = { version = "0.1.1"} +ppproto = { version = "0.1.2"} embassy-sync = { version = "0.2.0", path = "../embassy-sync" } [package.metadata.embassy_docs] diff --git a/embassy-net-ppp/src/lib.rs b/embassy-net-ppp/src/lib.rs index ca87fbaea..66496ee0a 100644 --- a/embassy-net-ppp/src/lib.rs +++ b/embassy-net-ppp/src/lib.rs @@ -53,6 +53,8 @@ pub enum RunError { WriteZero, /// Writing to the serial got EOF. Eof, + /// PPP protocol was terminated by the peer + Terminated, } impl From> for RunError { @@ -128,6 +130,9 @@ impl<'d> Runner<'d> { let status = ppp.status(); match status.phase { + ppproto::Phase::Dead => { + return Err(RunError::Terminated); + } ppproto::Phase::Open => { if !was_up { on_ipv4_up(status.ipv4.unwrap());