diff --git a/config.c b/config.c index 7262049..e4b9c22 100644 --- a/config.c +++ b/config.c @@ -22,6 +22,7 @@ #include "config.h" #include "ether.h" #include "print.h" +#include "util.h" enum config_section { GLOBAL_SECTION, @@ -157,6 +158,17 @@ static enum parser_result parse_port_setting(const char *option, return PARSED_OK; } +static int count_char(const char *str, char c) +{ + int num = 0; + char s; + while ((s = *(str++))) { + if (s == c) + num++; + } + return num; +} + static enum parser_result parse_global_setting(const char *option, const char *value, struct config *cfg) @@ -166,6 +178,7 @@ static enum parser_result parse_global_setting(const char *option, UInteger16 u16; UInteger8 u8; unsigned char mac[MAC_LEN]; + unsigned char oui[OUI_LEN]; struct defaultDS *dds = &cfg->dds.dds; struct port_defaults *pod = &cfg->pod; @@ -342,6 +355,29 @@ static enum parser_result parse_global_setting(const char *option, else return BAD_VALUE; + } else if (!strcmp(option, "productDescription")) { + if (count_char(value, ';') != 2) + return BAD_VALUE; + if (static_ptp_text_set(&cfg->dds.clock_desc.productDescription, value) != 0) + return BAD_VALUE; + + } else if (!strcmp(option, "revisionData")) { + if (count_char(value, ';') != 2) + return BAD_VALUE; + if (static_ptp_text_set(&cfg->dds.clock_desc.revisionData, value) != 0) + return BAD_VALUE; + + } else if (!strcmp(option, "userDescription")) { + if (static_ptp_text_set(&cfg->dds.clock_desc.userDescription, value) != 0) + return BAD_VALUE; + + } else if (!strcmp(option, "manufacturerIdentity")) { + if (OUI_LEN != sscanf(value, "%hhx:%hhx:%hhx", + &oui[0], &oui[1], &oui[2])) + return BAD_VALUE; + for (i = 0; i < OUI_LEN; i++) + cfg->dds.clock_desc.manufacturerIdentity[i] = oui[i]; + } else return NOT_PARSED; diff --git a/default.cfg b/default.cfg index d551a3b..10401ac 100644 --- a/default.cfg +++ b/default.cfg @@ -52,3 +52,9 @@ udp6_scope 0x0E network_transport UDPv4 delay_mechanism E2E time_stamping hardware +# +# Clock description +# +productDescription ;; +revisionData ;; +manufacturerIdentity 00:00:00 diff --git a/ptp4l.8 b/ptp4l.8 index 0b9f558..370b7cf 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -310,6 +310,26 @@ The default is 1 (enabled). .B time_stamping The time stamping method. The allowed values are hardware, software and legacy. The default is hardware. +.TP +.B productDescription +The product description string. Allowed values must be of the form +manufacturerName;modelNumber;instanceIdentifier and contain at most 64 +utf8 symbols. The default is ";;". +.TP +.B revisionData +The revision description string which contains the revisions for node +hardware (HW), firmware (FW), and software (SW). Allowed values are of +the form HW;FW;SW and contain at most 32 utf8 symbols. The default is +an ";;". +.TP +.B userDescription +The user description string. Allowed values are of the form +name;location and contain at most 128 utf8 symbols. The default is an +empty string. +.TP +.B manufacturerIdentity +The manufacturer id which should be an OUI owned by the manufacturer. +The default is 00:00:00. .SH SEE ALSO .BR pmc (8),