Annotation of src/usr.bin/netstat/if.c, Revision 1.54
1.54 ! deraadt 1: /* $OpenBSD: if.c,v 1.53 2007/09/11 16:14:41 mk Exp $ */
1.6 deraadt 2: /* $NetBSD: if.c,v 1.16.4.2 1996/06/07 21:46:46 thorpej Exp $ */
1.1 deraadt 3:
4: /*
5: * Copyright (c) 1983, 1988, 1993
6: * The Regents of the University of California. All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions
10: * are met:
11: * 1. Redistributions of source code must retain the above copyright
12: * notice, this list of conditions and the following disclaimer.
13: * 2. Redistributions in binary form must reproduce the above copyright
14: * notice, this list of conditions and the following disclaimer in the
15: * documentation and/or other materials provided with the distribution.
1.35 millert 16: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 17: * may be used to endorse or promote products derived from this software
18: * without specific prior written permission.
19: *
20: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30: * SUCH DAMAGE.
31: */
32:
33: #ifndef lint
34: #if 0
35: static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94";
36: #else
1.54 ! deraadt 37: static char *rcsid = "$OpenBSD: if.c,v 1.53 2007/09/11 16:14:41 mk Exp $";
1.1 deraadt 38: #endif
39: #endif /* not lint */
40:
41: #include <sys/types.h>
42: #include <sys/protosw.h>
43: #include <sys/socket.h>
44:
45: #include <net/if.h>
46: #include <net/if_dl.h>
1.5 deraadt 47: #include <net/if_types.h>
1.1 deraadt 48: #include <netinet/in.h>
49: #include <netinet/in_var.h>
1.11 millert 50: #include <netinet/if_ether.h>
1.1 deraadt 51: #include <arpa/inet.h>
52:
1.13 millert 53: #include <limits.h>
1.1 deraadt 54: #include <signal.h>
55: #include <stdio.h>
1.36 david 56: #include <stdlib.h>
1.1 deraadt 57: #include <string.h>
58: #include <unistd.h>
59:
60: #include "netstat.h"
61:
62: #define YES 1
63: #define NO 0
64:
1.29 millert 65: static void sidewaysintpr(u_int, u_long);
66: static void catchalarm(int);
1.1 deraadt 67:
68: /*
69: * Print a description of the network interfaces.
1.3 deraadt 70: * NOTE: ifnetaddr is the location of the kernel global "ifnet",
71: * which is a TAILQ_HEAD.
1.1 deraadt 72: */
73: void
1.33 deraadt 74: intpr(int interval, u_long ifnetaddr)
1.1 deraadt 75: {
76: struct ifnet ifnet;
77: union {
78: struct ifaddr ifa;
79: struct in_ifaddr in;
1.18 itojun 80: struct in6_ifaddr in6;
1.1 deraadt 81: } ifaddr;
1.52 claudio 82: u_int64_t total;
83: u_long ifaddraddr;
1.1 deraadt 84: struct sockaddr *sa;
1.3 deraadt 85: struct ifnet_head ifhead; /* TAILQ_HEAD */
86: char name[IFNAMSIZ];
1.1 deraadt 87:
88: if (ifnetaddr == 0) {
89: printf("ifnet: symbol not defined\n");
90: return;
91: }
92: if (interval) {
93: sidewaysintpr((unsigned)interval, ifnetaddr);
94: return;
95: }
1.3 deraadt 96:
97: /*
98: * Find the pointer to the first ifnet structure. Replace
99: * the pointer to the TAILQ_HEAD with the actual pointer
100: * to the first list element.
101: */
1.43 jaredy 102: if (kread(ifnetaddr, &ifhead, sizeof ifhead))
1.1 deraadt 103: return;
1.45 otto 104: ifnetaddr = (u_long)TAILQ_FIRST(&ifhead);
1.3 deraadt 105:
1.22 camield 106: printf("%-7.7s %-5.5s %-11.11s %-17.17s ",
1.33 deraadt 107: "Name", "Mtu", "Network", "Address");
1.22 camield 108: if (bflag)
109: printf("%10.10s %10.10s", "Ibytes", "Obytes");
110: else
111: printf("%8.8s %5.5s %8.8s %5.5s %5.5s",
112: "Ipkts", "Ierrs", "Opkts", "Oerrs", "Colls");
1.1 deraadt 113: if (tflag)
114: printf(" %s", "Time");
115: if (dflag)
116: printf(" %s", "Drop");
117: putchar('\n');
118: ifaddraddr = 0;
119: while (ifnetaddr || ifaddraddr) {
120: struct sockaddr_in *sin;
1.18 itojun 121: struct sockaddr_in6 *sin6;
1.27 mpech 122: char *cp;
1.1 deraadt 123: int n, m;
124:
125: if (ifaddraddr == 0) {
1.43 jaredy 126: if (kread(ifnetaddr, &ifnet, sizeof ifnet))
1.1 deraadt 127: return;
1.3 deraadt 128: bcopy(ifnet.if_xname, name, IFNAMSIZ);
129: name[IFNAMSIZ - 1] = '\0'; /* sanity */
1.45 otto 130: ifnetaddr = (u_long)TAILQ_NEXT(&ifnet, if_list);
1.3 deraadt 131: if (interface != 0 && strcmp(name, interface) != 0)
1.1 deraadt 132: continue;
1.10 millert 133: cp = strchr(name, '\0');
1.1 deraadt 134: if ((ifnet.if_flags & IFF_UP) == 0)
135: *cp++ = '*';
136: *cp = '\0';
1.45 otto 137: ifaddraddr = (u_long)TAILQ_FIRST(&ifnet.if_addrlist);
1.1 deraadt 138: }
1.25 brian 139:
140: if (qflag) {
141: total = ifnet.if_ibytes + ifnet.if_obytes +
142: ifnet.if_ipackets + ifnet.if_ierrors +
143: ifnet.if_opackets + ifnet.if_oerrors +
144: ifnet.if_collisions;
145: if (tflag)
146: total += ifnet.if_timer;
147: if (dflag)
148: total += ifnet.if_snd.ifq_drops;
149: if (total == 0) {
150: ifaddraddr = 0;
151: continue;
152: }
153: }
154:
1.51 ray 155: printf("%-7s %-5ld ", name, ifnet.if_mtu);
1.1 deraadt 156: if (ifaddraddr == 0) {
157: printf("%-11.11s ", "none");
1.37 deraadt 158: printf("%-17.17s ", "none");
1.1 deraadt 159: } else {
1.43 jaredy 160: if (kread(ifaddraddr, &ifaddr, sizeof ifaddr)) {
1.1 deraadt 161: ifaddraddr = 0;
162: continue;
163: }
164: #define CP(x) ((char *)(x))
165: cp = (CP(ifaddr.ifa.ifa_addr) - CP(ifaddraddr)) +
166: CP(&ifaddr); sa = (struct sockaddr *)cp;
167: switch (sa->sa_family) {
168: case AF_UNSPEC:
169: printf("%-11.11s ", "none");
170: printf("%-17.17s ", "none");
171: break;
172: case AF_INET:
173: sin = (struct sockaddr_in *)sa;
174: #ifdef notdef
175: /* can't use inet_makeaddr because kernel
176: * keeps nets unshifted.
177: */
178: in = inet_makeaddr(ifaddr.in.ia_subnet,
1.30 deraadt 179: INADDR_ANY);
1.47 claudio 180: cp = netname4(in.s_addr,
1.30 deraadt 181: ifaddr.in.ia_subnetmask);
1.1 deraadt 182: #else
1.47 claudio 183: cp = netname4(ifaddr.in.ia_subnet,
1.20 itojun 184: ifaddr.in.ia_subnetmask);
1.1 deraadt 185: #endif
1.20 itojun 186: if (vflag)
187: n = strlen(cp) < 11 ? 11 : strlen(cp);
188: else
189: n = 11;
190: printf("%-*.*s ", n, n, cp);
1.47 claudio 191: cp = routename4(sin->sin_addr.s_addr);
1.20 itojun 192: if (vflag)
193: n = strlen(cp) < 17 ? 17 : strlen(cp);
194: else
195: n = 17;
196: printf("%-*.*s ", n, n, cp);
1.1 deraadt 197:
198: if (aflag) {
199: u_long multiaddr;
200: struct in_multi inm;
1.28 mickey 201:
1.45 otto 202: multiaddr = (u_long)LIST_FIRST(&ifaddr.in.ia_multiaddrs);
1.1 deraadt 203: while (multiaddr != 0) {
1.43 jaredy 204: kread(multiaddr, &inm, sizeof inm);
1.19 itojun 205: printf("\n%25s %-17.17s ", "",
1.47 claudio 206: routename4(inm.inm_addr.s_addr));
1.45 otto 207: multiaddr = (u_long)LIST_NEXT(&inm, inm_list);
1.1 deraadt 208: }
1.8 mickey 209: }
210: break;
1.18 itojun 211: case AF_INET6:
212: sin6 = (struct sockaddr_in6 *)sa;
1.34 itojun 213: #ifdef __KAME__
1.20 itojun 214: if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
215: sin6->sin6_scope_id =
1.30 deraadt 216: ntohs(*(u_int16_t *)
1.38 deraadt 217: &sin6->sin6_addr.s6_addr[2]);
1.20 itojun 218: sin6->sin6_addr.s6_addr[2] = 0;
219: sin6->sin6_addr.s6_addr[3] = 0;
220: }
221: #endif
222: cp = netname6(&ifaddr.in6.ia_addr,
1.47 claudio 223: &ifaddr.in6.ia_prefixmask);
1.20 itojun 224: if (vflag)
225: n = strlen(cp) < 11 ? 11 : strlen(cp);
226: else
227: n = 11;
228: printf("%-*.*s ", n, n, cp);
229: cp = routename6(sin6);
230: if (vflag)
231: n = strlen(cp) < 17 ? 17 : strlen(cp);
232: else
233: n = 17;
234: printf("%-*.*s ", n, n, cp);
1.19 itojun 235: if (aflag) {
236: u_long multiaddr;
237: struct in6_multi inm;
1.31 itojun 238: struct sockaddr_in6 m6;
1.28 mickey 239:
1.45 otto 240: multiaddr = (u_long)LIST_FIRST(&ifaddr.in6.ia6_multiaddrs);
1.19 itojun 241: while (multiaddr != 0) {
1.43 jaredy 242: kread(multiaddr, &inm, sizeof inm);
1.31 itojun 243: memset(&m6, 0, sizeof(m6));
244: m6.sin6_len = sizeof(struct sockaddr_in6);
245: m6.sin6_family = AF_INET6;
246: m6.sin6_addr = inm.in6m_addr;
1.34 itojun 247: #ifdef __KAME__
1.49 itojun 248: if (IN6_IS_ADDR_MC_LINKLOCAL(&m6.sin6_addr) ||
249: IN6_IS_ADDR_MC_INTFACELOCAL(&m6.sin6_addr)) {
1.31 itojun 250: m6.sin6_scope_id =
251: ntohs(*(u_int16_t *)
1.38 deraadt 252: &m6.sin6_addr.s6_addr[2]);
1.31 itojun 253: m6.sin6_addr.s6_addr[2] = 0;
254: m6.sin6_addr.s6_addr[3] = 0;
255: }
256: #endif
257: cp = routename6(&m6);
1.19 itojun 258: if (vflag)
1.31 itojun 259: n = strlen(cp) < 17 ? 17 : strlen(cp);
1.19 itojun 260: else
261: n = 17;
262: printf("\n%25s %-*.*s ", "",
1.31 itojun 263: n, n, cp);
1.45 otto 264: multiaddr = (u_long)LIST_NEXT(&inm, in6m_entry);
1.19 itojun 265: }
266: }
1.18 itojun 267: break;
1.15 denny 268: case AF_APPLETALK:
269: printf("atlk:%-12s",atalk_print(sa,0x10) );
270: printf("%-12s ",atalk_print(sa,0x0b) );
1.1 deraadt 271: break;
272: case AF_LINK:
273: {
274: struct sockaddr_dl *sdl =
275: (struct sockaddr_dl *)sa;
1.5 deraadt 276: m = printf("%-11.11s ", "<Link>");
277: if (sdl->sdl_type == IFT_ETHER ||
1.42 mpf 278: sdl->sdl_type == IFT_CARP ||
1.23 fgsch 279: sdl->sdl_type == IFT_FDDI ||
280: sdl->sdl_type == IFT_ISO88025)
1.5 deraadt 281: printf("%-17.17s ",
1.11 millert 282: ether_ntoa((struct ether_addr *)LLADDR(sdl)));
1.5 deraadt 283: else {
284: cp = (char *)LLADDR(sdl);
285: n = sdl->sdl_alen;
286: goto hexprint;
287: }
1.1 deraadt 288: }
1.5 deraadt 289: break;
1.1 deraadt 290: default:
291: m = printf("(%d)", sa->sa_family);
292: for (cp = sa->sa_len + (char *)sa;
293: --cp > sa->sa_data && (*cp == 0);) {}
294: n = cp - sa->sa_data + 1;
295: cp = sa->sa_data;
296: hexprint:
297: while (--n >= 0)
298: m += printf("%x%c", *cp++ & 0xff,
299: n > 0 ? '.' : ' ');
300: m = 30 - m;
301: while (m-- > 0)
302: putchar(' ');
303: break;
304: }
1.45 otto 305: ifaddraddr = (u_long)TAILQ_NEXT(&ifaddr.ifa, ifa_list);
1.1 deraadt 306: }
1.22 camield 307: if (bflag)
1.52 claudio 308: printf("%10llu %10llu",
1.22 camield 309: ifnet.if_ibytes, ifnet.if_obytes);
310: else
1.52 claudio 311: printf("%8llu %5llu %8llu %5llu %5llu",
1.22 camield 312: ifnet.if_ipackets, ifnet.if_ierrors,
313: ifnet.if_opackets, ifnet.if_oerrors,
314: ifnet.if_collisions);
1.1 deraadt 315: if (tflag)
1.22 camield 316: printf(" %4d", ifnet.if_timer);
1.1 deraadt 317: if (dflag)
1.22 camield 318: printf(" %4d", ifnet.if_snd.ifq_drops);
1.1 deraadt 319: putchar('\n');
320: }
321: }
322:
1.4 deraadt 323: #define MAXIF 100
1.1 deraadt 324: struct iftot {
1.3 deraadt 325: char ift_name[IFNAMSIZ]; /* interface name */
1.53 mk 326: u_int64_t ift_ip; /* input packets */
327: u_int64_t ift_ib; /* input bytes */
328: u_int64_t ift_ie; /* input errors */
329: u_int64_t ift_op; /* output packets */
330: u_int64_t ift_ob; /* output bytes */
331: u_int64_t ift_oe; /* output errors */
332: u_int64_t ift_co; /* collisions */
333: u_int64_t ift_dr; /* drops */
1.1 deraadt 334: } iftot[MAXIF];
335:
1.26 millert 336: volatile sig_atomic_t signalled; /* set if alarm goes off "early" */
1.1 deraadt 337:
338: /*
339: * Print a running summary of interface statistics.
340: * Repeat display every interval seconds, showing statistics
341: * collected over that interval. Assumes that interval is non-zero.
342: * First line printed at top of screen is always cumulative.
343: */
344: static void
1.33 deraadt 345: sidewaysintpr(unsigned int interval, u_long off)
1.1 deraadt 346: {
347: struct ifnet ifnet;
348: u_long firstifnet;
1.27 mpech 349: struct iftot *ip, *total;
350: int line;
1.1 deraadt 351: struct iftot *lastif, *sum, *interesting;
1.3 deraadt 352: struct ifnet_head ifhead; /* TAILQ_HEAD */
1.26 millert 353: sigset_t emptyset;
1.1 deraadt 354:
1.3 deraadt 355: /*
356: * Find the pointer to the first ifnet structure. Replace
357: * the pointer to the TAILQ_HEAD with the actual pointer
358: * to the first list element.
359: */
1.43 jaredy 360: if (kread(off, &ifhead, sizeof ifhead))
1.1 deraadt 361: return;
1.45 otto 362: firstifnet = (u_long)TAILQ_FIRST(&ifhead);
1.3 deraadt 363:
1.1 deraadt 364: lastif = iftot;
365: sum = iftot + MAXIF - 1;
366: total = sum - 1;
1.4 deraadt 367: interesting = (interface == NULL) ? iftot : NULL;
1.1 deraadt 368: for (off = firstifnet, ip = iftot; off;) {
1.43 jaredy 369: if (kread(off, &ifnet, sizeof ifnet))
1.1 deraadt 370: break;
1.6 deraadt 371: bzero(ip->ift_name, sizeof(ip->ift_name));
1.22 camield 372: snprintf(ip->ift_name, IFNAMSIZ, "%s", ifnet.if_xname);
1.6 deraadt 373: if (interface && strcmp(ifnet.if_xname, interface) == 0)
1.1 deraadt 374: interesting = ip;
375: ip++;
376: if (ip >= iftot + MAXIF - 2)
377: break;
1.45 otto 378: off = (u_long)TAILQ_NEXT(&ifnet, if_list);
1.4 deraadt 379: }
380: if (interesting == NULL) {
381: fprintf(stderr, "%s: %s: unknown interface\n",
382: __progname, interface);
383: exit(1);
1.1 deraadt 384: }
385: lastif = ip;
386:
387: (void)signal(SIGALRM, catchalarm);
388: signalled = NO;
389: (void)alarm(interval);
390: banner:
1.22 camield 391: if (bflag)
392: printf("%7.7s in %8.8s %6.6s out %5.5s",
393: interesting->ift_name, " ",
394: interesting->ift_name, " ");
395: else
396: printf("%5.5s in %5.5s%5.5s out %5.5s %5.5s",
397: interesting->ift_name, " ",
398: interesting->ift_name, " ", " ");
399: if (dflag)
400: printf(" %5.5s", " ");
1.1 deraadt 401: if (lastif - iftot > 0) {
1.22 camield 402: if (bflag)
403: printf(" %7.7s in %8.8s %6.6s out %5.5s",
404: "total", " ", "total", " ");
405: else
406: printf(" %5.5s in %5.5s%5.5s out %5.5s %5.5s",
407: "total", " ", "total", " ", " ");
1.1 deraadt 408: if (dflag)
1.22 camield 409: printf(" %5.5s", " ");
1.1 deraadt 410: }
411: for (ip = iftot; ip < iftot + MAXIF; ip++) {
412: ip->ift_ip = 0;
1.22 camield 413: ip->ift_ib = 0;
1.1 deraadt 414: ip->ift_ie = 0;
415: ip->ift_op = 0;
1.22 camield 416: ip->ift_ob = 0;
1.1 deraadt 417: ip->ift_oe = 0;
418: ip->ift_co = 0;
419: ip->ift_dr = 0;
420: }
421: putchar('\n');
1.22 camield 422: if (bflag)
423: printf("%10.10s %8.8s %10.10s %5.5s",
424: "bytes", " ", "bytes", " ");
425: else
426: printf("%8.8s %5.5s %8.8s %5.5s %5.5s",
427: "packets", "errs", "packets", "errs", "colls");
1.1 deraadt 428: if (dflag)
429: printf(" %5.5s", "drops");
1.22 camield 430: if (lastif - iftot > 0) {
431: if (bflag)
432: printf(" %10.10s %8.8s %10.10s %5.5s",
433: "bytes", " ", "bytes", " ");
434: else
435: printf(" %8.8s %5.5s %8.8s %5.5s %5.5s",
436: "packets", "errs", "packets", "errs", "colls");
437: if (dflag)
438: printf(" %5.5s", "drops");
439: }
1.1 deraadt 440: putchar('\n');
441: fflush(stdout);
442: line = 0;
443: loop:
444: sum->ift_ip = 0;
1.22 camield 445: sum->ift_ib = 0;
1.1 deraadt 446: sum->ift_ie = 0;
447: sum->ift_op = 0;
1.22 camield 448: sum->ift_ob = 0;
1.1 deraadt 449: sum->ift_oe = 0;
450: sum->ift_co = 0;
451: sum->ift_dr = 0;
452: for (off = firstifnet, ip = iftot; off && ip < lastif; ip++) {
1.43 jaredy 453: if (kread(off, &ifnet, sizeof ifnet)) {
1.1 deraadt 454: off = 0;
455: continue;
456: }
457: if (ip == interesting) {
1.22 camield 458: if (bflag)
1.53 mk 459: printf("%10llu %8.8s %10llu %5.5s",
1.22 camield 460: ifnet.if_ibytes - ip->ift_ib, " ",
461: ifnet.if_obytes - ip->ift_ob, " ");
462: else
1.53 mk 463: printf("%8llu %5llu %8llu %5llu %5llu",
1.22 camield 464: ifnet.if_ipackets - ip->ift_ip,
465: ifnet.if_ierrors - ip->ift_ie,
466: ifnet.if_opackets - ip->ift_op,
467: ifnet.if_oerrors - ip->ift_oe,
468: ifnet.if_collisions - ip->ift_co);
1.1 deraadt 469: if (dflag)
1.53 mk 470: printf(" %5llu",
1.1 deraadt 471: ifnet.if_snd.ifq_drops - ip->ift_dr);
472: }
473: ip->ift_ip = ifnet.if_ipackets;
1.22 camield 474: ip->ift_ib = ifnet.if_ibytes;
1.1 deraadt 475: ip->ift_ie = ifnet.if_ierrors;
476: ip->ift_op = ifnet.if_opackets;
1.22 camield 477: ip->ift_ob = ifnet.if_obytes;
1.1 deraadt 478: ip->ift_oe = ifnet.if_oerrors;
479: ip->ift_co = ifnet.if_collisions;
480: ip->ift_dr = ifnet.if_snd.ifq_drops;
481: sum->ift_ip += ip->ift_ip;
1.22 camield 482: sum->ift_ib += ip->ift_ib;
1.1 deraadt 483: sum->ift_ie += ip->ift_ie;
484: sum->ift_op += ip->ift_op;
1.22 camield 485: sum->ift_ob += ip->ift_ob;
1.1 deraadt 486: sum->ift_oe += ip->ift_oe;
487: sum->ift_co += ip->ift_co;
488: sum->ift_dr += ip->ift_dr;
1.45 otto 489: off = (u_long)TAILQ_NEXT(&ifnet, if_list);
1.1 deraadt 490: }
491: if (lastif - iftot > 0) {
1.22 camield 492: if (bflag)
1.53 mk 493: printf(" %10llu %8.8s %10llu %5.5s",
1.41 jaredy 494: sum->ift_ib - total->ift_ib, " ",
495: sum->ift_ob - total->ift_ob, " ");
1.22 camield 496: else
1.53 mk 497: printf(" %8llu %5llu %8llu %5llu %5llu",
1.41 jaredy 498: sum->ift_ip - total->ift_ip,
499: sum->ift_ie - total->ift_ie,
500: sum->ift_op - total->ift_op,
501: sum->ift_oe - total->ift_oe,
502: sum->ift_co - total->ift_co);
1.1 deraadt 503: if (dflag)
1.53 mk 504: printf(" %5llu", sum->ift_dr - total->ift_dr);
1.1 deraadt 505: }
506: *total = *sum;
507: putchar('\n');
508: fflush(stdout);
509: line++;
1.26 millert 510: sigemptyset(&emptyset);
511: if (!signalled)
512: sigsuspend(&emptyset);
1.1 deraadt 513: signalled = NO;
514: (void)alarm(interval);
515: if (line == 21)
516: goto banner;
517: goto loop;
518: /*NOTREACHED*/
519: }
520:
521: /*
522: * Called if an interval expires before sidewaysintpr has completed a loop.
523: * Sets a flag to not wait for the alarm.
524: */
1.46 deraadt 525: /* ARGSUSED */
1.1 deraadt 526: static void
1.33 deraadt 527: catchalarm(int signo)
1.1 deraadt 528: {
529: signalled = YES;
1.47 claudio 530: }