Lines Matching +full:100 +full:base +full:- +full:fx
2 * ntpq - query an NTP server using mode 6 commands
54 #ifdef SYS_VXWORKS /* vxWorks needs mode flag -casey*/
72 * use old readvars behavior? --old-rv processing in ntpq resets
73 * this value based on the presence or absence of --old-rv. It is
84 te_Refid drefid = -1;
125 #define FX 6 /* test flags */ macro
129 #define SN 10 /* signed number: must display +/- sign */
134 * mostly plain-text mode 6 responses. A few variable names are by
135 * default "cooked" to provide more human-friendly output.
146 { "flash", FX },
262 * Built-in commands we understand
278 { "-4|-6", "hostname", "", "" },
345 #define MAXCMDS 100 /* maximum commands on cmd line */
398 * For commands typed on the command line (with the -c option)
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.
487 * main - parse arguments and handle options
514 taskPrioritySet(taskIdSelf(), 100 ); in ntpqmain()
547 builtins[icmd].desc[0] = "digest-name"; in ntpqmain()
565 argc -= optct; in ntpqmain()
570 * Process options other than -c and -p, which are specially in ntpqmain()
600 if ('-' == *argv[ihost]) { in ntpqmain()
661 * openhost - open a socket to a host
683 if (!cp || (octets = (size_t)(cp - hname) - 1) >= sizeof(name)) { in openhost()
697 * will return an "IPv4-mapped IPv6 address" address if you in openhost()
724 * is useful to short-circuit DNS lookups for IP protocols in openhost()
727 * to off-host connectivity and so fails lookup when in openhost()
734 * So we get more ugly platform-specific workarounds. in openhost()
752 octets = min(sizeof(addr), ai->ai_addrlen); in openhost()
753 memcpy(&addr, ai->ai_addr, octets); in openhost()
755 if (ai->ai_canonname == NULL) { in openhost()
759 strlcpy(temphost, ai->ai_canonname, sizeof(temphost)); in openhost()
766 (ai->ai_family == AF_INET) in openhost()
768 : (ai->ai_family == AF_INET6) in openhost()
770 : "AF-???" in openhost()
784 ((struct sockaddr_in6 *)&hostaddr)->sin6_port = htons(SERVER_PORT_NUM); in openhost()
785 if (ai->ai_family == AF_INET) in openhost()
787 *((struct sockaddr_in *)ai->ai_addr); in openhost()
790 *((struct sockaddr_in6 *)ai->ai_addr); in openhost()
810 sockfd = socket(ai->ai_family, ai->ai_socktype, in openhost()
811 ai->ai_protocol); in openhost()
823 (void *)&rbufsize, sizeof(int)) == -1) in openhost()
832 sizeof(hostaddr)) == -1) in openhost()
834 (connect(sockfd, (struct sockaddr *)ai->ai_addr, in openhost()
835 ai->ai_addrlen) == -1) in openhost()
860 *--------------- in dump_hex_printable()
876 len -= rowlen; in dump_hex_printable()
887 } while (--rowlen); in dump_hex_printable()
898 * sendpkt - send a packet to the remote host
909 if (send(sockfd, xdata, xdatalen, 0) == -1) { in sendpkt()
911 return -1; in sendpkt()
922 * getresponse - get a (series of) response packet(s) and return the data
949 uint32_t tobase; /* base value for timeout */ in getresponse()
989 if (n == -1) { in getresponse()
996 * Under non-windows targets we map EINTR as in getresponse()
1006 return -1; in getresponse()
1013 todiff = (((uint32_t)time(NULL)) - tobase) & 0x7FFFFFFFu; in getresponse()
1016 n -= n; /* faked timeout return from 'select()', in getresponse()
1058 return -1; in getresponse()
1112 * Check the error code. If non-zero, return it. in getresponse()
1117 TRACE(1, ("Error code %d received on not-final packet\n", in getresponse()
1147 * validate received payload size is padded to next 32-bit in getresponse()
1160 count, (long)(n - CTL_HEADER_LEN)); in getresponse()
1176 maclen = n - shouldbesize; in getresponse()
1183 (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_int32) - 3]), in getresponse()
1184 (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_int32) - 2]), in getresponse()
1185 (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_int32) - 1]), in getresponse()
1186 (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_int32)]), in getresponse()
1187 (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_int32) + 1]), in getresponse()
1188 (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_int32) + 2])); in getresponse()
1189 key = ntohl(lpkt[(n - maclen) / sizeof(u_int32)]); in getresponse()
1195 n - maclen, maclen)) { in getresponse()
1205 if (count > (n - CTL_HEADER_LEN)) { in getresponse()
1207 count, (long)n - CTL_HEADER_LEN)); in getresponse()
1211 TRACE(1, ("Received count of 0 in non-final fragment\n")); in getresponse()
1230 if (numfrags > (MAXFRAGS - 1)) { in getresponse()
1232 MAXFRAGS - 1)); in getresponse()
1252 if (f > 0 && (offsets[f-1] + counts[f-1]) > offset) { in getresponse()
1254 offset, counts[f-1], offsets[f-1])); in getresponse()
1264 for (ff = numfrags; ff > f; ff--) { in getresponse()
1265 offsets[ff] = offsets[ff-1]; in getresponse()
1266 counts[ff] = counts[ff-1]; in getresponse()
1284 * timout base in case we need more. in getresponse()
1299 if (offsets[f-1] + counts[f-1] != in getresponse()
1303 *rsize = offsets[f-1] + counts[f-1]; in getresponse()
1314 * sendrequest - format and send a request packet
1355 * If we have data, copy and pad it out to a 32-bit boundary. in sendrequest()
1360 while (pktsize & (sizeof(u_int32) - 1)) { in sendrequest()
1426 * show_error_msg - display the error text for a mode 6 error response.
1497 * doquery - send a request and process the response, displaying
1518 * doqueryex - send a request and process the response, optionally
1542 return -1; in doqueryex()
1583 * getcmds - read commands from the standard input and execute them
1608 * abortcmd - catch interrupts and abort the current command
1628 * docmd - decode the command line and execute a command
1682 for (i = 0; i < MAXARGS && xcmd->arg[i] != NO; i++) { in docmd()
1684 if (!(xcmd->arg[i] & OPT)) { in docmd()
1690 if ((xcmd->arg[i] & OPT) && (*tokens[i+1] == '>')) in docmd()
1692 if (!getarg(tokens[i+1], (int)xcmd->arg[i], &pcmd.argval[i])) in docmd()
1730 (xcmd->handler)(&pcmd, current_output); in docmd()
1740 (xcmd->handler)(&pcmd, current_output); in docmd()
1750 * tokenize - turn a command line into tokens
1755 * eating inter-token whitespace) the 2nd token is the rest of the line.
1774 /* Skip inter-token whitespace */ in tokenize()
1788 if (sp - tspace >= MAXLINE) in tokenize()
1800 if (sp - tspace >= MAXLINE) in tokenize()
1808 if (sp - tspace >= MAXLINE) in tokenize()
1815 if (sp - tspace >= MAXLINE) in tokenize()
1831 * getarg - interpret an argument token
1844 argp->string = str; in getarg()
1848 if (!getnetnum(str, &argp->netnum, NULL, 0)) in getarg()
1870 argp->uval = assoc_cache[ul - 1].assid; in getarg()
1873 if (!atouint(str, &argp->uval)) { in getarg()
1881 if (!atoint(str, &argp->ival)) { in getarg()
1889 if (!strcmp("-6", str)) { in getarg()
1890 argp->ival = 6; in getarg()
1891 } else if (!strcmp("-4", str)) { in getarg()
1892 argp->ival = 4; in getarg()
1906 * findcmd - find a command in a command description table
1932 for (cl = clist; cl->keyword != 0; cl++) { in findcmd()
1934 if (*str != *(cl->keyword)) in findcmd()
1936 if (strncmp(str, cl->keyword, (unsigned)clen) == 0) { in findcmd()
1942 if (*((cl->keyword) + clen) == '\0') { in findcmd()
1973 * getnetnum - given a host name, return its net number
1998 getnameinfo(&num->sa, SOCKLEN(num), fullhost, in getnetnum()
2002 INSIST(sizeof(*num) >= ai->ai_addrlen); in getnetnum()
2003 memcpy(num, ai->ai_addr, ai->ai_addrlen); in getnetnum()
2005 if (ai->ai_canonname != NULL) in getnetnum()
2006 strlcpy(fullhost, ai->ai_canonname, in getnetnum()
2009 getnameinfo(&num->sa, SOCKLEN(num), in getnetnum()
2023 * nntohost - convert network number to host name. This routine enforces
2031 return nntohost_col(netnum, LIB_BUFLENGTH - 1, FALSE); in nntohost()
2036 * nntohost_col - convert network number to host name in fixed width.
2091 * rtdatetolfp - decode an RT-11 date into an l_fp
2107 * An RT-11 date looks like: in rtdatetolfp()
2109 * d[d]-Mth-y[y] hh:mm:ss in rtdatetolfp()
2111 * (No docs, but assume 4-digit years are also legal...) in rtdatetolfp()
2113 * d[d]-Mth-y[y[y[y]]] hh:mm:ss in rtdatetolfp()
2117 if (*cp == '-') { in rtdatetolfp()
2127 cal.monthday = (u_char) (*cp++ - '0'); /* ascii dependent */ in rtdatetolfp()
2130 cal.monthday = (u_char)(cal.monthday + *cp++ - '0'); in rtdatetolfp()
2133 if (*cp++ != '-') in rtdatetolfp()
2147 if (*cp++ != '-') in rtdatetolfp()
2152 cal.year = (u_short)(*cp++ - '0'); in rtdatetolfp()
2155 cal.year = (u_short)(*cp++ - '0'); in rtdatetolfp()
2159 cal.year = (u_short)(cal.year + *cp++ - '0'); in rtdatetolfp()
2163 cal.year = (u_short)(cal.year + *cp++ - '0'); in rtdatetolfp()
2176 cal.hour = (u_char)(*cp++ - '0'); in rtdatetolfp()
2179 cal.hour = (u_char)(cal.hour + *cp++ - '0'); in rtdatetolfp()
2184 cal.minute = (u_char)(*cp++ - '0'); in rtdatetolfp()
2187 cal.minute = (u_char)(cal.minute + *cp++ - '0'); in rtdatetolfp()
2192 cal.second = (u_char)(*cp++ - '0'); in rtdatetolfp()
2195 cal.second = (u_char)(cal.second + *cp++ - '0'); in rtdatetolfp()
2199 * For RT-11, 1972 seems to be the pivot year in rtdatetolfp()
2203 if (cal.year < 100) in rtdatetolfp()
2207 lfp->l_uf = 0; in rtdatetolfp()
2209 lfp->l_ui = caltontp(&cal); in rtdatetolfp()
2215 * decodets - decode a timestamp into an l_fp format number, with
2235 * If it starts with a '"', try it as an RT-11 date. in decodets()
2241 b < COUNTOF(buf) - 1) in decodets()
2256 * RT-11 date. This code should go away eventually. in decodets()
2266 * decodetime - decode a time value. It should be in milliseconds
2279 * decodeint - decode an integer
2297 * decodeuint - decode an unsigned integer
2315 * decodearr - decode an array of time values
2338 if (bp != (buf + sizeof(buf) - 1)) in decodearr()
2359 * help - tell about commands, or details of a particular command
2369 const char *list[100]; in help()
2375 if (pcmd->nargs == 0) { in help()
2377 for (xcp = builtins; xcp->keyword != NULL; xcp++) { in help()
2378 if (*(xcp->keyword) != '?' && in help()
2380 list[words++] = xcp->keyword; in help()
2382 for (xcp = opcmds; xcp->keyword != NULL; xcp++) in help()
2384 list[words++] = xcp->keyword; in help()
2394 rows = (words + cols - 1) / cols; in help()
2400 fprintf(fp, "%-*.*s", (int)col, in help()
2401 (int)col - 1, list[word]); in help()
2405 cmd = pcmd->argval[0].string; in help()
2416 fprintf(fp, "function: %s\n", xcp->comment); in help()
2423 * helpsort - do hostname qsort comparisons
2439 * printusage - print usage information for a command
2451 (void) fprintf(fp, "usage: %s", xcp->keyword); in printusage()
2452 for (i = 0; i < MAXARGS && xcp->arg[i] != NO; i++) { in printusage()
2453 if (xcp->arg[i] & OPT) in printusage()
2454 (void) fprintf(fp, " [ %s ]", xcp->desc[i]); in printusage()
2456 (void) fprintf(fp, " %s", xcp->desc[i]); in printusage()
2463 * timeout - set time out time
2473 if (pcmd->nargs == 0) { in timeout()
2477 tvout.tv_sec = pcmd->argval[0].uval / 1000; in timeout()
2478 tvout.tv_usec = (pcmd->argval[0].uval - ((long)tvout.tv_sec * 1000)) in timeout()
2485 * auth_delay - set delay for auth requests
2496 if (pcmd->nargs == 0) { in auth_delay()
2500 if (pcmd->argval[0].ival < 0) { in auth_delay()
2502 val = (u_long)(-pcmd->argval[0].ival); in auth_delay()
2505 val = (u_long)pcmd->argval[0].ival; in auth_delay()
2519 * host - set the host we are dealing with.
2529 if (pcmd->nargs == 0) { in host()
2540 if (pcmd->nargs == 2) { in host()
2541 if (!strcmp("-4", pcmd->argval[i].string)) in host()
2543 else if (!strcmp("-6", pcmd->argval[i].string)) in host()
2549 if (openhost(pcmd->argval[i].string, ai_fam_templ)) { in host()
2563 * poll - do one (or more) polls of the host via NTP
2577 * showdrefid2str - return a string explanation of the value of drefid
2594 * drefid - display/change "display hash"
2602 if (pcmd->nargs == 0) { in showdrefid()
2605 } else if (STREQ(pcmd->argval[0].string, "hash")) { in showdrefid()
2607 } else if (STREQ(pcmd->argval[0].string, "ipv4")) { in showdrefid()
2618 * keyid - get a keyid to use for authenticating requests
2626 if (pcmd->nargs == 0) { in keyid()
2633 if(pcmd->argval[0].uval > NTP_MAXKEY) in keyid()
2635 info_auth_keyid = pcmd->argval[0].uval; in keyid()
2640 * keytype - get type of key to use for authenticating requests
2652 if (!pcmd->nargs) { in keytype()
2659 digest_name = pcmd->argval[0].string; in keytype()
2679 * passwd - get an authentication key
2697 if (pcmd->nargs >= 1) in passwd()
2698 pass = pcmd->argval[0].string; in passwd()
2713 * hostnames - set the showhostnames flag
2721 if (pcmd->nargs == 0) { in hostnames()
2727 if (STREQ(pcmd->argval[0].string, "yes")) in hostnames()
2729 else if (STREQ(pcmd->argval[0].string, "no")) in hostnames()
2739 * setdebug - set/change debugging level
2747 if (pcmd->nargs == 0) { in setdebug()
2750 } else if (STREQ(pcmd->argval[0].string, "no")) { in setdebug()
2752 } else if (STREQ(pcmd->argval[0].string, "more")) { in setdebug()
2754 } else if (STREQ(pcmd->argval[0].string, "less")) { in setdebug()
2755 debug--; in setdebug()
2765 * quit - stop this nonsense
2781 * version - print the current version number
2797 * raw - set raw mode output
2812 * cooked - set cooked mode output
2828 * authenticate - always authenticate requests to this host
2836 if (pcmd->nargs == 0) { in authenticate()
2844 if (STREQ(pcmd->argval[0].string, "yes")) { in authenticate()
2846 } else if (STREQ(pcmd->argval[0].string, "no")) { in authenticate()
2855 * ntpversion - choose the NTP version to use
2863 if (pcmd->nargs == 0) { in ntpversion()
2867 if (pcmd->argval[0].uval < NTP_OLDVERSION in ntpversion()
2868 || pcmd->argval[0].uval > NTP_VERSION) { in ntpversion()
2872 pktversion = (u_char) pcmd->argval[0].uval; in ntpversion()
2888 * warning - print a warning message
2904 * error - print a message and exit
2919 * getkeyid - prompt the user for a keyid to use
2941 for (i = 0, ilim = COUNTOF(pbuf) - 1; in getkeyid()
2954 * atoascii - printable-ize possibly ascii data using the character
2955 * transformations cat -v uses.
2982 if (0 == --out_octets) { \ in atoascii()
2995 ONEOUT('-'); in atoascii()
3014 * makeascii - print possibly ascii data using the character
3015 * transformations that cat -v uses.
3034 putc('-', fp); in makeascii()
3051 * asciize - same thing as makeascii except add a newline
3067 * "too long" -> "too l"
3081 if (sl > width && LIB_BUFLENGTH - 1 > width && width > 0) { in trunc_right()
3095 * "too long" -> "_long"
3109 if (sl > width && LIB_BUFLENGTH - 1 > width && width > 1) { in trunc_left()
3112 memcpy(&out[1], &src[sl + 1 - width], width); in trunc_left()
3130 /* --------------------------------------------------------------------
3229 while (cpl != cpr && *(const unsigned char*)(cpr - 1) <= ' ') in str_strip()
3230 --cpr; in str_strip()
3232 len = (size_t)(cpr - cpl); in str_strip()
3250 size_t len = (size_t)(whend - where); in pf_error()
3267 * nextvar - find the next variable in the buffer
3299 case sInit: /* handle inter-item chars */ in nextvar()
3315 nlen = (size_t)(*datap - np); in nextvar()
3334 vlen = (size_t)(*datap - vp); in nextvar()
3378 /* copy name and value into NUL-terminated buffers */ in nextvar()
3388 *datalen = (size_t)(cpend - *datap); in nextvar()
3412 * printvars - print variables returned in response packet
3432 * rawprint - do a printout of the data in raw mode
3463 if (cp == (cpend - 1) || *(cp + 1) != '\n') in rawprint()
3482 * startoutput - get ready to do cooked output
3493 * output - output a variable=value combination
3527 * endoutput - terminate a block of cooked output
3540 * outputarr - output an array of values
3564 for (i = narr; i > 0; i--) { in outputarr()
3591 # error CBLEN is too small -- increase! in tstflags()
3607 cb -= l; in tstflags()
3613 cb -= l; in tstflags()
3625 cp += cb - 4; in tstflags()
3629 cb -= l; in tstflags()
3634 cb -= l; in tstflags()
3648 * cookedprint - output variables in cooked mode
3776 case FX: in cookedprint()
3788 atoascii (value, MAXVALLEN, bv+1, sizeof(bv)-1); in cookedprint()
3791 output_raw = '*'; /* output as-is */ in cookedprint()
3802 /* TALOS-CAN-0063: avoid buffer overrun */ in cookedprint()
3806 bv, sizeof(bv) - 1); in cookedprint()
3822 * sortassoc - sort associations in the cache into ascending order
3834 * assoccmp - compare two associations
3845 if (ass1->assid < ass2->assid) in assoccmp()
3846 return -1; in assoccmp()
3847 if (ass1->assid > ass2->assid) in assoccmp()
3854 * grow_assoc_cache() - enlarge dynamic assoc_cache array
3867 new_sz -= 4 * sizeof(void *); in grow_assoc_cache()
3876 * ntpq_custom_opt_handler - autoopts handler for -c and -p
3878 * By default, autoopts loses the relative order of -c and -p options
3889 switch (pOptDesc->optValue) { in ntpq_custom_opt_handler()
3894 pOptDesc->optValue, pOptDesc->optValue); in ntpq_custom_opt_handler()
3898 if ((pOptDesc->fOptState & OPTST_SET_MASK) == OPTST_DEFINED) in ntpq_custom_opt_handler()
3900 ADDCMD(pOptDesc->pzLastArg); in ntpq_custom_opt_handler()
3904 if ((pOptDesc->fOptState & OPTST_SET_MASK) == OPTST_DEFINED) in ntpq_custom_opt_handler()
3941 /* m is MD obj, from is name or alias, to is base name for alias */ in list_md_fn()
3957 for (seen = hstate->seen; *seen; seen++) in list_md_fn()
3961 n = (seen - hstate->seen) + 2; in list_md_fn()
3962 hstate->seen = erealloc((void *)hstate->seen, n * sizeof(*seen)); in list_md_fn()
3963 hstate->seen[n-2] = name; in list_md_fn()
3964 hstate->seen[n-1] = NULL; in list_md_fn()
3966 if (hstate->list != NULL) in list_md_fn()
3967 len += strlen(hstate->list); in list_md_fn()
3969 len += (hstate->idx >= K_PER_LINE) in list_md_fn()
3973 if (hstate->list == NULL) { in list_md_fn()
3974 hstate->list = (char *)emalloc(len); in list_md_fn()
3975 hstate->list[0] = '\0'; in list_md_fn()
3977 hstate->list = (char *)erealloc(hstate->list, len); in list_md_fn()
3980 sprintf(hstate->list + strlen(hstate->list), "%s%s", in list_md_fn()
3981 ((hstate->idx >= K_PER_LINE) ? K_NL_PFX_STR : K_DELIM_STR), in list_md_fn()
3984 if (hstate->idx >= K_PER_LINE) in list_md_fn()
3985 hstate->idx = 1; in list_md_fn()
3987 hstate->idx++; in list_md_fn()
4009 /* Check if CMAC already in list - future proofing */ in insert_cmac()
4047 /* No - end of list */ in insert_cmac()
4058 if (strncmp(CMAC, point, delim - point) < 0) { in insert_cmac()
4075 /* Space for list could move - save offset */ in insert_cmac()
4076 ptrdiff_t p_offset = point - list; in insert_cmac()
4123 list = (char *)emalloc(sizeof("md5, others (upgrade to OpenSSL-1.0 for full list)")); in list_digest_names()
4124 strcpy(list, "md5, others (upgrade to OpenSSL-1.0 for full list)"); in list_digest_names()
4162 --size; in pop_ctrl_c_handler()
4177 if ((*ctrlc_stack[--size])()) in on_ctrlc()
4215 if ((size_t)prc < (len - 32)) in my_easprintf()