From 9fe2ffd2efbbc35dcb185af6a0f21be9261da0e4 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 29 Sep 2013 20:57:00 +0200 Subject: [PATCH] Introduce a configuration file option for the server's UDS address. Signed-off-by: Richard Cochran --- config.c | 5 +++++ config.h | 1 + default.cfg | 1 + gPTP.cfg | 1 + ptp4l.8 | 6 +++++- ptp4l.c | 2 ++ 6 files changed, 15 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 8cae57f..fe4c0f3 100644 --- a/config.c +++ b/config.c @@ -393,6 +393,11 @@ static enum parser_result parse_global_setting(const char *option, return r; *cfg->udp6_scope = uval; + } else 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, "logging_level")) { r = get_ranged_int(value, &val, PRINT_LEVEL_MIN, PRINT_LEVEL_MAX); diff --git a/config.h b/config.h index 94704a4..4a2cbaa 100644 --- a/config.h +++ b/config.h @@ -89,6 +89,7 @@ struct config { unsigned char *ptp_dst_mac; unsigned char *p2p_dst_mac; unsigned char *udp6_scope; + char *uds_address; int print_level; int use_syslog; diff --git a/default.cfg b/default.cfg index 72665a6..0a42a92 100644 --- a/default.cfg +++ b/default.cfg @@ -59,6 +59,7 @@ transportSpecific 0x0 ptp_dst_mac 01:1B:19:00:00:00 p2p_dst_mac 01:80:C2:00:00:0E udp6_scope 0x0E +uds_address /var/run/ptp4l # # Default interface options # diff --git a/gPTP.cfg b/gPTP.cfg index 30719b6..9c26ec5 100644 --- a/gPTP.cfg +++ b/gPTP.cfg @@ -57,6 +57,7 @@ clock_servo pi transportSpecific 0x1 ptp_dst_mac 01:80:C2:00:00:0E p2p_dst_mac 01:80:C2:00:00:0E +uds_address /var/run/ptp4l # # Default interface options # diff --git a/ptp4l.8 b/ptp4l.8 index 493626d..221d7d1 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -1,4 +1,4 @@ -.TH PTP4l 8 "July 2013" "linuxptp" +.TH PTP4l 8 "October 2013" "linuxptp" .SH NAME ptp4l \- PTP Boundary/Ordinary Clock @@ -354,6 +354,10 @@ will be used as the second byte of the primary address. This option is only relevant with IPv6 transport. See RFC 4291. The default is 0x0E for the global scope. .TP +.B uds_address +Specifies the address of the UNIX domain socket for receiving local +management messages. The default is /var/run/ptp4l. +.TP .B logging_level The maximum logging level of messages which should be printed. The default is 6 (LOG_INFO). diff --git a/ptp4l.c b/ptp4l.c index b0d1c9c..dac303a 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -32,6 +32,7 @@ #include "sk.h" #include "transport.h" #include "udp6.h" +#include "uds.h" #include "util.h" #include "version.h" @@ -111,6 +112,7 @@ static struct config cfg_settings = { .ptp_dst_mac = ptp_dst_mac, .p2p_dst_mac = p2p_dst_mac, .udp6_scope = &udp6_scope, + .uds_address = uds_path, .print_level = LOG_INFO, .use_syslog = 1,