In the near future, the transports will need to consult the configuration
database in order to obtain various options.  This patch also introduces
the idea of a configuration file into the phc2sys and pmc programs.

Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 phc2sys.c    | 10 ++++++----
 pmc.c        |  3 ++-
 pmc_common.c |  7 ++++---
 pmc_common.h |  8 +++++---
 4 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 9ff5bf9..5ba99c3 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -119,6 +119,8 @@ struct node {
        struct clock *master;
 };
 
+static struct config phc2sys_config;
+
 static int update_pmc(struct node *node, int subscribe);
 static int clock_handle_leap(struct node *node, struct clock *clock,
                             int64_t offset, uint64_t ts);
@@ -777,13 +779,13 @@ static void send_subscription(struct node *node)
        pmc_send_set_action(node->pmc, TLV_SUBSCRIBE_EVENTS_NP, &sen, 
sizeof(sen));
 }
 
-static int init_pmc(struct node *node, int domain_number)
+static int init_pmc(struct config *cfg, struct node *node, int domain_number)
 {
        char uds_local[MAX_IFNAME_SIZE + 1];
 
        snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
                 getpid());
-       node->pmc = pmc_create(TRANS_UDS, uds_local, 0, domain_number, 0, 1);
+       node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, domain_number, 0, 
1);
        if (!node->pmc) {
                pr_err("failed to create pmc");
                return -1;
@@ -1395,7 +1397,7 @@ int main(int argc, char *argv[])
        print_set_level(print_level);
 
        if (autocfg) {
-               if (init_pmc(&node, domain_number))
+               if (init_pmc(&phc2sys_config, &node, domain_number))
                        return -1;
                if (auto_init_ports(&node, rt) < 0)
                        return -1;
@@ -1431,7 +1433,7 @@ int main(int argc, char *argv[])
        r = -1;
 
        if (wait_sync) {
-               if (init_pmc(&node, domain_number))
+               if (init_pmc(&phc2sys_config, &node, domain_number))
                        goto end;
 
                while (is_running()) {
diff --git a/pmc.c b/pmc.c
index 0774f88..1fe8183 100644
--- a/pmc.c
+++ b/pmc.c
@@ -42,6 +42,7 @@
 #define P41 ((double)(1ULL << 41))
 
 static struct pmc *pmc;
+static struct config pmc_config;
 
 static void do_get_action(int action, int index, char *str);
 static void do_set_action(int action, int index, char *str);
@@ -816,7 +817,7 @@ int main(int argc, char *argv[])
        print_set_syslog(1);
        print_set_verbose(1);
 
-       pmc = pmc_create(transport_type, iface_name, boundary_hops,
+       pmc = pmc_create(&pmc_config, transport_type, iface_name, boundary_hops,
                         domain_number, transport_specific, zero_datalen);
        if (!pmc) {
                fprintf(stderr, "failed to create pmc\n");
diff --git a/pmc_common.c b/pmc_common.c
index afd6e5f..0a365f5 100644
--- a/pmc_common.c
+++ b/pmc_common.c
@@ -61,9 +61,10 @@ struct pmc {
        int zero_length_gets;
 };
 
-struct pmc *pmc_create(enum transport_type transport_type, const char 
*iface_name,
-                      UInteger8 boundary_hops, UInteger8 domain_number,
-                      UInteger8 transport_specific, int zero_datalen)
+struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type,
+                      const char *iface_name, UInteger8 boundary_hops,
+                      UInteger8 domain_number, UInteger8 transport_specific,
+                      int zero_datalen)
 {
        struct pmc *pmc;
 
diff --git a/pmc_common.h b/pmc_common.h
index 9adb9d1..bb3a1f1 100644
--- a/pmc_common.h
+++ b/pmc_common.h
@@ -21,14 +21,16 @@
 #ifndef HAVE_PMC_COMMON_H
 #define HAVE_PMC_COMMON_H
 
+#include "config.h"
 #include "msg.h"
 #include "transport.h"
 
 struct pmc;
 
-struct pmc *pmc_create(enum transport_type transport_type, const char 
*iface_name,
-                      UInteger8 boundary_hops, UInteger8 domain_number,
-                      UInteger8 transport_specific, int zero_datalen);
+struct pmc *pmc_create(struct config *cfg, enum transport_type transport_type,
+                      const char *iface_name, UInteger8 boundary_hops,
+                      UInteger8 domain_number, UInteger8 transport_specific,
+                      int zero_datalen);
 
 void pmc_destroy(struct pmc *pmc);
 
-- 
2.1.4


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

Reply via email to