config: convert 'slaveOnly' and 'twoStepFlag' to the new scheme.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-15 19:16:32 +02:00
parent 6fa42d3491
commit ea574c7e4f
3 changed files with 16 additions and 28 deletions

View File

@ -126,11 +126,13 @@ struct config_item config_tab[] = {
GLOB_ITEM_DBL("pi_proportional_norm_max", 0.7, DBL_MIN, 1.0), GLOB_ITEM_DBL("pi_proportional_norm_max", 0.7, DBL_MIN, 1.0),
GLOB_ITEM_DBL("pi_proportional_scale", 0.0, 0.0, DBL_MAX), GLOB_ITEM_DBL("pi_proportional_scale", 0.0, 0.0, DBL_MAX),
GLOB_ITEM_INT("sanity_freq_limit", 200000000, 0, INT_MAX), GLOB_ITEM_INT("sanity_freq_limit", 200000000, 0, INT_MAX),
GLOB_ITEM_INT("slaveOnly", 0, 0, 1),
GLOB_ITEM_DBL("step_threshold", 0.0, 0.0, DBL_MAX), GLOB_ITEM_DBL("step_threshold", 0.0, 0.0, DBL_MAX),
GLOB_ITEM_INT("summary_interval", 0, INT_MIN, INT_MAX), GLOB_ITEM_INT("summary_interval", 0, INT_MIN, INT_MAX),
PORT_ITEM_INT("syncReceiptTimeout", 0, 0, UINT8_MAX), PORT_ITEM_INT("syncReceiptTimeout", 0, 0, UINT8_MAX),
GLOB_ITEM_INT("timeSource", INTERNAL_OSCILLATOR, 0x10, 0xfe), GLOB_ITEM_INT("timeSource", INTERNAL_OSCILLATOR, 0x10, 0xfe),
PORT_ITEM_INT("transportSpecific", 0, 0, 0x0F), PORT_ITEM_INT("transportSpecific", 0, 0, 0x0F),
GLOB_ITEM_INT("twoStepFlag", 1, 0, 1),
GLOB_ITEM_INT("tx_timestamp_timeout", 1, 1, INT_MAX), GLOB_ITEM_INT("tx_timestamp_timeout", 1, 1, INT_MAX),
PORT_ITEM_INT("udp_ttl", 1, 1, 255), PORT_ITEM_INT("udp_ttl", 1, 1, 255),
PORT_ITEM_INT("udp6_scope", 0x0E, 0x00, 0x0F), PORT_ITEM_INT("udp6_scope", 0x0E, 0x00, 0x0F),
@ -382,7 +384,7 @@ static enum parser_result parse_global_setting(const char *option,
const char *value, const char *value,
struct config *cfg) struct config *cfg)
{ {
int i, val, cfg_ignore = cfg->cfg_ignore; int i, cfg_ignore = cfg->cfg_ignore;
unsigned int uval; unsigned int uval;
unsigned char mac[MAC_LEN]; unsigned char mac[MAC_LEN];
unsigned char oui[OUI_LEN]; unsigned char oui[OUI_LEN];
@ -394,27 +396,7 @@ static enum parser_result parse_global_setting(const char *option,
if (r != NOT_PARSED) if (r != NOT_PARSED)
return r; return r;
if (!strcmp(option, "twoStepFlag")) { if (!strcmp(option, "priority1")) {
r = get_ranged_int(value, &val, 0, 1);
if (r != PARSED_OK)
return r;
if (val)
dds->flags |= DDS_TWO_STEP_FLAG;
else
dds->flags &= ~DDS_TWO_STEP_FLAG;
} else if (!strcmp(option, "slaveOnly")) {
r = get_ranged_int(value, &val, 0, 1);
if (r != PARSED_OK)
return r;
if (!(cfg_ignore & CFG_IGNORE_SLAVEONLY)) {
if (val)
dds->flags |= DDS_SLAVE_ONLY;
else
dds->flags &= ~DDS_SLAVE_ONLY;
}
} else if (!strcmp(option, "priority1")) {
r = get_ranged_uint(value, &uval, 0, UINT8_MAX); r = get_ranged_uint(value, &uval, 0, UINT8_MAX);
if (r != PARSED_OK) if (r != PARSED_OK)
return r; return r;
@ -436,7 +418,6 @@ static enum parser_result parse_global_setting(const char *option,
r = get_ranged_uint(value, &uval, 0, UINT8_MAX); r = get_ranged_uint(value, &uval, 0, UINT8_MAX);
if (r != PARSED_OK) if (r != PARSED_OK)
return r; return r;
if (!(cfg_ignore & CFG_IGNORE_SLAVEONLY))
dds->clockQuality.clockClass = uval; dds->clockQuality.clockClass = uval;
} else if (!strcmp(option, "clockAccuracy")) { } else if (!strcmp(option, "clockAccuracy")) {

View File

@ -45,7 +45,6 @@ struct interface {
#define CFG_IGNORE_DM (1 << 0) #define CFG_IGNORE_DM (1 << 0)
#define CFG_IGNORE_TRANSPORT (1 << 1) #define CFG_IGNORE_TRANSPORT (1 << 1)
#define CFG_IGNORE_TIMESTAMPING (1 << 2) #define CFG_IGNORE_TIMESTAMPING (1 << 2)
#define CFG_IGNORE_SLAVEONLY (1 << 3)
struct config { struct config {
/* configuration override */ /* configuration override */

14
ptp4l.c
View File

@ -44,7 +44,6 @@ static struct config cfg_settings = {
.dds = { .dds = {
.dds = { .dds = {
.flags = DDS_TWO_STEP_FLAG,
.priority1 = 128, .priority1 = 128,
.clockQuality.clockClass = 248, .clockQuality.clockClass = 248,
.clockQuality.clockAccuracy = 0xfe, .clockQuality.clockAccuracy = 0xfe,
@ -187,8 +186,9 @@ int main(int argc, char *argv[])
req_phc = optarg; req_phc = optarg;
break; break;
case 's': case 's':
ds->flags |= DDS_SLAVE_ONLY; if (config_set_int(cfg, "slaveOnly", 1)) {
*cfg_ignore |= CFG_IGNORE_SLAVEONLY; return -1;
}
break; break;
case 'l': case 'l':
if (get_arg_val_i(c, optarg, &print_level, if (get_arg_val_i(c, optarg, &print_level,
@ -225,6 +225,14 @@ int main(int argc, char *argv[])
sk_check_fupsync = config_get_int(cfg, NULL, "check_fup_sync"); sk_check_fupsync = config_get_int(cfg, NULL, "check_fup_sync");
sk_tx_timeout = config_get_int(cfg, NULL, "tx_timestamp_timeout"); sk_tx_timeout = config_get_int(cfg, NULL, "tx_timestamp_timeout");
if (config_get_int(cfg, NULL, "slaveOnly")) {
ds->flags |= DDS_SLAVE_ONLY;
ds->clockQuality.clockClass = 248;
}
if (config_get_int(cfg, NULL, "twoStepFlag")) {
ds->flags |= DDS_TWO_STEP_FLAG;
}
if (!config_get_int(cfg, NULL, "gmCapable") && if (!config_get_int(cfg, NULL, "gmCapable") &&
ds->flags & DDS_SLAVE_ONLY) { ds->flags & DDS_SLAVE_ONLY) {
fprintf(stderr, fprintf(stderr,