config: convert 'productDescription' to the new scheme.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-22 18:14:46 +02:00
parent efa91dda77
commit 4e23ac1b21
2 changed files with 13 additions and 13 deletions

View File

@ -213,6 +213,7 @@ struct config_item config_tab[] = {
GLOB_ITEM_DBL("pi_proportional_scale", 0.0, 0.0, DBL_MAX),
GLOB_ITEM_INT("priority1", 128, 0, UINT8_MAX),
GLOB_ITEM_INT("priority2", 128, 0, UINT8_MAX),
GLOB_ITEM_STR("productDescription", ";;"),
PORT_ITEM_STR("ptp_dst_mac", "01:1B:19:00:00:00"),
PORT_ITEM_STR("p2p_dst_mac", "01:80:C2:00:00:0E"),
GLOB_ITEM_INT("sanity_freq_limit", 200000000, 0, INT_MAX),
@ -458,13 +459,7 @@ static enum parser_result parse_global_setting(const char *option,
if (r != NOT_PARSED)
return r;
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 (!strcmp(option, "revisionData")) {
if (count_char(value, ';') != 2)
return BAD_VALUE;
if (static_ptp_text_set(&cfg->dds.clock_desc.revisionData, value) != 0)

17
ptp4l.c
View File

@ -44,11 +44,6 @@ static struct config cfg_settings = {
.dds = {
.clock_desc = {
.productDescription = {
.max_symbols = 64,
.text = ";;",
.length = 2,
},
.revisionData = {
.max_symbols = 32,
.text = ";;",
@ -94,11 +89,12 @@ static void usage(char *progname)
int main(int argc, char *argv[])
{
char *config = NULL, *req_phc = NULL, *progname;
char *config = NULL, *req_phc = NULL, *progname, *tmp;
int c;
struct interface *iface;
struct clock *clock;
struct config *cfg = &cfg_settings;
struct default_ds *dds = &cfg_settings.dds;
struct defaultDS *ds = &cfg_settings.dds.dds;
int phc_index = -1, print_level, required_modes = 0;
@ -213,6 +209,15 @@ int main(int argc, char *argv[])
ds->clockQuality.offsetScaledLogVariance =
config_get_int(cfg, NULL, "offsetScaledLogVariance");
dds->clock_desc.productDescription.max_symbols = 64;
tmp = config_get_string(cfg, NULL, "productDescription");
if (count_char(tmp, ';') != 2 ||
static_ptp_text_set(&dds->clock_desc.productDescription, tmp)) {
fprintf(stderr, "invalid productDescription '%s'.\n", tmp);
return -1;
}
ds->domainNumber = config_get_int(cfg, NULL, "domainNumber");
if (config_get_int(cfg, NULL, "slaveOnly")) {