/*
* The actual main function.
*/
-int
+int
sntp_main (
- int argc,
+ int argc,
char **argv
- )
+ )
{
- register int c;
- struct kod_entry *reason = NULL;
- int optct;
- /* boolean, u_int quiets gcc4 signed overflow warning */
- u_int sync_data_suc;
- struct addrinfo **bcastaddr = NULL;
- struct addrinfo **resh = NULL;
- struct addrinfo *ai;
- int resc;
- int kodc;
- int ow_ret;
- int bcast = 0;
- char *hostname;
+ int i;
+ int exitcode;
+ int optct;
+ struct event_config * evcfg;
+
+ /* Initialize logging system - sets up progname */
+ sntp_init_logging(argv[0]);
- optct = optionProcess(&sntpOptions, argc, argv);
+ if (!libevent_version_ok())
+ exit(EX_SOFTWARE);
+
+ init_lib();
+
+ optct = ntpOptionProcess(&sntpOptions, argc, argv);
argc -= optct;
- argv += optct;
+ argv += optct;
+
+ debug = DESC(DEBUG_LEVEL).optOccCt;
+ TRACE(1, ("%s\n", Version));
+
+ TRACE(2, ("init_lib() done, %s%s\n",
+ (ipv4_works)
+ ? "ipv4_works "
+ : "",
+ (ipv6_works)
+ ? "ipv6_works "
+ : ""));
+ ntpver = OPT_VALUE_NTPVERSION;
+ steplimit = OPT_VALUE_STEPLIMIT / 1e3;
+ gap.tv_usec = max(0, OPT_VALUE_GAP * 1000);
+ gap.tv_usec = min(gap.tv_usec, 999999);
- if (HAVE_OPT(FILELOG))
- open_logfile(OPT_ARG(FILELOG));
- /* Initialize logging system */
- init_logging();
+ if (HAVE_OPT(LOGFILE))
+ open_logfile(OPT_ARG(LOGFILE));
- msyslog(LOG_NOTICE, "Started sntp");
+ if (0 == argc && !HAVE_OPT(BROADCAST) && !HAVE_OPT(CONCURRENT)) {
+ printf("%s: Must supply at least one of -b hostname, -c hostname, or hostname.\n",
+ progname);
+ exit(EX_USAGE);
+ }
+
+
+ /*
+ ** Eventually, we probably want:
+ ** - separate bcst and ucst timeouts
+ ** - multiple --timeout values in the commandline
+ */
+ bcst_timeout_tv.tv_sec = OPT_VALUE_BCTIMEOUT;
+ bcst_timeout_tv.tv_usec = 0;
+
+ ucst_timeout = OPT_VALUE_UCTIMEOUT;
/* IPv6 available? */
if (isc_net_probeipv6() != ISC_R_SUCCESS) {