Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 clock.c   | 3 ++-
 config.c  | 8 ++------
 config.h  | 1 -
 phc2sys.c | 5 ++++-
 pmc.c     | 6 +++++-
 ptp4l.c   | 2 --
 uds.c     | 3 +--
 uds.h     | 5 -----
 8 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/clock.c b/clock.c
index 320a84c..f94960d 100644
--- a/clock.c
+++ b/clock.c
@@ -820,7 +820,8 @@ struct clock *clock_create(struct config *config, int 
phc_index,
        if (c->nports)
                clock_destroy(c);
 
-       snprintf(udsif->name, sizeof(udsif->name), "%s", uds_path);
+       snprintf(udsif->name, sizeof(udsif->name), "%s",
+                config_get_string(config, NULL, "uds_address"));
        if (config_set_section_int(config, udsif->name,
                                    "network_transport", TRANS_UDS)) {
                return NULL;
diff --git a/config.c b/config.c
index 5aac1c7..cc4e0f2 100644
--- a/config.c
+++ b/config.c
@@ -228,6 +228,7 @@ struct config_item config_tab[] = {
        GLOB_ITEM_INT("tx_timestamp_timeout", 1, 1, INT_MAX),
        PORT_ITEM_INT("udp_ttl", 1, 1, 255),
        PORT_ITEM_INT("udp6_scope", 0x0E, 0x00, 0x0F),
+       GLOB_ITEM_STR("uds_address", "/var/run/ptp4l"),
        GLOB_ITEM_INT("use_syslog", 1, 0, 1),
        GLOB_ITEM_INT("verbose", 0, 0, 1),
 };
@@ -468,12 +469,7 @@ static enum parser_result parse_global_setting(const char 
*option,
        if (r != NOT_PARSED)
                return r;
 
-       if (!strcmp(option, "uds_address")) {
-               if (strlen(value) > MAX_IFNAME_SIZE)
-                       return OUT_OF_RANGE;
-               strncpy(cfg->uds_address, value, MAX_IFNAME_SIZE);
-
-       } else if (!strcmp(option, "productDescription")) {
+       if (!strcmp(option, "productDescription")) {
                if (count_char(value, ';') != 2)
                        return BAD_VALUE;
                if 
(static_ptp_text_set(&cfg->dds.clock_desc.productDescription, value) != 0)
diff --git a/config.h b/config.h
index 827e848..9a265c0 100644
--- a/config.h
+++ b/config.h
@@ -47,7 +47,6 @@ struct config {
 
        /* the rest are legacy fields */
        struct default_ds dds;
-       char *uds_address;
 };
 
 int config_read(char *name, struct config *cfg);
diff --git a/phc2sys.c b/phc2sys.c
index 4088a91..55062b9 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -1359,7 +1359,10 @@ int main(int argc, char *argv[])
                                        optarg, MAX_IFNAME_SIZE);
                                return -1;
                        }
-                       strncpy(uds_path, optarg, MAX_IFNAME_SIZE);
+                       if (config_set_string(&phc2sys_config, "uds_address",
+                                             optarg)) {
+                               return -1;
+                       }
                        break;
                case 'l':
                        if (get_arg_val_i(c, optarg, &print_level,
diff --git a/pmc.c b/pmc.c
index b5cfd4c..f4779ef 100644
--- a/pmc.c
+++ b/pmc.c
@@ -782,7 +782,11 @@ int main(int argc, char *argv[])
                                config_destroy(cfg);
                                return -1;
                        }
-                       strncpy(uds_path, optarg, MAX_IFNAME_SIZE);
+                       if (config_set_string(&pmc_config, "uds_address",
+                                             optarg)) {
+                               config_destroy(cfg);
+                               return -1;
+                       }
                        break;
                case 't':
                        if (1 == sscanf(optarg, "%x", &c))
diff --git a/ptp4l.c b/ptp4l.c
index db27935..7cfe570 100644
--- a/ptp4l.c
+++ b/ptp4l.c
@@ -58,8 +58,6 @@ static struct config cfg_settings = {
                        .manufacturerIdentity = { 0, 0, 0 },
                },
        },
-
-       .uds_address = uds_path,
 };
 
 static void usage(char *progname)
diff --git a/uds.c b/uds.c
index 97edb97..d5e8f50 100644
--- a/uds.c
+++ b/uds.c
@@ -31,8 +31,6 @@
 #include "transport_private.h"
 #include "uds.h"
 
-char uds_path[MAX_IFNAME_SIZE + 1] = "/var/run/ptp4l";
-
 #define UDS_FILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) /*0660*/
 
 struct uds {
@@ -60,6 +58,7 @@ static int uds_open(struct transport *t, const char *name, 
struct fdarray *fda,
        int fd, err;
        struct sockaddr_un sa;
        struct uds *uds = container_of(t, struct uds, t);
+       char *uds_path = config_get_string(t->cfg, NULL, "uds_address");
 
        fd = socket(AF_LOCAL, SOCK_DGRAM, 0);
        if (fd < 0) {
diff --git a/uds.h b/uds.h
index d7f6626..54f3c5d 100644
--- a/uds.h
+++ b/uds.h
@@ -25,11 +25,6 @@
 #include "transport.h"
 
 /**
- * Address of the server.
- */
-extern char uds_path[MAX_IFNAME_SIZE + 1];
-
-/**
  * Allocate an instance of a UDS 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