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 */
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 );
547 builtins[icmd].desc[0] = "digest-name";
565 argc -= optct;
570 * Process options other than -c and -p, which are specially
600 if ('-' == *argv[ihost]) {
661 * openhost - open a socket to a host
683 if (!cp || (octets = (size_t)(cp - hname) - 1) >= sizeof(name)) {
697 * will return an "IPv4-mapped IPv6 address" address if you
724 * is useful to short-circuit DNS lookups for IP protocols
727 * to off-host connectivity and so fails lookup when
734 * So we get more ugly platform-specific workarounds.
752 octets = min(sizeof(addr), ai->ai_addrlen);
753 memcpy(&addr, ai->ai_addr, octets);
755 if (ai->ai_canonname == NULL) {
759 strlcpy(temphost, ai->ai_canonname, sizeof(temphost));
766 (ai->ai_family == AF_INET)
768 : (ai->ai_family == AF_INET6)
770 : "AF-???"
784 ((struct sockaddr_in6 *)&hostaddr)->sin6_port = htons(SERVER_PORT_NUM);
785 if (ai->ai_family == AF_INET)
787 *((struct sockaddr_in *)ai->ai_addr);
790 *((struct sockaddr_in6 *)ai->ai_addr);
810 sockfd = socket(ai->ai_family, ai->ai_socktype,
811 ai->ai_protocol);
823 (void *)&rbufsize, sizeof(int)) == -1)
832 sizeof(hostaddr)) == -1)
834 (connect(sockfd, (struct sockaddr *)ai->ai_addr,
835 ai->ai_addrlen) == -1)
860 *---------------
876 len -= rowlen;
887 } while (--rowlen);
898 * sendpkt - send a packet to the remote host
909 if (send(sockfd, xdata, xdatalen, 0) == -1) {
911 return -1;
922 * getresponse - get a (series of) response packet(s) and return the data
949 uint32_t tobase; /* base value for timeout */
989 if (n == -1) {
996 * Under non-windows targets we map EINTR as
1006 return -1;
1013 todiff = (((uint32_t)time(NULL)) - tobase) & 0x7FFFFFFFu;
1016 n -= n; /* faked timeout return from 'select()',
1058 return -1;
1112 * Check the error code. If non-zero, return it.
1117 TRACE(1, ("Error code %d received on not-final packet\n",
1147 * validate received payload size is padded to next 32-bit
1160 count, (long)(n - CTL_HEADER_LEN));
1176 maclen = n - shouldbesize;
1183 (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_int32) - 3]),
1184 (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_int32) - 2]),
1185 (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_int32) - 1]),
1186 (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_int32)]),
1187 (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_int32) + 1]),
1188 (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_int32) + 2]));
1189 key = ntohl(lpkt[(n - maclen) / sizeof(u_int32)]);
1195 n - maclen, maclen)) {
1205 if (count > (n - CTL_HEADER_LEN)) {
1207 count, (long)n - CTL_HEADER_LEN));
1211 TRACE(1, ("Received count of 0 in non-final fragment\n"));
1230 if (numfrags > (MAXFRAGS - 1)) {
1232 MAXFRAGS - 1));
1252 if (f > 0 && (offsets[f-1] + counts[f-1]) > offset) {
1254 offset, counts[f-1], offsets[f-1]));
1264 for (ff = numfrags; ff > f; ff--) {
1265 offsets[ff] = offsets[ff-1];
1266 counts[ff] = counts[ff-1];
1284 * timout base in case we need more.
1299 if (offsets[f-1] + counts[f-1] !=
1303 *rsize = offsets[f-1] + counts[f-1];
1314 * sendrequest - format and send a request packet
1355 * If we have data, copy and pad it out to a 32-bit boundary.
1360 while (pktsize & (sizeof(u_int32) - 1)) {
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;
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++) {
1684 if (!(xcmd->arg[i] & OPT)) {
1690 if ((xcmd->arg[i] & OPT) && (*tokens[i+1] == '>'))
1692 if (!getarg(tokens[i+1], (int)xcmd->arg[i], &pcmd.argval[i]))
1730 (xcmd->handler)(&pcmd, current_output);
1740 (xcmd->handler)(&pcmd, current_output);
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 */
1788 if (sp - tspace >= MAXLINE)
1800 if (sp - tspace >= MAXLINE)
1808 if (sp - tspace >= MAXLINE)
1815 if (sp - tspace >= MAXLINE)
1831 * getarg - interpret an argument token
1844 argp->string = str;
1848 if (!getnetnum(str, &argp->netnum, NULL, 0))
1870 argp->uval = assoc_cache[ul - 1].assid;
1873 if (!atouint(str, &argp->uval)) {
1881 if (!atoint(str, &argp->ival)) {
1889 if (!strcmp("-6", str)) {
1890 argp->ival = 6;
1891 } else if (!strcmp("-4", str)) {
1892 argp->ival = 4;
1906 * findcmd - find a command in a command description table
1932 for (cl = clist; cl->keyword != 0; cl++) {
1934 if (*str != *(cl->keyword))
1936 if (strncmp(str, cl->keyword, (unsigned)clen) == 0) {
1942 if (*((cl->keyword) + clen) == '\0') {
1973 * getnetnum - given a host name, return its net number
1998 getnameinfo(&num->sa, SOCKLEN(num), fullhost,
2002 INSIST(sizeof(*num) >= ai->ai_addrlen);
2003 memcpy(num, ai->ai_addr, ai->ai_addrlen);
2005 if (ai->ai_canonname != NULL)
2006 strlcpy(fullhost, ai->ai_canonname,
2009 getnameinfo(&num->sa, SOCKLEN(num),
2023 * nntohost - convert network number to host name. This routine enforces
2031 return nntohost_col(netnum, LIB_BUFLENGTH - 1, FALSE);
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:
2109 * d[d]-Mth-y[y] hh:mm:ss
2111 * (No docs, but assume 4-digit years are also legal...)
2113 * d[d]-Mth-y[y[y[y]]] hh:mm:ss
2117 if (*cp == '-') {
2127 cal.monthday = (u_char) (*cp++ - '0'); /* ascii dependent */
2130 cal.monthday = (u_char)(cal.monthday + *cp++ - '0');
2133 if (*cp++ != '-')
2147 if (*cp++ != '-')
2152 cal.year = (u_short)(*cp++ - '0');
2155 cal.year = (u_short)(*cp++ - '0');
2159 cal.year = (u_short)(cal.year + *cp++ - '0');
2163 cal.year = (u_short)(cal.year + *cp++ - '0');
2176 cal.hour = (u_char)(*cp++ - '0');
2179 cal.hour = (u_char)(cal.hour + *cp++ - '0');
2184 cal.minute = (u_char)(*cp++ - '0');
2187 cal.minute = (u_char)(cal.minute + *cp++ - '0');
2192 cal.second = (u_char)(*cp++ - '0');
2195 cal.second = (u_char)(cal.second + *cp++ - '0');
2199 * For RT-11, 1972 seems to be the pivot year
2203 if (cal.year < 100)
2207 lfp->l_uf = 0;
2209 lfp->l_ui = caltontp(&cal);
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.
2241 b < COUNTOF(buf) - 1)
2256 * RT-11 date. This code should go away eventually.
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))
2359 * help - tell about commands, or details of a particular command
2369 const char *list[100];
2375 if (pcmd->nargs == 0) {
2377 for (xcp = builtins; xcp->keyword != NULL; xcp++) {
2378 if (*(xcp->keyword) != '?' &&
2380 list[words++] = xcp->keyword;
2382 for (xcp = opcmds; xcp->keyword != NULL; xcp++)
2384 list[words++] = xcp->keyword;
2394 rows = (words + cols - 1) / cols;
2400 fprintf(fp, "%-*.*s", (int)col,
2401 (int)col - 1, list[word]);
2405 cmd = pcmd->argval[0].string;
2416 fprintf(fp, "function: %s\n", xcp->comment);
2423 * helpsort - do hostname qsort comparisons
2439 * printusage - print usage information for a command
2451 (void) fprintf(fp, "usage: %s", xcp->keyword);
2452 for (i = 0; i < MAXARGS && xcp->arg[i] != NO; i++) {
2453 if (xcp->arg[i] & OPT)
2454 (void) fprintf(fp, " [ %s ]", xcp->desc[i]);
2456 (void) fprintf(fp, " %s", xcp->desc[i]);
2463 * timeout - set time out time
2473 if (pcmd->nargs == 0) {
2477 tvout.tv_sec = pcmd->argval[0].uval / 1000;
2478 tvout.tv_usec = (pcmd->argval[0].uval - ((long)tvout.tv_sec * 1000))
2485 * auth_delay - set delay for auth requests
2496 if (pcmd->nargs == 0) {
2500 if (pcmd->argval[0].ival < 0) {
2502 val = (u_long)(-pcmd->argval[0].ival);
2505 val = (u_long)pcmd->argval[0].ival;
2519 * host - set the host we are dealing with.
2529 if (pcmd->nargs == 0) {
2540 if (pcmd->nargs == 2) {
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)) {
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) {
2605 } else if (STREQ(pcmd->argval[0].string, "hash")) {
2607 } else if (STREQ(pcmd->argval[0].string, "ipv4")) {
2618 * keyid - get a keyid to use for authenticating requests
2626 if (pcmd->nargs == 0) {
2633 if(pcmd->argval[0].uval > NTP_MAXKEY)
2635 info_auth_keyid = pcmd->argval[0].uval;
2640 * keytype - get type of key to use for authenticating requests
2652 if (!pcmd->nargs) {
2659 digest_name = pcmd->argval[0].string;
2679 * passwd - get an authentication key
2697 if (pcmd->nargs >= 1)
2698 pass = pcmd->argval[0].string;
2713 * hostnames - set the showhostnames flag
2721 if (pcmd->nargs == 0) {
2727 if (STREQ(pcmd->argval[0].string, "yes"))
2729 else if (STREQ(pcmd->argval[0].string, "no"))
2739 * setdebug - set/change debugging level
2747 if (pcmd->nargs == 0) {
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")) {
2755 debug--;
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) {
2844 if (STREQ(pcmd->argval[0].string, "yes")) {
2846 } else if (STREQ(pcmd->argval[0].string, "no")) {
2855 * ntpversion - choose the NTP version to use
2863 if (pcmd->nargs == 0) {
2867 if (pcmd->argval[0].uval < NTP_OLDVERSION
2868 || pcmd->argval[0].uval > NTP_VERSION) {
2872 pktversion = (u_char) pcmd->argval[0].uval;
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;
2954 * atoascii - printable-ize possibly ascii data using the character
2955 * transformations cat -v uses.
2982 if (0 == --out_octets) { \
2995 ONEOUT('-');
3014 * makeascii - print possibly ascii data using the character
3015 * transformations that cat -v uses.
3034 putc('-', fp);
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) {
3095 * "too long" -> "_long"
3109 if (sl > width && LIB_BUFLENGTH - 1 > width && width > 1) {
3112 memcpy(&out[1], &src[sl + 1 - width], width);
3130 /* --------------------------------------------------------------------
3229 while (cpl != cpr && *(const unsigned char*)(cpr - 1) <= ' ')
3230 --cpr;
3232 len = (size_t)(cpr - cpl);
3250 size_t len = (size_t)(whend - where);
3267 * nextvar - find the next variable in the buffer
3299 case sInit: /* handle inter-item chars */
3315 nlen = (size_t)(*datap - np);
3334 vlen = (size_t)(*datap - vp);
3378 /* copy name and value into NUL-terminated buffers */
3388 *datalen = (size_t)(cpend - *datap);
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')
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--) {
3591 # error CBLEN is too small -- increase!
3607 cb -= l;
3613 cb -= l;
3625 cp += cb - 4;
3629 cb -= l;
3634 cb -= l;
3648 * cookedprint - output variables in cooked mode
3776 case FX:
3788 atoascii (value, MAXVALLEN, bv+1, sizeof(bv)-1);
3791 output_raw = '*'; /* output as-is */
3802 /* TALOS-CAN-0063: avoid buffer overrun */
3806 bv, sizeof(bv) - 1);
3822 * sortassoc - sort associations in the cache into ascending order
3834 * assoccmp - compare two associations
3845 if (ass1->assid < ass2->assid)
3846 return -1;
3847 if (ass1->assid > ass2->assid)
3854 * grow_assoc_cache() - enlarge dynamic assoc_cache array
3867 new_sz -= 4 * sizeof(void *);
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) {
3894 pOptDesc->optValue, pOptDesc->optValue);
3898 if ((pOptDesc->fOptState & OPTST_SET_MASK) == OPTST_DEFINED)
3900 ADDCMD(pOptDesc->pzLastArg);
3904 if ((pOptDesc->fOptState & OPTST_SET_MASK) == OPTST_DEFINED)
3941 /* m is MD obj, from is name or alias, to is base name for alias */
3957 for (seen = hstate->seen; *seen; seen++)
3961 n = (seen - hstate->seen) + 2;
3962 hstate->seen = erealloc((void *)hstate->seen, n * sizeof(*seen));
3963 hstate->seen[n-2] = name;
3964 hstate->seen[n-1] = NULL;
3966 if (hstate->list != NULL)
3967 len += strlen(hstate->list);
3969 len += (hstate->idx >= K_PER_LINE)
3973 if (hstate->list == NULL) {
3974 hstate->list = (char *)emalloc(len);
3975 hstate->list[0] = '\0';
3977 hstate->list = (char *)erealloc(hstate->list, len);
3980 sprintf(hstate->list + strlen(hstate->list), "%s%s",
3981 ((hstate->idx >= K_PER_LINE) ? K_NL_PFX_STR : K_DELIM_STR),
3984 if (hstate->idx >= K_PER_LINE)
3985 hstate->idx = 1;
3987 hstate->idx++;
4009 /* Check if CMAC already in list - future proofing */
4047 /* No - end of list */
4058 if (strncmp(CMAC, point, delim - point) < 0) {
4075 /* Space for list could move - save offset */
4076 ptrdiff_t p_offset = point - list;
4123 list = (char *)emalloc(sizeof("md5, others (upgrade to OpenSSL-1.0 for full list)"));
4124 strcpy(list, "md5, others (upgrade to OpenSSL-1.0 for full list)");
4162 --size;
4177 if ((*ctrlc_stack[--size])())
4215 if ((size_t)prc < (len - 32))