aboutsummaryrefslogtreecommitdiff
path: root/src/proto.rs
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2025-04-05 21:08:20 +0200
committerHimbeer <himbeer@disroot.org>2025-04-05 22:16:05 +0200
commit0815b09aafc392806c634205e0fe655f36b467e1 (patch)
tree5cdb96736007e39f3dd032aa113df3f5002bcb98 /src/proto.rs
parentbe07f0089801adf20bec7b98b0dedc00085d095c (diff)
Send LCP Protocol-Reject packets in response to unsupported protocolsHEADmaster
This fixes a bug where the client crashes/hangs instead of handling the condition gracefully and reporting it to the peer.
Diffstat (limited to 'src/proto.rs')
-rw-r--r--src/proto.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/proto.rs b/src/proto.rs
index 1fd0929..39fa0d6 100644
--- a/src/proto.rs
+++ b/src/proto.rs
@@ -491,6 +491,22 @@ impl<O: ProtocolOption> NegotiationProtocol<O> {
self.lower_status_rx.clone()
}
+ /// Sends a Protocol-Reject for the specified protocol ID to the peer.
+ pub fn reject(&self, id: u16) {
+ if self.state != ProtocolState::Opened {
+ return;
+ }
+
+ self.output_tx
+ .send(Packet {
+ ty: PacketType::ProtocolReject,
+ options: Vec::default(),
+ rejected_code: PacketType::Unknown(0),
+ rejected_protocol: id,
+ })
+ .expect("output channel is closed");
+ }
+
fn timeout_positive(&mut self) -> Option<Packet<O>> {
match self.state {
ProtocolState::Initial