diff --git a/config.c b/config.c index 08e29a2..b8f2bdb 100644 --- a/config.c +++ b/config.c @@ -91,6 +91,10 @@ static void scan_line(char *s, struct config *cfg) pod->transportSpecific = u8 << 4; + } else if (1 == sscanf(s, " assume_two_step %u", &val)) { + + *cfg->assume_two_step = val ? 1 : 0; + } else if (1 == sscanf(s, " tx_timestamp_retries %u", &val)) { if (val > 0) diff --git a/config.h b/config.h index 8fde9c1..fb22341 100644 --- a/config.h +++ b/config.h @@ -25,6 +25,7 @@ struct config { struct defaultDS *dds; struct port_defaults *pod; + int *assume_two_step; int *tx_timestamp_retries; int *rx_timestamp_l2only; double *pi_proportional_const; diff --git a/msg.h b/msg.h index f479e9c..d737ee2 100644 --- a/msg.h +++ b/msg.h @@ -284,6 +284,11 @@ void msg_put(struct ptp_message *m); */ int msg_sots_missing(struct ptp_message *m); +/** + * Work around buggy 802.1AS switches. + */ +extern int assume_two_step; + /** * Test whether a message is one-step message. * @param m Message to test. @@ -291,6 +296,8 @@ int msg_sots_missing(struct ptp_message *m); */ static inline Boolean one_step(struct ptp_message *m) { + if (assume_two_step) + return 0; return !field_is_set(m, 0, TWO_STEP); } diff --git a/ptp4l.c b/ptp4l.c index 52ba480..deadf62 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -30,6 +30,7 @@ #define DEFAULT_PHC "/dev/ptp0" +int assume_two_step; int sk_tx_retries = 2, sk_prefer_layer2 = 0; /*see sk.c*/ double configured_pi_kp, configured_pi_ki; /*see pi.c*/ extern unsigned char ptp_dst_mac[]; /*see raw.c*/ @@ -219,6 +220,7 @@ int main(int argc, char *argv[]) cfg_settings.dds = &ds; cfg_settings.pod = &pod; + cfg_settings.assume_two_step = &assume_two_step; cfg_settings.tx_timestamp_retries = &sk_tx_retries; cfg_settings.rx_timestamp_l2only = &sk_prefer_layer2; cfg_settings.pi_proportional_const = &configured_pi_kp;