diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-05 12:36:04 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-05 12:36:04 +0100 |
commit | 47e03ae6a340071db539b587abd76d395b0274e1 (patch) | |
tree | 88cf80002b300634c1d34c8bff218a9eca3af855 | |
parent | b81c59e28aa2db6de84abd3528c5c701493ab169 (diff) |
add getter for locally negotiated options
-rw-r--r-- | src/proto.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/proto.rs b/src/proto.rs index d583ea8..9d95f1b 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -428,8 +428,14 @@ impl<O: ProtocolOption> NegotiationProtocol<O> { self.is_closed() || self.is_stopped() } + /// Returns the options currently requested by us. + /// This is most useful while the protocol is in the `Opened` state. + pub fn our_options(&self) -> &[O] { + &self.request + } + /// Returns the options set by the peer. - pub fn peer(&self) -> &[O] { + pub fn peer_options(&self) -> &[O] { &self.peer } @@ -1161,7 +1167,7 @@ impl<O: ProtocolOption> ProtocolOptionNeedProtocol for &NegotiationProtocol<O> { impl LcpOptNeedProtocol for NegotiationProtocol<LcpOpt> { fn need_protocol(&self, protocol: u16) -> bool { - let our_auth = self.request.iter().find_map(|option| { + let our_auth = self.our_options().iter().find_map(|option| { if let LcpOpt::AuthenticationProtocol(auth_protocol) = option { Some(auth_protocol) } else { @@ -1169,7 +1175,7 @@ impl LcpOptNeedProtocol for NegotiationProtocol<LcpOpt> { } }); - let peer_auth = self.peer().iter().find_map(|option| { + let peer_auth = self.peer_options().iter().find_map(|option| { if let LcpOpt::AuthenticationProtocol(auth_protocol) = option { Some(auth_protocol) } else { |