Lines Matching +full:test2 +full:. +full:good
4 #include <config.h>
5 #include <ctype.h>
6 #include <signal.h>
7 #include <setjmp.h>
8 #include <stddef.h>
9 #include <stdio.h>
10 #include <sys/types.h>
11 #include <sys/time.h>
13 # include <unistd.h>
16 # include <fcntl.h>
19 # include <mswsock.h>
24 #include <isc/net.h>
25 #include <isc/result.h>
27 #include "ntpq.h"
28 #include "ntp_unixtime.h"
29 #include "ntp_calendar.h"
30 #include "ntp_select.h"
31 #include "ntp_lineedit.h"
32 #include "ntp_debug.h"
34 # include "openssl/evp.h"
35 # include "openssl/objects.h"
36 # include "openssl/err.h"
38 # include "openssl/opensslv.h"
43 # include "libssl_compat.h"
45 # include <openssl/cmac.h>
49 #include <ssl_applink.c>
51 #include "ntp_libopts.h"
52 #include "safecast.h"
66 * interactive if connected to a terminal.
73 * this value based on the presence or absence of --old-rv. It is
76 * desired.
92 * Keyid used for authenticated requests. Obtained on the fly.
106 * Flag which indicates raw mode output.
134 * mostly plain-text mode 6 responses. A few variable names are by
135 * default "cooked" to provide more human-friendly output.
165 "pkt_bogus", /* TEST2 */
222 static void warning (const char *, ...) NTP_PRINTF(1, 2);
223 static void error (const char *, ...) NTP_PRINTF(1, 2);
239 static int my_easprintf (char**, const char *, ...) NTP_PRINTF(2, 3);
328 * Default values we use.
335 * response is a bit over 2 * DEFTIMEOUT, or 10 seconds. At the other
339 * 93 seconds to fail each of two times, or 186 seconds.
341 * "mrulist", so the cumulative timeouts are even longer for those.
375 * Sequence number used for requests. It is incremented before
376 * it is used.
381 * Holds data returned from queries. Declare buffer long to be sure of
382 * alignment.
389 * associations using &1 ... &N for n associations, avoiding manual
390 * lookup of the current association IDs for a given ntpd. It also
391 * caches the status word for each association, retrieved incidentally.
406 * When multiple hosts are specified.
415 chosts[numhosts].name = (cp); \
416 chosts[numhosts].fam = ai_fam_templ; \
429 * Jump buffer for longjumping back to the command level.
432 * if available. The signal is blocked by default during the excution of
434 * restore the signal mask. They do on BSD, it depends on the GLIBC
435 * version on Linux, and the gods know what happens on other OSes...
438 * for them the semantics are well-defined. If we have to fall back to
439 * '{set,long}jmp()', the CTRL-C handling might be a bit erratic.
462 * Command table imported from ntpdc_ops.c
517 delay_time.l_ui = 0;
518 delay_time.l_uf = DEFDELAY;
524 /* Check to see if we have IPv6. Otherwise default to IPv4 */
537 if (strcmp("keytype", builtins[icmd].keyword) == 0) {
547 builtins[icmd].desc[0] = "digest-name";
552 builtins[icmd].desc[0] = "md5";
557 builtins[icmd].comment = msg;
571 * handled by ntpq_custom_opt_handler().
605 // and there are other cases as well...
634 if (openhost(chosts[ihost].name, chosts[ihost].fam)) {
650 (void) openhost(chosts[0].name, chosts[0].fam);
695 * do a fullblown (dns) lookup. That way we only use the dns
698 * give it an IPv4 address to lookup.
701 hints.ai_family = fam;
702 hints.ai_protocol = IPPROTO_UDP;
703 hints.ai_socktype = SOCK_DGRAM;
704 hints.ai_flags = Z_AI_NUMERICHOST;
713 hints.ai_flags = AI_CANONNAME;
715 hints.ai_flags |= AI_ADDRCONFIG;
721 * Some older implementations don't like AI_ADDRCONFIG.
723 * global address and AI_ADDRCONFIG is used. AI_ADDRCONFIG
725 * for which the host has no local addresses. Windows
728 * localhost works.
729 * To further muddy matters, some versions of WS2tcpip.h
734 * So we get more ugly platform-specific workarounds.
741 hints.ai_flags &= ~AI_ADDRCONFIG;
886 *pptr++ = isprint(ch) ? (char)ch : '.';
896 /* XXX ELIMINATE sendpkt similar in ntpq.c, ntpdc.c, ntp_io.c, ntptrace.c */
948 /* absolute timeout checks. Not 'time_t' by intention! */
957 * This is pretty tricky. We may get between 1 and MAXFRAG packets
958 * back in response to the request. We peel the data out of
959 * each packet and collect it in one long block. When the last
961 * should have had. Note we use one long time out, should reconsider.
976 * Loop until we have an error or a complete response. Nearly all
977 * code paths to loop again use continue.
985 tospan = (uint32_t)tvo.tv_sec + (tvo.tv_usec != 0);
994 * handling anyway.
998 * the receive sequence.
1010 * Check if this is already too late. Trash the data and
1011 * fake a timeout if this is so.
1023 * Timed out. Return what we have
1067 * Check for format errors. Bug proofing.
1074 if (PKT_VERSION(rpkt.li_vn_mode) > NTP_VERSION
1075 || PKT_VERSION(rpkt.li_vn_mode) < NTP_OLDVERSION) {
1078 PKT_VERSION(rpkt.li_vn_mode));
1081 if (PKT_MODE(rpkt.li_vn_mode) != MODE_CONTROL) {
1084 PKT_MODE(rpkt.li_vn_mode));
1087 if (!CTL_ISRESPONSE(rpkt.r_m_e_op)) {
1094 * Check opcode and sequence number for a match.
1095 * Could be old data getting to us.
1097 if (ntohs(rpkt.sequence) != sequence) {
1100 ntohs(rpkt.sequence), sequence);
1103 if (CTL_OP(rpkt.r_m_e_op) != opcode) {
1107 CTL_OP(rpkt.r_m_e_op), opcode);
1112 * Check the error code. If non-zero, return it.
1114 if (CTL_ISERROR(rpkt.r_m_e_op)) {
1115 errcode = (ntohs(rpkt.status) >> 8) & 0xff;
1116 if (CTL_ISMORE(rpkt.r_m_e_op))
1126 * we sent.
1128 if (ntohs(rpkt.associd) != associd) {
1130 ntohs(rpkt.associd), associd));
1133 * return an assID of sys.peer when queried for system variables.
1141 * Collect offset and count. Make sure they make sense.
1143 offset = ntohs(rpkt.offset);
1144 count = ntohs(rpkt.count);
1148 * boundary and no smaller than claimed by rpkt.count
1171 * we watch it here.
1210 if (count == 0 && CTL_ISMORE(rpkt.r_m_e_op)) {
1219 if (seenlastfrag && !CTL_ISMORE(rpkt.r_m_e_op)) {
1225 * So far, so good. Record this fragment, making sure it doesn't
1226 * overlap anything.
1238 * previously received.
1273 * Got that stuffed in right. Figure out if this was the last.
1274 * Record status info out of the last packet.
1276 if (!CTL_ISMORE(rpkt.r_m_e_op)) {
1279 *rstatus = ntohs(rpkt.status);
1284 * timout base in case we need more.
1286 memcpy((char *)pktdata + offset, &rpkt.u, count);
1290 * If we've seen the last fragment, look for holes in the sequence.
1291 * If there aren't any, we're done.
1344 qpkt.li_vn_mode = PKT_LI_VN_MODE(0, pktversion, MODE_CONTROL);
1345 qpkt.r_m_e_op = (u_char)(opcode & CTL_OP_MASK);
1346 qpkt.sequence = htons(sequence);
1347 qpkt.status = 0;
1348 qpkt.associd = htons((u_short)associd);
1349 qpkt.offset = 0;
1350 qpkt.count = htons((u_short)qsize);
1355 * If we have data, copy and pad it out to a 32-bit boundary.
1358 memcpy(&qpkt.u, qdata, (size_t)qsize);
1361 qpkt.u.data[qsize++] = 0;
1367 * If it isn't authenticated we can just send it. Otherwise
1368 * we're going to have to think about it a little.
1376 * receiver can handle it.
1379 qpkt.u.data[qsize++] = 0;
1384 * Get the keyid and the password if we don't have one.
1407 * Do the encryption.
1426 * show_error_msg - display the error text for a mode 6 error response.
1498 * error messages for any error responses.
1519 * displaying error messages for any error responses.
1557 * Get the response. If we got a standard error, print a message
1566 * get confused about differing fragments.
1643 * Tokenize the command line. If nothing on it, return.
1658 * Find the appropriate command description.
1678 * as we go.
1680 pcmd.keyword = tokens[0];
1681 pcmd.nargs = 0;
1692 if (!getarg(tokens[i+1], (int)xcmd->arg[i], &pcmd.argval[i]))
1694 pcmd.nargs++;
1755 * eating inter-token whitespace) the 2nd token is the rest of the line.
1783 * with a ':', then just grab to EOL.
1794 /* Check if this token begins with a double quote.
1870 argp->uval = assoc_cache[ul - 1].assid;
1938 * Could be extact match, could be approximate.
1940 * same as the str.
1952 * See if there is more to do. If so, go again. Sorry about the
1953 * goto, too much looking at BSD sources...
1962 * of matches.
1987 hints.ai_flags = AI_CANONNAME;
1989 hints.ai_flags |= AI_ADDRCONFIG;
2023 * nntohost - convert network number to host name. This routine enforces
2024 * the showhostnames setting.
2036 * nntohost_col - convert network number to host name in fixed width.
2037 * This routine enforces the showhostnames setting.
2039 * the first part of the hostname is displayed. When
2042 * the first or last of the numeric address is used.
2104 cal.yearday = 0;
2111 * (No docs, but assume 4-digit years are also legal...)
2127 cal.monthday = (u_char) (*cp++ - '0'); /* ascii dependent */
2129 cal.monthday = (u_char)((cal.monthday << 3) + (cal.monthday << 1));
2130 cal.monthday = (u_char)(cal.monthday + *cp++ - '0');
2145 cal.month = (u_char)(i + 1);
2152 cal.year = (u_short)(*cp++ - '0');
2154 cal.year = (u_short)((cal.year << 3) + (cal.year << 1));
2155 cal.year = (u_short)(*cp++ - '0');
2158 cal.year = (u_short)((cal.year << 3) + (cal.year << 1));
2159 cal.year = (u_short)(cal.year + *cp++ - '0');
2162 cal.year = (u_short)((cal.year << 3) + (cal.year << 1));
2163 cal.year = (u_short)(cal.year + *cp++ - '0');
2167 * Catch special case. If cal.year == 0 this is a zero timestamp.
2169 if (cal.year == 0) {
2176 cal.hour = (u_char)(*cp++ - '0');
2178 cal.hour = (u_char)((cal.hour << 3) + (cal.hour << 1));
2179 cal.hour = (u_char)(cal.hour + *cp++ - '0');
2184 cal.minute = (u_char)(*cp++ - '0');
2186 cal.minute = (u_char)((cal.minute << 3) + (cal.minute << 1));
2187 cal.minute = (u_char)(cal.minute + *cp++ - '0');
2192 cal.second = (u_char)(*cp++ - '0');
2194 cal.second = (u_char)((cal.second << 3) + (cal.second << 1));
2195 cal.second = (u_char)(cal.second + *cp++ - '0');
2201 if (cal.year < 72)
2202 cal.year += 2000;
2203 if (cal.year < 100)
2204 cal.year += 1900;
2216 * consideration of fuzzball formats.
2229 * If it starts with a 0x, decode as hex.
2235 * If it starts with a '"', try it as an RT-11 date.
2248 * Might still be hex. Check out the first character. Talk
2255 * Try it as a decimal. If this fails, try as an unquoted
2256 * RT-11 date. This code should go away eventually.
2266 * decodetime - decode a time value. It should be in milliseconds
2400 fprintf(fp, "%-*.*s", (int)col,
2405 cmd = pcmd->argval[0].string;
2474 val = (int)tvout.tv_sec * 1000 + tvout.tv_usec / 1000;
2477 tvout.tv_sec = pcmd->argval[0].uval / 1000;
2478 tvout.tv_usec = (pcmd->argval[0].uval - ((long)tvout.tv_sec * 1000))
2497 val = delay_time.l_ui * 1000 + delay_time.l_uf / 4294967;
2500 if (pcmd->argval[0].ival < 0) {
2502 val = (u_long)(-pcmd->argval[0].ival);
2505 val = (u_long)pcmd->argval[0].ival;
2508 delay_time.l_ui = val / 1000;
2510 delay_time.l_uf = val * 4294967; /* 2**32/1000 */
2519 * host - set the host we are dealing with.
2541 if (!strcmp("-4", pcmd->argval[i].string))
2543 else if (!strcmp("-6", pcmd->argval[i].string))
2549 if (openhost(pcmd->argval[i].string, ai_fam_templ)) {
2605 } else if (STREQ(pcmd->argval[0].string, "hash")) {
2607 } else if (STREQ(pcmd->argval[0].string, "ipv4")) {
2632 /* allow zero so that keyid can be cleared. */
2633 if(pcmd->argval[0].uval > NTP_MAXKEY)
2635 info_auth_keyid = pcmd->argval[0].uval;
2659 digest_name = pcmd->argval[0].string;
2664 fprintf(fp, "keytype is not valid. "
2666 "Type \"help keytype\" for the available digest types.\n");
2668 "Only \"md5\" is available.\n");
2698 pass = pcmd->argval[0].string;
2727 if (STREQ(pcmd->argval[0].string, "yes"))
2729 else if (STREQ(pcmd->argval[0].string, "no"))
2750 } else if (STREQ(pcmd->argval[0].string, "no")) {
2752 } else if (STREQ(pcmd->argval[0].string, "more")) {
2754 } else if (STREQ(pcmd->argval[0].string, "less")) {
2844 if (STREQ(pcmd->argval[0].string, "yes")) {
2846 } else if (STREQ(pcmd->argval[0].string, "no")) {
2867 if (pcmd->argval[0].uval < NTP_OLDVERSION
2868 || pcmd->argval[0].uval > NTP_VERSION) {
2872 pktversion = (u_char) pcmd->argval[0].uval;
2893 ...
2909 ...
2955 * transformations cat -v uses.
3015 * transformations that cat -v uses.
3066 * truncate string to fit clipping excess at end.
3068 * Used for hostnames.
3096 * Used for local IPv6 addresses, where low bits differentiate.
3134 * some pitfalls.
3145 * to copy names and values into local buffers. If these would overflow,
3146 * the item should be skipped without terminating the parsing sequence.
3149 * we treat that equivalent.
3151 * Parsing an item definitely breaks on a CR/LF. If an item is not
3152 * followed by a comma (','), parsing stops. In the middle of a quoted
3154 * returning a value.
3157 * only CR, LF, ',', '=' and '"' are characters with a special meaning.
3159 * through the buffer, before making the local copies. If whitespace
3160 * stripping results in an empty name, parsing resumes.
3185 /* predicate: characters *between* list items. We're relaxed here. */
3254 fprintf(ofp, "nextvar: %s: '%.*s'\n",
3360 * over. If there's no name at all after whitespace stripping,
3361 * redo silently.
3404 if (!strcmp(varname, cookedvars[n].varname))
3405 return cookedvars[n].fmt;
3448 * Essentially print the data as is. We reformat unprintables, though.
3460 * \n, supress this, else pretty print it. Otherwise
3461 * just output the character.
3627 l = strlcpy (cp, "...", cb);
3716 * and output them as text.
3719 unsigned char *str = (unsigned char *)&(hval.sa4).sin_addr;
3857 * room for malloc() bookkeeping overhead equivalent to 4 pointers.
3879 * on the command line. This routine replaces the default handler for
3881 * the order.
3946 /* Discard MACs that NTP won't accept. */
3947 /* Keep this consistent with keytype_from_text() in ssl_init.c. */
3955 /* There are duplicates. Discard if name has been seen. */
4113 hstate.seen = emalloc_zero(sizeof(const char*));
4117 list = hstate.list;
4118 free((void *)hstate.seen);
4187 ...
4197 * increment in buffer size actually overflows.
4206 /* might be very old vsnprintf. Or actually MSVC... */
4211 /* at least we have the proper size now... */