Attributes are global ones in config file which also is an in argument

Signed-off-by: Anders Selhammer <anders.selham...@est.tech>
---
 phc2sys.c    |  4 +---
 pmc.c        |  6 ++----
 pmc_common.c | 21 +++++++++++----------
 pmc_common.h |  1 -
 4 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index 0742393..083eca2 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -904,9 +904,7 @@ static int init_pmc(struct config *cfg, struct node *node)
 
        snprintf(uds_local, sizeof(uds_local), "/var/run/phc2sys.%d",
                 getpid());
-       node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0,
-                              config_get_int(cfg, NULL, "domainNumber"),
-                              config_get_int(cfg, NULL, "transportSpecific") 
<< 4, 1);
+       node->pmc = pmc_create(cfg, TRANS_UDS, uds_local, 0, 1);
        if (!node->pmc) {
                pr_err("failed to create pmc");
                return -1;
diff --git a/pmc.c b/pmc.c
index 6f23167..d7a10e5 100644
--- a/pmc.c
+++ b/pmc.c
@@ -685,7 +685,7 @@ int main(int argc, char *argv[])
        int ret = 0;
        char line[1024], *command = NULL, uds_local[MAX_IFNAME_SIZE + 1];
        enum transport_type transport_type = TRANS_UDP_IPV4;
-       UInteger8 boundary_hops = 1, domain_number = 0, transport_specific = 0;
+       UInteger8 boundary_hops = 1;
        struct ptp_message *msg;
        struct option *opts;
        struct config *cfg;
@@ -797,8 +797,6 @@ int main(int argc, char *argv[])
        }
 
        transport_type = config_get_int(cfg, NULL, "network_transport");
-       transport_specific = config_get_int(cfg, NULL, "transportSpecific") << 
4;
-       domain_number = config_get_int(cfg, NULL, "domainNumber");
 
        if (!iface_name) {
                if (transport_type == TRANS_UDS) {
@@ -818,7 +816,7 @@ int main(int argc, char *argv[])
        print_set_verbose(1);
 
        pmc = pmc_create(cfg, transport_type, iface_name, boundary_hops,
-                        domain_number, transport_specific, zero_datalen);
+                        zero_datalen);
        if (!pmc) {
                fprintf(stderr, "failed to create pmc\n");
                config_destroy(cfg);
diff --git a/pmc_common.c b/pmc_common.c
index fcb9c8e..b19f4fa 100644
--- a/pmc_common.c
+++ b/pmc_common.c
@@ -21,11 +21,11 @@
 #include <string.h>
 #include <stdlib.h>
 
+#include "pmc_common.h"
 #include "print.h"
 #include "tlv.h"
 #include "transport.h"
 #include "util.h"
-#include "pmc_common.h"
 
 /*
    Field                  Len  Type
@@ -49,13 +49,11 @@
 #define EMPTY_PTP_TEXT 2
 
 struct pmc {
+       struct config *cfg;
        UInteger16 sequence_id;
        UInteger8 boundary_hops;
-       UInteger8 domain_number;
-       UInteger8 transport_specific;
        struct PortIdentity port_identity;
        struct PortIdentity target;
-
        struct transport *transport;
        struct fdarray fdarray;
        int zero_length_gets;
@@ -63,7 +61,6 @@ struct pmc {
 
 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 interface iface;
@@ -81,12 +78,11 @@ struct pmc *pmc_create(struct config *cfg, enum 
transport_type transport_type,
                pr_err("failed to generate a clock identity");
                goto failed;
        }
+       pmc->cfg = cfg;
        pmc->port_identity.portNumber = 1;
        pmc_target_all(pmc);
 
        pmc->boundary_hops = boundary_hops;
-       pmc->domain_number = domain_number;
-       pmc->transport_specific = transport_specific;
 
        pmc->transport = transport_create(cfg, transport_type);
        if (!pmc->transport) {
@@ -124,20 +120,25 @@ void pmc_destroy(struct pmc *pmc)
 
 static struct ptp_message *pmc_message(struct pmc *pmc, uint8_t action)
 {
+       UInteger8 transportSpecific;
        struct ptp_message *msg;
        int pdulen;
 
        msg = msg_allocate();
-       if (!msg)
+       if (!msg) {
                return NULL;
+       }
+
+       transportSpecific = config_get_int(pmc->cfg, NULL, "transportSpecific");
+       transportSpecific <<= 4;
 
        pdulen = sizeof(struct management_msg);
        msg->hwts.type = TS_SOFTWARE;
 
-       msg->header.tsmt               = MANAGEMENT | pmc->transport_specific;
+       msg->header.tsmt               = MANAGEMENT | transportSpecific;
        msg->header.ver                = PTP_VERSION;
        msg->header.messageLength      = pdulen;
-       msg->header.domainNumber       = pmc->domain_number;
+       msg->header.domainNumber       = config_get_int(pmc->cfg, NULL, 
"domainNumber");
        msg->header.sourcePortIdentity = pmc->port_identity;
        msg->header.sequenceId         = pmc->sequence_id++;
        msg->header.control            = CTL_MANAGEMENT;
diff --git a/pmc_common.h b/pmc_common.h
index bb3a1f1..4fc9428 100644
--- a/pmc_common.h
+++ b/pmc_common.h
@@ -29,7 +29,6 @@ struct pmc;
 
 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);
-- 
1.8.3.1


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to