diff --git a/config.c b/config.c index b99d156..20f6273 100644 --- a/config.c +++ b/config.c @@ -196,6 +196,7 @@ struct config_item config_tab[] = { PORT_ITEM_INT("logMinPdelayReqInterval", 0, INT8_MIN, INT8_MAX), PORT_ITEM_INT("logSyncInterval", 0, INT8_MIN, INT8_MAX), GLOB_ITEM_INT("logging_level", LOG_INFO, PRINT_LEVEL_MIN, PRINT_LEVEL_MAX), + GLOB_ITEM_STR("manufacturerIdentity", "00:00:00"), GLOB_ITEM_INT("max_frequency", 900000000, 0, INT_MAX), PORT_ITEM_INT("min_neighbor_prop_delay", -20000000, INT_MIN, -1), PORT_ITEM_INT("neighborPropDelayThresh", 20000000, 0, INT_MAX), @@ -453,25 +454,13 @@ static enum parser_result parse_global_setting(const char *option, const char *value, struct config *cfg) { - int i; - unsigned char oui[OUI_LEN]; enum parser_result r; r = parse_fault_interval(cfg, NULL, option, value); if (r != NOT_PARSED) return r; - 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 parse_item(cfg, NULL, option, value); - - return PARSED_OK; + return parse_item(cfg, NULL, option, value); } static enum parser_result parse_setting_line(char *line, diff --git a/ptp4l.c b/ptp4l.c index d4d440b..7fe2144 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -41,12 +41,6 @@ int assume_two_step = 0; static struct config cfg_settings = { .interfaces = STAILQ_HEAD_INITIALIZER(cfg_settings.interfaces), - - .dds = { - .clock_desc = { - .manufacturerIdentity = { 0, 0, 0 }, - }, - }, }; static void usage(char *progname) @@ -91,6 +85,7 @@ int main(int argc, char *argv[]) struct default_ds *dds = &cfg_settings.dds; struct defaultDS *ds = &cfg_settings.dds.dds; int phc_index = -1, print_level, required_modes = 0; + unsigned char oui[OUI_LEN]; if (handle_term_signals()) return -1; @@ -224,6 +219,12 @@ int main(int argc, char *argv[]) fprintf(stderr, "invalid userDescription '%s'.\n", tmp); return -1; } + tmp = config_get_string(cfg, NULL, "manufacturerIdentity"); + if (OUI_LEN != sscanf(tmp, "%hhx:%hhx:%hhx", &oui[0], &oui[1], &oui[2])) { + fprintf(stderr, "invalid manufacturerIdentity '%s'.\n", tmp); + return -1; + } + memcpy(dds->clock_desc.manufacturerIdentity, oui, OUI_LEN); ds->domainNumber = config_get_int(cfg, NULL, "domainNumber");