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

diff --git a/config.c b/config.c
index c88a308..5aac1c7 100644
--- a/config.c
+++ b/config.c
@@ -214,6 +214,7 @@ struct config_item config_tab[] = {
        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"),
+       PORT_ITEM_STR("p2p_dst_mac", "01:80:C2:00:00:0E"),
        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),
@@ -460,7 +461,6 @@ static enum parser_result parse_global_setting(const char 
*option,
                                               struct config *cfg)
 {
        int i;
-       unsigned char mac[MAC_LEN];
        unsigned char oui[OUI_LEN];
        enum parser_result r;
 
@@ -468,14 +468,7 @@ static enum parser_result parse_global_setting(const char 
*option,
        if (r != NOT_PARSED)
                return r;
 
-       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;
-               for (i = 0; i < MAC_LEN; i++)
-                       cfg->p2p_dst_mac[i] = mac[i];
-
-       } else if (!strcmp(option, "uds_address")) {
+       if (!strcmp(option, "uds_address")) {
                if (strlen(value) > MAX_IFNAME_SIZE)
                        return OUT_OF_RANGE;
                strncpy(cfg->uds_address, value, MAX_IFNAME_SIZE);
diff --git a/config.h b/config.h
index 32c1ceb..827e848 100644
--- a/config.h
+++ b/config.h
@@ -47,7 +47,6 @@ struct config {
 
        /* the rest are legacy fields */
        struct default_ds dds;
-       unsigned char *p2p_dst_mac;
        char *uds_address;
 };
 
diff --git a/ether.h b/ether.h
index a07fde4..ce3d663 100644
--- a/ether.h
+++ b/ether.h
@@ -23,7 +23,6 @@
 #include <stdint.h>
 
 #define MAC_LEN 6
-#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 f76e18c..14830c5 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -189,6 +189,10 @@ The default is E2E.
 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 p2p_dst_mac
+The MAC address to which peer delay messages should be sent.
+Relevant only with L2 transport. The default is 01:80:C2:00:00:0E.
+.TP
 .B network_transport
 Select the network transport. Possible values are UDPv4, UDPv6 and L2.
 The default is UDPv4.
@@ -416,10 +420,6 @@ disabled. The default is 200000000 (20%).
 The number of the SHM segment used by ntpshm servo.
 The default is 0.
 .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.
-.TP
 .B udp6_scope
 Specifies the desired scope for the IPv6 multicast messages.  This
 will be used as the second byte of the primary address.  This option
diff --git a/ptp4l.c b/ptp4l.c
index ddb7e16..db27935 100644
--- a/ptp4l.c
+++ b/ptp4l.c
@@ -59,7 +59,6 @@ static struct config cfg_settings = {
                },
        },
 
-       .p2p_dst_mac = p2p_dst_mac,
        .uds_address = uds_path,
 };
 
diff --git a/raw.c b/raw.c
index 5cf6986..48c43b0 100644
--- a/raw.c
+++ b/raw.c
@@ -149,9 +149,8 @@ static int raw_close(struct transport *t, struct fdarray 
*fda)
        return 0;
 }
 
-unsigned char p2p_dst_mac[MAC_LEN] = { P2P_DST_MAC };
-
-static int open_socket(const char *name, int event, unsigned char *ptp_dst_mac)
+static int open_socket(const char *name, int event, unsigned char *ptp_dst_mac,
+                      unsigned char *p2p_dst_mac)
 {
        struct sockaddr_ll addr;
        int fd, index;
@@ -204,6 +203,7 @@ static int raw_open(struct transport *t, const char *name,
 {
        struct raw *raw = container_of(t, struct raw, t);
        unsigned char ptp_dst_mac[MAC_LEN];
+       unsigned char p2p_dst_mac[MAC_LEN];
        int efd, gfd;
        char *str;
 
@@ -212,17 +212,22 @@ static int raw_open(struct transport *t, const char *name,
                pr_err("invalid ptp_dst_mac %s", str);
                return -1;
        }
+       str = config_get_string(t->cfg, name, "p2p_dst_mac");
+       if (str2mac(str, p2p_dst_mac)) {
+               pr_err("invalid p2p_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, ptp_dst_mac);
+       efd = open_socket(name, 1, ptp_dst_mac, p2p_dst_mac);
        if (efd < 0)
                goto no_event;
 
-       gfd = open_socket(name, 0, ptp_dst_mac);
+       gfd = open_socket(name, 0, ptp_dst_mac, p2p_dst_mac);
        if (gfd < 0)
                goto no_general;
 
diff --git a/raw.h b/raw.h
index ada1e84..d062d41 100644
--- a/raw.h
+++ b/raw.h
@@ -24,11 +24,6 @@
 #include "transport.h"
 
 /**
- * The MAC address to use for peer messages.
- */
-extern unsigned char p2p_dst_mac[];
-
-/**
  * Allocate an instance of a raw Ethernet transport.
  * @return Pointer to a new transport instance on success, NULL otherwise.
  */
-- 
2.1.4


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

Reply via email to