diff --git a/clock.c b/clock.c index b66dda59..6f7722cf 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 ad675c86..fe65b766 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 9a83c369..e088e079 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 0873bba5..b56adc54 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 62e34a66..5092c09b 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;