Commit 85bca8fe authored by Aurelio Colosimo's avatar Aurelio Colosimo

make pp_parse_cmdline receive a pp_globals ptr

Command line now acts globally. If multilink context (ppsi.conf defined and
cointaining more than one link), the behaviour of -g and -e flags is common
to each link. On the other way, -b flag can not be used in this case.
Signed-off-by: Aurelio Colosimo's avatarAurelio Colosimo <aurelio@aureliocolosimo.it>
parent 63df7dcf
...@@ -120,10 +120,8 @@ int main(int argc, char **argv) ...@@ -120,10 +120,8 @@ int main(int argc, char **argv)
pp_open_globals(ppg, NULL); pp_open_globals(ppg, NULL);
/* FIXME cmdline shall receive a pp_globals if (pp_parse_cmdline(ppg, argc, argv) != 0)
if (pp_parse_cmdline(ppi, argc, argv) != 0)
return -1; return -1;
*/
posix_main_loop(ppg); posix_main_loop(ppg);
return 0; /* never reached */ return 0; /* never reached */
......
...@@ -233,7 +233,7 @@ extern int pp_open_globals(struct pp_globals *ppg, ...@@ -233,7 +233,7 @@ extern int pp_open_globals(struct pp_globals *ppg,
extern int pp_close_globals(struct pp_globals *ppg); extern int pp_close_globals(struct pp_globals *ppg);
extern int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv); extern int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv);
extern int pp_parse_conf(struct pp_globals *ppg, char *conf, int len); extern int pp_parse_conf(struct pp_globals *ppg, char *conf, int len);
......
...@@ -55,7 +55,7 @@ int ppsi_main(int argc, char **argv) ...@@ -55,7 +55,7 @@ int ppsi_main(int argc, char **argv)
/* This just llocates the stuff */ /* This just llocates the stuff */
pp_open_globals(ppg, NULL); pp_open_globals(ppg, NULL);
if (pp_parse_cmdline(ppi, argc, argv) != 0) if (pp_parse_cmdline(ppg, argc, argv) != 0)
return -1; return -1;
/* The actual sockets are opened in state-initializing */ /* The actual sockets are opened in state-initializing */
......
...@@ -82,9 +82,10 @@ static void cmd_line_parse_two(char *a, int *n1, int *n2) ...@@ -82,9 +82,10 @@ static void cmd_line_parse_two(char *a, int *n1, int *n2)
a[comma] = ','; a[comma] = ',';
} }
int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv) int pp_parse_cmdline(struct pp_globals *ppg, int argc, char **argv)
{ {
int i, err = 0; int i, err = 0;
int j;
char *a; /* cmd line argument */ char *a; /* cmd line argument */
int n1, n2; /* used by cmd_line_parse_two */ int n1, n2; /* used by cmd_line_parse_two */
...@@ -111,12 +112,12 @@ int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv) ...@@ -111,12 +112,12 @@ int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv)
pp_global_flags = pp_diag_parse(a); pp_global_flags = pp_diag_parse(a);
break; break;
case 'x': case 'x':
OPTS(ppi)->no_rst_clk = 1; GOPTS(ppg)->no_rst_clk = 1;
break; break;
case 'O': case 'O':
a = argv[++i]; a = argv[++i];
OPTS(ppi)->max_rst = atoi(a); GOPTS(ppg)->max_rst = atoi(a);
if(OPTS(ppi)->max_rst < PP_NSEC_PER_SEC) { if (GOPTS(ppg)->max_rst < PP_NSEC_PER_SEC) {
pp_printf("Use -x to prevent jumps of" pp_printf("Use -x to prevent jumps of"
" more than one second\n"); " more than one second\n");
return -1; return -1;
...@@ -124,15 +125,15 @@ int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv) ...@@ -124,15 +125,15 @@ int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv)
break; break;
case 'M': case 'M':
a = argv[++i]; a = argv[++i];
OPTS(ppi)->max_dly = atoi(a); GOPTS(ppg)->max_dly = atoi(a);
if(OPTS(ppi)->max_dly < PP_NSEC_PER_SEC) { if (GOPTS(ppg)->max_dly < PP_NSEC_PER_SEC) {
pp_printf("Use -x to prevent jumps of" pp_printf("Use -x to prevent jumps of"
" more than one second\n"); " more than one second\n");
return -1; return -1;
} }
break; break;
case 't': case 't':
OPTS(ppi)->no_adjust = 1; GOPTS(ppg)->no_adjust = 1;
break; break;
case 'a': case 'a':
a = argv[++i]; a = argv[++i];
...@@ -140,71 +141,83 @@ int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv) ...@@ -140,71 +141,83 @@ int pp_parse_cmdline(struct pp_instance *ppi, int argc, char **argv)
/* no negative or zero attenuation */ /* no negative or zero attenuation */
if (n1 < 1 || n2 < 1) if (n1 < 1 || n2 < 1)
return -1; return -1;
OPTS(ppi)->ap = n1; GOPTS(ppg)->ap = n1;
OPTS(ppi)->ai = n2; GOPTS(ppg)->ai = n2;
break; break;
case 'w': case 'w':
a = argv[++i]; a = argv[++i];
OPTS(ppi)->s = atoi(a); GOPTS(ppg)->s = atoi(a);
break; break;
case 'b': case 'b':
a = argv[++i]; a = argv[++i];
ppi->iface_name = a; if (ppg->nlinks == 1)
ppg->pp_instances[0].iface_name = a;
else {
/* If ppsi.conf exists and more than one link is
* configured, it makes no sense trying to set an iface
* name */
pp_printf("Can not use -b option in multi-link conf");
return -1;
}
break; break;
case 'l': case 'l':
a = argv[++i]; a = argv[++i];
cmd_line_parse_two(a, &n1, &n2); cmd_line_parse_two(a, &n1, &n2);
OPTS(ppi)->inbound_latency.nanoseconds = n1; GOPTS(ppg)->inbound_latency.nanoseconds = n1;
OPTS(ppi)->outbound_latency.nanoseconds = n2; GOPTS(ppg)->outbound_latency.nanoseconds = n2;
break; break;
case 'i': case 'i':
a = argv[++i]; a = argv[++i];
OPTS(ppi)->domain_number = atoi(a); GOPTS(ppg)->domain_number = atoi(a);
break; break;
case 'y': case 'y':
a = argv[++i]; a = argv[++i];
OPTS(ppi)->sync_intvl = atoi(a); GOPTS(ppg)->sync_intvl = atoi(a);
break; break;
case 'n': case 'n':
a = argv[++i]; a = argv[++i];
/* Page 237 says 0 to 4 (1s .. 16s) */ /* Page 237 says 0 to 4 (1s .. 16s) */
OPTS(ppi)->announce_intvl = atoi(a); GOPTS(ppg)->announce_intvl = atoi(a);
if (OPTS(ppi)->announce_intvl < 0) if (GOPTS(ppg)->announce_intvl < 0)
OPTS(ppi)->announce_intvl = 0; GOPTS(ppg)->announce_intvl = 0;
if (OPTS(ppi)->announce_intvl > 4) if (GOPTS(ppg)->announce_intvl > 4)
OPTS(ppi)->announce_intvl = 4; GOPTS(ppg)->announce_intvl = 4;
break; break;
case 'g': case 'g':
ppi->slave_only = 1; /* Apply -g option globally, to each configured link */
for (j = 0; j < ppg->nlinks; j++)
ppg->pp_instances[j].slave_only = 1;
break; break;
case 'v': case 'v':
a = argv[++i]; a = argv[++i];
DSDEF(ppi)->clockQuality. GDSDEF(ppg)->clockQuality.
offsetScaledLogVariance = atoi(a); offsetScaledLogVariance = atoi(a);
break; break;
case 'r': case 'r':
a = argv[++i]; a = argv[++i];
DSDEF(ppi)->clockQuality.clockAccuracy = GDSDEF(ppg)->clockQuality.clockAccuracy =
atoi(a); atoi(a);
break; break;
case 's': case 's':
a = argv[++i]; a = argv[++i];
DSDEF(ppi)->clockQuality.clockClass = GDSDEF(ppg)->clockQuality.clockClass =
atoi(a); atoi(a);
break; break;
case 'p': case 'p':
a = argv[++i]; a = argv[++i];
OPTS(ppi)->prio1 = atoi(a); GOPTS(ppg)->prio1 = atoi(a);
break; break;
case 'q': case 'q':
a = argv[++i]; a = argv[++i];
OPTS(ppi)->prio2 = atoi(a); GOPTS(ppg)->prio2 = atoi(a);
break; break;
case 'h': case 'h':
/* ignored: was "OPTS(ppi)->e2e_mode = 1;" */ /* ignored: was "GOPTS(ppg)->e2e_mode = 1;" */
break; break;
case 'e': case 'e':
ppi->ethernet_mode = 1; /* Apply -e option globally, to each configured link */
for (j = 0; j < ppg->nlinks; j++)
ppg->pp_instances[j].ethernet_mode = 1;
break; break;
case 'G': case 'G':
/* gptp_mode not supported: fall through */ /* gptp_mode not supported: fall through */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment