Because of the implementation of the UDS module, it is not possible
for a process to act as both a PTP management client (PMC) and server.
Going forward, one ptp4l instance will need to subscribe to another
using the PMC methods.  Pave the way by allowing the interface to
include an optional remote UDS address.

Signed-off-by: Richard Cochran <richardcoch...@gmail.com>
---
 clock.c      |  4 ++--
 config.c     |  2 +-
 interface.c  | 12 ++++++++++--
 interface.h  | 10 +++++++++-
 pmc_common.c |  2 +-
 5 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/clock.c b/clock.c
index b66dda5..6f7722c 100644
--- a/clock.c
+++ b/clock.c
@@ -1242,7 +1242,7 @@ struct clock *clock_create(enum clock_type type, struct 
config *config,
        /* Configure the UDS. */
 
        uds_ifname = config_get_string(config, NULL, "uds_address");
-       c->uds_rw_if = interface_create(uds_ifname);
+       c->uds_rw_if = interface_create(uds_ifname, NULL);
        if (config_set_section_int(config, interface_name(c->uds_rw_if),
                                   "announceReceiptTimeout", 0)) {
                return NULL;
@@ -1261,7 +1261,7 @@ struct clock *clock_create(enum clock_type type, struct 
config *config,
        }
 
        uds_ifname = config_get_string(config, NULL, "uds_ro_address");
-       c->uds_ro_if = interface_create(uds_ifname);
+       c->uds_ro_if = interface_create(uds_ifname, NULL);
        if (config_set_section_int(config, interface_name(c->uds_ro_if),
                                   "announceReceiptTimeout", 0)) {
                return NULL;
diff --git a/config.c b/config.c
index ad675c8..fe65b76 100644
--- a/config.c
+++ b/config.c
@@ -896,7 +896,7 @@ struct interface *config_create_interface(const char *name, 
struct config *cfg)
                        return iface;
        }
 
-       iface = interface_create(name);
+       iface = interface_create(name, NULL);
        if (!iface) {
                fprintf(stderr, "cannot allocate memory for a port\n");
                return NULL;
diff --git a/interface.c b/interface.c
index 9a83c36..e088e07 100644
--- a/interface.c
+++ b/interface.c
@@ -12,12 +12,13 @@ struct interface {
        STAILQ_ENTRY(interface) list;
        char name[MAX_IFNAME_SIZE + 1];
        char ts_label[MAX_IFNAME_SIZE + 1];
+       char remote[MAX_IFNAME_SIZE + 1];
        struct sk_ts_info ts_info;
        struct sk_if_info if_info;
        int vclock;
 };
 
-struct interface *interface_create(const char *name)
+struct interface *interface_create(const char *name, const char *remote)
 {
        struct interface *iface;
 
@@ -27,6 +28,9 @@ struct interface *interface_create(const char *name)
        }
        strncpy(iface->name, name, MAX_IFNAME_SIZE);
        strncpy(iface->ts_label, name, MAX_IFNAME_SIZE);
+       if (remote) {
+               strncpy(iface->remote, remote, MAX_IFNAME_SIZE);
+       }
        iface->vclock = -1;
 
        return iface;
@@ -57,7 +61,6 @@ bool interface_ifinfo_valid(struct interface *iface)
        return iface->if_info.valid ? true : false;
 }
 
-
 const char *interface_name(struct interface *iface)
 {
        return iface->name;
@@ -68,6 +71,11 @@ int interface_phc_index(struct interface *iface)
        return iface->ts_info.phc_index;
 }
 
+const char *interface_remote(struct interface *iface)
+{
+       return iface->remote;
+}
+
 void interface_set_label(struct interface *iface, const char *label)
 {
        strncpy(iface->ts_label, label, MAX_IFNAME_SIZE);
diff --git a/interface.h b/interface.h
index 0873bba..b56adc5 100644
--- a/interface.h
+++ b/interface.h
@@ -23,9 +23,10 @@ struct interface;
 /**
  * Creates an instance of an interface.
  * @param name  The device which indentifies this interface.
+ * @param remote  For UDS interfaces, the address of the remote server, 
possibly NULL.
  * @return      A pointer to an interface instance on success, NULL otherwise.
  */
-struct interface *interface_create(const char *name);
+struct interface *interface_create(const char *name, const char *remote);
 
 /**
  * Destroys an instance of an interface.
@@ -70,6 +71,13 @@ const char *interface_name(struct interface *iface);
  */
 int interface_phc_index(struct interface *iface);
 
+/**
+ * Obtains the remote address from a UDS interface.
+ * @param iface  The interface of interest.
+ * @return       The device name of the network interface.
+ */
+const char *interface_remote(struct interface *iface);
+
 /**
  * Set the time stamping label of a given interface.
  * @param iface  The interface of interest.
diff --git a/pmc_common.c b/pmc_common.c
index 62e34a6..5092c09 100644
--- a/pmc_common.c
+++ b/pmc_common.c
@@ -524,7 +524,7 @@ struct pmc *pmc_create(struct config *cfg, enum 
transport_type transport_type,
                goto failed;
        }
 
-       pmc->iface = interface_create(iface_name);
+       pmc->iface = interface_create(iface_name, NULL);
        if (!pmc->iface) {
                pr_err("failed to create interface");
                goto failed;
-- 
2.39.2



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

Reply via email to