config: convert 'network_transport' to the new scheme.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-15 20:52:09 +02:00
parent 5d184839d0
commit 3d1d93bcb2
5 changed files with 26 additions and 38 deletions

View File

@ -819,7 +819,10 @@ struct clock *clock_create(struct config *config, int phc_index,
clock_destroy(c);
snprintf(udsif->name, sizeof(udsif->name), "%s", uds_path);
udsif->transport = TRANS_UDS;
if (config_set_section_int(config, udsif->name,
"network_transport", TRANS_UDS)) {
return NULL;
}
if (config_set_section_int(config, udsif->name, "delay_filter_length", 1)) {
return NULL;
}

View File

@ -110,6 +110,13 @@ struct config_item {
#define PORT_ITEM_INT(label, _default, min, max) \
CONFIG_ITEM_INT(label, 1, _default, min, max)
static struct config_enum nw_trans_enu[] = {
{ "L2", TRANS_IEEE_802_3 },
{ "UDPv4", TRANS_UDP_IPV4 },
{ "UDPv6", TRANS_UDP_IPV6 },
{ NULL, 0 },
};
struct config_item config_tab[] = {
PORT_ITEM_INT("announceReceiptTimeout", 3, 2, UINT8_MAX),
GLOB_ITEM_INT("assume_two_step", 0, 0, 1),
@ -138,6 +145,7 @@ struct config_item config_tab[] = {
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),
PORT_ITEM_ENU("network_transport", TRANS_UDP_IPV4, nw_trans_enu),
GLOB_ITEM_INT("ntpshm_segment", 0, INT_MIN, INT_MAX),
GLOB_ITEM_INT("offsetScaledLogVariance", 0xffff, 0, UINT16_MAX),
PORT_ITEM_INT("path_trace_enabled", 0, 0, 1),
@ -359,17 +367,7 @@ static enum parser_result parse_port_setting(struct config *cfg,
if (r != NOT_PARSED)
return r;
if (!strcmp(option, "network_transport")) {
if (!strcasecmp("L2", value))
iface->transport = TRANS_IEEE_802_3;
else if (!strcasecmp("UDPv4", value))
iface->transport = TRANS_UDP_IPV4;
else if (!strcasecmp("UDPv6", value))
iface->transport = TRANS_UDP_IPV6;
else
return BAD_VALUE;
} else if (!strcmp(option, "delay_mechanism")) {
if (!strcmp(option, "delay_mechanism")) {
if (!strcasecmp("Auto", value))
iface->dm = DM_AUTO;
else if (!strcasecmp("E2E", value))
@ -472,18 +470,6 @@ static enum parser_result parse_global_setting(const char *option,
return BAD_VALUE;
}
} else if (!strcmp(option, "network_transport")) {
if (!(cfg_ignore & CFG_IGNORE_TRANSPORT)) {
if (!strcasecmp("UDPv4", value))
cfg->transport = TRANS_UDP_IPV4;
else if (!strcasecmp("UDPv6", value))
cfg->transport = TRANS_UDP_IPV6;
else if (!strcasecmp("L2", value))
cfg->transport = TRANS_IEEE_802_3;
else
return BAD_VALUE;
}
} else if (!strcmp(option, "clock_servo")) {
if (!strcasecmp("pi", value))
cfg->clock_servo = CLOCK_SERVO_PI;
@ -720,7 +706,6 @@ struct interface *config_create_interface(char *name, struct config *cfg)
void config_init_interface(struct interface *iface, struct config *cfg)
{
iface->dm = cfg->dm;
iface->transport = cfg->transport;
sk_get_ts_info(iface->name, &iface->ts_info);
iface->delay_filter = cfg->dds.delay_filter;
}

View File

@ -36,14 +36,12 @@ struct interface {
STAILQ_ENTRY(interface) list;
char name[MAX_IFNAME_SIZE + 1];
enum delay_mechanism dm;
enum transport_type transport;
struct sk_ts_info ts_info;
enum tsproc_mode tsproc_mode;
enum filter_type delay_filter;
};
#define CFG_IGNORE_DM (1 << 0)
#define CFG_IGNORE_TRANSPORT (1 << 1)
#define CFG_IGNORE_TIMESTAMPING (1 << 2)
struct config {
@ -58,7 +56,6 @@ struct config {
/* the rest are legacy fields */
enum timestamp_type timestamping;
enum transport_type transport;
enum delay_mechanism dm;
struct default_ds dds;

6
port.c
View File

@ -2506,6 +2506,7 @@ struct port *port_open(int phc_index,
{
struct config *cfg = clock_config(clock);
struct port *p = malloc(sizeof(*p));
enum transport_type transport;
int i;
if (!p)
@ -2515,8 +2516,9 @@ struct port *port_open(int phc_index,
p->phc_index = phc_index;
p->jbod = config_get_int(cfg, interface->name, "boundary_clock_jbod");
transport = config_get_int(cfg, interface->name, "network_transport");
if (interface->transport == TRANS_UDS)
if (transport == TRANS_UDS)
; /* UDS cannot have a PHC. */
else if (!interface->ts_info.valid)
pr_warning("port %d: get_ts_info not supported", number);
@ -2541,7 +2543,7 @@ struct port *port_open(int phc_index,
p->rx_timestamp_offset = config_get_int(cfg, p->name, "ingressLatency");
p->tx_timestamp_offset = config_get_int(cfg, p->name, "egressLatency");
p->clock = clock;
p->trp = transport_create(cfg, interface->transport);
p->trp = transport_create(cfg, transport);
if (!p->trp)
goto err_port;
p->timestamping = timestamping;

17
ptp4l.c
View File

@ -63,7 +63,6 @@ static struct config cfg_settings = {
.timestamping = TS_HARDWARE,
.dm = DM_E2E,
.transport = TRANS_UDP_IPV4,
.clock_servo = CLOCK_SERVO_PI,
.ptp_dst_mac = ptp_dst_mac,
@ -112,7 +111,6 @@ int main(int argc, char *argv[])
struct interface *iface;
int *cfg_ignore = &cfg_settings.cfg_ignore;
enum delay_mechanism *dm = &cfg_settings.dm;
enum transport_type *transport = &cfg_settings.transport;
enum timestamp_type *timestamping = &cfg_settings.timestamping;
struct clock *clock;
struct config *cfg = &cfg_settings;
@ -144,16 +142,19 @@ int main(int argc, char *argv[])
*cfg_ignore |= CFG_IGNORE_DM;
break;
case '2':
*transport = TRANS_IEEE_802_3;
*cfg_ignore |= CFG_IGNORE_TRANSPORT;
if (config_set_int(cfg, "network_transport",
TRANS_IEEE_802_3))
return -1;
break;
case '4':
*transport = TRANS_UDP_IPV4;
*cfg_ignore |= CFG_IGNORE_TRANSPORT;
if (config_set_int(cfg, "network_transport",
TRANS_UDP_IPV4))
return -1;
break;
case '6':
*transport = TRANS_UDP_IPV6;
*cfg_ignore |= CFG_IGNORE_TRANSPORT;
if (config_set_int(cfg, "network_transport",
TRANS_UDP_IPV6))
return -1;
break;
case 'H':
*timestamping = TS_HARDWARE;