config: convert 'uds_address' to the new scheme.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2015-08-21 23:25:15 +02:00
parent 852c288ebe
commit e27b036d09
8 changed files with 14 additions and 19 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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
View File

@ -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))

View File

@ -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
View File

@ -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) {

5
uds.h
View File

@ -24,11 +24,6 @@
#include "fd.h"
#include "transport.h"
/**
* Address of the server.
*/
extern char uds_path[MAX_IFNAME_SIZE + 1];
/**
* Allocate an instance of a UDS transport.
* @return Pointer to a new transport instance on success, NULL otherwise.