From 490c3e22a725c9e5f31cb12ff488b01241f6727c Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Mon, 20 Aug 2012 10:57:17 -0700 Subject: [PATCH] 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 --- ptp4l.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ptp4l.c b/ptp4l.c index 3724999..cbb727a 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -110,9 +110,10 @@ static void usage(char *progname) int main(int argc, char *argv[]) { char *config = NULL, *req_phc = NULL, *progname; - int c; + int c, i; 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; enum delay_mechanism *dm = &cfg_settings.dm; enum transport_type *transport = &cfg_settings.transport; @@ -166,10 +167,8 @@ int main(int argc, char *argv[]) config = optarg; break; case 'i': - if (config_create_interface(optarg, &cfg_settings) < 0) { - fprintf(stderr, "too many interfaces\n"); - return -1; - } + ports[nports] = optarg; + nports++; break; case 'p': req_phc = optarg; @@ -208,7 +207,14 @@ int main(int argc, char *argv[]) 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"); usage(progname); return -1; @@ -241,7 +247,8 @@ int main(int argc, char *argv[]) print_set_syslog(cfg_settings.use_syslog); 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) { fprintf(stderr, "failed to create a clock\n"); return -1;