diff --git a/config.c b/config.c index 374aee9..efa76f2 100644 --- a/config.c +++ b/config.c @@ -19,14 +19,16 @@ #include #include #include "config.h" +#include "ether.h" static void scan_line(char *s, struct config *cfg) { double df; - int val; + int i, val; Integer8 i8; UInteger16 u16; UInteger8 u8; + unsigned char mac[MAC_LEN]; struct defaultDS *dds = cfg->dds; struct port_defaults *pod = cfg->pod; @@ -99,6 +101,18 @@ static void scan_line(char *s, struct config *cfg) if (df > 0.0 && df < 1.0) *cfg->pi_integral_const = df; + + } else if (MAC_LEN == sscanf(s, " ptp_dst_mac %hhx:%hhx:%hhx:%hhx:%hhx:%hhx", + &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5])) { + + for (i = 0; i < MAC_LEN; i++) + cfg->ptp_dst_mac[i] = mac[i]; + + } else if (MAC_LEN == sscanf(s, " p2p_dst_mac %hhx:%hhx:%hhx:%hhx:%hhx:%hhx", + &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5])) { + + for (i = 0; i < MAC_LEN; i++) + cfg->p2p_dst_mac[i] = mac[i]; } } diff --git a/config.h b/config.h index 0e69666..1c278f1 100644 --- a/config.h +++ b/config.h @@ -28,6 +28,8 @@ struct config { int *tx_timestamp_retries; double *pi_proportional_const; double *pi_integral_const; + unsigned char *ptp_dst_mac; + unsigned char *p2p_dst_mac; }; int config_read(char *name, struct config *cfg); diff --git a/default.cfg b/default.cfg index 701e7bd..b92c682 100644 --- a/default.cfg +++ b/default.cfg @@ -19,7 +19,12 @@ announceReceiptTimeout 3 # # Run time options # -transportSpecific 0x0 tx_timestamp_retries 2 pi_proportional_const 0.0 pi_integral_const 0.0 +# +# Transport options +# +transportSpecific 0x0 +ptp_dst_mac 01:1B:19:00:00:00 +p2p_dst_mac 01:80:C2:00:00:0E diff --git a/ptp4l.c b/ptp4l.c index 2a0387a..cb29eb3 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -32,6 +32,8 @@ int sk_tx_retries = 2; /*see sk.c*/ double configured_pi_kp, configured_pi_ki; /*see pi.c*/ +extern unsigned char ptp_dst_mac[]; /*see raw.c*/ +extern unsigned char p2p_dst_mac[]; /*see raw.c*/ static int running = 1; static struct defaultDS ds; @@ -219,6 +221,8 @@ int main(int argc, char *argv[]) cfg_settings.tx_timestamp_retries = &sk_tx_retries; cfg_settings.pi_proportional_const = &configured_pi_kp; cfg_settings.pi_integral_const = &configured_pi_ki; + cfg_settings.ptp_dst_mac = ptp_dst_mac; + cfg_settings.p2p_dst_mac = p2p_dst_mac; if (config && config_read(config, &cfg_settings)) { fprintf(stderr, "failed to read configuration file\n"); diff --git a/raw.c b/raw.c index 5ea1e1c..4f53c49 100644 --- a/raw.c +++ b/raw.c @@ -138,8 +138,8 @@ static int raw_close(struct transport *t, struct fdarray *fda) return 0; } -static unsigned char ptp_dst_mac[MAC_LEN] = { PTP_DST_MAC }; -static unsigned char p2p_dst_mac[MAC_LEN] = { P2P_DST_MAC }; +unsigned char ptp_dst_mac[MAC_LEN] = { PTP_DST_MAC }; +unsigned char p2p_dst_mac[MAC_LEN] = { P2P_DST_MAC }; static int open_socket(char *name, int event) {