config: convert 'uds_address' to the new scheme.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
852c288ebe
commit
e27b036d09
3
clock.c
3
clock.c
|
@ -820,7 +820,8 @@ struct clock *clock_create(struct config *config, int phc_index,
|
|||
if (c->nports)
|
||||
clock_destroy(c);
|
||||
|
||||
snprintf(udsif->name, sizeof(udsif->name), "%s", uds_path);
|
||||
snprintf(udsif->name, sizeof(udsif->name), "%s",
|
||||
config_get_string(config, NULL, "uds_address"));
|
||||
if (config_set_section_int(config, udsif->name,
|
||||
"network_transport", TRANS_UDS)) {
|
||||
return NULL;
|
||||
|
|
8
config.c
8
config.c
|
@ -228,6 +228,7 @@ struct config_item config_tab[] = {
|
|||
GLOB_ITEM_INT("tx_timestamp_timeout", 1, 1, INT_MAX),
|
||||
PORT_ITEM_INT("udp_ttl", 1, 1, 255),
|
||||
PORT_ITEM_INT("udp6_scope", 0x0E, 0x00, 0x0F),
|
||||
GLOB_ITEM_STR("uds_address", "/var/run/ptp4l"),
|
||||
GLOB_ITEM_INT("use_syslog", 1, 0, 1),
|
||||
GLOB_ITEM_INT("verbose", 0, 0, 1),
|
||||
};
|
||||
|
@ -468,12 +469,7 @@ static enum parser_result parse_global_setting(const char *option,
|
|||
if (r != NOT_PARSED)
|
||||
return r;
|
||||
|
||||
if (!strcmp(option, "uds_address")) {
|
||||
if (strlen(value) > MAX_IFNAME_SIZE)
|
||||
return OUT_OF_RANGE;
|
||||
strncpy(cfg->uds_address, value, MAX_IFNAME_SIZE);
|
||||
|
||||
} else if (!strcmp(option, "productDescription")) {
|
||||
if (!strcmp(option, "productDescription")) {
|
||||
if (count_char(value, ';') != 2)
|
||||
return BAD_VALUE;
|
||||
if (static_ptp_text_set(&cfg->dds.clock_desc.productDescription, value) != 0)
|
||||
|
|
1
config.h
1
config.h
|
@ -47,7 +47,6 @@ struct config {
|
|||
|
||||
/* the rest are legacy fields */
|
||||
struct default_ds dds;
|
||||
char *uds_address;
|
||||
};
|
||||
|
||||
int config_read(char *name, struct config *cfg);
|
||||
|
|
|
@ -1359,7 +1359,10 @@ int main(int argc, char *argv[])
|
|||
optarg, MAX_IFNAME_SIZE);
|
||||
return -1;
|
||||
}
|
||||
strncpy(uds_path, optarg, MAX_IFNAME_SIZE);
|
||||
if (config_set_string(&phc2sys_config, "uds_address",
|
||||
optarg)) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
if (get_arg_val_i(c, optarg, &print_level,
|
||||
|
|
6
pmc.c
6
pmc.c
|
@ -782,7 +782,11 @@ int main(int argc, char *argv[])
|
|||
config_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
strncpy(uds_path, optarg, MAX_IFNAME_SIZE);
|
||||
if (config_set_string(&pmc_config, "uds_address",
|
||||
optarg)) {
|
||||
config_destroy(cfg);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
if (1 == sscanf(optarg, "%x", &c))
|
||||
|
|
2
ptp4l.c
2
ptp4l.c
|
@ -58,8 +58,6 @@ static struct config cfg_settings = {
|
|||
.manufacturerIdentity = { 0, 0, 0 },
|
||||
},
|
||||
},
|
||||
|
||||
.uds_address = uds_path,
|
||||
};
|
||||
|
||||
static void usage(char *progname)
|
||||
|
|
3
uds.c
3
uds.c
|
@ -31,8 +31,6 @@
|
|||
#include "transport_private.h"
|
||||
#include "uds.h"
|
||||
|
||||
char uds_path[MAX_IFNAME_SIZE + 1] = "/var/run/ptp4l";
|
||||
|
||||
#define UDS_FILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) /*0660*/
|
||||
|
||||
struct uds {
|
||||
|
@ -60,6 +58,7 @@ static int uds_open(struct transport *t, const char *name, struct fdarray *fda,
|
|||
int fd, err;
|
||||
struct sockaddr_un sa;
|
||||
struct uds *uds = container_of(t, struct uds, t);
|
||||
char *uds_path = config_get_string(t->cfg, NULL, "uds_address");
|
||||
|
||||
fd = socket(AF_LOCAL, SOCK_DGRAM, 0);
|
||||
if (fd < 0) {
|
||||
|
|
Loading…
Reference in New Issue