17c478bd9Sstevel@tonic-gate /*
2*e11c3f44Smeem * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
37c478bd9Sstevel@tonic-gate * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate *
57c478bd9Sstevel@tonic-gate * Copyright (c) 1983, 1988, 1993
67c478bd9Sstevel@tonic-gate * The Regents of the University of California. All rights reserved.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without
97c478bd9Sstevel@tonic-gate * modification, are permitted provided that the following conditions
107c478bd9Sstevel@tonic-gate * are met:
117c478bd9Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright
127c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer.
137c478bd9Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright
147c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the
157c478bd9Sstevel@tonic-gate * documentation and/or other materials provided with the distribution.
167c478bd9Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software
177c478bd9Sstevel@tonic-gate * must display the following acknowledgment:
187c478bd9Sstevel@tonic-gate * This product includes software developed by the University of
197c478bd9Sstevel@tonic-gate * California, Berkeley and its contributors.
207c478bd9Sstevel@tonic-gate * 4. Neither the name of the University nor the names of its contributors
217c478bd9Sstevel@tonic-gate * may be used to endorse or promote products derived from this software
227c478bd9Sstevel@tonic-gate * without specific prior written permission.
237c478bd9Sstevel@tonic-gate *
247c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
257c478bd9Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
267c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
277c478bd9Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
287c478bd9Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
297c478bd9Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
307c478bd9Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
317c478bd9Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
327c478bd9Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
337c478bd9Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
347c478bd9Sstevel@tonic-gate * SUCH DAMAGE.
357c478bd9Sstevel@tonic-gate *
367c478bd9Sstevel@tonic-gate * $FreeBSD: src/sbin/routed/trace.c,v 1.6 2000/08/11 08:24:38 sheldonh Exp $
377c478bd9Sstevel@tonic-gate */
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate #include "defs.h"
407c478bd9Sstevel@tonic-gate #include "pathnames.h"
417c478bd9Sstevel@tonic-gate #include <signal.h>
427c478bd9Sstevel@tonic-gate #include <sys/stat.h>
437c478bd9Sstevel@tonic-gate #include <sys/signal.h>
447c478bd9Sstevel@tonic-gate #include <strings.h>
457c478bd9Sstevel@tonic-gate #include <fcntl.h>
467c478bd9Sstevel@tonic-gate #include <protocols/routed.h>
477c478bd9Sstevel@tonic-gate
487c478bd9Sstevel@tonic-gate #define NRECORDS 50 /* size of circular trace buffer */
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate int tracelevel, new_tracelevel;
517c478bd9Sstevel@tonic-gate FILE *ftrace = stdout; /* output trace file */
527c478bd9Sstevel@tonic-gate static const char *sigtrace_pat = "%s";
537c478bd9Sstevel@tonic-gate static char savetracename[MAXPATHLEN+1];
547c478bd9Sstevel@tonic-gate static char *ripcmds[RIPCMD_MAX] =
557c478bd9Sstevel@tonic-gate {"#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF", "POLL",
567c478bd9Sstevel@tonic-gate "POLLENTRY"};
577c478bd9Sstevel@tonic-gate char inittracename[MAXPATHLEN+1];
587c478bd9Sstevel@tonic-gate static boolean_t file_trace; /* 1=tracing to file, not stdout */
597c478bd9Sstevel@tonic-gate
607c478bd9Sstevel@tonic-gate static void tmsg(const char *, ...);
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate const char *
rip_strerror(int err)637c478bd9Sstevel@tonic-gate rip_strerror(int err)
647c478bd9Sstevel@tonic-gate {
657c478bd9Sstevel@tonic-gate const char *cp = strerror(err);
667c478bd9Sstevel@tonic-gate static char msgbuf[64];
677c478bd9Sstevel@tonic-gate
687c478bd9Sstevel@tonic-gate if (cp == NULL) {
697c478bd9Sstevel@tonic-gate if (err == 0) {
707c478bd9Sstevel@tonic-gate cp = "success";
717c478bd9Sstevel@tonic-gate } else {
727c478bd9Sstevel@tonic-gate (void) snprintf(msgbuf, sizeof (msgbuf),
737c478bd9Sstevel@tonic-gate "unknown error %d", err);
747c478bd9Sstevel@tonic-gate cp = msgbuf;
757c478bd9Sstevel@tonic-gate }
767c478bd9Sstevel@tonic-gate }
777c478bd9Sstevel@tonic-gate return (cp);
787c478bd9Sstevel@tonic-gate }
797c478bd9Sstevel@tonic-gate
807c478bd9Sstevel@tonic-gate /* convert IP address to a string, but not into a single buffer */
817c478bd9Sstevel@tonic-gate char *
naddr_ntoa(in_addr_t a)827c478bd9Sstevel@tonic-gate naddr_ntoa(in_addr_t a)
837c478bd9Sstevel@tonic-gate {
847c478bd9Sstevel@tonic-gate #define NUM_BUFS 4
857c478bd9Sstevel@tonic-gate static int bufno;
867c478bd9Sstevel@tonic-gate static struct {
877c478bd9Sstevel@tonic-gate char str[INET_ADDRSTRLEN]; /* xxx.xxx.xxx.xxx\0 */
887c478bd9Sstevel@tonic-gate } bufs[NUM_BUFS];
897c478bd9Sstevel@tonic-gate char *s;
907c478bd9Sstevel@tonic-gate struct in_addr addr;
917c478bd9Sstevel@tonic-gate
927c478bd9Sstevel@tonic-gate addr.s_addr = a;
937c478bd9Sstevel@tonic-gate s = strcpy(bufs[bufno].str, inet_ntoa(addr));
947c478bd9Sstevel@tonic-gate bufno = (bufno+1) % NUM_BUFS;
957c478bd9Sstevel@tonic-gate return (s);
967c478bd9Sstevel@tonic-gate #undef NUM_BUFS
977c478bd9Sstevel@tonic-gate }
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gate
1007c478bd9Sstevel@tonic-gate const char *
saddr_ntoa(struct sockaddr_storage * ss)1017c478bd9Sstevel@tonic-gate saddr_ntoa(struct sockaddr_storage *ss)
1027c478bd9Sstevel@tonic-gate {
1037c478bd9Sstevel@tonic-gate return (ss == NULL) ? "?" : naddr_ntoa(S_ADDR(ss));
1047c478bd9Sstevel@tonic-gate }
1057c478bd9Sstevel@tonic-gate
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate static char *
ts(time_t secs)1087c478bd9Sstevel@tonic-gate ts(time_t secs)
1097c478bd9Sstevel@tonic-gate {
1107c478bd9Sstevel@tonic-gate static char s[20];
1117c478bd9Sstevel@tonic-gate
1127c478bd9Sstevel@tonic-gate secs += epoch.tv_sec;
1137c478bd9Sstevel@tonic-gate (void) strftime(s, sizeof (s), "%T", localtime(&secs));
1147c478bd9Sstevel@tonic-gate return (s);
1157c478bd9Sstevel@tonic-gate }
1167c478bd9Sstevel@tonic-gate
1177c478bd9Sstevel@tonic-gate static char *
ts_full(struct timeval * tv)1187c478bd9Sstevel@tonic-gate ts_full(struct timeval *tv)
1197c478bd9Sstevel@tonic-gate {
1207c478bd9Sstevel@tonic-gate static char s[32];
1217c478bd9Sstevel@tonic-gate time_t secs;
1227c478bd9Sstevel@tonic-gate int len;
1237c478bd9Sstevel@tonic-gate
1247c478bd9Sstevel@tonic-gate secs = tv->tv_sec + epoch.tv_sec;
1257c478bd9Sstevel@tonic-gate (void) strftime(s, sizeof (s), "%Y/%m/%d %T", localtime(&secs));
1267c478bd9Sstevel@tonic-gate len = strlen(s);
1277c478bd9Sstevel@tonic-gate (void) snprintf(s + len, sizeof (s) - len, ".%06ld", tv->tv_usec);
1287c478bd9Sstevel@tonic-gate return (s);
1297c478bd9Sstevel@tonic-gate }
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gate /*
1327c478bd9Sstevel@tonic-gate * On each event, display a time stamp.
1337c478bd9Sstevel@tonic-gate * This assumes that 'now' is update once for each event, and
1347c478bd9Sstevel@tonic-gate * that at least now.tv_usec changes.
1357c478bd9Sstevel@tonic-gate */
1367c478bd9Sstevel@tonic-gate static struct timeval lastlog_time;
1377c478bd9Sstevel@tonic-gate
1387c478bd9Sstevel@tonic-gate void
lastlog(void)1397c478bd9Sstevel@tonic-gate lastlog(void)
1407c478bd9Sstevel@tonic-gate {
1417c478bd9Sstevel@tonic-gate if (lastlog_time.tv_sec != now.tv_sec ||
1427c478bd9Sstevel@tonic-gate lastlog_time.tv_usec != now.tv_usec) {
1437c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "-- %s --\n", ts_full(&now));
1447c478bd9Sstevel@tonic-gate lastlog_time = now;
1457c478bd9Sstevel@tonic-gate }
1467c478bd9Sstevel@tonic-gate }
1477c478bd9Sstevel@tonic-gate
1487c478bd9Sstevel@tonic-gate
1497c478bd9Sstevel@tonic-gate static void
tmsg(const char * p,...)1507c478bd9Sstevel@tonic-gate tmsg(const char *p, ...)
1517c478bd9Sstevel@tonic-gate {
1527c478bd9Sstevel@tonic-gate va_list args;
1537c478bd9Sstevel@tonic-gate
1547c478bd9Sstevel@tonic-gate if (ftrace != NULL) {
1557c478bd9Sstevel@tonic-gate lastlog();
1567c478bd9Sstevel@tonic-gate va_start(args, p);
1577c478bd9Sstevel@tonic-gate (void) vfprintf(ftrace, p, args);
1587c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
1597c478bd9Sstevel@tonic-gate (void) fflush(ftrace);
1607c478bd9Sstevel@tonic-gate (void) va_end(args);
1617c478bd9Sstevel@tonic-gate }
1627c478bd9Sstevel@tonic-gate }
1637c478bd9Sstevel@tonic-gate
1647c478bd9Sstevel@tonic-gate
1657c478bd9Sstevel@tonic-gate void
trace_close(int zap_stdio)1667c478bd9Sstevel@tonic-gate trace_close(int zap_stdio)
1677c478bd9Sstevel@tonic-gate {
1687c478bd9Sstevel@tonic-gate int fd;
1697c478bd9Sstevel@tonic-gate
1707c478bd9Sstevel@tonic-gate
1717c478bd9Sstevel@tonic-gate (void) fflush(stdout);
1727c478bd9Sstevel@tonic-gate (void) fflush(stderr);
1737c478bd9Sstevel@tonic-gate
1747c478bd9Sstevel@tonic-gate if (ftrace != NULL && zap_stdio) {
1757c478bd9Sstevel@tonic-gate if (ftrace != stdout)
1767c478bd9Sstevel@tonic-gate (void) fclose(ftrace);
1777c478bd9Sstevel@tonic-gate ftrace = NULL;
1787c478bd9Sstevel@tonic-gate fd = open("/dev/null", O_RDWR);
1797c478bd9Sstevel@tonic-gate if (isatty(STDIN_FILENO))
1807c478bd9Sstevel@tonic-gate (void) dup2(fd, STDIN_FILENO);
1817c478bd9Sstevel@tonic-gate if (isatty(STDOUT_FILENO))
1827c478bd9Sstevel@tonic-gate (void) dup2(fd, STDOUT_FILENO);
1837c478bd9Sstevel@tonic-gate if (isatty(STDERR_FILENO))
1847c478bd9Sstevel@tonic-gate (void) dup2(fd, STDERR_FILENO);
1857c478bd9Sstevel@tonic-gate (void) close(fd);
1867c478bd9Sstevel@tonic-gate }
1877c478bd9Sstevel@tonic-gate lastlog_time.tv_sec = 0;
1887c478bd9Sstevel@tonic-gate }
1897c478bd9Sstevel@tonic-gate
1907c478bd9Sstevel@tonic-gate
1917c478bd9Sstevel@tonic-gate void
trace_flush(void)1927c478bd9Sstevel@tonic-gate trace_flush(void)
1937c478bd9Sstevel@tonic-gate {
1947c478bd9Sstevel@tonic-gate if (ftrace != NULL) {
1957c478bd9Sstevel@tonic-gate (void) fflush(ftrace);
1967c478bd9Sstevel@tonic-gate if (ferror(ftrace))
1977c478bd9Sstevel@tonic-gate trace_off("tracing off: %s",
1987c478bd9Sstevel@tonic-gate rip_strerror(ferror(ftrace)));
1997c478bd9Sstevel@tonic-gate }
2007c478bd9Sstevel@tonic-gate }
2017c478bd9Sstevel@tonic-gate
2027c478bd9Sstevel@tonic-gate
2037c478bd9Sstevel@tonic-gate void
trace_off(const char * p,...)2047c478bd9Sstevel@tonic-gate trace_off(const char *p, ...)
2057c478bd9Sstevel@tonic-gate {
2067c478bd9Sstevel@tonic-gate va_list args;
2077c478bd9Sstevel@tonic-gate
2087c478bd9Sstevel@tonic-gate
2097c478bd9Sstevel@tonic-gate if (ftrace != NULL) {
2107c478bd9Sstevel@tonic-gate lastlog();
2117c478bd9Sstevel@tonic-gate va_start(args, p);
2127c478bd9Sstevel@tonic-gate (void) vfprintf(ftrace, p, args);
2137c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
2147c478bd9Sstevel@tonic-gate (void) va_end(args);
2157c478bd9Sstevel@tonic-gate }
2167c478bd9Sstevel@tonic-gate trace_close(file_trace);
2177c478bd9Sstevel@tonic-gate
2187c478bd9Sstevel@tonic-gate new_tracelevel = tracelevel = 0;
2197c478bd9Sstevel@tonic-gate }
2207c478bd9Sstevel@tonic-gate
2217c478bd9Sstevel@tonic-gate
2227c478bd9Sstevel@tonic-gate /* log a change in tracing */
2237c478bd9Sstevel@tonic-gate void
tracelevel_msg(const char * pat,int dump)2247c478bd9Sstevel@tonic-gate tracelevel_msg(const char *pat,
2257c478bd9Sstevel@tonic-gate int dump) /* -1=no dump, 0=default, 1=force */
2267c478bd9Sstevel@tonic-gate {
2277c478bd9Sstevel@tonic-gate static const char *off_msgs[MAX_TRACELEVEL] = {
2287c478bd9Sstevel@tonic-gate "Tracing actions stopped",
2297c478bd9Sstevel@tonic-gate "Tracing packets stopped",
2307c478bd9Sstevel@tonic-gate "Tracing packet contents stopped",
2317c478bd9Sstevel@tonic-gate "Tracing kernel changes stopped",
2327c478bd9Sstevel@tonic-gate "Tracing routing socket messages stopped",
2337c478bd9Sstevel@tonic-gate };
2347c478bd9Sstevel@tonic-gate static const char *on_msgs[MAX_TRACELEVEL] = {
2357c478bd9Sstevel@tonic-gate "Tracing actions started",
2367c478bd9Sstevel@tonic-gate "Tracing packets started",
2377c478bd9Sstevel@tonic-gate "Tracing packet contents started",
2387c478bd9Sstevel@tonic-gate "Tracing kernel changes started",
2397c478bd9Sstevel@tonic-gate "Tracing routing socket messages started",
2407c478bd9Sstevel@tonic-gate };
2417c478bd9Sstevel@tonic-gate uint_t old_tracelevel = tracelevel;
2427c478bd9Sstevel@tonic-gate
2437c478bd9Sstevel@tonic-gate
2447c478bd9Sstevel@tonic-gate if (new_tracelevel < 0)
2457c478bd9Sstevel@tonic-gate new_tracelevel = 0;
2467c478bd9Sstevel@tonic-gate else if (new_tracelevel > MAX_TRACELEVEL)
2477c478bd9Sstevel@tonic-gate new_tracelevel = MAX_TRACELEVEL;
2487c478bd9Sstevel@tonic-gate
2497c478bd9Sstevel@tonic-gate if (new_tracelevel < tracelevel) {
2507c478bd9Sstevel@tonic-gate if (new_tracelevel <= 0) {
2517c478bd9Sstevel@tonic-gate trace_off(pat, off_msgs[0]);
2527c478bd9Sstevel@tonic-gate } else {
2537c478bd9Sstevel@tonic-gate do {
2547c478bd9Sstevel@tonic-gate tmsg(pat, off_msgs[tracelevel]);
2557c478bd9Sstevel@tonic-gate } while (--tracelevel != new_tracelevel);
2567c478bd9Sstevel@tonic-gate }
2577c478bd9Sstevel@tonic-gate
2587c478bd9Sstevel@tonic-gate } else if (new_tracelevel > tracelevel) {
2597c478bd9Sstevel@tonic-gate do {
2607c478bd9Sstevel@tonic-gate tmsg(pat, on_msgs[tracelevel++]);
2617c478bd9Sstevel@tonic-gate } while (tracelevel != new_tracelevel);
2627c478bd9Sstevel@tonic-gate }
2637c478bd9Sstevel@tonic-gate
2647c478bd9Sstevel@tonic-gate if (dump > 0 ||
2657c478bd9Sstevel@tonic-gate (dump == 0 && old_tracelevel == 0 && tracelevel != 0))
2667c478bd9Sstevel@tonic-gate trace_dump();
2677c478bd9Sstevel@tonic-gate }
2687c478bd9Sstevel@tonic-gate
2697c478bd9Sstevel@tonic-gate void
set_tracefile(const char * filename,const char * pat,int dump)2707c478bd9Sstevel@tonic-gate set_tracefile(const char *filename,
2717c478bd9Sstevel@tonic-gate const char *pat,
2727c478bd9Sstevel@tonic-gate int dump) /* -1=no dump, 0=default, 1=force */
2737c478bd9Sstevel@tonic-gate {
2747c478bd9Sstevel@tonic-gate struct stat stbuf;
2757c478bd9Sstevel@tonic-gate struct stat stbuf2;
2767c478bd9Sstevel@tonic-gate FILE *n_ftrace;
2777c478bd9Sstevel@tonic-gate const char *fn;
2787c478bd9Sstevel@tonic-gate int nfd;
2797c478bd9Sstevel@tonic-gate boolean_t allow_create;
2807c478bd9Sstevel@tonic-gate
2817c478bd9Sstevel@tonic-gate /*
2827c478bd9Sstevel@tonic-gate * main() calls this routine with "dump == -1". All others
2837c478bd9Sstevel@tonic-gate * call it with 0, so we take dump == -1 to mean "can create
2847c478bd9Sstevel@tonic-gate * the file."
2857c478bd9Sstevel@tonic-gate */
2867c478bd9Sstevel@tonic-gate allow_create = (dump == -1);
2877c478bd9Sstevel@tonic-gate
2887c478bd9Sstevel@tonic-gate /*
2897c478bd9Sstevel@tonic-gate * Allow a null filename to increase the level if the trace file
2907c478bd9Sstevel@tonic-gate * is already open or if coming from a trusted source, such as
2917c478bd9Sstevel@tonic-gate * a signal or the command line.
2927c478bd9Sstevel@tonic-gate */
2937c478bd9Sstevel@tonic-gate if (filename == NULL || filename[0] == '\0') {
2947c478bd9Sstevel@tonic-gate filename = NULL;
2957c478bd9Sstevel@tonic-gate if (ftrace == NULL) {
2967c478bd9Sstevel@tonic-gate if (inittracename[0] == '\0') {
2977c478bd9Sstevel@tonic-gate msglog("missing trace file name");
2987c478bd9Sstevel@tonic-gate return;
2997c478bd9Sstevel@tonic-gate }
3007c478bd9Sstevel@tonic-gate fn = inittracename;
3017c478bd9Sstevel@tonic-gate } else {
3027c478bd9Sstevel@tonic-gate goto set_tracelevel;
3037c478bd9Sstevel@tonic-gate }
3047c478bd9Sstevel@tonic-gate
3057c478bd9Sstevel@tonic-gate } else if (strcmp(filename, "dump/../table") == 0) {
3067c478bd9Sstevel@tonic-gate trace_dump();
3077c478bd9Sstevel@tonic-gate return;
3087c478bd9Sstevel@tonic-gate
3097c478bd9Sstevel@tonic-gate } else {
3107c478bd9Sstevel@tonic-gate /*
3117c478bd9Sstevel@tonic-gate * Allow the file specified with "-T file" to be reopened,
3127c478bd9Sstevel@tonic-gate * but require all other names specified over the net to
3137c478bd9Sstevel@tonic-gate * match the official path. The path can specify a directory
3147c478bd9Sstevel@tonic-gate * in which the file is to be created.
3157c478bd9Sstevel@tonic-gate */
3167c478bd9Sstevel@tonic-gate
3177c478bd9Sstevel@tonic-gate if (strcmp(filename, inittracename) != 0) {
3187c478bd9Sstevel@tonic-gate if (strncmp(filename, PATH_TRACE,
3197c478bd9Sstevel@tonic-gate sizeof (PATH_TRACE)-1) != 0 ||
3207c478bd9Sstevel@tonic-gate (strstr(filename, "../") != NULL)) {
3217c478bd9Sstevel@tonic-gate msglog("wrong trace file \"%s\"", filename);
3227c478bd9Sstevel@tonic-gate return;
3237c478bd9Sstevel@tonic-gate }
3247c478bd9Sstevel@tonic-gate if (stat(PATH_TRACE, &stbuf) == -1) {
3257c478bd9Sstevel@tonic-gate fn = PATH_TRACE;
3267c478bd9Sstevel@tonic-gate goto missing_file;
3277c478bd9Sstevel@tonic-gate }
3287c478bd9Sstevel@tonic-gate if (filename[sizeof (PATH_TRACE) - 1] != '\0' &&
3297c478bd9Sstevel@tonic-gate (filename[sizeof (PATH_TRACE) - 1] != '/' ||
3307c478bd9Sstevel@tonic-gate !S_ISDIR(stbuf.st_mode))) {
3317c478bd9Sstevel@tonic-gate goto bad_file_type;
3327c478bd9Sstevel@tonic-gate }
3337c478bd9Sstevel@tonic-gate if (S_ISDIR(stbuf.st_mode))
3347c478bd9Sstevel@tonic-gate allow_create = _B_TRUE;
3357c478bd9Sstevel@tonic-gate }
3367c478bd9Sstevel@tonic-gate
3377c478bd9Sstevel@tonic-gate fn = filename;
3387c478bd9Sstevel@tonic-gate }
3397c478bd9Sstevel@tonic-gate /* fn cannot be null here */
3407c478bd9Sstevel@tonic-gate
3417c478bd9Sstevel@tonic-gate /* If the new tracefile exists, it must be a regular file. */
3427c478bd9Sstevel@tonic-gate if (lstat(fn, &stbuf) == -1) {
3437c478bd9Sstevel@tonic-gate if (!allow_create)
3447c478bd9Sstevel@tonic-gate goto missing_file;
3457c478bd9Sstevel@tonic-gate nfd = open(fn, O_CREAT|O_EXCL|O_WRONLY, 0644);
3467c478bd9Sstevel@tonic-gate if (nfd != -1 && fstat(nfd, &stbuf) == -1) {
3477c478bd9Sstevel@tonic-gate (void) close(nfd);
3487c478bd9Sstevel@tonic-gate goto missing_file;
3497c478bd9Sstevel@tonic-gate }
3507c478bd9Sstevel@tonic-gate } else if (S_ISREG(stbuf.st_mode)) {
3517c478bd9Sstevel@tonic-gate nfd = open(fn, O_APPEND|O_WRONLY, 0644);
3527c478bd9Sstevel@tonic-gate } else {
3537c478bd9Sstevel@tonic-gate goto bad_file_type;
3547c478bd9Sstevel@tonic-gate }
3557c478bd9Sstevel@tonic-gate
3567c478bd9Sstevel@tonic-gate if (nfd == -1 || (n_ftrace = fdopen(nfd, "a")) == NULL) {
3577c478bd9Sstevel@tonic-gate msglog("failed to open trace file \"%s\" %s", fn,
3587c478bd9Sstevel@tonic-gate rip_strerror(errno));
3597c478bd9Sstevel@tonic-gate if (fn == inittracename)
3607c478bd9Sstevel@tonic-gate inittracename[0] = '\0';
3617c478bd9Sstevel@tonic-gate if (nfd != -1)
3627c478bd9Sstevel@tonic-gate (void) close(nfd);
3637c478bd9Sstevel@tonic-gate return;
3647c478bd9Sstevel@tonic-gate }
3657c478bd9Sstevel@tonic-gate
3667c478bd9Sstevel@tonic-gate if (fstat(nfd, &stbuf2) == -1 || !S_ISREG(stbuf2.st_mode) ||
3677c478bd9Sstevel@tonic-gate stbuf2.st_dev != stbuf.st_dev || stbuf2.st_ino != stbuf.st_ino) {
3687c478bd9Sstevel@tonic-gate msglog("trace file \"%s\" moved", fn);
3697c478bd9Sstevel@tonic-gate (void) fclose(n_ftrace);
3707c478bd9Sstevel@tonic-gate return;
3717c478bd9Sstevel@tonic-gate }
3727c478bd9Sstevel@tonic-gate
3737c478bd9Sstevel@tonic-gate tmsg("switch to trace file %s", fn);
3747c478bd9Sstevel@tonic-gate trace_close(file_trace = _B_TRUE);
3757c478bd9Sstevel@tonic-gate (void) dup2(nfd, STDOUT_FILENO);
3767c478bd9Sstevel@tonic-gate (void) dup2(nfd, STDERR_FILENO);
3777c478bd9Sstevel@tonic-gate
3787c478bd9Sstevel@tonic-gate if (fn != savetracename)
3797c478bd9Sstevel@tonic-gate (void) strlcpy(savetracename, fn, sizeof (savetracename) - 1);
3807c478bd9Sstevel@tonic-gate ftrace = n_ftrace;
3817c478bd9Sstevel@tonic-gate
3827c478bd9Sstevel@tonic-gate set_tracelevel:
3837c478bd9Sstevel@tonic-gate if (new_tracelevel == 0 || filename == NULL)
3847c478bd9Sstevel@tonic-gate new_tracelevel++;
3857c478bd9Sstevel@tonic-gate tracelevel_msg(pat, dump != 0 ? dump : (filename != NULL));
3867c478bd9Sstevel@tonic-gate return;
3877c478bd9Sstevel@tonic-gate
3887c478bd9Sstevel@tonic-gate missing_file:
3897c478bd9Sstevel@tonic-gate msglog("trace \"%s\" missing", fn);
3907c478bd9Sstevel@tonic-gate return;
3917c478bd9Sstevel@tonic-gate
3927c478bd9Sstevel@tonic-gate bad_file_type:
3937c478bd9Sstevel@tonic-gate msglog("wrong type (%#x) of trace file \"%s\"", stbuf.st_mode, fn);
3947c478bd9Sstevel@tonic-gate }
3957c478bd9Sstevel@tonic-gate
3967c478bd9Sstevel@tonic-gate
3977c478bd9Sstevel@tonic-gate /* ARGSUSED */
3987c478bd9Sstevel@tonic-gate void
sigtrace_more(int s)3997c478bd9Sstevel@tonic-gate sigtrace_more(int s)
4007c478bd9Sstevel@tonic-gate {
4017c478bd9Sstevel@tonic-gate new_tracelevel++;
4027c478bd9Sstevel@tonic-gate sigtrace_pat = "SIGUSR1: %s";
4037c478bd9Sstevel@tonic-gate if (signal(s, sigtrace_more) == SIG_ERR)
4047c478bd9Sstevel@tonic-gate msglog("signal: %s", rip_strerror(errno));
4057c478bd9Sstevel@tonic-gate }
4067c478bd9Sstevel@tonic-gate
4077c478bd9Sstevel@tonic-gate
4087c478bd9Sstevel@tonic-gate /* ARGSUSED */
4097c478bd9Sstevel@tonic-gate void
sigtrace_less(int s)4107c478bd9Sstevel@tonic-gate sigtrace_less(int s)
4117c478bd9Sstevel@tonic-gate {
4127c478bd9Sstevel@tonic-gate new_tracelevel--;
4137c478bd9Sstevel@tonic-gate sigtrace_pat = "SIGUSR2: %s";
4147c478bd9Sstevel@tonic-gate if (signal(s, sigtrace_less) == SIG_ERR)
4157c478bd9Sstevel@tonic-gate msglog("signal: %s", rip_strerror(errno));
4167c478bd9Sstevel@tonic-gate }
4177c478bd9Sstevel@tonic-gate
4187c478bd9Sstevel@tonic-gate /* ARGSUSED */
4197c478bd9Sstevel@tonic-gate void
sigtrace_dump(int s)4207c478bd9Sstevel@tonic-gate sigtrace_dump(int s)
4217c478bd9Sstevel@tonic-gate {
4227c478bd9Sstevel@tonic-gate trace_dump();
4237c478bd9Sstevel@tonic-gate if (signal(s, sigtrace_dump) == SIG_ERR)
4247c478bd9Sstevel@tonic-gate msglog("signal: %s", rip_strerror(errno));
4257c478bd9Sstevel@tonic-gate }
4267c478bd9Sstevel@tonic-gate
4277c478bd9Sstevel@tonic-gate /* Set tracing after a signal. */
4287c478bd9Sstevel@tonic-gate void
set_tracelevel(void)4297c478bd9Sstevel@tonic-gate set_tracelevel(void)
4307c478bd9Sstevel@tonic-gate {
4317c478bd9Sstevel@tonic-gate if (new_tracelevel == tracelevel)
4327c478bd9Sstevel@tonic-gate return;
4337c478bd9Sstevel@tonic-gate
4347c478bd9Sstevel@tonic-gate /*
4357c478bd9Sstevel@tonic-gate * If tracing entirely off, and there was no tracefile specified
4367c478bd9Sstevel@tonic-gate * on the command line, then leave it off.
4377c478bd9Sstevel@tonic-gate */
4387c478bd9Sstevel@tonic-gate if (new_tracelevel > tracelevel && ftrace == NULL) {
4397c478bd9Sstevel@tonic-gate if (savetracename[0] != '\0') {
4407c478bd9Sstevel@tonic-gate set_tracefile(savetracename, sigtrace_pat, 0);
4417c478bd9Sstevel@tonic-gate } else if (inittracename[0] != '\0') {
4427c478bd9Sstevel@tonic-gate set_tracefile(inittracename, sigtrace_pat, 0);
4437c478bd9Sstevel@tonic-gate } else {
4447c478bd9Sstevel@tonic-gate new_tracelevel = 0;
4457c478bd9Sstevel@tonic-gate return;
4467c478bd9Sstevel@tonic-gate }
4477c478bd9Sstevel@tonic-gate } else {
4487c478bd9Sstevel@tonic-gate tracelevel_msg(sigtrace_pat, 0);
4497c478bd9Sstevel@tonic-gate }
4507c478bd9Sstevel@tonic-gate }
4517c478bd9Sstevel@tonic-gate
4527c478bd9Sstevel@tonic-gate
4537c478bd9Sstevel@tonic-gate /* display an address */
4547c478bd9Sstevel@tonic-gate char *
addrname(in_addr_t addr,in_addr_t mask,int force)4557c478bd9Sstevel@tonic-gate addrname(in_addr_t addr, /* in network byte order */
4567c478bd9Sstevel@tonic-gate in_addr_t mask,
4577c478bd9Sstevel@tonic-gate int force) /* 0=show mask if nonstandard, */
4587c478bd9Sstevel@tonic-gate { /* 1=always show mask, 2=never */
4597c478bd9Sstevel@tonic-gate #define NUM_BUFS 4
4607c478bd9Sstevel@tonic-gate static int bufno;
4617c478bd9Sstevel@tonic-gate static struct {
4627c478bd9Sstevel@tonic-gate /*
4637c478bd9Sstevel@tonic-gate * this array can hold either of the following strings terminated
4647c478bd9Sstevel@tonic-gate * by a null character:
4657c478bd9Sstevel@tonic-gate * "xxx.xxx.xxx.xxx/xx"
4667c478bd9Sstevel@tonic-gate * "xxx.xxx.xxx.xxx (mask xxx.xxx.xxx.xxx)"
4677c478bd9Sstevel@tonic-gate *
4687c478bd9Sstevel@tonic-gate */
4697c478bd9Sstevel@tonic-gate char str[2*INET_ADDRSTRLEN + sizeof (" (mask )")];
4707c478bd9Sstevel@tonic-gate } bufs[NUM_BUFS];
4717c478bd9Sstevel@tonic-gate char *s, *sp;
4727c478bd9Sstevel@tonic-gate in_addr_t dmask;
4737c478bd9Sstevel@tonic-gate int i, len;
4747c478bd9Sstevel@tonic-gate struct in_addr tmp_addr;
4757c478bd9Sstevel@tonic-gate
4767c478bd9Sstevel@tonic-gate tmp_addr.s_addr = addr;
4777c478bd9Sstevel@tonic-gate len = strlcpy(bufs[bufno].str, inet_ntoa(tmp_addr),
4787c478bd9Sstevel@tonic-gate sizeof (bufs[bufno].str));
4797c478bd9Sstevel@tonic-gate s = bufs[bufno].str;
4807c478bd9Sstevel@tonic-gate bufno = (bufno+1) % NUM_BUFS;
4817c478bd9Sstevel@tonic-gate
4827c478bd9Sstevel@tonic-gate if (force == 1 || (force == 0 && mask != std_mask(addr))) {
4837c478bd9Sstevel@tonic-gate sp = &s[strlen(s)];
4847c478bd9Sstevel@tonic-gate
4857c478bd9Sstevel@tonic-gate dmask = mask & -mask;
4867c478bd9Sstevel@tonic-gate if (mask + dmask == 0) {
4877c478bd9Sstevel@tonic-gate i = ffs(mask);
4887c478bd9Sstevel@tonic-gate (void) snprintf(sp,
4897c478bd9Sstevel@tonic-gate (sizeof (bufs[bufno].str) - len), "/%d",
4907c478bd9Sstevel@tonic-gate (NBBY * sizeof (in_addr_t) + 1) - i);
4917c478bd9Sstevel@tonic-gate
4927c478bd9Sstevel@tonic-gate } else {
4937c478bd9Sstevel@tonic-gate (void) snprintf(sp,
4947c478bd9Sstevel@tonic-gate (sizeof (bufs[bufno].str) - len), " (mask %s)",
4957c478bd9Sstevel@tonic-gate naddr_ntoa(htonl(mask)));
4967c478bd9Sstevel@tonic-gate }
4977c478bd9Sstevel@tonic-gate }
4987c478bd9Sstevel@tonic-gate
4997c478bd9Sstevel@tonic-gate return (s);
5007c478bd9Sstevel@tonic-gate #undef NUM_BUFS
5017c478bd9Sstevel@tonic-gate }
5027c478bd9Sstevel@tonic-gate
5037c478bd9Sstevel@tonic-gate
5047c478bd9Sstevel@tonic-gate /* display a bit-field */
5057c478bd9Sstevel@tonic-gate struct or_bits {
5067c478bd9Sstevel@tonic-gate uint8_t origin;
5077c478bd9Sstevel@tonic-gate const char *origin_name;
5087c478bd9Sstevel@tonic-gate };
5097c478bd9Sstevel@tonic-gate
5107c478bd9Sstevel@tonic-gate static struct or_bits origin_bits[] = {
5117c478bd9Sstevel@tonic-gate { RO_RIP, "RIP" },
5127c478bd9Sstevel@tonic-gate { RO_RDISC, "RDISC" },
5137c478bd9Sstevel@tonic-gate { RO_STATIC, "STATIC" },
5147c478bd9Sstevel@tonic-gate { RO_LOOPBCK, "LOOPBCK" },
5157c478bd9Sstevel@tonic-gate { RO_PTOPT, "PTOPT" },
5167c478bd9Sstevel@tonic-gate { RO_NET_SYN, "NET_SYN" },
5177c478bd9Sstevel@tonic-gate { RO_IF, "IF" },
5187c478bd9Sstevel@tonic-gate { RO_FILE, "FILE" },
5197c478bd9Sstevel@tonic-gate { RO_NONE, " " },
5207c478bd9Sstevel@tonic-gate { 0, NULL}
5217c478bd9Sstevel@tonic-gate };
5227c478bd9Sstevel@tonic-gate
5237c478bd9Sstevel@tonic-gate /* display a bit-field */
5247c478bd9Sstevel@tonic-gate struct bits {
525aee32e3dScarlsonj uint64_t bits_mask;
526aee32e3dScarlsonj uint64_t bits_clear;
5277c478bd9Sstevel@tonic-gate const char *bits_name;
5287c478bd9Sstevel@tonic-gate };
5297c478bd9Sstevel@tonic-gate
5307c478bd9Sstevel@tonic-gate static struct bits if_bits[] = {
5317c478bd9Sstevel@tonic-gate { IFF_BROADCAST, 0, "BROADCAST" },
5327c478bd9Sstevel@tonic-gate { IFF_DEBUG, 0, "DEBUG" },
5337c478bd9Sstevel@tonic-gate { IFF_LOOPBACK, 0, "LOOPBACK" },
5347c478bd9Sstevel@tonic-gate { IFF_POINTOPOINT, 0, "POINTOPOINT" },
5357c478bd9Sstevel@tonic-gate { IFF_NOTRAILERS, 0, "NOTRAILERS" },
5367c478bd9Sstevel@tonic-gate { IFF_RUNNING, 0, "RUNNING" },
5377c478bd9Sstevel@tonic-gate { IFF_NOARP, 0, "NOARP" },
5387c478bd9Sstevel@tonic-gate { IFF_PROMISC, 0, "PROMISC" },
5397c478bd9Sstevel@tonic-gate { IFF_ALLMULTI, 0, "ALLMULTI" },
5407c478bd9Sstevel@tonic-gate { IFF_INTELLIGENT, 0, "INTELLIGENT" },
5417c478bd9Sstevel@tonic-gate { IFF_MULTICAST, 0, "MULTICAST" },
5427c478bd9Sstevel@tonic-gate { IFF_MULTI_BCAST, 0, "MULTI_BCAST" },
5437c478bd9Sstevel@tonic-gate { IFF_UNNUMBERED, 0, "UNNUMBERED" },
5447c478bd9Sstevel@tonic-gate { IFF_DHCPRUNNING, 0, "DHCP" },
5457c478bd9Sstevel@tonic-gate { IFF_PRIVATE, 0, "PRIVATE" },
5467c478bd9Sstevel@tonic-gate { IFF_NOXMIT, 0, "NOXMIT" },
5477c478bd9Sstevel@tonic-gate { IFF_NOLOCAL, 0, "NOLOCAL" },
5487c478bd9Sstevel@tonic-gate { IFF_DEPRECATED, 0, "DEPRECATED" },
5497c478bd9Sstevel@tonic-gate { IFF_ADDRCONF, 0, "ADDRCONF" },
5507c478bd9Sstevel@tonic-gate { IFF_ROUTER, 0, "ROUTER" },
5517c478bd9Sstevel@tonic-gate { IFF_NONUD, 0, "NONUD" },
5527c478bd9Sstevel@tonic-gate { IFF_ANYCAST, 0, "ANYCAST" },
5537c478bd9Sstevel@tonic-gate { IFF_NORTEXCH, 0, "NORTEXCH" },
5547c478bd9Sstevel@tonic-gate { IFF_IPV4, 0, "IPv4" },
5557c478bd9Sstevel@tonic-gate { IFF_IPV6, 0, "IPv6" },
5567c478bd9Sstevel@tonic-gate { IFF_NOFAILOVER, 0, "NOFAILOVER" },
5577c478bd9Sstevel@tonic-gate { IFF_FAILED, 0, "FAILED" },
5587c478bd9Sstevel@tonic-gate { IFF_STANDBY, 0, "STANDBY" },
5597c478bd9Sstevel@tonic-gate { IFF_INACTIVE, 0, "INACTIVE" },
5607c478bd9Sstevel@tonic-gate { IFF_OFFLINE, 0, "OFFLINE" },
5617c478bd9Sstevel@tonic-gate { IFF_XRESOLV, 0, "XRESOLV" },
5627c478bd9Sstevel@tonic-gate { IFF_COS_ENABLED, 0, "CoS" },
5637c478bd9Sstevel@tonic-gate { IFF_PREFERRED, 0, "PREFERRED" },
5647c478bd9Sstevel@tonic-gate { IFF_TEMPORARY, 0, "TEMPORARY" },
5657c478bd9Sstevel@tonic-gate { IFF_FIXEDMTU, 0, "FIXEDMTU" },
5667c478bd9Sstevel@tonic-gate { IFF_VIRTUAL, 0, "VIRTUAL"},
567*e11c3f44Smeem { IFF_IPMP, 0, "IPMP"},
5687c478bd9Sstevel@tonic-gate { 0, 0, NULL}
5697c478bd9Sstevel@tonic-gate };
5707c478bd9Sstevel@tonic-gate
5717c478bd9Sstevel@tonic-gate static struct bits is_bits[] = {
5727c478bd9Sstevel@tonic-gate { IS_ALIAS, 0, "ALIAS" },
5737c478bd9Sstevel@tonic-gate { IS_SUBNET, 0, "" },
5747c478bd9Sstevel@tonic-gate { IS_REMOTE, (IS_NO_RDISC |
5757c478bd9Sstevel@tonic-gate IS_BCAST_RDISC), "REMOTE" },
5767c478bd9Sstevel@tonic-gate { IS_PASSIVE, (IS_NO_RDISC |
5777c478bd9Sstevel@tonic-gate IS_NO_RIP |
5787c478bd9Sstevel@tonic-gate IS_NO_SUPER_AG |
5797c478bd9Sstevel@tonic-gate IS_PM_RDISC |
5807c478bd9Sstevel@tonic-gate IS_NO_AG), "PASSIVE" },
5817c478bd9Sstevel@tonic-gate { IS_EXTERNAL, 0, "EXTERNAL" },
5827c478bd9Sstevel@tonic-gate { IS_CHECKED, 0, "" },
5837c478bd9Sstevel@tonic-gate { IS_ALL_HOSTS, 0, "" },
5847c478bd9Sstevel@tonic-gate { IS_ALL_ROUTERS, 0, "" },
5857c478bd9Sstevel@tonic-gate { IS_DISTRUST, 0, "DISTRUST" },
5867c478bd9Sstevel@tonic-gate { IS_BROKE, IS_SICK, "BROKEN" },
5877c478bd9Sstevel@tonic-gate { IS_SICK, 0, "SICK" },
5887c478bd9Sstevel@tonic-gate { IS_DUP, 0, "DUPLICATE" },
5897c478bd9Sstevel@tonic-gate { IS_REDIRECT_OK, 0, "REDIRECT_OK" },
5907c478bd9Sstevel@tonic-gate { IS_NEED_NET_SYN, 0, "" },
5917c478bd9Sstevel@tonic-gate { IS_NO_AG, IS_NO_SUPER_AG, "NO_AG" },
5927c478bd9Sstevel@tonic-gate { IS_NO_SUPER_AG, 0, "NO_SUPER_AG" },
5937c478bd9Sstevel@tonic-gate { (IS_NO_RIPV1_IN |
5947c478bd9Sstevel@tonic-gate IS_NO_RIPV2_IN |
5957c478bd9Sstevel@tonic-gate IS_NO_RIPV1_OUT |
5967c478bd9Sstevel@tonic-gate IS_NO_RIPV2_OUT), 0, "NO_RIP" },
5977c478bd9Sstevel@tonic-gate { (IS_NO_RIPV1_IN |
5987c478bd9Sstevel@tonic-gate IS_NO_RIPV1_OUT), 0, "RIPV2" },
5997c478bd9Sstevel@tonic-gate { IS_NO_RIPV1_IN, 0, "NO_RIPV1_IN" },
6007c478bd9Sstevel@tonic-gate { IS_NO_RIPV2_IN, 0, "NO_RIPV2_IN" },
6017c478bd9Sstevel@tonic-gate { IS_NO_RIPV1_OUT, 0, "NO_RIPV1_OUT" },
6027c478bd9Sstevel@tonic-gate { IS_NO_RIPV2_OUT, 0, "NO_RIPV2_OUT" },
6037c478bd9Sstevel@tonic-gate { IS_NO_RIP_MCAST, 0, "NO_RIP_MCAST" },
6047c478bd9Sstevel@tonic-gate { (IS_NO_ADV_IN |
6057c478bd9Sstevel@tonic-gate IS_NO_SOL_OUT |
6067c478bd9Sstevel@tonic-gate IS_NO_ADV_OUT), IS_BCAST_RDISC, "NO_RDISC" },
6077c478bd9Sstevel@tonic-gate { IS_NO_SOL_OUT, 0, "NO_SOLICIT" },
6087c478bd9Sstevel@tonic-gate { IS_SOL_OUT, 0, "SEND_SOLICIT" },
6097c478bd9Sstevel@tonic-gate { IS_NO_ADV_OUT, IS_BCAST_RDISC, "NO_RDISC_ADV" },
6107c478bd9Sstevel@tonic-gate { IS_ADV_OUT, 0, "RDISC_ADV" },
6117c478bd9Sstevel@tonic-gate { IS_BCAST_RDISC, 0, "BCAST_RDISC" },
6127c478bd9Sstevel@tonic-gate { IS_PM_RDISC, 0, "" },
6137c478bd9Sstevel@tonic-gate { IS_NO_HOST, 0, "NO_HOST" },
6147c478bd9Sstevel@tonic-gate { IS_SUPPRESS_RDISC, 0, "SUPPRESS_RDISC" },
6157c478bd9Sstevel@tonic-gate { IS_FLUSH_RDISC, 0, "FLUSH_RDISC" },
6167c478bd9Sstevel@tonic-gate { 0, 0, NULL}
6177c478bd9Sstevel@tonic-gate };
6187c478bd9Sstevel@tonic-gate
6197c478bd9Sstevel@tonic-gate static struct bits rs_bits[] = {
6207c478bd9Sstevel@tonic-gate { RS_IF, 0, "IF" },
6217c478bd9Sstevel@tonic-gate { RS_NET_INT, RS_NET_SYN, "NET_INT" },
6227c478bd9Sstevel@tonic-gate { RS_NET_SYN, 0, "NET_SYN" },
6237c478bd9Sstevel@tonic-gate { RS_SUBNET, 0, "" },
6247c478bd9Sstevel@tonic-gate { RS_LOCAL, 0, "LOCAL" },
6257c478bd9Sstevel@tonic-gate { RS_MHOME, 0, "MHOME" },
6267c478bd9Sstevel@tonic-gate { RS_STATIC, 0, "STATIC" },
6277c478bd9Sstevel@tonic-gate { RS_NOPROPAGATE, 0, "NOPROP" },
6287c478bd9Sstevel@tonic-gate { RS_BADIF, 0, "BADIF" },
6297c478bd9Sstevel@tonic-gate { 0, 0, NULL}
6307c478bd9Sstevel@tonic-gate };
6317c478bd9Sstevel@tonic-gate
6327c478bd9Sstevel@tonic-gate static struct bits ks_bits[] = {
6337c478bd9Sstevel@tonic-gate { KS_NEW, 0, "NEW" },
6347c478bd9Sstevel@tonic-gate { KS_DELETE, 0, "DELETE" },
6357c478bd9Sstevel@tonic-gate { KS_ADD, 0, "ADD" },
6367c478bd9Sstevel@tonic-gate { KS_CHANGE, 0, "CHANGE" },
6377c478bd9Sstevel@tonic-gate { KS_DEL_ADD, 0, "DEL_ADD" },
6387c478bd9Sstevel@tonic-gate { KS_STATIC, 0, "STATIC" },
6397c478bd9Sstevel@tonic-gate { KS_GATEWAY, 0, "GATEWAY" },
6407c478bd9Sstevel@tonic-gate { KS_DYNAMIC, 0, "DYNAMIC" },
6417c478bd9Sstevel@tonic-gate { KS_DELETED, 0, "DELETED" },
6427c478bd9Sstevel@tonic-gate { KS_PRIVATE, 0, "PRIVATE" },
6437c478bd9Sstevel@tonic-gate { KS_CHECK, 0, "CHECK" },
6447c478bd9Sstevel@tonic-gate { KS_IF, 0, "IF" },
6457c478bd9Sstevel@tonic-gate { KS_PASSIVE, 0, "PASSIVE" },
6467c478bd9Sstevel@tonic-gate { KS_DEPRE_IF, 0, "DEPRE_IF" },
6477c478bd9Sstevel@tonic-gate { KS_FILE, 0, "FILE" },
6487c478bd9Sstevel@tonic-gate { 0, 0, NULL}
6497c478bd9Sstevel@tonic-gate };
6507c478bd9Sstevel@tonic-gate
6517c478bd9Sstevel@tonic-gate static void
trace_bits(const struct bits * tbl,uint64_t field,boolean_t force)6527c478bd9Sstevel@tonic-gate trace_bits(const struct bits *tbl,
653aee32e3dScarlsonj uint64_t field,
6547c478bd9Sstevel@tonic-gate boolean_t force)
6557c478bd9Sstevel@tonic-gate {
656aee32e3dScarlsonj uint64_t b;
6577c478bd9Sstevel@tonic-gate char c;
6587c478bd9Sstevel@tonic-gate
6597c478bd9Sstevel@tonic-gate if (force) {
6607c478bd9Sstevel@tonic-gate (void) putc('<', ftrace);
6617c478bd9Sstevel@tonic-gate c = '\0';
6627c478bd9Sstevel@tonic-gate } else {
6637c478bd9Sstevel@tonic-gate c = '<';
6647c478bd9Sstevel@tonic-gate }
6657c478bd9Sstevel@tonic-gate
6667c478bd9Sstevel@tonic-gate while (field != 0 &&
6677c478bd9Sstevel@tonic-gate (b = tbl->bits_mask) != 0) {
6687c478bd9Sstevel@tonic-gate if ((b & field) == b) {
6697c478bd9Sstevel@tonic-gate if (tbl->bits_name[0] != '\0') {
6707c478bd9Sstevel@tonic-gate if (c != '\0')
6717c478bd9Sstevel@tonic-gate (void) putc(c, ftrace);
6727c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%s", tbl->bits_name);
6737c478bd9Sstevel@tonic-gate c = '|';
6747c478bd9Sstevel@tonic-gate }
6757c478bd9Sstevel@tonic-gate field &= ~(b | tbl->bits_clear);
6767c478bd9Sstevel@tonic-gate }
6777c478bd9Sstevel@tonic-gate tbl++;
6787c478bd9Sstevel@tonic-gate }
6797c478bd9Sstevel@tonic-gate if (field != 0) {
6807c478bd9Sstevel@tonic-gate if (c != '\0')
6817c478bd9Sstevel@tonic-gate (void) putc(c, ftrace);
682aee32e3dScarlsonj (void) fprintf(ftrace, "%#llx", field);
6837c478bd9Sstevel@tonic-gate c = '|';
6847c478bd9Sstevel@tonic-gate }
6857c478bd9Sstevel@tonic-gate
6867c478bd9Sstevel@tonic-gate if (c != '<' || force)
6877c478bd9Sstevel@tonic-gate (void) fputs("> ", ftrace);
6887c478bd9Sstevel@tonic-gate }
6897c478bd9Sstevel@tonic-gate
6907c478bd9Sstevel@tonic-gate static char *
trace_string(const struct bits * tbl,uint_t field,boolean_t force)6917c478bd9Sstevel@tonic-gate trace_string(const struct bits *tbl, uint_t field, boolean_t force)
6927c478bd9Sstevel@tonic-gate {
6937c478bd9Sstevel@tonic-gate const struct bits *tbp;
6947c478bd9Sstevel@tonic-gate char *sbuf, *cp, chr;
6957c478bd9Sstevel@tonic-gate size_t slen;
6967c478bd9Sstevel@tonic-gate
6977c478bd9Sstevel@tonic-gate /* minimum default string */
6987c478bd9Sstevel@tonic-gate slen = sizeof ("<0x12345678>");
6997c478bd9Sstevel@tonic-gate for (tbp = tbl; tbp->bits_mask != 0; tbp++)
7007c478bd9Sstevel@tonic-gate if (tbp->bits_name[0] != '\0')
7017c478bd9Sstevel@tonic-gate slen += strlen(tbp->bits_name) + 1;
7027c478bd9Sstevel@tonic-gate if ((sbuf = malloc(slen)) == NULL)
7037c478bd9Sstevel@tonic-gate return (NULL);
7047c478bd9Sstevel@tonic-gate cp = sbuf;
7057c478bd9Sstevel@tonic-gate
7067c478bd9Sstevel@tonic-gate if (force) {
7077c478bd9Sstevel@tonic-gate *cp++ = '<';
7087c478bd9Sstevel@tonic-gate chr = '\0';
7097c478bd9Sstevel@tonic-gate } else {
7107c478bd9Sstevel@tonic-gate chr = '<';
7117c478bd9Sstevel@tonic-gate }
7127c478bd9Sstevel@tonic-gate
7137c478bd9Sstevel@tonic-gate while (field != 0 && tbl->bits_mask != 0) {
7147c478bd9Sstevel@tonic-gate if ((tbl->bits_mask & field) == tbl->bits_mask) {
7157c478bd9Sstevel@tonic-gate if (tbl->bits_name[0] != '\0') {
7167c478bd9Sstevel@tonic-gate if (chr != '\0')
7177c478bd9Sstevel@tonic-gate *cp++ = chr;
7187c478bd9Sstevel@tonic-gate (void) strcpy(cp, tbl->bits_name);
7197c478bd9Sstevel@tonic-gate cp += strlen(tbl->bits_name);
7207c478bd9Sstevel@tonic-gate chr = '|';
7217c478bd9Sstevel@tonic-gate }
7227c478bd9Sstevel@tonic-gate field &= ~(tbl->bits_mask | tbl->bits_clear);
7237c478bd9Sstevel@tonic-gate }
7247c478bd9Sstevel@tonic-gate tbl++;
7257c478bd9Sstevel@tonic-gate }
7267c478bd9Sstevel@tonic-gate if (field != 0) {
7277c478bd9Sstevel@tonic-gate if (chr != '\0')
7287c478bd9Sstevel@tonic-gate *cp++ = chr;
7297c478bd9Sstevel@tonic-gate cp += sprintf(cp, "%#x", field);
7307c478bd9Sstevel@tonic-gate chr = '|';
7317c478bd9Sstevel@tonic-gate }
7327c478bd9Sstevel@tonic-gate
7337c478bd9Sstevel@tonic-gate if (chr != '<' || force)
7347c478bd9Sstevel@tonic-gate *cp++ = '>';
7357c478bd9Sstevel@tonic-gate *cp = '\0';
7367c478bd9Sstevel@tonic-gate return (sbuf);
7377c478bd9Sstevel@tonic-gate }
7387c478bd9Sstevel@tonic-gate
7397c478bd9Sstevel@tonic-gate char *
if_bit_string(uint_t field,boolean_t force)7407c478bd9Sstevel@tonic-gate if_bit_string(uint_t field, boolean_t force)
7417c478bd9Sstevel@tonic-gate {
7427c478bd9Sstevel@tonic-gate return (trace_string(if_bits, field, force));
7437c478bd9Sstevel@tonic-gate }
7447c478bd9Sstevel@tonic-gate
7457c478bd9Sstevel@tonic-gate char *
rtname(in_addr_t dst,in_addr_t mask,in_addr_t gate)7467c478bd9Sstevel@tonic-gate rtname(in_addr_t dst,
7477c478bd9Sstevel@tonic-gate in_addr_t mask,
7487c478bd9Sstevel@tonic-gate in_addr_t gate)
7497c478bd9Sstevel@tonic-gate {
7507c478bd9Sstevel@tonic-gate static char buf[sizeof ("xxx.xxx.xxx.xxx/xx-->xxx.xxx.xxx.xxx")];
7517c478bd9Sstevel@tonic-gate int i;
7527c478bd9Sstevel@tonic-gate
7537c478bd9Sstevel@tonic-gate (void) snprintf(buf, sizeof (buf), "%-16s-->", addrname(dst, mask, 0));
7547c478bd9Sstevel@tonic-gate i = strlen(buf);
7557c478bd9Sstevel@tonic-gate (void) snprintf(&buf[i], (sizeof (buf) -i), "%-*s", 15+24-MAX(24, i),
7567c478bd9Sstevel@tonic-gate naddr_ntoa(gate));
7577c478bd9Sstevel@tonic-gate return (buf);
7587c478bd9Sstevel@tonic-gate }
7597c478bd9Sstevel@tonic-gate
7607c478bd9Sstevel@tonic-gate
7617c478bd9Sstevel@tonic-gate static void
print_rts(struct rt_spare * rts,int force_metric,int force_ifp,int force_router,int force_tag,int force_time)7627c478bd9Sstevel@tonic-gate print_rts(struct rt_spare *rts,
7637c478bd9Sstevel@tonic-gate int force_metric, /* -1=suppress, 0=default */
7647c478bd9Sstevel@tonic-gate int force_ifp, /* -1=suppress, 0=default */
7657c478bd9Sstevel@tonic-gate int force_router, /* -1=suppress, 0=default, 1=display */
7667c478bd9Sstevel@tonic-gate int force_tag, /* -1=suppress, 0=default, 1=display */
7677c478bd9Sstevel@tonic-gate int force_time) /* 0=suppress, 1=display */
7687c478bd9Sstevel@tonic-gate {
7697c478bd9Sstevel@tonic-gate int i;
7707c478bd9Sstevel@tonic-gate
7717c478bd9Sstevel@tonic-gate if (force_metric >= 0)
7727c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "metric=%-2d ", rts->rts_metric);
7737c478bd9Sstevel@tonic-gate if (force_ifp >= 0)
7747c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%s ", (rts->rts_ifp == 0 ?
7757c478bd9Sstevel@tonic-gate "if?" : rts->rts_ifp->int_name));
7767c478bd9Sstevel@tonic-gate if (force_router > 0 ||
7777c478bd9Sstevel@tonic-gate (force_router == 0 && rts->rts_router != rts->rts_gate))
7787c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "router=%s ",
7797c478bd9Sstevel@tonic-gate naddr_ntoa(rts->rts_router));
7807c478bd9Sstevel@tonic-gate if (force_time > 0)
7817c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%s ", ts(rts->rts_time));
7827c478bd9Sstevel@tonic-gate if (force_tag > 0 ||
7837c478bd9Sstevel@tonic-gate (force_tag == 0 && rts->rts_tag != 0))
7847c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "tag=%#x ", ntohs(rts->rts_tag));
7857c478bd9Sstevel@tonic-gate if (rts->rts_de_ag != 0) {
7867c478bd9Sstevel@tonic-gate for (i = 1; (uint_t)(1 << i) <= rts->rts_de_ag; i++)
7877c478bd9Sstevel@tonic-gate continue;
7887c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "de_ag=%d ", i);
7897c478bd9Sstevel@tonic-gate }
7907c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "flags 0x%x ", rts->rts_flags);
7917c478bd9Sstevel@tonic-gate
7927c478bd9Sstevel@tonic-gate }
7937c478bd9Sstevel@tonic-gate
7947c478bd9Sstevel@tonic-gate
7957c478bd9Sstevel@tonic-gate static void
print_rtsorigin(const struct or_bits * tbl,uint8_t route_origin)7967c478bd9Sstevel@tonic-gate print_rtsorigin(const struct or_bits *tbl, uint8_t route_origin)
7977c478bd9Sstevel@tonic-gate {
7987c478bd9Sstevel@tonic-gate
7997c478bd9Sstevel@tonic-gate uint8_t tblentry;
8007c478bd9Sstevel@tonic-gate while ((tblentry = tbl->origin) != 0) {
8017c478bd9Sstevel@tonic-gate if (tblentry == route_origin) {
8027c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "origin=%s ", tbl->origin_name);
8037c478bd9Sstevel@tonic-gate }
8047c478bd9Sstevel@tonic-gate tbl++;
8057c478bd9Sstevel@tonic-gate }
8067c478bd9Sstevel@tonic-gate }
8077c478bd9Sstevel@tonic-gate
8087c478bd9Sstevel@tonic-gate
8097c478bd9Sstevel@tonic-gate void
trace_if(const char * act,struct interface * ifp)8107c478bd9Sstevel@tonic-gate trace_if(const char *act, struct interface *ifp)
8117c478bd9Sstevel@tonic-gate {
8127c478bd9Sstevel@tonic-gate if (!TRACEACTIONS || ftrace == NULL)
8137c478bd9Sstevel@tonic-gate return;
8147c478bd9Sstevel@tonic-gate
8157c478bd9Sstevel@tonic-gate lastlog();
8167c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%-3s interface %-4s #%-3d ", act,
8177c478bd9Sstevel@tonic-gate ifp->int_name,
8187c478bd9Sstevel@tonic-gate ifp->int_phys != NULL ? ifp->int_phys->phyi_index : 0);
8197c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%-15s-->%-15s",
8207c478bd9Sstevel@tonic-gate naddr_ntoa(ifp->int_addr),
8217c478bd9Sstevel@tonic-gate addrname(((ifp->int_if_flags & IFF_POINTOPOINT) ?
8227c478bd9Sstevel@tonic-gate ifp->int_dstaddr : htonl(ifp->int_net)),
8237c478bd9Sstevel@tonic-gate ifp->int_mask, 1));
8247c478bd9Sstevel@tonic-gate if (ifp->int_metric != 0)
8257c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, " metric=%d", ifp->int_metric);
8267c478bd9Sstevel@tonic-gate if (!IS_RIP_OUT_OFF(ifp->int_state) &&
8277c478bd9Sstevel@tonic-gate ifp->int_d_metric != 0)
8287c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, " fake_default=%d", ifp->int_d_metric);
8297c478bd9Sstevel@tonic-gate (void) fputs("\n ", ftrace);
8307c478bd9Sstevel@tonic-gate trace_bits(if_bits, ifp->int_if_flags, _B_FALSE);
8317c478bd9Sstevel@tonic-gate trace_bits(is_bits, ifp->int_state, _B_FALSE);
8327c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
8337c478bd9Sstevel@tonic-gate }
8347c478bd9Sstevel@tonic-gate
8357c478bd9Sstevel@tonic-gate void
trace_khash(const struct khash * krt)8367c478bd9Sstevel@tonic-gate trace_khash(const struct khash *krt)
8377c478bd9Sstevel@tonic-gate {
8387c478bd9Sstevel@tonic-gate if (ftrace == NULL)
8397c478bd9Sstevel@tonic-gate return;
8407c478bd9Sstevel@tonic-gate
8417c478bd9Sstevel@tonic-gate lastlog();
8427c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, " %-15s-->%-15s metric=%d ",
8437c478bd9Sstevel@tonic-gate addrname(krt->k_dst, krt->k_mask, 0),
8447c478bd9Sstevel@tonic-gate naddr_ntoa(krt->k_gate), krt->k_metric);
8457c478bd9Sstevel@tonic-gate if (krt->k_ifp != NULL)
8467c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "ifp %s ", krt->k_ifp->int_name);
8477c478bd9Sstevel@tonic-gate else
8487c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "ifp NULL ");
8497c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%s ", ts(krt->k_keep));
8507c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%s ", ts(krt->k_redirect_time));
8517c478bd9Sstevel@tonic-gate trace_bits(ks_bits, krt->k_state, _B_TRUE);
8527c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
8537c478bd9Sstevel@tonic-gate }
8547c478bd9Sstevel@tonic-gate
8557c478bd9Sstevel@tonic-gate void
trace_dr(const struct dr * drp)8567c478bd9Sstevel@tonic-gate trace_dr(const struct dr *drp)
8577c478bd9Sstevel@tonic-gate {
8587c478bd9Sstevel@tonic-gate if (ftrace == NULL)
8597c478bd9Sstevel@tonic-gate return;
8607c478bd9Sstevel@tonic-gate
8617c478bd9Sstevel@tonic-gate lastlog();
8627c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, " %-4s %-15s %s ",
8637c478bd9Sstevel@tonic-gate drp->dr_ifp != NULL ? drp->dr_ifp->int_name : "?",
8647c478bd9Sstevel@tonic-gate naddr_ntoa(drp->dr_gate), ts(drp->dr_ts));
8657c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%s %d %u\n", ts(drp->dr_life),
8667c478bd9Sstevel@tonic-gate SIGN_PREF(drp->dr_recv_pref), drp->dr_pref);
8677c478bd9Sstevel@tonic-gate }
8687c478bd9Sstevel@tonic-gate
8697c478bd9Sstevel@tonic-gate void
trace_upslot(struct rt_entry * rt,struct rt_spare * rts,struct rt_spare * new)8707c478bd9Sstevel@tonic-gate trace_upslot(struct rt_entry *rt,
8717c478bd9Sstevel@tonic-gate struct rt_spare *rts,
8727c478bd9Sstevel@tonic-gate struct rt_spare *new)
8737c478bd9Sstevel@tonic-gate {
8747c478bd9Sstevel@tonic-gate if (!TRACEACTIONS || ftrace == NULL)
8757c478bd9Sstevel@tonic-gate return;
8767c478bd9Sstevel@tonic-gate
8777c478bd9Sstevel@tonic-gate if (rts->rts_gate == new->rts_gate &&
8787c478bd9Sstevel@tonic-gate rts->rts_router == new->rts_router &&
8797c478bd9Sstevel@tonic-gate rts->rts_metric == new->rts_metric &&
8807c478bd9Sstevel@tonic-gate rts->rts_tag == new->rts_tag &&
8817c478bd9Sstevel@tonic-gate rts->rts_de_ag == new->rts_de_ag)
8827c478bd9Sstevel@tonic-gate return;
8837c478bd9Sstevel@tonic-gate
8847c478bd9Sstevel@tonic-gate lastlog();
8857c478bd9Sstevel@tonic-gate if (new->rts_gate == 0) {
8867c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "Del #%d %-35s ",
8877c478bd9Sstevel@tonic-gate (int)(rts - rt->rt_spares),
8887c478bd9Sstevel@tonic-gate rtname(rt->rt_dst, rt->rt_mask, rts->rts_gate));
8897c478bd9Sstevel@tonic-gate print_rts(rts, 0, 0, 0, 0,
8907c478bd9Sstevel@tonic-gate (rts != rt->rt_spares ||
8917c478bd9Sstevel@tonic-gate AGE_RT(rt->rt_state, rts->rts_origin, new->rts_ifp)));
8927c478bd9Sstevel@tonic-gate
8937c478bd9Sstevel@tonic-gate } else if (rts->rts_gate != RIP_DEFAULT) {
8947c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "Chg #%d %-35s ",
8957c478bd9Sstevel@tonic-gate (int)(rts - rt->rt_spares),
8967c478bd9Sstevel@tonic-gate rtname(rt->rt_dst, rt->rt_mask, rts->rts_gate));
8977c478bd9Sstevel@tonic-gate print_rts(rts, 0, 0,
8987c478bd9Sstevel@tonic-gate rts->rts_gate != new->rts_gate,
8997c478bd9Sstevel@tonic-gate rts->rts_tag != new->rts_tag,
900*e11c3f44Smeem rts != rt->rt_spares ||
901*e11c3f44Smeem AGE_RT(rt->rt_state, rts->rts_origin, rt->rt_ifp));
9027c478bd9Sstevel@tonic-gate
9037c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "\n %19s%-16s ", "",
9047c478bd9Sstevel@tonic-gate (new->rts_gate != rts->rts_gate ?
9057c478bd9Sstevel@tonic-gate naddr_ntoa(new->rts_gate) : ""));
9067c478bd9Sstevel@tonic-gate print_rts(new,
9077c478bd9Sstevel@tonic-gate ((new->rts_metric == rts->rts_metric) ? -1 : 0),
9087c478bd9Sstevel@tonic-gate ((new->rts_ifp == rts->rts_ifp) ? -1 : 0),
9097c478bd9Sstevel@tonic-gate 0,
9107c478bd9Sstevel@tonic-gate rts->rts_tag != new->rts_tag,
9117c478bd9Sstevel@tonic-gate (new->rts_time != rts->rts_time &&
9127c478bd9Sstevel@tonic-gate (rts != rt->rt_spares ||
9137c478bd9Sstevel@tonic-gate AGE_RT(rt->rt_state, new->rts_origin, new->rts_ifp))));
9147c478bd9Sstevel@tonic-gate
9157c478bd9Sstevel@tonic-gate } else {
9167c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "Add #%d %-35s ",
9177c478bd9Sstevel@tonic-gate (int)(rts - rt->rt_spares),
9187c478bd9Sstevel@tonic-gate rtname(rt->rt_dst, rt->rt_mask, new->rts_gate));
9197c478bd9Sstevel@tonic-gate print_rts(new, 0, 0, 0, 0,
9207c478bd9Sstevel@tonic-gate (rts != rt->rt_spares ||
9217c478bd9Sstevel@tonic-gate AGE_RT(rt->rt_state, new->rts_origin, new->rts_ifp)));
9227c478bd9Sstevel@tonic-gate }
9237c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
9247c478bd9Sstevel@tonic-gate }
9257c478bd9Sstevel@tonic-gate
9267c478bd9Sstevel@tonic-gate
9277c478bd9Sstevel@tonic-gate /* miscellaneous message checked by the caller */
9287c478bd9Sstevel@tonic-gate void
trace_misc(const char * p,...)9297c478bd9Sstevel@tonic-gate trace_misc(const char *p, ...)
9307c478bd9Sstevel@tonic-gate {
9317c478bd9Sstevel@tonic-gate va_list args;
9327c478bd9Sstevel@tonic-gate
9337c478bd9Sstevel@tonic-gate if (ftrace == NULL)
9347c478bd9Sstevel@tonic-gate return;
9357c478bd9Sstevel@tonic-gate
9367c478bd9Sstevel@tonic-gate lastlog();
9377c478bd9Sstevel@tonic-gate va_start(args, p);
9387c478bd9Sstevel@tonic-gate (void) vfprintf(ftrace, p, args);
9397c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
9407c478bd9Sstevel@tonic-gate (void) va_end(args);
9417c478bd9Sstevel@tonic-gate }
9427c478bd9Sstevel@tonic-gate
9437c478bd9Sstevel@tonic-gate
9447c478bd9Sstevel@tonic-gate /* display a message if tracing actions */
9457c478bd9Sstevel@tonic-gate void
trace_act(const char * p,...)9467c478bd9Sstevel@tonic-gate trace_act(const char *p, ...)
9477c478bd9Sstevel@tonic-gate {
9487c478bd9Sstevel@tonic-gate va_list args;
9497c478bd9Sstevel@tonic-gate
9507c478bd9Sstevel@tonic-gate if (!TRACEACTIONS || ftrace == NULL)
9517c478bd9Sstevel@tonic-gate return;
9527c478bd9Sstevel@tonic-gate
9537c478bd9Sstevel@tonic-gate lastlog();
9547c478bd9Sstevel@tonic-gate va_start(args, p);
9557c478bd9Sstevel@tonic-gate (void) vfprintf(ftrace, p, args);
9567c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
9577c478bd9Sstevel@tonic-gate (void) va_end(args);
9587c478bd9Sstevel@tonic-gate }
9597c478bd9Sstevel@tonic-gate
9607c478bd9Sstevel@tonic-gate
9617c478bd9Sstevel@tonic-gate /* display a message if tracing packets */
9627c478bd9Sstevel@tonic-gate void
trace_pkt(const char * p,...)9637c478bd9Sstevel@tonic-gate trace_pkt(const char *p, ...)
9647c478bd9Sstevel@tonic-gate {
9657c478bd9Sstevel@tonic-gate va_list args;
9667c478bd9Sstevel@tonic-gate
9677c478bd9Sstevel@tonic-gate if (!TRACEPACKETS || ftrace == NULL)
9687c478bd9Sstevel@tonic-gate return;
9697c478bd9Sstevel@tonic-gate
9707c478bd9Sstevel@tonic-gate lastlog();
9717c478bd9Sstevel@tonic-gate va_start(args, p);
9727c478bd9Sstevel@tonic-gate (void) vfprintf(ftrace, p, args);
9737c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
9747c478bd9Sstevel@tonic-gate (void) va_end(args);
9757c478bd9Sstevel@tonic-gate }
9767c478bd9Sstevel@tonic-gate
9777c478bd9Sstevel@tonic-gate
9787c478bd9Sstevel@tonic-gate void
trace_change(struct rt_entry * rt,uint16_t state,struct rt_spare * new,const char * label)9797c478bd9Sstevel@tonic-gate trace_change(struct rt_entry *rt,
9807c478bd9Sstevel@tonic-gate uint16_t state,
9817c478bd9Sstevel@tonic-gate struct rt_spare *new,
9827c478bd9Sstevel@tonic-gate const char *label)
9837c478bd9Sstevel@tonic-gate {
9847c478bd9Sstevel@tonic-gate if (ftrace == NULL)
9857c478bd9Sstevel@tonic-gate return;
9867c478bd9Sstevel@tonic-gate
9877c478bd9Sstevel@tonic-gate if (rt->rt_metric == new->rts_metric &&
9887c478bd9Sstevel@tonic-gate rt->rt_gate == new->rts_gate &&
9897c478bd9Sstevel@tonic-gate rt->rt_router == new->rts_router &&
9907c478bd9Sstevel@tonic-gate rt->rt_state == state &&
9917c478bd9Sstevel@tonic-gate rt->rt_tag == new->rts_tag &&
9927c478bd9Sstevel@tonic-gate rt->rt_de_ag == new->rts_de_ag)
9937c478bd9Sstevel@tonic-gate return;
9947c478bd9Sstevel@tonic-gate
9957c478bd9Sstevel@tonic-gate lastlog();
9967c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%s %-35s ",
9977c478bd9Sstevel@tonic-gate label,
9987c478bd9Sstevel@tonic-gate rtname(rt->rt_dst, rt->rt_mask, rt->rt_gate));
9997c478bd9Sstevel@tonic-gate print_rts(rt->rt_spares,
10007c478bd9Sstevel@tonic-gate 0, 0, 0, 0, AGE_RT(rt->rt_state, rt->rt_spares->rts_origin,
10017c478bd9Sstevel@tonic-gate rt->rt_ifp));
10027c478bd9Sstevel@tonic-gate print_rtsorigin(origin_bits, rt->rt_spares->rts_origin);
10037c478bd9Sstevel@tonic-gate trace_bits(rs_bits, rt->rt_state, rt->rt_state != state);
10047c478bd9Sstevel@tonic-gate
10057c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "\n%*s %19s%-16s ",
10067c478bd9Sstevel@tonic-gate strlen(label), "", "",
10077c478bd9Sstevel@tonic-gate (rt->rt_gate != new->rts_gate ?
10087c478bd9Sstevel@tonic-gate naddr_ntoa(new->rts_gate) : ""));
10097c478bd9Sstevel@tonic-gate print_rts(new,
10107c478bd9Sstevel@tonic-gate ((new->rts_metric == rt->rt_metric) ? -1 : 0),
10117c478bd9Sstevel@tonic-gate ((new->rts_ifp == rt->rt_ifp) ? -1 : 0),
10127c478bd9Sstevel@tonic-gate 0,
10137c478bd9Sstevel@tonic-gate rt->rt_tag != new->rts_tag,
10147c478bd9Sstevel@tonic-gate (rt->rt_time != new->rts_time &&
10157c478bd9Sstevel@tonic-gate AGE_RT(rt->rt_state, new->rts_origin, new->rts_ifp)));
10167c478bd9Sstevel@tonic-gate if (rt->rt_state != state) {
10177c478bd9Sstevel@tonic-gate print_rtsorigin(origin_bits, new->rts_origin);
10187c478bd9Sstevel@tonic-gate trace_bits(rs_bits, state, _B_TRUE);
10197c478bd9Sstevel@tonic-gate }
10207c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
10217c478bd9Sstevel@tonic-gate }
10227c478bd9Sstevel@tonic-gate
10237c478bd9Sstevel@tonic-gate
10247c478bd9Sstevel@tonic-gate void
trace_add_del(const char * action,struct rt_entry * rt)10257c478bd9Sstevel@tonic-gate trace_add_del(const char *action, struct rt_entry *rt)
10267c478bd9Sstevel@tonic-gate {
10277c478bd9Sstevel@tonic-gate if (ftrace == NULL)
10287c478bd9Sstevel@tonic-gate return;
10297c478bd9Sstevel@tonic-gate
10307c478bd9Sstevel@tonic-gate lastlog();
10317c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%s %-35s ",
10327c478bd9Sstevel@tonic-gate action,
10337c478bd9Sstevel@tonic-gate rtname(rt->rt_dst, rt->rt_mask, rt->rt_gate));
10347c478bd9Sstevel@tonic-gate print_rts(rt->rt_spares, 0, 0, 0, 0, AGE_RT(rt->rt_state,
10357c478bd9Sstevel@tonic-gate rt->rt_spares->rts_origin, rt->rt_ifp));
10367c478bd9Sstevel@tonic-gate print_rtsorigin(origin_bits, rt->rt_spares->rts_origin);
10377c478bd9Sstevel@tonic-gate trace_bits(rs_bits, rt->rt_state, _B_FALSE);
10387c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
10397c478bd9Sstevel@tonic-gate }
10407c478bd9Sstevel@tonic-gate
10417c478bd9Sstevel@tonic-gate
10427c478bd9Sstevel@tonic-gate /* ARGSUSED */
10437c478bd9Sstevel@tonic-gate static int
walk_trace(struct radix_node * rn,void * w)10447c478bd9Sstevel@tonic-gate walk_trace(struct radix_node *rn,
10457c478bd9Sstevel@tonic-gate void *w)
10467c478bd9Sstevel@tonic-gate {
10477c478bd9Sstevel@tonic-gate #define RT ((struct rt_entry *)rn)
10487c478bd9Sstevel@tonic-gate struct rt_spare *rts;
10497c478bd9Sstevel@tonic-gate int i;
10507c478bd9Sstevel@tonic-gate
10517c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, " %-35s ",
10527c478bd9Sstevel@tonic-gate rtname(RT->rt_dst, RT->rt_mask, RT->rt_gate));
10537c478bd9Sstevel@tonic-gate print_rts(&RT->rt_spares[0], 0, 0, 0, 0,
10547c478bd9Sstevel@tonic-gate AGE_RT(RT->rt_state, RT->rt_spares[0].rts_origin, RT->rt_ifp));
10557c478bd9Sstevel@tonic-gate print_rtsorigin(origin_bits, RT->rt_spares[0].rts_origin);
10567c478bd9Sstevel@tonic-gate trace_bits(rs_bits, RT->rt_state, _B_FALSE);
10577c478bd9Sstevel@tonic-gate if (RT->rt_poison_time >= now_garbage &&
10587c478bd9Sstevel@tonic-gate RT->rt_poison_metric < RT->rt_metric)
10597c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "pm=%d@%s",
10607c478bd9Sstevel@tonic-gate RT->rt_poison_metric, ts(RT->rt_poison_time));
106109f979dcSsowmini (void) fprintf(ftrace, "%d spare slots", RT->rt_num_spares);
10627c478bd9Sstevel@tonic-gate
10637c478bd9Sstevel@tonic-gate rts = &RT->rt_spares[1];
10647c478bd9Sstevel@tonic-gate for (i = 1; i < RT->rt_num_spares; i++, rts++) {
10657c478bd9Sstevel@tonic-gate if (rts->rts_gate != RIP_DEFAULT) {
10667c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "\n #%d%15s%-16s ",
10677c478bd9Sstevel@tonic-gate i, "", naddr_ntoa(rts->rts_gate));
10687c478bd9Sstevel@tonic-gate print_rts(rts, 0, 0, 0, 0, 1);
10697c478bd9Sstevel@tonic-gate print_rtsorigin(origin_bits, rts->rts_origin);
10707c478bd9Sstevel@tonic-gate }
10717c478bd9Sstevel@tonic-gate }
10727c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
10737c478bd9Sstevel@tonic-gate
10747c478bd9Sstevel@tonic-gate return (0);
10757c478bd9Sstevel@tonic-gate }
10767c478bd9Sstevel@tonic-gate
10777c478bd9Sstevel@tonic-gate
10787c478bd9Sstevel@tonic-gate void
trace_dump(void)10797c478bd9Sstevel@tonic-gate trace_dump(void)
10807c478bd9Sstevel@tonic-gate {
10817c478bd9Sstevel@tonic-gate struct interface *ifp;
10827c478bd9Sstevel@tonic-gate
10837c478bd9Sstevel@tonic-gate if (ftrace == NULL)
10847c478bd9Sstevel@tonic-gate return;
10857c478bd9Sstevel@tonic-gate lastlog();
10867c478bd9Sstevel@tonic-gate
10877c478bd9Sstevel@tonic-gate /*
10887c478bd9Sstevel@tonic-gate * Warning: the rtquery.trace.* family of STC tests depend on
10897c478bd9Sstevel@tonic-gate * the log file format here. If you need to change this next
10907c478bd9Sstevel@tonic-gate * message, make sure that you change the TRACE_DUMP variable
10917c478bd9Sstevel@tonic-gate * as well.
10927c478bd9Sstevel@tonic-gate */
10937c478bd9Sstevel@tonic-gate (void) fputs("current daemon state:\n", ftrace);
10947c478bd9Sstevel@tonic-gate for (ifp = ifnet; ifp != NULL; ifp = ifp->int_next)
10957c478bd9Sstevel@tonic-gate trace_if("", ifp);
10967c478bd9Sstevel@tonic-gate (void) fputs("Routes:\n", ftrace);
10977c478bd9Sstevel@tonic-gate (void) rn_walktree(rhead, walk_trace, NULL);
10987c478bd9Sstevel@tonic-gate (void) fputs("Kernel routes:\n", ftrace);
10997c478bd9Sstevel@tonic-gate kern_dump();
11007c478bd9Sstevel@tonic-gate (void) fputs("Discovered routers:\n", ftrace);
11017c478bd9Sstevel@tonic-gate rdisc_dump();
11027c478bd9Sstevel@tonic-gate }
11037c478bd9Sstevel@tonic-gate
11047c478bd9Sstevel@tonic-gate
11057c478bd9Sstevel@tonic-gate void
trace_rip(const char * dir1,const char * dir2,struct sockaddr_in * who,struct interface * ifp,struct rip * msg,int size)11067c478bd9Sstevel@tonic-gate trace_rip(const char *dir1, const char *dir2,
11077c478bd9Sstevel@tonic-gate struct sockaddr_in *who,
11087c478bd9Sstevel@tonic-gate struct interface *ifp,
11097c478bd9Sstevel@tonic-gate struct rip *msg,
11107c478bd9Sstevel@tonic-gate int size) /* total size of message */
11117c478bd9Sstevel@tonic-gate {
11127c478bd9Sstevel@tonic-gate struct netinfo *n, *lim;
11137c478bd9Sstevel@tonic-gate #define NA ((struct netauth *)n)
11147c478bd9Sstevel@tonic-gate int i, seen_route;
11157c478bd9Sstevel@tonic-gate struct in_addr tmp_mask;
11167c478bd9Sstevel@tonic-gate
11177c478bd9Sstevel@tonic-gate if (!TRACEPACKETS || ftrace == NULL)
11187c478bd9Sstevel@tonic-gate return;
11197c478bd9Sstevel@tonic-gate
11207c478bd9Sstevel@tonic-gate lastlog();
11217c478bd9Sstevel@tonic-gate if (msg->rip_cmd >= RIPCMD_MAX || msg->rip_vers == 0) {
11227c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%s bad RIPv%d cmd=%d %s"
11237c478bd9Sstevel@tonic-gate " %s.%d size=%d\n",
11247c478bd9Sstevel@tonic-gate dir1, msg->rip_vers, msg->rip_cmd, dir2,
11257c478bd9Sstevel@tonic-gate naddr_ntoa(who->sin_addr.s_addr),
11267c478bd9Sstevel@tonic-gate ntohs(who->sin_port),
11277c478bd9Sstevel@tonic-gate size);
11287c478bd9Sstevel@tonic-gate return;
11297c478bd9Sstevel@tonic-gate }
11307c478bd9Sstevel@tonic-gate
11317c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%s RIPv%d %s %s %s.%d%s%s\n",
11327c478bd9Sstevel@tonic-gate dir1, msg->rip_vers, ripcmds[msg->rip_cmd], dir2,
11337c478bd9Sstevel@tonic-gate naddr_ntoa(who->sin_addr.s_addr), ntohs(who->sin_port),
11347c478bd9Sstevel@tonic-gate ifp ? " via " : "", ifp ? ifp->int_name : "");
11357c478bd9Sstevel@tonic-gate if (!TRACECONTENTS)
11367c478bd9Sstevel@tonic-gate return;
11377c478bd9Sstevel@tonic-gate
11387c478bd9Sstevel@tonic-gate seen_route = 0;
11397c478bd9Sstevel@tonic-gate switch (msg->rip_cmd) {
11407c478bd9Sstevel@tonic-gate case RIPCMD_REQUEST:
11417c478bd9Sstevel@tonic-gate case RIPCMD_RESPONSE:
11427c478bd9Sstevel@tonic-gate
11437c478bd9Sstevel@tonic-gate n = msg->rip_nets;
11447c478bd9Sstevel@tonic-gate tmp_mask.s_addr = n->n_mask;
11457c478bd9Sstevel@tonic-gate lim = n + (size - 4) / sizeof (struct netinfo);
11467c478bd9Sstevel@tonic-gate for (; n < lim; n++) {
11477c478bd9Sstevel@tonic-gate if (!seen_route &&
11487c478bd9Sstevel@tonic-gate n->n_family == RIP_AF_UNSPEC &&
11497c478bd9Sstevel@tonic-gate ntohl(n->n_metric) == HOPCNT_INFINITY &&
11507c478bd9Sstevel@tonic-gate msg->rip_cmd == RIPCMD_REQUEST &&
11517c478bd9Sstevel@tonic-gate (n+1 == lim ||
11527c478bd9Sstevel@tonic-gate (n+2 == lim &&
11537c478bd9Sstevel@tonic-gate (n+1)->n_family == RIP_AF_AUTH))) {
11547c478bd9Sstevel@tonic-gate (void) fputs("\tQUERY ", ftrace);
11557c478bd9Sstevel@tonic-gate if (n->n_dst != 0)
11567c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%s ",
11577c478bd9Sstevel@tonic-gate naddr_ntoa(n->n_dst));
11587c478bd9Sstevel@tonic-gate if (n->n_mask != 0)
11597c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "mask=%s ",
11607c478bd9Sstevel@tonic-gate inet_ntoa(tmp_mask));
11617c478bd9Sstevel@tonic-gate if (n->n_nhop != 0)
11627c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "nhop=%s ",
11637c478bd9Sstevel@tonic-gate naddr_ntoa(n->n_nhop));
11647c478bd9Sstevel@tonic-gate if (n->n_tag != 0)
11657c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "tag=%#x ",
11667c478bd9Sstevel@tonic-gate ntohs(n->n_tag));
11677c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
11687c478bd9Sstevel@tonic-gate continue;
11697c478bd9Sstevel@tonic-gate }
11707c478bd9Sstevel@tonic-gate
11717c478bd9Sstevel@tonic-gate if (n->n_family == RIP_AF_AUTH) {
11727c478bd9Sstevel@tonic-gate if (NA->a_type == RIP_AUTH_PW &&
11737c478bd9Sstevel@tonic-gate n == msg->rip_nets) {
11747c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "\tPassword"
1175*e11c3f44Smeem " Authentication: \"%s\"\n",
11767c478bd9Sstevel@tonic-gate qstring(NA->au.au_pw,
11777c478bd9Sstevel@tonic-gate RIP_AUTH_PW_LEN));
11787c478bd9Sstevel@tonic-gate continue;
11797c478bd9Sstevel@tonic-gate }
11807c478bd9Sstevel@tonic-gate
11817c478bd9Sstevel@tonic-gate if (NA->a_type == RIP_AUTH_MD5 &&
11827c478bd9Sstevel@tonic-gate n == msg->rip_nets) {
11837c478bd9Sstevel@tonic-gate (void) fprintf(ftrace,
11847c478bd9Sstevel@tonic-gate "\tMD5 Auth"
11857c478bd9Sstevel@tonic-gate " pkt_len=%d KeyID=%u"
11867c478bd9Sstevel@tonic-gate " auth_len=%d"
1187*e11c3f44Smeem " seqno=%#x"
1188*e11c3f44Smeem " rsvd=%#hx,%#hx\n",
11897c478bd9Sstevel@tonic-gate ntohs(NA->au.a_md5.md5_pkt_len),
11907c478bd9Sstevel@tonic-gate NA->au.a_md5.md5_keyid,
11917c478bd9Sstevel@tonic-gate NA->au.a_md5.md5_auth_len,
1192*e11c3f44Smeem ntohl(NA->au.a_md5.md5_seqno),
11937c478bd9Sstevel@tonic-gate ntohs(NA->au.a_md5.rsvd[0]),
11947c478bd9Sstevel@tonic-gate ntohs(NA->au.a_md5.rsvd[1]));
11957c478bd9Sstevel@tonic-gate continue;
11967c478bd9Sstevel@tonic-gate }
11977c478bd9Sstevel@tonic-gate (void) fprintf(ftrace,
11987c478bd9Sstevel@tonic-gate "\tAuthentication type %d: ",
11997c478bd9Sstevel@tonic-gate ntohs(NA->a_type));
12007c478bd9Sstevel@tonic-gate for (i = 0; i < (int)sizeof (NA->au.au_pw);
12017c478bd9Sstevel@tonic-gate i++)
12027c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "%02x ",
12037c478bd9Sstevel@tonic-gate NA->au.au_pw[i]);
12047c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
12057c478bd9Sstevel@tonic-gate continue;
12067c478bd9Sstevel@tonic-gate }
12077c478bd9Sstevel@tonic-gate
12087c478bd9Sstevel@tonic-gate seen_route = 1;
12097c478bd9Sstevel@tonic-gate if (n->n_family != RIP_AF_INET) {
12107c478bd9Sstevel@tonic-gate (void) fprintf(ftrace,
12117c478bd9Sstevel@tonic-gate "\t(af %d) %-18s mask=%s ",
12127c478bd9Sstevel@tonic-gate ntohs(n->n_family),
12137c478bd9Sstevel@tonic-gate naddr_ntoa(n->n_dst),
12147c478bd9Sstevel@tonic-gate inet_ntoa(tmp_mask));
12157c478bd9Sstevel@tonic-gate } else if (msg->rip_vers == RIPv1) {
12167c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "\t%-18s ",
1217*e11c3f44Smeem addrname(n->n_dst, ntohl(n->n_mask),
12187c478bd9Sstevel@tonic-gate n->n_mask == 0 ? 2 : 1));
12197c478bd9Sstevel@tonic-gate } else {
12207c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "\t%-18s ",
1221*e11c3f44Smeem addrname(n->n_dst, ntohl(n->n_mask),
12227c478bd9Sstevel@tonic-gate n->n_mask == 0 ? 2 : 0));
12237c478bd9Sstevel@tonic-gate }
12247c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "metric=%-2lu ",
12257c478bd9Sstevel@tonic-gate (unsigned long)ntohl(n->n_metric));
12267c478bd9Sstevel@tonic-gate if (n->n_nhop != 0)
12277c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, " nhop=%s ",
12287c478bd9Sstevel@tonic-gate naddr_ntoa(n->n_nhop));
12297c478bd9Sstevel@tonic-gate if (n->n_tag != 0)
12307c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "tag=%#x",
12317c478bd9Sstevel@tonic-gate ntohs(n->n_tag));
12327c478bd9Sstevel@tonic-gate (void) fputc('\n', ftrace);
12337c478bd9Sstevel@tonic-gate }
12347c478bd9Sstevel@tonic-gate if (size != (char *)n - (char *)msg)
12357c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "truncated record, len %d\n",
12367c478bd9Sstevel@tonic-gate size);
12377c478bd9Sstevel@tonic-gate break;
12387c478bd9Sstevel@tonic-gate
12397c478bd9Sstevel@tonic-gate case RIPCMD_TRACEON:
12407c478bd9Sstevel@tonic-gate (void) fprintf(ftrace, "\tfile=\"%.*s\"\n", size - 4,
12417c478bd9Sstevel@tonic-gate msg->rip_tracefile);
12427c478bd9Sstevel@tonic-gate break;
12437c478bd9Sstevel@tonic-gate
12447c478bd9Sstevel@tonic-gate case RIPCMD_TRACEOFF:
12457c478bd9Sstevel@tonic-gate break;
12467c478bd9Sstevel@tonic-gate }
12477c478bd9Sstevel@tonic-gate }
1248