IEEE1588-2008 Annex D to I define for each PTP transport how transport specific field should be interpreted by the receiver. Instead of requiring a full match with the locally configured value, ignore the bits that should be ignored according to the transport used. As defined in the respective Annex.
Signed-off-by: Petr Kulhavy <[email protected]> --- port.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/port.c b/port.c index d8e29d5..bdee1b4 100644 --- a/port.c +++ b/port.c @@ -631,6 +631,29 @@ static int port_clr_tmo(int fd) return timerfd_settime(fd, 0, &tmo, NULL); } +/** + * Check message transport specific field against the port transport specific, + * using a policy defined by the respective transport type + * @return 0 = transport specific OK; otherwise transport specific mismatch (i.e. drop message), + */ +static int check_transport_specific(struct port *p, struct ptp_message *m) +{ + switch(transport_type(p->trp)) { + case TRANS_UDP_IPV4: /* Annex D.4: bits 1-3 ignored by the receiver */ + return ((msg_transport_specific(m) ^ p->transportSpecific) & 0x10); + case TRANS_IEEE_802_3: /* Annex F.4: TS bits are interpreted as Ethertype subtype, i.e. full match */ + return (msg_transport_specific(m) ^ p->transportSpecific); + case TRANS_UDS: /* ignore all bits */ + case TRANS_PROFINET: /* Annex I.4: TS has no PROFINET counterpart, i.e. ignore? */ + case TRANS_CONTROLNET: /* Annex H.5: all bits ignored by the receiver */ + case TRANS_DEVICENET: /* Annex G.6: all bits ignored by the receiver */ + case TRANS_UDP_IPV6: /* Annex E.4: all bits ignored by the receiver */ + return 0; + default: + return 1; + } +} + static int port_ignore(struct port *p, struct ptp_message *m) { struct ClockIdentity c1, c2; @@ -641,7 +664,7 @@ static int port_ignore(struct port *p, struct ptp_message *m) if (path_trace_ignore(p, m)) { return 1; } - if (msg_transport_specific(m) != p->transportSpecific) { + if (check_transport_specific(p, m)) { return 1; } if (pid_eq(&m->header.sourcePortIdentity, &p->portIdentity)) { -- 2.7.4 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Linuxptp-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
