*** ntpdc.c.dist Sun Jul 16 23:40:07 1989 --- ntpdc.c Sun Jul 16 23:39:57 1989 *************** *** 88,93 **** --- 88,100 ---- #include #include "ntp.h" + #ifndef DIST + #include + #include + + void init_cvtname(); + #endif DIST + #define WTIME 10 /* Time to wait for all responses */ #define STIME 500000 /* usec to wait for another response */ #define MAXPACKETSIZE 1500 *************** *** 115,120 **** --- 122,130 ---- char *p; int on = 48*1024; + #ifndef DIST + init_cvtname(); + #else DIST (void) gethostname(LocalHostName, sizeof LocalHostName); if (p = index(LocalHostName, '.')) { *p++ = '\0'; *************** *** 122,128 **** } else LocalDomain = ""; ! if (argc < 2) { usage: printf("usage: %s [ -v ][ -n ] hosts...\n", argv[0]); --- 132,138 ---- } else LocalDomain = ""; ! #endif DIST if (argc < 2) { usage: printf("usage: %s [ -v ][ -n ] hosts...\n", argv[0]); *************** *** 223,229 **** --- 233,243 ---- first = 0; replies = (1L << msg->npkts) - 1; if (!vflag) { + #ifndef DIST + printf(" Peer Refid Strat Poll Reach Delay Offset Disp\n"); + #else printf(" (rem) Address (lcl) Strat Poll Reach Delay Offset Disp\n"); + #endif printf("==========================================================================\n"); } } *************** *** 317,328 **** if (flags & PEER_FL_SELECTED) c = '*'; /* mark peer selection */ sin.sin_addr.s_addr = n->net_address; ! printf("%c%-15.15s ", c, cvthname(&sin)); sin.sin_addr.s_addr = n->my_address; printf("%-16.16s %2d %4d %03o %8.1f %8.1f %8.1f\n", sin.sin_addr.s_addr ? inet_ntoa(sin.sin_addr) : "wildcard", n->stratum, (int)ntohl((u_long)n->timer), ntohs(n->reach) & SHIFT_MASK, del, off, dsp); } print_verbose(n) --- 331,368 ---- if (flags & PEER_FL_SELECTED) c = '*'; /* mark peer selection */ sin.sin_addr.s_addr = n->net_address; ! printf("%c%-18.18s ", c, cvthname(&sin)); ! #ifndef DIST ! if (n->stratum == 0 || n->stratum == 1) ! { ! int i; ! unsigned char *cp; ! ! fputs(" ",stdout); ! cp = (unsigned char *) & n->refid; ! for (i=0;i<4;i++) { ! if (*cp < ' ' || *cp >= 128) ! putchar(*cp == 0 ? ' ' : '?'); ! else ! putchar(*cp); ! cp += 1; ! } ! } ! else ! { ! sin.sin_addr.s_addr = n->refid; ! printf("%14.13s", cvthname(&sin)); ! } ! printf("%2d %4d %03o %8.0f %8.0f %8.0f\n", ! n->stratum, (int)ntohl((u_long)n->timer), ! ntohs(n->reach) & SHIFT_MASK, del, off, dsp); ! #else DIST sin.sin_addr.s_addr = n->my_address; printf("%-16.16s %2d %4d %03o %8.1f %8.1f %8.1f\n", sin.sin_addr.s_addr ? inet_ntoa(sin.sin_addr) : "wildcard", n->stratum, (int)ntohl((u_long)n->timer), ntohs(n->reach) & SHIFT_MASK, del, off, dsp); + #endif DIST } print_verbose(n) *************** *** 404,406 **** --- 444,479 ---- *p = '\0'; return (hp->h_name); } + + #ifndef DIST + void + init_cvtname() + { + long gethostid(); + struct hostent *hp; + char *p; + long hid = gethostid(); + + + hp = gethostbyaddr(&hid, sizeof(hid), AF_INET); + + if ( hp == NULL) + { + printf("ntpdc: Couldn't get hostname for this host.\n"); + exit(-1); + } + + strcpy(LocalHostName, hp->h_name); + + if (p = index(LocalHostName, '.')) { + *p++ = '\0'; + LocalDomain = p; + } + else + LocalDomain = ""; + + /* poke name lookup to give up quickly */ + _res.retrans = 1; /* from bin/login/login.c! */ + _res.retry = 1; + } + #endif DIST