From 6258aa0badf22b039e60ba5ef7923a03b73ff7f4 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Fri, 27 Jul 2012 22:17:56 +0200 Subject: [PATCH] Drop incoming packets on transportSpecific mismatch. Signed-off-by: Richard Cochran --- msg.h | 11 +++++++++++ port.c | 3 +++ 2 files changed, 14 insertions(+) diff --git a/msg.h b/msg.h index c28dd0b..f479e9c 100644 --- a/msg.h +++ b/msg.h @@ -212,6 +212,17 @@ static inline Boolean field_is_set(struct ptp_message *m, int index, Octet bit) return m->header.flagField[index] & bit ? TRUE : FALSE; } +/** + * Obtain the transportSpecific field from a message. + * @param m Message to test. + * @return The value of the transportSpecific field. Note that the + * value is returned unshifted, in the upper nibble. + */ +static inline UInteger8 msg_transport_specific(struct ptp_message *m) +{ + return m->header.tsmt & 0xf0; +} + /** * Obtain the message type. * @param m Message to test. diff --git a/port.c b/port.c index e2fe9cc..910ecee 100644 --- a/port.c +++ b/port.c @@ -290,6 +290,9 @@ static int port_ignore(struct port *p, struct ptp_message *m) { struct ClockIdentity c1, c2; + if (msg_transport_specific(m) != p->transportSpecific) { + return 1; + } if (pid_eq(&m->header.sourcePortIdentity, &p->portIdentity)) { return 1; }