ptp4l: build the interfaces from cmdline after parsing options
this patch causes interfaces to be built after the options have finished scanning rather than during option parsing. This removes the ability to specify on the command line separate transport, or dm modes for each port. Instead this functionality will be added in a follow-on patch via the configuration file Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>master
parent
a7db3a1c2b
commit
490c3e22a7
23
ptp4l.c
23
ptp4l.c
|
@ -110,9 +110,10 @@ static void usage(char *progname)
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *config = NULL, *req_phc = NULL, *progname;
|
char *config = NULL, *req_phc = NULL, *progname;
|
||||||
int c;
|
int c, i;
|
||||||
struct interface *iface = cfg_settings.iface;
|
struct interface *iface = cfg_settings.iface;
|
||||||
int *nports = &cfg_settings.nports;
|
char *ports[MAX_PORTS];
|
||||||
|
int nports = 0;
|
||||||
int *cfg_ignore = &cfg_settings.cfg_ignore;
|
int *cfg_ignore = &cfg_settings.cfg_ignore;
|
||||||
enum delay_mechanism *dm = &cfg_settings.dm;
|
enum delay_mechanism *dm = &cfg_settings.dm;
|
||||||
enum transport_type *transport = &cfg_settings.transport;
|
enum transport_type *transport = &cfg_settings.transport;
|
||||||
|
@ -166,10 +167,8 @@ int main(int argc, char *argv[])
|
||||||
config = optarg;
|
config = optarg;
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
if (config_create_interface(optarg, &cfg_settings) < 0) {
|
ports[nports] = optarg;
|
||||||
fprintf(stderr, "too many interfaces\n");
|
nports++;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
req_phc = optarg;
|
req_phc = optarg;
|
||||||
|
@ -208,7 +207,14 @@ int main(int argc, char *argv[])
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!*nports) {
|
for (i = 0; i < nports; i++) {
|
||||||
|
if (config_create_interface(ports[i], &cfg_settings) < 0) {
|
||||||
|
fprintf(stderr, "too many interfaces\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cfg_settings.nports) {
|
||||||
fprintf(stderr, "no interface specified\n");
|
fprintf(stderr, "no interface specified\n");
|
||||||
usage(progname);
|
usage(progname);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -241,7 +247,8 @@ int main(int argc, char *argv[])
|
||||||
print_set_syslog(cfg_settings.use_syslog);
|
print_set_syslog(cfg_settings.use_syslog);
|
||||||
print_set_level(cfg_settings.print_level);
|
print_set_level(cfg_settings.print_level);
|
||||||
|
|
||||||
clock = clock_create(phc_index, iface, *nports, *timestamping, ds);
|
clock = clock_create(phc_index, iface, cfg_settings.nports,
|
||||||
|
*timestamping, ds);
|
||||||
if (!clock) {
|
if (!clock) {
|
||||||
fprintf(stderr, "failed to create a clock\n");
|
fprintf(stderr, "failed to create a clock\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue