config: convert 'manufacturerIdentity' to the new scheme.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-22 20:59:56 +02:00
parent bf229e1e0f
commit e82462e295
2 changed files with 9 additions and 19 deletions

View File

@ -196,6 +196,7 @@ struct config_item config_tab[] = {
PORT_ITEM_INT("logMinPdelayReqInterval", 0, INT8_MIN, INT8_MAX), PORT_ITEM_INT("logMinPdelayReqInterval", 0, INT8_MIN, INT8_MAX),
PORT_ITEM_INT("logSyncInterval", 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_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), GLOB_ITEM_INT("max_frequency", 900000000, 0, INT_MAX),
PORT_ITEM_INT("min_neighbor_prop_delay", -20000000, INT_MIN, -1), PORT_ITEM_INT("min_neighbor_prop_delay", -20000000, INT_MIN, -1),
PORT_ITEM_INT("neighborPropDelayThresh", 20000000, 0, INT_MAX), 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, const char *value,
struct config *cfg) struct config *cfg)
{ {
int i;
unsigned char oui[OUI_LEN];
enum parser_result r; enum parser_result r;
r = parse_fault_interval(cfg, NULL, option, value); r = parse_fault_interval(cfg, NULL, option, value);
if (r != NOT_PARSED) if (r != NOT_PARSED)
return r; return r;
if (!strcmp(option, "manufacturerIdentity")) { return parse_item(cfg, NULL, option, value);
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;
} }
static enum parser_result parse_setting_line(char *line, static enum parser_result parse_setting_line(char *line,

13
ptp4l.c
View File

@ -41,12 +41,6 @@ int assume_two_step = 0;
static struct config cfg_settings = { static struct config cfg_settings = {
.interfaces = STAILQ_HEAD_INITIALIZER(cfg_settings.interfaces), .interfaces = STAILQ_HEAD_INITIALIZER(cfg_settings.interfaces),
.dds = {
.clock_desc = {
.manufacturerIdentity = { 0, 0, 0 },
},
},
}; };
static void usage(char *progname) static void usage(char *progname)
@ -91,6 +85,7 @@ int main(int argc, char *argv[])
struct default_ds *dds = &cfg_settings.dds; struct default_ds *dds = &cfg_settings.dds;
struct defaultDS *ds = &cfg_settings.dds.dds; struct defaultDS *ds = &cfg_settings.dds.dds;
int phc_index = -1, print_level, required_modes = 0; int phc_index = -1, print_level, required_modes = 0;
unsigned char oui[OUI_LEN];
if (handle_term_signals()) if (handle_term_signals())
return -1; return -1;
@ -224,6 +219,12 @@ int main(int argc, char *argv[])
fprintf(stderr, "invalid userDescription '%s'.\n", tmp); fprintf(stderr, "invalid userDescription '%s'.\n", tmp);
return -1; 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"); ds->domainNumber = config_get_int(cfg, NULL, "domainNumber");