Lines Matching +full:lo +full:- +full:x2 +full:- +full:en
2 * ntpq-subs.c - subroutines which are called to perform ntpq commands.
11 #include "ntpq-opts.h"
159 { "-4|-6", "", "", "" },
162 { "-4|-6", "", "", "" },
165 { "-4|-6", "", "", "" },
168 { "-4|-6", "", "", "" },
171 { "-4|-6", "", "", "" },
176 { "config-from-file", config_from_file, { NTP_STR, NO, NO, NO },
210 { "-4|-6", "", "", "" }, "" }
222 #define MRU_GOT_LAST 0x2
247 "-lstint", /* MRUSORT_R_DEF */
249 "-avgint", /* MRUSORT_R_AVGINT */
251 "-addr", /* MRUSORT_R_ADDR */
253 "-count", /* MRUSORT_R_COUNT */
274 char flash3[] = " x.-+#*o"; /* flash decode for peer status version 3 */
390 * NULL-pointer safe FILE I/O: use stderr if no file supplied.
427 * checkassocid - return the association ID, checking to see if it is valid
451 * findlistvar - Look for the named variable in a varlist. If found,
464 for (vl = list; vl < list + MAXLIST && vl->name != NULL; vl++)
465 if (!strcmp(name, vl->name))
475 * doaddvlist - add variable(s) to the variable list
497 if (NULL == vl->name) {
498 vl->name = estrdup(name);
499 } else if (vl->value != NULL) {
500 free(vl->value);
501 vl->value = NULL;
505 vl->value = estrdup(value);
511 * dormvlist - remove variable(s) from the variable list
528 if (vl == 0 || vl->name == 0) {
532 free((void *)(intptr_t)vl->name);
533 if (vl->value != 0)
534 free(vl->value);
536 && (vl+1)->name != 0; vl++) {
537 vl->name = (vl+1)->name;
538 vl->value = (vl+1)->value;
540 vl->name = vl->value = 0;
547 * doclearvlist - clear a variable list
556 for (vl = vlist; vl < vlist + MAXLIST && vl->name != 0; vl++) {
557 free((void *)(intptr_t)vl->name);
558 vl->name = 0;
559 if (vl->value != 0) {
560 free(vl->value);
561 vl->value = 0;
568 * makequerydata - form a data buffer to be included with a query
585 for (vl = vlist; vl < vlist + MAXLIST && vl->name != 0; vl++) {
586 namelen = strlen(vl->name);
587 if (vl->value == 0)
590 valuelen = strlen(vl->value);
595 vl->name);
601 memcpy(cp, vl->name, (size_t)namelen);
605 memcpy(cp, vl->value, (size_t)valuelen);
609 *datalen = (size_t)(cp - data);
614 * doquerylist - send a message including variables in a list
639 * doprintvlist - print the variables on a list
649 if (NULL == vlist->name) {
663 * addvars - add variables to the variable list
672 doaddvlist(g_varlist, pcmd->argval[0].string);
677 * rmvars - remove variables from the variable list
686 dormvlist(g_varlist, pcmd->argval[0].string);
691 * clearvars - clear the variable list
705 * showvars - show variables on the variable list
719 * dolist - send a request with the given list of variables
743 quiet = (vlist->name != NULL);
772 * readlist - send a read variables request with the variables on the list
783 if (pcmd->nargs == 0) {
787 if (pcmd->argval[0].uval == 0)
789 else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
801 * writelist - send a write variables request with the variables on the list
815 if (pcmd->nargs == 0) {
819 if (pcmd->argval[0].uval == 0)
821 else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
845 * readvar - send a read variables request with the specified variables
861 if (pcmd->nargs == 0 || pcmd->argval[0].uval == 0)
863 else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
867 if (pcmd->nargs > 1) {
868 tmpcount = pcmd->nargs - 1;
870 doaddvlist(tmplist, pcmd->argval[1 + u].string);
883 * writevar - send a write variables request with the specified variables
900 if (pcmd->argval[0].uval == 0)
902 else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
906 doaddvlist(tmplist, pcmd->argval[1].string);
932 * clocklist - send a clock variables request with the variables on the list
943 if (pcmd->nargs == 0) {
946 if (pcmd->argval[0].uval == 0)
948 else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
957 * clockvar - send a clock variables request with the specified variables
969 if (pcmd->nargs == 0 || pcmd->argval[0].uval == 0)
971 else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
975 if (pcmd->nargs >= 2)
976 doaddvlist(tmplist, pcmd->argval[1].string);
985 * findassidrange - verify a range of association ID's
1013 ind[a] = -1;
1019 if (-1 == ind[a]) {
1039 * mreadlist - send a read variables request for multiple associations
1051 if (!findassidrange(pcmd->argval[0].uval, pcmd->argval[1].uval,
1067 * mreadvar - send a read variables request for multiple associations
1081 if (!findassidrange(pcmd->argval[0].uval, pcmd->argval[1].uval,
1086 if (pcmd->nargs >= 3) {
1087 doaddvlist(tmplist, pcmd->argval[2].string);
1107 * dogetassoc - query the host for its list of associations
1154 dsize -= 2 * sizeof(*pus);
1170 * printassoc - print the current list of associations
1366 while (bp > buf && ' ' == bp[-1])
1367 --bp;
1375 * associations - get, record and print a list of associations
1390 * lassociations - get, record and print a long list of associations
1405 * passociations - print the association list
1419 * lpassociations - print the long association list
1433 * saveconfig - dump ntp server configuration to server file
1446 if (0 == pcmd->nargs)
1450 strlen(pcmd->argval[0].string),
1451 pcmd->argval[0].string, &rstatus, &dsize,
1466 * radiostatus - print the radio status returned by the server
1498 * when - return how long its been since his last packet arrived
1509 if (rec->l_ui != 0)
1511 else if (reftime->l_ui != 0)
1516 if (ts->l_ui < lasttime->l_ui)
1517 return -1;
1518 return (ts->l_ui - lasttime->l_ui);
1523 * Pretty-print an interval into the given buffer, in a human-friendly format.
1533 buf[0] = '-';
1577 char ch = '-';
1586 ((dummy&0xffffffe0)==0x00000000) ? '-' :
1596 ch = '-';
1744 len -= 2;
1911 (size_t)min(LIB_BUFLENGTH - 1, maxhostlen),
1920 xprintf(fp, "%-*s ", (int)maxhostlen, serverlocal);
1926 /* wide and long source - space over on next line */
1933 xprintf(fp, "%c%-15.15s ", c, clock_name);
1946 xprintf(fp, "%-6d", associd);
1952 " %2ld %c %4.4s %4.4s %3lo %7.7s %8.7s %7.7s\n",
1971 * dogetpeers - given an association ID, read and print the spreadsheet
2016 * peers - print a peer spreadsheet
2042 xprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
2071 * doapeers - print a peer spreadsheet with assocIDs
2097 xprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
2126 * peers - print a peer spreadsheet
2140 if (pcmd->nargs == 1) {
2141 if (pcmd->argval->ival == 6)
2152 * apeers - print a peer spreadsheet, with assocIDs
2163 if (pcmd->nargs == 1) {
2164 if (pcmd->argval->ival == 6)
2174 * lpeers - print a peer spreadsheet including all fuzzball peers
2185 if (pcmd->nargs == 1) {
2186 if (pcmd->argval->ival == 6)
2196 * opeers - print a peer spreadsheet
2217 xprintf(fp, "%-*.*s ", (int)maxhostlen, (int)maxhostlen,
2242 * opeers - print a peer spreadsheet the old way
2253 if (pcmd->nargs == 1) {
2254 if (pcmd->argval->ival == 6)
2264 * lopeers - print a peer spreadsheet including all fuzzball peers
2275 if (pcmd->nargs == 1) {
2276 if (pcmd->argval->ival == 6)
2286 * config - send a configuration command to a remote host
2303 cfgcmd = pcmd->argval[0].string;
2309 "Command = %s\n", pcmd->keyword, cfgcmd);
2318 if (rsize > 0 && '\n' == rdata[rsize - 1])
2319 rsize--;
2325 col = -1;
2342 * config_from_file - remotely configure an ntpd daemon using the
2346 * 1. ntpq uses UDP, which means that there is no guarantee of in-order,
2347 * error-free delivery.
2379 "Filename = %s\n", pcmd->keyword,
2380 pcmd->argval[0].string);
2382 config_fd = fopen(pcmd->argval[0].string, "r");
2385 pcmd->argval[0].string);
2395 ? (size_t)(cp - config_cmd)
2404 (u_char)config_cmd[config_len-1] <= ' ')
2405 --config_len;
2417 while (res != 0 && retry_limit--);
2426 /* Right-strip the result code string, then output the
2428 while (rsize != 0 && (u_char)rdata[rsize - 1] <= ' ')
2429 --rsize;
2464 if (rsize <= sizeof(nonce_eq) - 1 ||
2465 strncmp(rdata, nonce_eq, sizeof(nonce_eq) - 1)) {
2470 chars = rsize - (sizeof(nonce_eq) - 1);
2473 memcpy(nonce, rdata + sizeof(nonce_eq) - 1, chars);
2476 ('\r' == nonce[chars - 1] || '\n' == nonce[chars - 1])) {
2477 chars--;
2500 hash = NTP_HASH_ADDR(&add->addr);
2502 for (mon = hash_table[hash]; mon != NULL; mon = mon->hlink)
2503 if (SOCK_EQ(&mon->addr, &add->addr))
2506 if (!L_ISGEQ(&add->first, &mon->first)) {
2509 sptoa(&add->addr), add->last.l_ui,
2510 add->last.l_uf, mon->last.l_ui,
2511 mon->last.l_uf);
2518 TRACE(2, ("(updated from %08x.%08x) ", mon->last.l_ui,
2519 mon->last.l_uf));
2524 add->last.l_ui, add->last.l_uf, add->count,
2525 (int)add->mode, (int)add->ver, (u_int)add->rs,
2526 add->first.l_ui, add->first.l_uf, sptoa(&add->addr)));
2650 while (ri--) {
2656 sptoa(&recent->addr));
2658 hash = NTP_HASH_ADDR(&recent->addr);
2663 mru_count--;
2670 "With high-traffic NTP servers, this can occur if the\n"
2677 "---> Restarting from the beginning, retry #%u\n",
2692 ntpd_row_limit--;
2723 * This is a cheap cop-out implementation of rawmode
2760 recent = recent->hlink)
2763 &recent->addr))
2772 &recent->last)) {
2777 recent->last.l_ui,
2778 recent->last.l_uf);
2785 else if (decodenetnum(val, &mon->addr))
2819 &head->last)) {
2823 head->last.l_ui,
2824 head->last.l_uf);
2832 !hextolfp(val + 2, &mon->last)) {
2842 *pnow = mon->last;
2850 !hextolfp(val + 2, &mon->first))
2871 1 != sscanf(val, "%d", &mon->count)
2872 || mon->count < 1)
2882 mon->mode = PKT_MODE(mv);
2883 mon->ver = PKT_VERSION(mv);
2890 1 != sscanf(val, "0x%hx", &mon->rs))
2958 * prepare next query with as many address and last-seen
2963 #define REQ_ROOM (req_end - req)
2987 ri, sptoa(&recent->addr), ri,
2988 recent->last.l_ui, recent->last.l_uf);
3013 * qcmp_mru_addr - sort MRU entries by remote address.
3036 af1 = AF(&pm1->addr);
3037 af2 = AF(&pm2->addr);
3041 ? -1
3049 return memcmp((const char *)&pm1->addr + addr_off,
3050 (const char *)&pm2->addr + addr_off,
3061 return -qcmp_mru_addr(v1, v2);
3066 * qcmp_mru_count - sort MRU entries by times seen (hit count).
3082 return (pm1->count < pm2->count)
3083 ? -1
3084 : ((pm1->count == pm2->count)
3096 return -qcmp_mru_count(v1, v2);
3101 * qcmp_mru_avgint - sort MRU entries by average interval.
3120 interval = pm1->last;
3121 L_SUB(&interval, &pm1->first);
3123 avg1 /= pm1->count;
3125 interval = pm2->last;
3126 L_SUB(&interval, &pm2->first);
3128 avg2 /= pm2->count;
3131 return -1;
3135 /* secondary sort on lstint - rarely tested */
3136 if (L_ISEQU(&pm1->last, &pm2->last))
3138 else if (L_ISGEQ(&pm1->last, &pm2->last))
3139 return -1;
3151 return -qcmp_mru_avgint(v1, v2);
3156 * mrulist - ntpq's mrulist command to fetch an arbitrarily large Most
3209 "Ctrl-C will stop MRU retrieval and display partial results.\n");
3215 for (i = 0; i < pcmd->nargs; i++) {
3216 arg = pcmd->argval[i].string;
3220 - 1) || !strncmp(resany_eq, arg,
3221 sizeof(resany_eq) - 1) || !strncmp(
3222 mincount_eq, arg, sizeof(mincount_eq) - 1)
3224 - 1) || !strncmp(maxlstint_eq, arg,
3225 sizeof(laddr_eq) - 1)) && parms + cb + 2 <=
3231 parms += cb - 1;
3233 sizeof(sort_eq) - 1)) {
3234 arg += sizeof(sort_eq) - 1;
3255 parms += cb - 1;
3289 if (ppentry - sorted != (int)mru_count) {
3292 mru_count, (long)(ppentry - sorted));
3297 /* re-sort sorted[] if not default or reverse default */
3309 L_SUB(&interval, &recent->last);
3312 interval = recent->last;
3313 L_SUB(&interval, &recent->first);
3315 favgint /= recent->count;
3318 lstint, avgint, recent->rs,
3319 (RES_KOD & recent->rs)
3321 : (RES_LIMITED & recent->rs)
3324 (int)recent->mode, (int)recent->ver,
3325 recent->count, SRCPORT(&recent->addr),
3326 nntohost(&recent->addr));
3330 xputs("\n --interrupted--\n", fp);
3338 "--- completed, freeing sorted[] pointers\n");
3364 * validate_ifnum - helper for ifstats()
3376 if (prow->ifnum == ifnum)
3378 if (prow->ifnum + 1 <= ifnum) {
3383 prow->ifnum = ifnum;
3388 ifnum, *pfields, IFSTATS_FIELDS, prow->ifnum);
3394 * another_ifstats_field - helper for ifstats()
3417 "%3u %-24.24s %c %4x %3u %2u %6u %6u %6u %5u %8d\n"
3419 prow->ifnum, prow->name,
3420 (prow->enabled)
3423 prow->flags, prow->ttl, prow->mcast_count,
3424 prow->received, prow->sent, prow->send_errors,
3425 prow->peer_count, prow->uptime, sptoa(&prow->addr));
3426 if (!SOCK_UNSPEC(&prow->bcast))
3427 xprintf(fp, " %s\n", sptoa(&prow->bcast));
3428 ifnum = prow->ifnum;
3430 prow->ifnum = ifnum;
3435 * ifstats - ntpq -c ifstats modeled on ntpdc -c ifstats.
3445 const char en_fmt[] = "en.%u"; /* enabled */
3524 len - 2 < sizeof(row.name)) {
3525 len -= 2;
3580 * validate_reslist_idx - helper for reslist()
3592 if (prow->idx == idx)
3594 if (prow->idx + 1 == idx) {
3599 prow->idx = idx;
3604 idx, *pfields, RESLIST_FIELDS, prow->idx);
3610 * another_reslist_field - helper for reslist()
3630 prefix = sockaddr_masktoprefixlen(&prow->mask);
3633 stoa(&prow->addr), prefix);
3636 stoa(&prow->addr), stoa(&prow->mask));
3646 prow->hits, addrmaskstr, prow->flagstr);
3647 idx = prow->idx;
3649 prow->idx = idx;
3654 * reslist - ntpq -c reslist modeled on ntpdc -c reslist.
3667 const int qdata_chars = COUNTOF(qdata) - 1;
3782 for (pvdc = table; pvdc->tag != NULL; pvdc++) {
3783 ZERO(pvdc->v);
3784 if (NTP_ADD != pvdc->type) {
3785 doaddvlist(vl, pvdc->tag);
3789 pvdc->tag, suf[n]);
3807 for (pvdc = table; pvdc->tag != NULL; pvdc++) {
3808 len = strlen(pvdc->tag);
3809 if (strncmp(tag, pvdc->tag, len))
3811 if (NTP_ADD != pvdc->type) {
3826 if (NULL == pvdc->tag)
3828 switch (pvdc->type) {
3834 if (len > 0 && '"' == val[len - 1]) {
3835 val[len - 1] = '\0';
3843 pvdc->v.str = estrdup(val);
3847 decodets(val, &pvdc->v.lfp);
3851 if (!decodenetnum(val, &pvdc->v.sau))
3853 pvdc->tag, val);
3858 if (!decodenetnum(val, &pvdc->v.sau))
3861 pvdc->tag, val);
3864 SET_PORT(&pvdc->v.sau,
3880 for (pvdc = table; pvdc->tag != NULL; pvdc++) {
3881 switch (pvdc->type) {
3884 if (pvdc->v.str != NULL) {
3885 xprintf(fp, "%s %s\n", pvdc->display,
3886 pvdc->v.str);
3887 free(pvdc->v.str);
3888 pvdc->v.str = NULL;
3894 xprintf(fp, "%s %s\n", pvdc->display,
3895 nntohostp(&pvdc->v.sau));
3899 xprintf(fp, "%s %s\n", pvdc->display,
3900 prettydate(&pvdc->v.lfp));
3904 atouint(pvdc->v.str, &ul);
3905 xprintf(fp, "%s %s\n", pvdc->display,
3907 free(pvdc->v.str);
3908 pvdc->v.str = NULL;
3912 atouint(pvdc->v.str, &ul);
3913 xprintf(fp, "%s %s\n", pvdc->display,
3915 free(pvdc->v.str);
3916 pvdc->v.str = NULL;
3920 if (!decodenetnum(pvdc->v.str, &sau)) {
3921 fprintf(fp, "%s %s\n", pvdc->display, /* Text fmt */
3922 pvdc->v.str);
3924 fprintf(fp, "%s %s\n", pvdc->display, /* IPv4 fmt */
3927 fprintf (fp, "%s 0x%08x\n", pvdc->display, /* Hex / hash */
3930 free(pvdc->v.str);
3931 pvdc->v.str = NULL;
3936 pvdc->type, pvdc->tag);
3944 * sysstats - implements ntpq -c sysstats modeled on ntpdc -c sysstats
3977 * sysinfo - modeled on ntpdc's sysinfo
4008 * kerninfo - modeled on ntpdc's kerninfo
4041 * monstats - implements ntpq -c monstats
4066 * iostats - ntpq -c iostats - network input and output counters
4095 * timerstats - ntpq -c timerstats - interval timer counters
4115 * authinfo - implements ntpq -c authinfo
4141 * pstats - show statistics for a peer
4167 associd = checkassocid(pcmd->argval[0].uval);