Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 config.c | 10 ++--------
 config.h |  1 -
 ether.h  |  1 -
 ptp4l.8  |  8 ++++----
 ptp4l.c  |  1 -
 raw.c    | 16 ++++++++++++----
 raw.h    |  5 -----
 7 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/config.c b/config.c
index c878178..c88a308 100644
--- a/config.c
+++ b/config.c
@@ -213,6 +213,7 @@ struct config_item config_tab[] = {
        GLOB_ITEM_DBL("pi_proportional_scale", 0.0, 0.0, DBL_MAX),
        GLOB_ITEM_INT("priority1", 128, 0, UINT8_MAX),
        GLOB_ITEM_INT("priority2", 128, 0, UINT8_MAX),
+       PORT_ITEM_STR("ptp_dst_mac", "01:1B:19:00:00:00"),
        GLOB_ITEM_INT("sanity_freq_limit", 200000000, 0, INT_MAX),
        GLOB_ITEM_INT("slaveOnly", 0, 0, 1),
        GLOB_ITEM_DBL("step_threshold", 0.0, 0.0, DBL_MAX),
@@ -467,14 +468,7 @@ static enum parser_result parse_global_setting(const char 
*option,
        if (r != NOT_PARSED)
                return r;
 
-       if (!strcmp(option, "ptp_dst_mac")) {
-               if (MAC_LEN != sscanf(value, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
-                                     &mac[0], &mac[1], &mac[2], &mac[3], 
&mac[4], &mac[5]))
-                       return BAD_VALUE;
-               for (i = 0; i < MAC_LEN; i++)
-                       cfg->ptp_dst_mac[i] = mac[i];
-
-       } else if (!strcmp(option, "p2p_dst_mac")) {
+       if (!strcmp(option, "p2p_dst_mac")) {
                if (MAC_LEN != sscanf(value, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
                                      &mac[0], &mac[1], &mac[2], &mac[3], 
&mac[4], &mac[5]))
                        return BAD_VALUE;
diff --git a/config.h b/config.h
index 7b1473a..32c1ceb 100644
--- a/config.h
+++ b/config.h
@@ -47,7 +47,6 @@ struct config {
 
        /* the rest are legacy fields */
        struct default_ds dds;
-       unsigned char *ptp_dst_mac;
        unsigned char *p2p_dst_mac;
        char *uds_address;
 };
diff --git a/ether.h b/ether.h
index 89e22c8..a07fde4 100644
--- a/ether.h
+++ b/ether.h
@@ -23,7 +23,6 @@
 #include <stdint.h>
 
 #define MAC_LEN 6
-#define PTP_DST_MAC 0x01, 0x1B, 0x19, 0x00, 0x00, 0x00
 #define P2P_DST_MAC 0x01, 0x80, 0xC2, 0x00, 0x00, 0x0E
 
 typedef uint8_t eth_addr[MAC_LEN];
diff --git a/ptp4l.8 b/ptp4l.8
index 0bdccb1..f76e18c 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -185,6 +185,10 @@ The default is 16 seconds.
 Select the delay mechanism. Possible values are E2E, P2P and Auto.
 The default is E2E.
 .TP
+.B ptp_dst_mac
+The MAC address to which PTP messages should be sent.
+Relevant only with L2 transport. The default is 01:1B:19:00:00:00.
+.TP
 .B network_transport
 Select the network transport. Possible values are UDPv4, UDPv6 and L2.
 The default is UDPv4.
@@ -412,10 +416,6 @@ disabled. The default is 200000000 (20%).
 The number of the SHM segment used by ntpshm servo.
 The default is 0.
 .TP
-.B ptp_dst_mac
-The MAC address where should be PTP messages sent.
-Relevant only with L2 transport. The default is 01:1B:19:00:00:00.
-.TP
 .B p2p_dst_mac
 The MAC address where should be peer delay messages the PTP peer.
 Relevant only with L2 transport. The default is 01:80:C2:00:00:0E.
diff --git a/ptp4l.c b/ptp4l.c
index cc94f66..ddb7e16 100644
--- a/ptp4l.c
+++ b/ptp4l.c
@@ -59,7 +59,6 @@ static struct config cfg_settings = {
                },
        },
 
-       .ptp_dst_mac = ptp_dst_mac,
        .p2p_dst_mac = p2p_dst_mac,
        .uds_address = uds_path,
 };
diff --git a/raw.c b/raw.c
index cd7bd90..5cf6986 100644
--- a/raw.c
+++ b/raw.c
@@ -37,12 +37,14 @@
 #include <linux/sockios.h>
 
 #include "address.h"
+#include "config.h"
 #include "contain.h"
 #include "ether.h"
 #include "print.h"
 #include "raw.h"
 #include "sk.h"
 #include "transport_private.h"
+#include "util.h"
 
 struct raw {
        struct transport t;
@@ -147,10 +149,9 @@ static int raw_close(struct transport *t, struct fdarray 
*fda)
        return 0;
 }
 
-unsigned char ptp_dst_mac[MAC_LEN] = { PTP_DST_MAC };
 unsigned char p2p_dst_mac[MAC_LEN] = { P2P_DST_MAC };
 
-static int open_socket(const char *name, int event)
+static int open_socket(const char *name, int event, unsigned char *ptp_dst_mac)
 {
        struct sockaddr_ll addr;
        int fd, index;
@@ -202,19 +203,26 @@ static int raw_open(struct transport *t, const char *name,
                    struct fdarray *fda, enum timestamp_type ts_type)
 {
        struct raw *raw = container_of(t, struct raw, t);
+       unsigned char ptp_dst_mac[MAC_LEN];
        int efd, gfd;
+       char *str;
 
+       str = config_get_string(t->cfg, name, "ptp_dst_mac");
+       if (str2mac(str, ptp_dst_mac)) {
+               pr_err("invalid ptp_dst_mac %s", str);
+               return -1;
+       }
        mac_to_addr(&raw->ptp_addr, ptp_dst_mac);
        mac_to_addr(&raw->p2p_addr, p2p_dst_mac);
 
        if (sk_interface_macaddr(name, &raw->src_addr))
                goto no_mac;
 
-       efd = open_socket(name, 1);
+       efd = open_socket(name, 1, ptp_dst_mac);
        if (efd < 0)
                goto no_event;
 
-       gfd = open_socket(name, 0);
+       gfd = open_socket(name, 0, ptp_dst_mac);
        if (gfd < 0)
                goto no_general;
 
diff --git a/raw.h b/raw.h
index c4747dd..ada1e84 100644
--- a/raw.h
+++ b/raw.h
@@ -24,11 +24,6 @@
 #include "transport.h"
 
 /**
- * The MAC address to use for non-peer messages.
- */
-extern unsigned char ptp_dst_mac[];
-
-/**
  * The MAC address to use for peer messages.
  */
 extern unsigned char p2p_dst_mac[];
-- 
2.1.4


------------------------------------------------------------------------------
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to