Commit Graph

37 Commits (master)

Author SHA1 Message Date
Richard Cochran b8194a177a Implement the synchronization uncertain flag.
IEEE 1588 v2.1 and ITU G.8275.1/2 call for an optional "synchronization
uncertain" flag passed in Announce messages along with the other flags
from the time properties data set.  The value of the flag depends is a
logical OR function of the inputs from the remote master and the local
process.  This patch adds background support for handling the flag.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2020-05-24 12:02:49 -07:00
Vedang Patel 630ce719fc port: implement message interval request processing
This implements transmission and receipt of message interval requests.
Using this mechanism, a time-aware device can request change in sync,
link delay and announce intervals on the device connected on the other
end.

As part of the commit, we are also saving the initial values of Announce
and Sync Interval.

For more information look at sections 10.2.4.4, 10.3.9.5, 10.3.14, 10.4,
10.5.4 and 11.2.17 of 802.1AS standard

Please note that this commit does not implement logic related to
computeNeighborRateRatio and computeNeighborPropDelay flags mentioned in
Section 10.5.4.3.9 of 802.1AS Standard.

[ RC - memset the targetPortIdentity to all ones. ]

Signed-off-by: Vedang Patel <vedang.patel@intel.com>
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2019-05-08 21:29:29 -07:00
Anders Selhammer 1a4f6a26ce msg: Added const flag in msg_type
Signed-off-by: Anders Selhammer <anders.selhammer@est.tech>
2019-01-06 19:47:51 -08:00
Michael Walle 57c2b46604 msg: inline net2host64() and host2net64()
These functions are just wrappers. Make it possible for the compiler to
optimize the calls when compiled with optimization.

Signed-off-by: Michael Walle <michael@walle.cc>
2018-07-21 16:28:07 -07:00
Michael Walle 8f484e8312 msg: Drop msg->tlv_count.
The field is redundant with the length tlv_list. Replace it with a
function msg_tlv_count() instead. This iterates over the tlv_list. The
computational overhead should be small, because the lists are very short
and the tlv_count is only used in management paths (yet).

Signed-off-by: Michael Walle <michael@walle.cc>
2018-07-21 16:28:07 -07:00
Richard Cochran ccfeb3b092 msg: Introduce a helper to test for unicast messages.
With increasing unicast support, the code needs to identify unicast
messages more often.  This patch replaces the open coded bit field
tests with a more readable in line helper function call.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-05-25 15:28:35 -07:00
Richard Cochran 51b540875f msg: Introduce a method to copy a message.
The transparent clock will want to have two copies of certain messages,
one for forwarding and one for internal use (in the BMCA and for
syntonization).  This patch add a function that duplicates a given
message, including all of the attached TLVs.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-04-13 22:37:09 -07:00
Richard Cochran 4842d2c7ec Introduce peer to peer one step.
The 1588 standard defines one step operation for both Sync and
PDelay_Resp messages.  Up until now, hardware with P2P one step has
been rare, and kernel support was lacking.  This patch adds support of
the mode in anticipation of new kernel and hardware developments.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-27 22:26:32 -07:00
Michael Brown 7f59858d08 msg: Represent hw_timestamp "sw" field as tmv_t
Convert a software timestamp to the internal tmv_t representation at
the earliest possible opportunity, to match the behaviour for hardware
timestamps.

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-17 19:04:28 -07:00
Michael Brown 29a99ad513 msg: Represent hw_timestamp "ts" field as tmv_t
Convert a hardware timestamp to the internal tmv_t representation at
the earliest possible opportunity.  This allows us to:

- eliminate multiple redundant calls to timespec_to_tmv()

- use tmv_add() instead of open-coded manipulation of a struct
  timespec in ts_add()

- use tmv_to_Timestamp() instead of open-coded manipulation of a
  struct timespec and struct Timestamp in ts_to_Timestamp()

- use tmv_is_zero() instead of open-coded manipulation of a struct
  timespec in msg_sots_valid()

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
2018-03-17 19:04:28 -07:00
Richard Cochran 9d48046e95 msg: Allow tacking a TLV onto a delay request message.
This will be needed in order to support the NetSync Monitor protocol.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran ecb5fa8ffb msg: Remove the 'last_tlv' field.
All users have been converted to the TLV list, so remove the field.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran 4a8877f904 msg: Introduce method for appending multiple TLVs on transmit.
In order to support multiple TLVs, the transmit code must be able to
append one TLV after another.  This patch adds a method that checks
whether there is room, allocates the TLV descriptor, sets the buffer
pointer, and appends the descriptor to the list.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran 7fe69e7ba0 msg: Populate the TLV list on receive.
This patch changes the receive message parsing code to place each TLV
into the list.  A method is introduced that allows attaching TLVs to
the end of the list.

In addition, msg.last_tlv is converted into a pointer to the last item
in the list.  Because of this change, the transmit code that uses this
field now allocates a TLV before using it.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran 22b894b687 msg: Introduce a TLV list.
In order to support multiple TLVs per message, a list is needed.
This patch adds the list to the message structure.  This list will
eventually replace the 'last_tlv' field.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2018-03-07 19:28:25 -08:00
Richard Cochran b295df24b5 Introduce a helper function to identify valid (non-zero) time stamps.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2014-12-12 21:44:56 +01:00
Jiri Benc e804e6f9a0 Common type holding an address
This modifies all transports to use a new common address type, struct
address. This address is stored in a ptp_message for all received messages.

For sending, the "default" address is used with the default sending
functions, transport_send and transport_peer. The default address depends on
the transport; it's supposed to be the multicast address assigned by the
transport specification.

Later, a new transport_sendto function will be implemented that sends to the
address contained in the passed ptp_message.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-04-25 14:28:14 +02:00
Jiri Benc bbe634d790 Let transport_recv/send/peer use ptp_message
The callers of those functions are all using ptp_message. As we're going to
return more information (the address), let those functions just fill in the
ptp_message fields directly.

Some minor reshuffling needed to prevent circular header dependencies.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2014-04-17 06:49:38 +02:00
Stephan Gatzka 110849d422 Make functions and structs dealing with string literals const correct.
This allows the compiler to check if someone writes into string
literals.

Signed-off-by: Stephan Gatzka <stephan.gatzka@gmail.com>
2014-02-07 19:41:47 +01:00
Libor Pechacek 0367bb5f1b Distinguish between ignored and malformed packets
When there is a peer speaking PTPv1 in the network we want to silently ignore
the packets instead of flooding system log with error messages.  At the same
time we still want to report malformed packets.  For that we reuse standard
error numbers and do more fine-grained error reporting in packet processing
routines.

Signed-off-by: Libor Pechacek <lpechacek@suse.cz>
2013-03-28 18:48:52 +01:00
Geoff Salmon f4e8f5be3f support TLVs with flexible size
These flexible TLVs don't need to be represented as a single packed
struct directly in the message buffer. Instead a separate struct
contains pointers to the individual parts of the TLV in the message
buffer. The flexible TLV can only be the last TLV in a message.

Signed-off-by: Geoff Salmon <gsalmon@se-instruments.com>
2013-02-25 18:11:03 +01:00
Richard Cochran d666149e91 Add missing documentation for msg_post_recv.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2013-01-22 18:31:17 +01:00
Richard Cochran 577d34facf Provide a method to release the message cache.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-27 21:09:10 +02:00
Richard Cochran 226bd355af Convert the follow up info tlv to and from network byte order.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-10 20:31:24 +02:00
Richard Cochran ba5c5704e6 Move the protocol version macro to a public header.
This will be needed by the management client program.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-05 21:46:03 +02:00
Richard Cochran f233528ea4 Provide a port method to allocate a management message reply.
This function will be needed for both positive replies and error status
messages.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-05 21:42:00 +02:00
Richard Cochran f20cf6225a Convert TLV type and length to host byte order on receive.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-08-01 17:16:23 +02:00
Richard Cochran eed8ed05c8 Add an option to assume two step messaging.
Some commercial 802.1AS switches do not feel obliged to set the two step
flag. When we try to synchronize to their apparent one step sync messages,
nothing good happens. This commit adds a global option to work around the
issue.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-07-28 06:29:15 +02:00
Richard Cochran 6258aa0bad Drop incoming packets on transportSpecific mismatch.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-07-27 22:41:00 +02:00
Richard Cochran d7a67e9f89 Prevent message buffer corruption on receive.
An oversize incoming packet might overwrite the reference counter in a
message. Prevent this by providing a buffer large enough for the largest
possible packet.

This will also be needed to support TLV suffixes.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-07-08 13:11:38 +02:00
Richard Cochran 018ba27ff8 Add declarations for the signaling and management message types.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-06-03 19:11:36 +02:00
Richard Cochran 2633df45cf Add the suffix field onto the general messages.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-06-03 18:55:42 +02:00
Richard Cochran aea4cfcd50 Add transport over UDP IPv6.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-04-20 16:30:01 +02:00
Richard Cochran e213ff0479 Add the peer delay messages into the message layer.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-04-02 17:20:04 +02:00
Richard Cochran 28dc3613d7 Fix a misspelled field name.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-04-02 16:45:44 +02:00
Richard Cochran 51162c01af Warn loudly whenever event messages are missing time stamps.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2012-03-11 09:53:28 +01:00
Richard Cochran edcb731cc2 Add a message layer.
Note that only some of the message types are implemented.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
2011-11-06 09:02:57 +01:00