Skip to content

Commit

Permalink
Allow handling of general messages through handle_timecritical_receive.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidv1992 committed Oct 4, 2023
1 parent dd17f02 commit 16c3ee4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
15 changes: 15 additions & 0 deletions statime/src/datastructures/messages/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,21 @@ pub(crate) struct Message<'a> {
pub(crate) suffix: TlvSet<'a>,
}

impl<'a> Message<'a> {
pub(crate) fn is_event(&self) -> bool {
use MessageBody::*;
match self.body {
Sync(_) | DelayReq(_) | PDelayReq(_) | PDelayResp(_) => true,
FollowUp(_)
| DelayResp(_)
| PDelayRespFollowUp(_)
| Announce(_)
| Signaling(_)
| Management(_) => false,
}
}
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) enum MessageBody {
Sync(SyncMessage),
Expand Down
26 changes: 16 additions & 10 deletions statime/src/port/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,18 @@ impl<'a, C: Clock, F: Filter, R: Rng> Port<Running<'a>, R, C, F> {
return actions![];
}

let actions = self.port_state.handle_event_receive(
message,
timestamp,
self.config.min_delay_req_interval(),
self.port_identity,
&mut self.clock,
&mut self.packet_buffer,
);

actions
if message.is_event() {
self.port_state.handle_event_receive(
message,
timestamp,
self.config.min_delay_req_interval(),
self.port_identity,
&mut self.clock,
&mut self.packet_buffer,
)
} else {
self.handle_general_internal(message)
}
}

// Handle a general ptp message
Expand All @@ -273,6 +275,10 @@ impl<'a, C: Clock, F: Filter, R: Rng> Port<Running<'a>, R, C, F> {
return actions![];
}

self.handle_general_internal(message)
}

fn handle_general_internal(&mut self, message: Message<'_>) -> PortActionIterator<'_> {
match message.body {
MessageBody::Announce(announce) => {
self.bmca
Expand Down

0 comments on commit 16c3ee4

Please sign in to comment.