From: Frank Kardel Date: Tue, 6 Jun 2006 06:41:29 +0000 (+0000) Subject: Merge bk://www.ntp.org/home/bk/ntp-dev X-Git-Tag: NTP_4_2_3P2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e3f4a7a29be893a7c0be4b11cfb486e1f06fb491;p=thirdparty%2Fntp.git Merge bk://www.ntp.org/home/bk/ntp-dev into pogo.udel.edu:/pogo/users/kardel/dynamic-if/ntp-dev bk: 44852399UMSBYF7rvmvt4i4d_bezug --- e3f4a7a29be893a7c0be4b11cfb486e1f06fb491 diff --cc ntpd/cmd_args.c index 0c30f32dd,e395a4d95..c93cd9d76 --- a/ntpd/cmd_args.c +++ b/ntpd/cmd_args.c @@@ -20,10 -17,12 +20,9 @@@ * Definitions of things either imported from or exported to outside */ extern char const *progname; +extern const char *specific_interface; extern int default_ai_family; -int listen_to_virtual_ips = 1; -char *specific_interface = NULL; /* interface name or IP address to bind to */ - -static const char *ntp_options = "46aAbB:c:C:dD:f:gHi:k:l:L:nNO:p:P:qr:s:S:t:T:W:U:u:v:V:xY:Z:-:"; - #ifdef HAVE_NETINFO extern int check_netinfo; #endif @@@ -240,132 -272,165 +239,145 @@@ getCmdOpts #else errflg++; #endif - case 'k': - getauthkeys(ntp_optarg); - break; + } - case 'L': /* already done at pre-scan */ - case 'l': /* already done at pre-scan */ - break; + if (HAVE_OPT( KEYFILE )) + getauthkeys(OPT_ARG( KEYFILE )); - case 'n': /* already done at pre-scan */ - break; + if (HAVE_OPT( PIDFILE )) + stats_config(STATS_PID_FILE, OPT_ARG( PIDFILE )); - case 'N': /* already done at pre-scan */ - break; + if (HAVE_OPT( QUIT )) + mode_ntpdate = TRUE; - case 'p': - stats_config(STATS_PID_FILE, ntp_optarg); - break; + if (HAVE_OPT( PROPAGATIONDELAY )) + do { + double tmp; + const char *my_ntp_optarg = OPT_ARG( PROPAGATIONDELAY ); - case 'P': -#if defined(HAVE_SCHED_SETSCHEDULER) - config_priority = (int)atol(ntp_optarg); - config_priority_override = 1; -#else - errflg++; -#endif - break; + if (sscanf(my_ntp_optarg, "%lf", &tmp) != 1) { + msyslog(LOG_ERR, + "command line broadcast delay value %s undecodable", + my_ntp_optarg); + } else { + proto_config(PROTO_BROADDELAY, 0, tmp, NULL); + } + } while (0); - case 'q': - mode_ntpdate = TRUE; - break; + if (HAVE_OPT( STATSDIR )) + stats_config(STATS_STATSDIR, OPT_ARG( STATSDIR )); - case 'r': - do { - double tmp; + if (HAVE_OPT( TRUSTEDKEY )) { + int ct = STACKCT_OPT( TRUSTEDKEY ); + const char** pp = STACKLST_OPT( TRUSTEDKEY ); - if (sscanf(ntp_optarg, "%lf", &tmp) != 1) { - msyslog(LOG_ERR, - "command line broadcast delay value %s undecodable", - ntp_optarg); - } else { - proto_config(PROTO_BROADDELAY, 0, tmp, NULL); - } - } while (0); - break; - - case 'u': -#ifdef HAVE_DROPROOT - droproot = 1; - if( ! ntp_optarg ) { - errflg++; + do { + u_long tkey; + const char* p = *pp++; + + tkey = (int)atol(p); + if (tkey <= 0 || tkey > NTP_MAXKEY) { + msyslog(LOG_ERR, + "command line trusted key %s is invalid", + p); } else { - user = malloc(strlen(ntp_optarg) + 1); - if (user == NULL) { - errflg++; - } else { - (void)strncpy(user, ntp_optarg, strlen(ntp_optarg) + 1); - group = rindex(user, ':'); - if (group) - *group++ = '\0'; /* get rid of the ':' */ - } + authtrust(tkey, 1); } -#else + } while (--ct > 0); + } + + if (HAVE_OPT( USER )) { +#ifdef HAVE_DROPROOT + char *ntp_optarg = OPT_ARG( USER ); + + droproot = 1; + user = malloc(strlen(ntp_optarg) + 1); + if (user == NULL) { errflg++; + } else { + (void)strncpy(user, ntp_optarg, strlen(ntp_optarg) + 1); + group = rindex(user, ':'); + if (group) + *group++ = '\0'; /* get rid of the ':' */ + } +#else + errflg++; #endif - break; - case 's': - stats_config(STATS_STATSDIR, ntp_optarg); - break; - - case 't': - do { - u_long tkey; - - tkey = (int)atol(ntp_optarg); - if (tkey <= 0 || tkey > NTP_MAXKEY) { - msyslog(LOG_ERR, - "command line trusted key %s is invalid", - ntp_optarg); - } else { - authtrust(tkey, 1); - } - } while (0); - break; + } - case 'U': - do - { - long val; - extern int interface_interval; - - if ((1 == sscanf(ntp_optarg, "%ld", &val)) && ((val >= 60) || (val == 0))) - interface_interval = val; - else - { - msyslog(LOG_ERR, - "command line interface update interval %s must be 0 or longer than 60 seconds", - ntp_optarg); - errflg++; - } - } - while(0); - break; + if (HAVE_OPT( VAR )) { + int ct = STACKCT_OPT( VAR ); + const char** pp = STACKLST_OPT( VAR ); - case 'v': - case 'V': - set_sys_var(ntp_optarg, strlen(ntp_optarg)+1, - (u_short) (RW | ((c == 'V') ? DEF : 0))); - break; + do { + const char* my_ntp_optarg = *pp++; - case 'x': - clock_max = 600; - break; + set_sys_var(my_ntp_optarg, strlen(my_ntp_optarg)+1, + (u_short) (RW)); + } while (--ct > 0); + } + + if (HAVE_OPT( DVAR )) { + int ct = STACKCT_OPT( DVAR ); + const char** pp = STACKLST_OPT( DVAR ); + + do { + const char* my_ntp_optarg = *pp++; + + set_sys_var(my_ntp_optarg, strlen(my_ntp_optarg)+1, + (u_short) (RW | DEF)); + } while (--ct > 0); + } + + if (HAVE_OPT( SLEW )) + clock_max = 600; + ++ if (HAVE_OPT( UPDATEINTERVAL ) { ++ long val; ++ extern int interface_interval; ++ ++ if ((1 == sscanf(OPT_ARG( UPDATEINTERVAL ), "%ld", &val)) && ((val >= 60) || (val == 0))) ++ interface_interval = val; ++ else { ++ msyslog(LOG_ERR, ++ "command line interface update interval %s must be 0 or longer than 60 seconds", ++ ntp_optarg); ++ errflg++; ++ } ++ } #ifdef SIM - case 'B': - sscanf(ntp_optarg, "%lf", &ntp_node.bdly); - break; + if (HAVE_OPT( SIMBROADCASTDELAY )) + sscanf(OPT_ARG( SIMBROADCASTDELAY ), "%lf", &ntp_node.bdly); - case 'C': - sscanf(ntp_optarg, "%lf", &ntp_node.snse); - break; + if (HAVE_OPT( PHASENOISE )) + sscanf(OPT_ARG( PHASENOISE ), "%lf", &ntp_node.snse); - case 'H': - sscanf(ntp_optarg, "%lf", &ntp_node.slew); - break; + if (HAVE_OPT( SIMSLEW )) + sscanf(OPT_ARG( SIMSLEW ), "%lf", &ntp_node.slew); - case 'O': - sscanf(ntp_optarg, "%lf", &ntp_node.clk_time); - break; + if (HAVE_OPT( SERVERTIME )) + sscanf(OPT_ARG( SERVERTIME ), "%lf", &ntp_node.clk_time); - case 'S': - sscanf(ntp_optarg, "%lf", &ntp_node.sim_time); - break; + if (HAVE_OPT( ENDSIMTIME )) + sscanf(OPT_ARG( ENDSIMTIME ), "%lf", &ntp_node.sim_time); - case 'T': - sscanf(ntp_optarg, "%lf", &ntp_node.ferr); - break; + if (HAVE_OPT( FREQERR )) + sscanf(OPT_ARG( FREQERR ), "%lf", &ntp_node.ferr); - case 'W': - sscanf(ntp_optarg, "%lf", &ntp_node.fnse); - break; + if (HAVE_OPT( WALKNOISE )) + sscanf(OPT_ARG( WALKNOISE ), "%lf", &ntp_node.fnse); - case 'Y': - sscanf(ntp_optarg, "%lf", &ntp_node.ndly); - break; + if (HAVE_OPT( NDELAY )) + sscanf(OPT_ARG( NDELAY ), "%lf", &ntp_node.ndly); - case 'Z': - sscanf(ntp_optarg, "%lf", &ntp_node.pdly); - break; + if (HAVE_OPT( PDELAY )) + sscanf(OPT_ARG( PDELAY ), "%lf", &ntp_node.pdly); #endif /* SIM */ - default: - errflg++; - break; - } - } - if (errflg || ntp_optind != argc) { - ntpd_usage(); - exit(2); + if (errflg || argc) { + printf("argc is <%d>\n", argc); + optionUsage(&myOptions, 2); } return; }