From: Harlan Stenn Date: Sun, 9 Jan 2011 06:52:29 +0000 (+0000) Subject: Use the same "debug" mechanism that the rest of NTP uses X-Git-Tag: NTP_4_2_7P131~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d7ef2b0d8c84520bed3ec80d5c437a66755905b4;p=thirdparty%2Fntp.git Use the same "debug" mechanism that the rest of NTP uses bk: 4d295b2dfemY1lhIEHU5O8MhIz3EtA --- diff --git a/sntp/configure.ac b/sntp/configure.ac index 3d1137c69..46c0adf81 100644 --- a/sntp/configure.ac +++ b/sntp/configure.ac @@ -669,6 +669,22 @@ case "$isc_cv_platform_havesalen" in [struct sockaddr has sa_len?]) esac +AC_MSG_CHECKING([if we're including sntp debugging code]) +AC_ARG_ENABLE( + [debugging], + [AS_HELP_STRING( + [--enable-debugging], + [+ include sntp debugging code] + )], + [ans=$enableval], + [ans=yes] +) +case "$ans" in + yes) + AC_DEFINE([DEBUG], [1], [Enable sntp debugging code?]) +esac +AC_MSG_RESULT([$ans]) + AC_ARG_ENABLE( [ipv6], [AS_HELP_STRING( diff --git a/sntp/crypto.c b/sntp/crypto.c index 7a4623291..b427e1fab 100644 --- a/sntp/crypto.c +++ b/sntp/crypto.c @@ -99,12 +99,12 @@ auth_init( char keystring[129]; if (keyf == NULL) { - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp auth_init: Couldn't open key file %s for reading!\n", keyfile); return -1; } if (feof(keyf)) { - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp auth_init: Key file %s is empty!\n", keyfile); fclose(keyf); return -1; diff --git a/sntp/kod_management.c b/sntp/kod_management.c index 33ea031fc..e94d14895 100644 --- a/sntp/kod_management.c +++ b/sntp/kod_management.c @@ -191,7 +191,7 @@ kod_init_kod_db( return; } - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("Starting to read KoD file %s...\n", db_file); /* First let's see how many entries there are and check for right syntax */ diff --git a/sntp/main.c b/sntp/main.c index 6b5b70b98..a03a838ca 100644 --- a/sntp/main.c +++ b/sntp/main.c @@ -82,6 +82,11 @@ sntp_main ( argc -= optct; argv += optct; +#ifdef DEBUG + debug = DESC(DEBUG_LEVEL).optOccCt; + DPRINTF(1, ("%s\n", Version)); +#endif + /* Initialize logging system */ init_logging(); if (HAVE_OPT(FILELOG)) @@ -377,7 +382,7 @@ printf("dns_cb: checking <%s>\n", hostname); /* Let's try using a wildcard... */ ZERO(name); - AF(&name) = AF_INET; + AF(&name) = AF_INET6; SET_ADDR6N(&name, in6addr_any); SET_PORT(&name, 0); @@ -490,12 +495,13 @@ ntp_cb( { struct ntp_ctx *ctx = ptr; - printf("Got an event on socket %d:%s%s%s%s [%s%s] <%s>", + if (debug) + printf("Got an event on socket %d:%s%s%s%s [%s%s] <%s>\n", (int) fd, - (what&EV_TIMEOUT) ? " timeout" : "", - (what&EV_READ) ? " read" : "", - (what&EV_WRITE) ? " write" : "", - (what&EV_SIGNAL) ? " signal" : "", + (what & EV_TIMEOUT) ? " timeout" : "", + (what & EV_READ) ? " read" : "", + (what & EV_WRITE) ? " write" : "", + (what & EV_SIGNAL) ? " signal" : "", (ctx->flags & CTX_BCST) ? "BCST" : "", (ctx->flags & CTX_UCST) ? "UCST" : "", ctx->name @@ -595,7 +601,7 @@ handle_pkt ( ref = (char *)&rpkt->refid; add_entry(hostname, ref); - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp handle_pkt: Received KOD packet with code: %c%c%c%c from %s, demobilizing all connections\n", ref[0], ref[1], ref[2], ref[3], hostname); @@ -609,7 +615,7 @@ handle_pkt ( break; case 1: - if (ENABLED_OPT(NORMALVERBOSE)) { + if (debug) { getnameinfo(host->ai_addr, host->ai_addrlen, addr_buf, sizeof(addr_buf), NULL, 0, NI_NUMERICHOST); printf("sntp handle_pkt: Received %i bytes from %s\n", @@ -726,7 +732,7 @@ offset_calculation ( *offset = (t21 + t34) / 2.; delta = t21 - t34; - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp offset_calculation:\tt21: %.6f\t\t t34: %.6f\n\t\tdelta: %.6f\t offset: %.6f\n", t21, t34, delta, *offset); } diff --git a/sntp/main.h b/sntp/main.h index e6965e172..ab4135033 100644 --- a/sntp/main.h +++ b/sntp/main.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include diff --git a/sntp/networking.c b/sntp/networking.c index 0b888d936..5ae94f15f 100644 --- a/sntp/networking.c +++ b/sntp/networking.c @@ -92,7 +92,7 @@ create_socket ( { *rsock = socket(AF(dest), SOCK_DGRAM, 0); - if (-1 == *rsock && ENABLED_OPT(NORMALVERBOSE)) + if (-1 == *rsock && debug) printf("Failed to create UDP socket with family %d\n", AF(dest)); } @@ -113,7 +113,7 @@ sendpkt ( pkt_output(pkt, len, stdout); #endif - if (ENABLED_OPT(NORMALVERBOSE)) { + if (debug) { printf("sntp sendpkt: Sending packet to %s ...\n", sptoa(dest)); } @@ -125,7 +125,7 @@ sendpkt ( if (errno != EWOULDBLOCK && errno != ENOBUFS) { /* oh well */ } - } else if (ENABLED_OPT(NORMALVERBOSE)) { + } else if (debug) { printf("Packet sent.\n"); } } @@ -199,7 +199,7 @@ recv_bcst_data ( setsockopt(rsock, SOL_SOCKET, SO_REUSEADDR, &btrue, sizeof(btrue)); if (IS_IPV4(sas)) { if (bind(rsock, &sas->sa, SOCKLEN(sas)) < 0) { - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp recv_bcst_data: Couldn't bind() address %s.\n", sptoa(sas)); } @@ -212,14 +212,14 @@ recv_bcst_data ( mdevadr.imr_multiaddr.s_addr = NSRCADR(sas); mdevadr.imr_interface.s_addr = htonl(INADDR_ANY); if (mdevadr.imr_multiaddr.s_addr == -1) { - if (ENABLED_OPT(NORMALVERBOSE)) { + if (debug) { printf("sntp recv_bcst_data: %s is not a broad-/multicast address, aborting...\n", sptoa(sas)); } return BROADCAST_FAILED; } if (setsockopt(rsock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mdevadr, sizeof(mdevadr)) < 0) { - if (ENABLED_OPT(NORMALVERBOSE)) { + if (debug) { buf = ss_to_str(sas); printf("sntp recv_bcst_data: Couldn't add IP membership for %s\n", buf); free(buf); @@ -230,7 +230,7 @@ recv_bcst_data ( #ifdef ISC_PLATFORM_HAVEIPV6 else if (IS_IPV6(sas)) { if (bind(rsock, &sas->sa, SOCKLEN(sas)) < 0) { - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp recv_bcst_data: Couldn't bind() address.\n"); } #ifdef INCLUDE_IPV6_MULTICAST_SUPPORT @@ -241,7 +241,7 @@ recv_bcst_data ( memset(&mdevadr6, 0, sizeof(mdevadr6)); mdevadr6.ipv6mr_multiaddr = SOCK_ADDR6(sas); if (!IN6_IS_ADDR_MULTICAST(&mdevadr6.ipv6mr_multiaddr)) { - if (ENABLED_OPT(NORMALVERBOSE)) { + if (debug) { buf = ss_to_str(sas); printf("sntp recv_bcst_data: %s is not a broad-/multicast address, aborting...\n", buf); free(buf); @@ -250,7 +250,7 @@ recv_bcst_data ( } if (setsockopt(rsock, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mdevadr6, sizeof(mdevadr6)) < 0) { - if (ENABLED_OPT(NORMALVERBOSE)) { + if (debug) { buf = ss_to_str(sas); printf("sntp recv_bcst_data: Couldn't join group for %s\n", buf); free(buf); @@ -269,12 +269,12 @@ recv_bcst_data ( rdy_socks = select(rsock + 1, &bcst_fd, 0, 0, &timeout_tv); switch (rdy_socks) { case -1: - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) perror("sntp recv_bcst_data: select()"); return BROADCAST_FAILED; break; case 0: - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp recv_bcst_data: select() reached timeout (%u sec), aborting.\n", (unsigned)timeout_tv.tv_sec); return BROADCAST_FAILED; @@ -285,7 +285,7 @@ recv_bcst_data ( break; } if (recv_bytes == -1) { - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) perror("sntp recv_bcst_data: recvfrom:"); recv_bytes = BROADCAST_FAILED; } @@ -333,7 +333,7 @@ process_pkt ( */ if (pkt_len < LEN_PKT_NOMAC || (pkt_len & 3) != 0) { unusable: - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp %s: Funny packet length: %i. Discarding package.\n", func_name, pkt_len); return PACKET_UNUSEABLE; } @@ -381,7 +381,7 @@ unusable: break; } /* Yay! Things worked out! */ - if (ENABLED_OPT(NORMALVERBOSE)) { + if (debug) { char *hostname = ss_to_str(sas); printf("sntp %s: packet received from %s successfully authenticated using key id %i.\n", func_name, hostname, key_id); @@ -396,7 +396,7 @@ unusable: if (!is_authentic) { if (ENABLED_OPT(AUTHENTICATION)) { /* We want a authenticated packet */ - if (ENABLED_OPT(NORMALVERBOSE)) { + if (debug) { char *hostname = ss_to_str(sas); printf("sntp %s: packet received from %s is not authentic. Will discard it.\n", func_name, hostname); @@ -408,7 +408,7 @@ unusable: ** We don't know if the user wanted authentication so let's ** use it anyways */ - if (ENABLED_OPT(NORMALVERBOSE)) { + if (debug) { char *hostname = ss_to_str(sas); printf("sntp %s: packet received from %s is not authentic. Authentication not enforced.\n", @@ -419,7 +419,7 @@ unusable: /* Check for server's ntp version */ if (PKT_VERSION(rpkt->li_vn_mode) < NTP_OLDVERSION || PKT_VERSION(rpkt->li_vn_mode) > NTP_VERSION) { - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp %s: Packet shows wrong version (%i)\n", func_name, PKT_VERSION(rpkt->li_vn_mode)); return SERVER_UNUSEABLE; @@ -427,7 +427,7 @@ unusable: /* We want a server to sync with */ if (PKT_MODE(rpkt->li_vn_mode) != mode && PKT_MODE(rpkt->li_vn_mode) != MODE_PASSIVE) { - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp %s: mode %d stratum %i\n", func_name, PKT_MODE(rpkt->li_vn_mode), rpkt->stratum); return SERVER_UNUSEABLE; @@ -436,11 +436,11 @@ unusable: if (STRATUM_PKT_UNSPEC == rpkt->stratum) { char *ref_char; - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp %s: Stratum unspecified, going to check for KOD (stratum: %i)\n", func_name, rpkt->stratum); ref_char = (char *) &rpkt->refid; - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp %s: Packet refid: %c%c%c%c\n", func_name, ref_char[0], ref_char[1], ref_char[2], ref_char[3]); /* If it's a KOD packet we'll just use the KOD information */ @@ -459,7 +459,7 @@ unusable: } /* If the server is not synced it's not really useable for us */ if (LEAP_NOTINSYNC == PKT_LEAP(rpkt->li_vn_mode)) { - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp %s: Server not in sync, skipping this server\n", func_name); return SERVER_UNUSEABLE; } @@ -475,7 +475,7 @@ unusable: l_fp_output(&spkt->xmt, stdout); #endif if (mode != MODE_BROADCAST && !L_ISEQU(&rpkt->org, &spkt->xmt)) { - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp process_pkt: pkt.org and peer.xmt differ\n"); return PACKET_UNUSEABLE; } @@ -534,12 +534,12 @@ recvpkt ( rdy_socks = select(rsock + 1, &recv_fd, 0, 0, &timeout_tv); switch (rdy_socks) { case -1: - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) perror("sntp recvpkt: select()"); return PACKET_UNUSEABLE; break; case 0: - if (ENABLED_OPT(NORMALVERBOSE)) + if (debug) printf("sntp recvpkt: select() reached timeout (%u sec), aborting.\n", (unsigned)timeout_tv.tv_sec); return PACKET_UNUSEABLE; diff --git a/sntp/sntp-opts.c b/sntp/sntp-opts.c index 9e427c216..d7450a62d 100644 --- a/sntp/sntp-opts.c +++ b/sntp/sntp-opts.c @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (sntp-opts.c) * - * It has been AutoGen-ed January 8, 2011 at 09:34:22 AM by AutoGen 5.11.6pre7 + * It has been AutoGen-ed January 9, 2011 at 06:03:48 AM by AutoGen 5.11.6pre7 * From the definitions sntp-opts.def * and the template file options * @@ -45,6 +45,15 @@ tSCC zCopyrightNotice[24] = extern tUsageProc optionUsage; +/* + * global included definitions + */ +#ifdef __windows + extern int atoi(const char*); +#else +# include +#endif + #ifndef NULL # define NULL 0 #endif @@ -55,6 +64,25 @@ extern tUsageProc optionUsage; # define EXIT_FAILURE 1 #endif +/* + * Debug_Level option description: + */ +static char const zDebug_LevelText[] = + "Increase output debug message level"; +static char const zDebug_Level_NAME[] = "DEBUG_LEVEL"; +static char const zDebug_Level_Name[] = "debug-level"; +#define DEBUG_LEVEL_FLAGS (OPTST_DISABLED) + +/* + * Set_Debug_Level option description: + */ +static char const zSet_Debug_LevelText[] = + "Set the output debug message level"; +static char const zSet_Debug_Level_NAME[] = "SET_DEBUG_LEVEL"; +static char const zSet_Debug_Level_Name[] = "set-debug-level"; +#define SET_DEBUG_LEVEL_FLAGS (OPTST_DISABLED \ + | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)) + /* * Ipv4 option description with * "Must also have options" and "Incompatible options": @@ -81,15 +109,6 @@ static const int INDEX_OPT_IPV4, NO_EQUIVALENT }; #define IPV6_FLAGS (OPTST_DISABLED) -/* - * Normalverbose option description: - */ -static char const zNormalverboseText[] = - "Normal verbose"; -static char const zNormalverbose_NAME[] = "NORMALVERBOSE"; -static char const zNormalverbose_Name[] = "normalverbose"; -#define NORMALVERBOSE_FLAGS (OPTST_DISABLED) - /* * Kod option description: */ @@ -235,6 +254,12 @@ static char const zNotLoad_Opts_Pfx[] = "no"; static tOptProc doUsageOpt; +/* + * #define map the "normal" callout procs to the test ones... + */ +#define SET_DEBUG_LEVEL_OPT_PROC optionStackArg + + #else /* NOT defined TEST_SNTP_OPTS */ /* * When not under test, there are different procs to use @@ -245,7 +270,14 @@ extern tOptProc optionStackArg, optionTimeVal, optionUnstackArg, optionVersionStderr; static tOptProc - doUsageOpt; + doOptSet_Debug_Level, doUsageOpt; + +/* + * #define map the "normal" callout procs + */ +#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level + +#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level #endif /* defined(TEST_SNTP_OPTS) */ #ifdef TEST_SNTP_OPTS # define DOVERPROC optionVersionStderr @@ -258,44 +290,56 @@ static tOptProc * Define the Sntp Option Descriptions. */ static tOptDesc optDesc[ OPTION_CT ] = { - { /* entry idx, value */ 0, VALUE_OPT_IPV4, - /* equiv idx, value */ 0, VALUE_OPT_IPV4, + { /* entry idx, value */ 0, VALUE_OPT_DEBUG_LEVEL, + /* equiv idx, value */ 0, VALUE_OPT_DEBUG_LEVEL, /* equivalenced to */ NO_EQUIVALENT, - /* min, max, act ct */ 0, 1, 0, - /* opt state flags */ IPV4_FLAGS, 0, + /* min, max, act ct */ 0, NOLIMIT, 0, + /* opt state flags */ DEBUG_LEVEL_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, - /* must/cannot opts */ NULL, aIpv4CantList, + /* must/cannot opts */ NULL, NULL, /* option proc */ NULL, - /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name, + /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name, + /* disablement strs */ NULL, NULL }, + + { /* entry idx, value */ 1, VALUE_OPT_SET_DEBUG_LEVEL, + /* equiv idx, value */ 1, VALUE_OPT_SET_DEBUG_LEVEL, + /* equivalenced to */ NO_EQUIVALENT, + /* min, max, act ct */ 0, NOLIMIT, 0, + /* opt state flags */ SET_DEBUG_LEVEL_FLAGS, 0, + /* last opt argumnt */ { NULL }, + /* arg list/cookie */ NULL, + /* must/cannot opts */ NULL, NULL, + /* option proc */ SET_DEBUG_LEVEL_OPT_PROC, + /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 1, VALUE_OPT_IPV6, - /* equiv idx, value */ 1, VALUE_OPT_IPV6, + { /* entry idx, value */ 2, VALUE_OPT_IPV4, + /* equiv idx, value */ 2, VALUE_OPT_IPV4, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, - /* opt state flags */ IPV6_FLAGS, 0, + /* opt state flags */ IPV4_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, - /* must/cannot opts */ NULL, aIpv6CantList, + /* must/cannot opts */ NULL, aIpv4CantList, /* option proc */ NULL, - /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name, + /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 2, VALUE_OPT_NORMALVERBOSE, - /* equiv idx, value */ 2, VALUE_OPT_NORMALVERBOSE, + { /* entry idx, value */ 3, VALUE_OPT_IPV6, + /* equiv idx, value */ 3, VALUE_OPT_IPV6, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, - /* opt state flags */ NORMALVERBOSE_FLAGS, 0, + /* opt state flags */ IPV6_FLAGS, 0, /* last opt argumnt */ { NULL }, /* arg list/cookie */ NULL, - /* must/cannot opts */ NULL, NULL, + /* must/cannot opts */ NULL, aIpv6CantList, /* option proc */ NULL, - /* desc, NAME, name */ zNormalverboseText, zNormalverbose_NAME, zNormalverbose_Name, + /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 3, VALUE_OPT_KOD, - /* equiv idx, value */ 3, VALUE_OPT_KOD, + { /* entry idx, value */ 4, VALUE_OPT_KOD, + /* equiv idx, value */ 4, VALUE_OPT_KOD, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ KOD_FLAGS, 0, @@ -306,8 +350,8 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zKodText, zKod_NAME, zKod_Name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 4, VALUE_OPT_SYSLOG, - /* equiv idx, value */ 4, VALUE_OPT_SYSLOG, + { /* entry idx, value */ 5, VALUE_OPT_SYSLOG, + /* equiv idx, value */ 5, VALUE_OPT_SYSLOG, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ SYSLOG_FLAGS, 0, @@ -318,8 +362,8 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zSyslogText, zSyslog_NAME, zSyslog_Name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 5, VALUE_OPT_FILELOG, - /* equiv idx, value */ 5, VALUE_OPT_FILELOG, + { /* entry idx, value */ 6, VALUE_OPT_FILELOG, + /* equiv idx, value */ 6, VALUE_OPT_FILELOG, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ FILELOG_FLAGS, 0, @@ -330,8 +374,8 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zFilelogText, zFilelog_NAME, zFilelog_Name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 6, VALUE_OPT_SETTOD, - /* equiv idx, value */ 6, VALUE_OPT_SETTOD, + { /* entry idx, value */ 7, VALUE_OPT_SETTOD, + /* equiv idx, value */ 7, VALUE_OPT_SETTOD, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ SETTOD_FLAGS, 0, @@ -342,8 +386,8 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zSettodText, zSettod_NAME, zSettod_Name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 7, VALUE_OPT_ADJTIME, - /* equiv idx, value */ 7, VALUE_OPT_ADJTIME, + { /* entry idx, value */ 8, VALUE_OPT_ADJTIME, + /* equiv idx, value */ 8, VALUE_OPT_ADJTIME, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ ADJTIME_FLAGS, 0, @@ -354,8 +398,8 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zAdjtimeText, zAdjtime_NAME, zAdjtime_Name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 8, VALUE_OPT_BROADCAST, - /* equiv idx, value */ 8, VALUE_OPT_BROADCAST, + { /* entry idx, value */ 9, VALUE_OPT_BROADCAST, + /* equiv idx, value */ 9, VALUE_OPT_BROADCAST, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ BROADCAST_FLAGS, 0, @@ -366,8 +410,8 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zBroadcastText, zBroadcast_NAME, zBroadcast_Name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 9, VALUE_OPT_TIMEOUT, - /* equiv idx, value */ 9, VALUE_OPT_TIMEOUT, + { /* entry idx, value */ 10, VALUE_OPT_TIMEOUT, + /* equiv idx, value */ 10, VALUE_OPT_TIMEOUT, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ TIMEOUT_FLAGS, 0, @@ -378,8 +422,8 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zTimeoutText, zTimeout_NAME, zTimeout_Name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 10, VALUE_OPT_AUTHENTICATION, - /* equiv idx, value */ 10, VALUE_OPT_AUTHENTICATION, + { /* entry idx, value */ 11, VALUE_OPT_AUTHENTICATION, + /* equiv idx, value */ 11, VALUE_OPT_AUTHENTICATION, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ AUTHENTICATION_FLAGS, 0, @@ -390,8 +434,8 @@ static tOptDesc optDesc[ OPTION_CT ] = { /* desc, NAME, name */ zAuthenticationText, zAuthentication_NAME, zAuthentication_Name, /* disablement strs */ NULL, NULL }, - { /* entry idx, value */ 11, VALUE_OPT_KEYFILE, - /* equiv idx, value */ 11, VALUE_OPT_KEYFILE, + { /* entry idx, value */ 12, VALUE_OPT_KEYFILE, + /* equiv idx, value */ 12, VALUE_OPT_KEYFILE, /* equivalenced to */ NO_EQUIVALENT, /* min, max, act ct */ 0, 1, 0, /* opt state flags */ KEYFILE_FLAGS, 0, @@ -491,7 +535,7 @@ It can be run interactively from the command line or as a cron job.\n\n\ NTP and SNTP are defined by RFC 5905, which obsoletes RFC 4330 and RFC\n\ 1305.\n"; static char const zFullVersion[] = SNTP_FULL_VERSION; -/* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 504 */ +/* extracted from /usr/local/share/autogen/optcode.tpl near line 504 */ #if defined(ENABLE_NLS) # define OPTPROC_BASE OPTPROC_TRANSLATE @@ -536,7 +580,7 @@ tOptions sntpOptions = { NO_EQUIVALENT, /* '-#' option index */ NO_EQUIVALENT /* index of default opt */ }, - 17 /* full option count */, 12 /* user option count */, + 18 /* full option count */, 13 /* user option count */, sntp_full_usage, sntp_short_usage, NULL, NULL, PKGDATADIR @@ -553,7 +597,21 @@ doUsageOpt( (void)pOptions; USAGE(EXIT_SUCCESS); } -/* extracted from /usr/local/gnu/share/autogen/optmain.tpl near line 107 */ + +#if ! defined(TEST_SNTP_OPTS) + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * + * For the set-debug-level option. + */ +static void +doOptSet_Debug_Level(tOptions* pOptions, tOptDesc* pOptDesc) +{ + /* extracted from ../include/debug-opt.def, line 27 */ +DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg ); +} +#endif /* defined(TEST_SNTP_OPTS) */ +/* extracted from /usr/local/share/autogen/optmain.tpl near line 107 */ #if defined(TEST_SNTP_OPTS) /* TEST MAIN PROCEDURE: */ @@ -571,7 +629,7 @@ main(int argc, char** argv) return res; } #endif /* defined TEST_SNTP_OPTS */ -/* extracted from /usr/local/gnu/share/autogen/optcode.tpl near line 641 */ +/* extracted from /usr/local/share/autogen/optcode.tpl near line 641 */ #if ENABLE_NLS #include diff --git a/sntp/sntp-opts.def b/sntp/sntp-opts.def index 78f143bf9..2a90323ee 100644 --- a/sntp/sntp-opts.def +++ b/sntp/sntp-opts.def @@ -4,6 +4,7 @@ autogen definitions options; #include autogen-version.def #include copyright.def +#include debug-opt.def prog-name = "sntp"; prog-title = "standard SNTP program"; @@ -49,18 +50,6 @@ flag = { }; -flag = { - name = normalverbose; - value = d; - descrip = "Normal verbose"; - doc = <<- _EndOfDoc_ - Diagnostic messages for non-fatal errors and a limited amount of - tracing should be written to standard error. Fatal ones always - produce a diagnostic. This option should be set when there is a - suspected problem with the server, network or the source. - _EndOfDoc_; -}; - flag = { name = kod; value = K; diff --git a/sntp/sntp-opts.h b/sntp/sntp-opts.h index a6719b141..a11cba3fb 100644 --- a/sntp/sntp-opts.h +++ b/sntp/sntp-opts.h @@ -1,7 +1,7 @@ /* * EDIT THIS FILE WITH CAUTION (sntp-opts.h) * - * It has been AutoGen-ed January 8, 2011 at 09:34:22 AM by AutoGen 5.11.6pre7 + * It has been AutoGen-ed January 9, 2011 at 06:03:48 AM by AutoGen 5.11.6pre7 * From the definitions sntp-opts.def * and the template file options * @@ -50,33 +50,34 @@ * Enumeration of each option: */ typedef enum { - INDEX_OPT_IPV4 = 0, - INDEX_OPT_IPV6 = 1, - INDEX_OPT_NORMALVERBOSE = 2, - INDEX_OPT_KOD = 3, - INDEX_OPT_SYSLOG = 4, - INDEX_OPT_FILELOG = 5, - INDEX_OPT_SETTOD = 6, - INDEX_OPT_ADJTIME = 7, - INDEX_OPT_BROADCAST = 8, - INDEX_OPT_TIMEOUT = 9, - INDEX_OPT_AUTHENTICATION = 10, - INDEX_OPT_KEYFILE = 11, - INDEX_OPT_VERSION = 12, - INDEX_OPT_HELP = 13, - INDEX_OPT_MORE_HELP = 14, - INDEX_OPT_SAVE_OPTS = 15, - INDEX_OPT_LOAD_OPTS = 16 + INDEX_OPT_DEBUG_LEVEL = 0, + INDEX_OPT_SET_DEBUG_LEVEL = 1, + INDEX_OPT_IPV4 = 2, + INDEX_OPT_IPV6 = 3, + INDEX_OPT_KOD = 4, + INDEX_OPT_SYSLOG = 5, + INDEX_OPT_FILELOG = 6, + INDEX_OPT_SETTOD = 7, + INDEX_OPT_ADJTIME = 8, + INDEX_OPT_BROADCAST = 9, + INDEX_OPT_TIMEOUT = 10, + INDEX_OPT_AUTHENTICATION = 11, + INDEX_OPT_KEYFILE = 12, + INDEX_OPT_VERSION = 13, + INDEX_OPT_HELP = 14, + INDEX_OPT_MORE_HELP = 15, + INDEX_OPT_SAVE_OPTS = 16, + INDEX_OPT_LOAD_OPTS = 17 } teOptIndex; -#define OPTION_CT 17 +#define OPTION_CT 18 #define SNTP_VERSION "4.2.7p114" #define SNTP_FULL_VERSION "sntp - standard SNTP program - Ver. 4.2.7p114" /* * Interface defines for all options. Replace "n" with the UPPER_CASED * option name (as in the teOptIndex enumeration above). - * e.g. HAVE_OPT(IPV4) + * e.g. HAVE_OPT(DEBUG_LEVEL) */ #define DESC(n) (sntpOptions.pOptDesc[INDEX_OPT_## n]) #define HAVE_OPT(n) (! UNUSED_OPT(& DESC(n))) @@ -107,6 +108,14 @@ typedef enum { * Make sure there are no #define name conflicts with the option names */ #ifndef NO_OPTION_NAME_WARNINGS +# ifdef DEBUG_LEVEL +# warning undefining DEBUG_LEVEL due to option name conflict +# undef DEBUG_LEVEL +# endif +# ifdef SET_DEBUG_LEVEL +# warning undefining SET_DEBUG_LEVEL due to option name conflict +# undef SET_DEBUG_LEVEL +# endif # ifdef IPV4 # warning undefining IPV4 due to option name conflict # undef IPV4 @@ -115,10 +124,6 @@ typedef enum { # warning undefining IPV6 due to option name conflict # undef IPV6 # endif -# ifdef NORMALVERBOSE -# warning undefining NORMALVERBOSE due to option name conflict -# undef NORMALVERBOSE -# endif # ifdef KOD # warning undefining KOD due to option name conflict # undef KOD @@ -156,9 +161,10 @@ typedef enum { # undef KEYFILE # endif #else /* NO_OPTION_NAME_WARNINGS */ +# undef DEBUG_LEVEL +# undef SET_DEBUG_LEVEL # undef IPV4 # undef IPV6 -# undef NORMALVERBOSE # undef KOD # undef SYSLOG # undef FILELOG @@ -174,9 +180,10 @@ typedef enum { * * Interface defines for specific options. */ +#define VALUE_OPT_DEBUG_LEVEL 'd' +#define VALUE_OPT_SET_DEBUG_LEVEL 'D' #define VALUE_OPT_IPV4 '4' #define VALUE_OPT_IPV6 '6' -#define VALUE_OPT_NORMALVERBOSE 'd' #define VALUE_OPT_KOD 'K' #define VALUE_OPT_SYSLOG 'p' #define VALUE_OPT_FILELOG 'l' @@ -209,7 +216,7 @@ typedef enum { sntpOptions.pzCurOpt = NULL) #define START_OPT RESTART_OPT(1) #define USAGE(c) (*sntpOptions.pUsageProc)(&sntpOptions, c) -/* extracted from /usr/local/gnu/share/autogen/opthead.tpl near line 435 */ +/* extracted from /usr/local/share/autogen/opthead.tpl near line 435 */ /* * * * * * * diff --git a/sntp/sntp-opts.texi b/sntp/sntp-opts.texi index f02391262..a1808b961 100644 --- a/sntp/sntp-opts.texi +++ b/sntp/sntp-opts.texi @@ -6,7 +6,7 @@ # # EDIT THIS FILE WITH CAUTION (sntp-opts.texi) # -# It has been AutoGen-ed January 8, 2011 at 04:45:30 AM by AutoGen 5.11.6pre7 +# It has been AutoGen-ed January 9, 2011 at 06:07:36 AM by AutoGen 5.11.6pre7 # From the definitions sntp-opts.def # and the template file aginfo.tpl @end ignore @@ -50,12 +50,13 @@ This software is released under a specialized copyright license. * sntp adjtime:: adjtime option (-j) * sntp authentication:: authentication option (-a) * sntp broadcast:: broadcast option (-b) +* sntp debug-level:: debug-level option (-d) * sntp filelog:: filelog option (-l) * sntp ipv4:: ipv4 option (-4) * sntp ipv6:: ipv6 option (-6) * sntp keyfile:: keyfile option (-k) * sntp kod:: kod option (-K) -* sntp normalverbose:: normalverbose option (-d) +* sntp set-debug-level:: set-debug-level option (-D) * sntp settod:: settod option (-s) * sntp syslog:: syslog option (-p) * sntp timeout:: timeout option (-t) @@ -72,13 +73,16 @@ This is the automatically generated usage text for sntp: sntp - standard SNTP program - Ver. 4.2.7p114 USAGE: sntp [ - [] | --[@{=| @}] ]... hostname-or-IP ... Flg Arg Option-Name Description + -d no debug-level Increase output debug message level + - may appear multiple times + -D Str set-debug-level Set the output debug message level + - may appear multiple times -4 no ipv4 Force IPv4 DNS name resolution - prohibits these options: ipv6 -6 no ipv6 Force IPv6 DNS name resolution - prohibits these options: ipv4 - -d no normalverbose Normal verbose -K Str kod KoD history filename -p no syslog Logging with syslog - prohibits these options: @@ -160,6 +164,20 @@ If specified SNTP will listen to the specified broadcast address for NTP broadcasts. The default maximum wait time, 68 seconds, can be modified with -t. +@node sntp debug-level +@subsection debug-level option (-d) +@cindex sntp-debug-level + +This is the ``increase output debug message level'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +may appear an unlimited number of times. +@end itemize + +Increase the debugging message output level. + @node sntp filelog @subsection filelog option (-l) @cindex sntp-filelog @@ -236,15 +254,20 @@ Modifies the filename to be used to persist the history of KoD responses received from servers. The default is /var/db/ntp-kod. -@node sntp normalverbose -@subsection normalverbose option (-d) -@cindex sntp-normalverbose +@node sntp set-debug-level +@subsection set-debug-level option (-D) +@cindex sntp-set-debug-level + +This is the ``set the output debug message level'' option. + +This option has some usage constraints. It: +@itemize @bullet +@item +may appear an unlimited number of times. +@end itemize -This is the ``normal verbose'' option. -Diagnostic messages for non-fatal errors and a limited amount of -tracing should be written to standard error. Fatal ones always -produce a diagnostic. This option should be set when there is a -suspected problem with the server, network or the source. +Set the output debugging level. Can be supplied multiple times, +but each overrides the previous value(s). @node sntp settod @subsection settod option (-s) diff --git a/sntp/sntp.1 b/sntp/sntp.1 index d31cacf2d..c1df8671d 100644 --- a/sntp/sntp.1 +++ b/sntp/sntp.1 @@ -1,7 +1,7 @@ -.TH SNTP 1 2011-01-08 "( 4.2.7p114)" "Programmer's Manual" +.TH SNTP 1 2011-01-09 "( 4.2.7p114)" "Programmer's Manual" .\" EDIT THIS FILE WITH CAUTION (sntp.1) .\" -.\" It has been AutoGen-ed January 8, 2011 at 04:45:30 AM by AutoGen 5.11.6pre7 +.\" It has been AutoGen-ed January 9, 2011 at 06:07:35 AM by AutoGen 5.11.6pre7 .\" From the definitions sntp-opts.def .\" and the template file agman1.tpl .\" @@ -47,6 +47,19 @@ is believed to be correct to within seconds. .SH OPTIONS .TP +.BR \-d ", " \--debug-level +Increase output debug message level. +This option may appear an unlimited number of times. +.sp +Increase the debugging message output level. +.TP +.BR \-D " \fIstring\fP, " \--set-debug-level "=" \fIstring\fP +Set the output debug message level. +This option may appear an unlimited number of times. +.sp +Set the output debugging level. Can be supplied multiple times, +but each overrides the previous value(s). +.TP .BR \-4 ", " \--ipv4 Force IPv4 DNS name resolution. This option must not appear in combination with any of the following options: @@ -63,14 +76,6 @@ ipv4. Force DNS resolution of following host names on the command line to the IPv6 namespace. .TP -.BR \-d ", " \--normalverbose -Normal verbose. -.sp -Diagnostic messages for non-fatal errors and a limited amount of -tracing should be written to standard error. Fatal ones always -produce a diagnostic. This option should be set when there is a -suspected problem with the server, network or the source. -.TP .BR \-K " \fIfile-name\fP, " \--kod "=" \fIfile-name\fP KoD history filename. .sp diff --git a/sntp/sntp.html b/sntp/sntp.html index b7923daf0..7da2de6c9 100644 --- a/sntp/sntp.html +++ b/sntp/sntp.html @@ -3,7 +3,7 @@ Sntp User's Manual - + @@ -14,18 +14,20 @@ pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } - span.sc { font-variant:small-caps } - span.roman { font-family: serif; font-weight: normal; } + span.sc { font-variant:small-caps } + span.roman { font-family:serif; font-weight:normal; } + span.sansserif { font-family:sans-serif; font-weight:normal; } -->

Sntp User's Manual


-Next: , + +Next: , Previous: (dir), Up: (dir) -
+

Simple Network Time Protocol User Manual

@@ -57,7 +59,8 @@ IETF specification.


-
+ +
@@ -74,7 +77,8 @@ error bound of the system clock relative to the server clock.


-
+ +

Invoking sntp

@@ -107,7 +111,7 @@ is believed to be correct to within seconds.

This section was generated by AutoGen, -the aginfo template and the option descriptions for the sntp program. It documents the sntp usage text and option meanings. +the aginfo template and the option descriptions for the sntp program. It documents the sntp usage text and option meanings.

This software is released under a specialized copyright license. @@ -116,12 +120,13 @@ the aginfo template and the option descriptions for the sn

  • sntp adjtime: adjtime option (-j)
  • sntp authentication: authentication option (-a)
  • sntp broadcast: broadcast option (-b) -
  • sntp filelog: filelog option (-l) -
  • sntp ipv4: ipv4 option (-4) -
  • sntp ipv6: ipv6 option (-6) -
  • sntp keyfile: keyfile option (-k) -
  • sntp kod: kod option (-K) -
  • sntp normalverbose: normalverbose option (-d) +
  • sntp debug-level: debug-level option (-d) +
  • sntp filelog: filelog option (-l) +
  • sntp ipv4: ipv4 option (-4) +
  • sntp ipv6: ipv6 option (-6) +
  • sntp keyfile: keyfile option (-k) +
  • sntp kod: kod option (-K) +
  • sntp set-debug-level: set-debug-level option (-D)
  • sntp settod: settod option (-s)
  • sntp syslog: syslog option (-p)
  • sntp timeout: timeout option (-t) @@ -129,9 +134,10 @@ the aginfo template and the option descriptions for the sn


    -Next: , + +Next: , Up: sntp Invocation -
    +

    sntp usage help (-?)

    @@ -142,13 +148,16 @@ This is the automatically generated usage text for sntp:
    sntp - standard SNTP program - Ver. 4.2.7p114
     USAGE:  sntp [ -<flag> [<val>] | --<name>[{=| }<val>] ]... hostname-or-IP ...
       Flg Arg Option-Name    Description
    +   -d no  debug-level    Increase output debug message level
    +                                - may appear multiple times
    +   -D Str set-debug-level Set the output debug message level
    +                                - may appear multiple times
        -4 no  ipv4           Force IPv4 DNS name resolution
                                     - prohibits these options:
                                     ipv6
        -6 no  ipv6           Force IPv6 DNS name resolution
                                     - prohibits these options:
                                     ipv4
    -   -d no  normalverbose  Normal verbose
        -K Str kod            KoD history filename
        -p no  syslog         Logging with syslog
                                     - prohibits these options:
    @@ -197,10 +206,11 @@ please send bug reports to:  http://bugs.ntp.org, bugs@ntp.org
     


    -Next: , + +Next: , Previous: sntp usage, Up: sntp Invocation -
    +

    adjtime option (-j)

    @@ -216,10 +226,11 @@ settod.


    -Next: , + +Next: , Previous: sntp adjtime, Up: sntp Invocation -
    +

    authentication option (-a)

    @@ -232,10 +243,11 @@ key's identifier. See the keyfile option (-k) for more details.


    -Next: , + +Next: , Previous: sntp authentication, Up: sntp Invocation -
    +

    broadcast option (-b)

    @@ -248,15 +260,38 @@ for NTP broadcasts. The default maximum wait time,


    -Next: , + + +Next: , Previous: sntp broadcast, Up: sntp Invocation -
    + +
    + +

    debug-level option (-d)

    + +

    +This is the “increase output debug message level” option. + +

    This option has some usage constraints. It: +

      +
    • may appear an unlimited number of times. +
    + +

    Increase the debugging message output level. + +

    +


    + +Next: , +Previous: sntp debug-level, +Up: sntp Invocation +

    filelog option (-l)

    -

    +

    This is the “log to specified logfile” option.

    This option has some usage constraints. It: @@ -270,15 +305,16 @@ logfile.


    -Next: , + +Next: , Previous: sntp filelog, Up: sntp Invocation -
    +

    ipv4 option (-4)

    -

    +

    This is the “force ipv4 dns name resolution” option.

    This option has some usage constraints. It: @@ -292,15 +328,16 @@ to the IPv4 namespace.


    -Next: , + +Next: , Previous: sntp ipv4, Up: sntp Invocation -
    +

    ipv6 option (-6)

    -

    +

    This is the “force ipv6 dns name resolution” option.

    This option has some usage constraints. It: @@ -314,15 +351,16 @@ to the IPv6 namespace.


    -Next: , + +Next: , Previous: sntp ipv6, Up: sntp Invocation -
    +

    keyfile option (-k)

    -

    +

    This is the “specify a keyfile. sntp will look in this file for the key specified with -a” option. This option specifies the keyfile. SNTP will search for the key specified with -a keyno in this file. Key files follow the following format: @@ -340,15 +378,16 @@ M Key in a 1-to-8 character ASCII string using the MD5 authentication scheme.


    -Next: , + +Next: , Previous: sntp keyfile, Up: sntp Invocation -
    +

    kod option (-K)

    -

    +

    This is the “kod history filename” option. Modifies the filename to be used to persist the history of KoD responses received from servers. The default is @@ -356,32 +395,39 @@ responses received from servers. The default is


    -Next: , + + +Next: , Previous: sntp kod, Up: sntp Invocation -
    +
    -

    normalverbose option (-d)

    +

    set-debug-level option (-D)

    -

    -This is the “normal verbose” option. -Diagnostic messages for non-fatal errors and a limited amount of -tracing should be written to standard error. Fatal ones always -produce a diagnostic. This option should be set when there is a -suspected problem with the server, network or the source. +

    +This is the “set the output debug message level” option. + +

    This option has some usage constraints. It: +

      +
    • may appear an unlimited number of times. +
    + +

    Set the output debugging level. Can be supplied multiple times, +but each overrides the previous value(s).


    -Next: , -Previous: sntp normalverbose, + +Next: , +Previous: sntp set-debug-level, Up: sntp Invocation -
    +

    settod option (-s)

    -

    +

    This is the “set (step) the time with settimeofday()” option.

    This option has some usage constraints. It: @@ -392,15 +438,16 @@ adjtime.


    -Next: , + +Next: , Previous: sntp settod, Up: sntp Invocation -
    +

    syslog option (-p)

    -

    +

    This is the “logging with syslog” option.

    This option has some usage constraints. It: @@ -413,14 +460,15 @@ filelog.


    -Previous: sntp syslog, + +Previous: sntp syslog, Up: sntp Invocation -
    +

    timeout option (-t)

    -

    +

    This is the “specify the number of seconds to wait for broadcasts” option. When waiting for a broadcast packet SNTP will wait the number of seconds specified before giving up. Default 68 seconds. @@ -428,7 +476,8 @@ of seconds specified before giving up. Default 68 seconds.


    -
    + +