trace.c revision 122760
111820Sjulian/* 211820Sjulian * Copyright (c) 1985, 1993 311820Sjulian * The Regents of the University of California. All rights reserved. 411820Sjulian * 511820Sjulian * Copyright (c) 1995 John Hay. All rights reserved. 611820Sjulian * 711820Sjulian * This file includes significant work done at Cornell University by 811820Sjulian * Bill Nesheim. That work included by permission. 911820Sjulian * 1011820Sjulian * Redistribution and use in source and binary forms, with or without 1111820Sjulian * modification, are permitted provided that the following conditions 1211820Sjulian * are met: 1311820Sjulian * 1. Redistributions of source code must retain the above copyright 1411820Sjulian * notice, this list of conditions and the following disclaimer. 1511820Sjulian * 2. Redistributions in binary form must reproduce the above copyright 1611820Sjulian * notice, this list of conditions and the following disclaimer in the 1711820Sjulian * documentation and/or other materials provided with the distribution. 1811820Sjulian * 3. All advertising materials mentioning features or use of this software 1911820Sjulian * must display the following acknowledgement: 2011820Sjulian * This product includes software developed by the University of 2111820Sjulian * California, Berkeley and its contributors. 2211820Sjulian * 4. Neither the name of the University nor the names of its contributors 2311820Sjulian * may be used to endorse or promote products derived from this software 2411820Sjulian * without specific prior written permission. 2511820Sjulian * 2611820Sjulian * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2711820Sjulian * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2811820Sjulian * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2911820Sjulian * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3011820Sjulian * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3111820Sjulian * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3211820Sjulian * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3311820Sjulian * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3411820Sjulian * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3511820Sjulian * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3611820Sjulian * SUCH DAMAGE. 3711820Sjulian */ 3811820Sjulian 3911820Sjulian#ifndef lint 4097632Swollman#if 0 4111820Sjulianstatic char sccsid[] = "@(#)trace.c 8.1 (Berkeley) 6/5/93"; 4297632Swollman#endif 4397632Swollmanstatic const char rcsid[] = 4497632Swollman "$FreeBSD: head/usr.sbin/IPXrouted/trace.c 122760 2003-11-15 17:10:56Z trhodes $"; 4511820Sjulian#endif /* not lint */ 4611820Sjulian 4711820Sjulian/* 4811820Sjulian * Routing Table Management Daemon 4911820Sjulian */ 5011820Sjulian#define RIPCMDS 5111820Sjulian#define SAPCMDS 5211820Sjulian#include <stdlib.h> 5311820Sjulian#include <unistd.h> 5411820Sjulian#include <sys/types.h> 5511820Sjulian#include <time.h> 5611820Sjulian#include "defs.h" 5711820Sjulian 5811820Sjulian#define NRECORDS 50 /* size of circular trace buffer */ 5911820Sjulian#ifdef DEBUG 6011820SjulianFILE *ftrace = stdout; 6111820Sjulianint tracing = 1; 6297632Swollman#else /* DEBUG */ 6311820SjulianFILE *ftrace = NULL; 6411820Sjulianint tracing = 0; 6511820Sjulian#endif 6611820Sjulian 6711820Sjulianvoid dumpif(FILE *fd, struct interface *ifp); 6811820Sjulianvoid dumptrace(FILE *fd, char *dir, struct ifdebug *ifd); 6911820Sjulian 7011820Sjulianvoid 7111820Sjuliantraceinit(ifp) 7211820Sjulian register struct interface *ifp; 7311820Sjulian{ 7411820Sjulian static int iftraceinit(); 7511820Sjulian 7611820Sjulian if (iftraceinit(ifp, &ifp->int_input) && 7711820Sjulian iftraceinit(ifp, &ifp->int_output)) 7811820Sjulian return; 7911820Sjulian tracing = 0; 8011820Sjulian syslog(LOG_ERR, "traceinit: can't init %s\n", ifp->int_name); 8111820Sjulian} 8211820Sjulian 8311820Sjulianstatic int 8411820Sjulianiftraceinit(ifp, ifd) 8511820Sjulian struct interface *ifp; 8611820Sjulian register struct ifdebug *ifd; 8711820Sjulian{ 8811820Sjulian register struct iftrace *t; 8911820Sjulian 9011820Sjulian ifd->ifd_records = 9111820Sjulian (struct iftrace *)malloc(NRECORDS * sizeof (struct iftrace)); 9211820Sjulian if (ifd->ifd_records == 0) 9311820Sjulian return (0); 9411820Sjulian ifd->ifd_front = ifd->ifd_records; 9511820Sjulian ifd->ifd_count = 0; 9611820Sjulian for (t = ifd->ifd_records; t < ifd->ifd_records + NRECORDS; t++) { 9711820Sjulian t->ift_size = 0; 9811820Sjulian t->ift_packet = 0; 9911820Sjulian } 10011820Sjulian ifd->ifd_if = ifp; 10111820Sjulian return (1); 10211820Sjulian} 10311820Sjulian 10411820Sjulianvoid 10511820Sjuliantraceon(file) 10611820Sjulian char *file; 10711820Sjulian{ 10811820Sjulian 10911820Sjulian if (ftrace != NULL) 11011820Sjulian return; 11111820Sjulian ftrace = fopen(file, "a"); 11211820Sjulian if (ftrace == NULL) 11311820Sjulian return; 11411820Sjulian dup2(fileno(ftrace), 1); 11511820Sjulian dup2(fileno(ftrace), 2); 11611820Sjulian tracing = 1; 11711820Sjulian} 11811820Sjulian 11911820Sjulianvoid 12011820Sjuliantraceoff(void) 12111820Sjulian{ 12211820Sjulian if (!tracing) 12311820Sjulian return; 12411820Sjulian if (ftrace != NULL) 12511820Sjulian fclose(ftrace); 12611820Sjulian ftrace = NULL; 12711820Sjulian tracing = 0; 12811820Sjulian} 12911820Sjulian 13011820Sjulianvoid 13111820Sjuliantrace(ifd, who, p, len, m) 13211820Sjulian register struct ifdebug *ifd; 13311820Sjulian struct sockaddr *who; 13411820Sjulian char *p; 13511820Sjulian int len, m; 13611820Sjulian{ 13711820Sjulian register struct iftrace *t; 13811820Sjulian 13911820Sjulian if (ifd->ifd_records == 0) 14011820Sjulian return; 14111820Sjulian t = ifd->ifd_front++; 14211820Sjulian if (ifd->ifd_front >= ifd->ifd_records + NRECORDS) 14311820Sjulian ifd->ifd_front = ifd->ifd_records; 14411820Sjulian if (ifd->ifd_count < NRECORDS) 14511820Sjulian ifd->ifd_count++; 14611820Sjulian if (t->ift_size > 0 && t->ift_packet) 14711820Sjulian free(t->ift_packet); 14811820Sjulian t->ift_packet = 0; 14911820Sjulian t->ift_stamp = time(0); 15011820Sjulian t->ift_who = *who; 15111820Sjulian if (len > 0) { 15211820Sjulian t->ift_packet = malloc(len); 15311820Sjulian if (t->ift_packet) 15411820Sjulian bcopy(p, t->ift_packet, len); 15511820Sjulian else 15611820Sjulian len = 0; 15711820Sjulian } 15811820Sjulian t->ift_size = len; 15911820Sjulian t->ift_metric = m; 16011820Sjulian} 16111820Sjulian 16211820Sjulianvoid 16311820Sjuliantraceaction(fd, action, rt) 16411820Sjulian FILE *fd; 16511820Sjulian char *action; 16611820Sjulian struct rt_entry *rt; 16711820Sjulian{ 16811820Sjulian struct sockaddr_ipx *dst, *gate; 16911820Sjulian static struct bits { 17011820Sjulian int t_bits; 17111820Sjulian char *t_name; 17211820Sjulian } flagbits[] = { 17311820Sjulian { RTF_UP, "UP" }, 17411820Sjulian { RTF_GATEWAY, "GATEWAY" }, 17511820Sjulian { RTF_HOST, "HOST" }, 17611820Sjulian { 0 } 17711820Sjulian }, statebits[] = { 17811820Sjulian { RTS_PASSIVE, "PASSIVE" }, 17911820Sjulian { RTS_REMOTE, "REMOTE" }, 18011820Sjulian { RTS_INTERFACE,"INTERFACE" }, 18111820Sjulian { RTS_CHANGED, "CHANGED" }, 18211820Sjulian { 0 } 18311820Sjulian }; 18411820Sjulian register struct bits *p; 18511820Sjulian register int first; 18611820Sjulian char *cp; 18711820Sjulian 18811820Sjulian if (fd == NULL) 18911820Sjulian return; 19011820Sjulian fprintf(fd, "%s ", action); 19111820Sjulian dst = (struct sockaddr_ipx *)&rt->rt_dst; 19211820Sjulian gate = (struct sockaddr_ipx *)&rt->rt_router; 19311820Sjulian fprintf(fd, "dst %s, ", ipxdp_ntoa(&dst->sipx_addr)); 19411820Sjulian fprintf(fd, "router %s, metric %d, ticks %d, flags", 19511820Sjulian ipxdp_ntoa(&gate->sipx_addr), rt->rt_metric, rt->rt_ticks); 19611820Sjulian cp = " %s"; 19711820Sjulian for (first = 1, p = flagbits; p->t_bits > 0; p++) { 19811820Sjulian if ((rt->rt_flags & p->t_bits) == 0) 19911820Sjulian continue; 20011820Sjulian fprintf(fd, cp, p->t_name); 20111820Sjulian if (first) { 20211820Sjulian cp = "|%s"; 20311820Sjulian first = 0; 20411820Sjulian } 20511820Sjulian } 20611820Sjulian fprintf(fd, " state"); 20711820Sjulian cp = " %s"; 20811820Sjulian for (first = 1, p = statebits; p->t_bits > 0; p++) { 20911820Sjulian if ((rt->rt_state & p->t_bits) == 0) 21011820Sjulian continue; 21111820Sjulian fprintf(fd, cp, p->t_name); 21211820Sjulian if (first) { 21311820Sjulian cp = "|%s"; 21411820Sjulian first = 0; 21511820Sjulian } 21611820Sjulian } 21711820Sjulian putc('\n', fd); 21811820Sjulian if (!tracepackets && (rt->rt_state & RTS_PASSIVE) == 0 && rt->rt_ifp) 21911820Sjulian dumpif(fd, rt->rt_ifp); 22011820Sjulian fflush(fd); 22111820Sjulian} 22211820Sjulian 22311820Sjulianvoid 22427244Sjhaytraceactionlog(action, rt) 22527244Sjhay char *action; 22627244Sjhay struct rt_entry *rt; 22727244Sjhay{ 22827244Sjhay struct sockaddr_ipx *dst, *gate; 22927244Sjhay static struct bits { 23027244Sjhay int t_bits; 23127244Sjhay char *t_name; 23227244Sjhay } flagbits[] = { 23327244Sjhay { RTF_UP, "UP" }, 23427244Sjhay { RTF_GATEWAY, "GATEWAY" }, 23527244Sjhay { RTF_HOST, "HOST" }, 23627244Sjhay { 0 } 23727244Sjhay }, statebits[] = { 23827244Sjhay { RTS_PASSIVE, "PASSIVE" }, 23927244Sjhay { RTS_REMOTE, "REMOTE" }, 24027244Sjhay { RTS_INTERFACE,"INTERFACE" }, 24127244Sjhay { RTS_CHANGED, "CHANGED" }, 24227244Sjhay { 0 } 24327244Sjhay }; 24427244Sjhay register struct bits *p; 24527244Sjhay register int first; 24627244Sjhay char *cp; 24727244Sjhay char *lstr, *olstr; 24827244Sjhay 24927244Sjhay dst = (struct sockaddr_ipx *)&rt->rt_dst; 25027244Sjhay gate = (struct sockaddr_ipx *)&rt->rt_router; 25127244Sjhay asprintf(&lstr, "%s dst %s,", action, ipxdp_ntoa(&dst->sipx_addr)); 25227244Sjhay olstr = lstr; 25327244Sjhay asprintf(&lstr, "%s router %s, metric %d, ticks %d, flags", 25427244Sjhay olstr, ipxdp_ntoa(&gate->sipx_addr), rt->rt_metric, rt->rt_ticks); 25527244Sjhay free(olstr); 25627244Sjhay olstr = lstr; 25727244Sjhay cp = "%s %s"; 25827244Sjhay for (first = 1, p = flagbits; p->t_bits > 0; p++) { 25927244Sjhay if ((rt->rt_flags & p->t_bits) == 0) 26027244Sjhay continue; 26127244Sjhay asprintf(&lstr, cp, olstr, p->t_name); 26227244Sjhay free(olstr); 26327244Sjhay olstr = lstr; 26427244Sjhay if (first) { 26527244Sjhay cp = "%s|%s"; 26627244Sjhay first = 0; 26727244Sjhay } 26827244Sjhay } 26927244Sjhay asprintf(&lstr, "%s state", olstr); 27027244Sjhay free(olstr); 27127244Sjhay olstr = lstr; 27227244Sjhay cp = "%s %s"; 27327244Sjhay for (first = 1, p = statebits; p->t_bits > 0; p++) { 27427244Sjhay if ((rt->rt_state & p->t_bits) == 0) 27527244Sjhay continue; 27627244Sjhay asprintf(&lstr, cp, olstr, p->t_name); 27727244Sjhay free(olstr); 27827244Sjhay olstr = lstr; 27927244Sjhay if (first) { 28027244Sjhay cp = "%s|%s"; 28127244Sjhay first = 0; 28227244Sjhay } 28327244Sjhay } 28462984Skris syslog(LOG_DEBUG, "%s", lstr); 28527244Sjhay free(lstr); 28627244Sjhay} 28727244Sjhay 28827244Sjhayvoid 28927244Sjhaytracesapactionlog(action, sap) 29027244Sjhay char *action; 29127244Sjhay struct sap_entry *sap; 29227244Sjhay{ 29327244Sjhay syslog(LOG_DEBUG, "%-12.12s service %04X %-20.20s " 29427244Sjhay "addr %s.%04X %c metric %d\n", 29527244Sjhay action, 29627244Sjhay ntohs(sap->sap.ServType), 29727244Sjhay sap->sap.ServName, 29827244Sjhay ipxdp_ntoa(&sap->sap.ipx), 29927244Sjhay ntohs(sap->sap.ipx.x_port), 30027244Sjhay (sap->clone ? 'C' : ' '), 30127244Sjhay ntohs(sap->sap.hops)); 30227244Sjhay} 30327244Sjhay 30427244Sjhayvoid 30511820Sjuliandumpif(fd, ifp) 30611820Sjulian register struct interface *ifp; 30711820Sjulian FILE *fd; 30811820Sjulian{ 30911820Sjulian if (ifp->int_input.ifd_count || ifp->int_output.ifd_count) { 31011820Sjulian fprintf(fd, "*** Packet history for interface %s ***\n", 31111820Sjulian ifp->int_name); 31211820Sjulian dumptrace(fd, "to", &ifp->int_output); 31311820Sjulian dumptrace(fd, "from", &ifp->int_input); 31411820Sjulian fprintf(fd, "*** end packet history ***\n"); 31511820Sjulian } 31611820Sjulian} 31711820Sjulian 31811820Sjulianvoid 31911820Sjuliandumptrace(fd, dir, ifd) 32011820Sjulian FILE *fd; 32111820Sjulian char *dir; 32211820Sjulian register struct ifdebug *ifd; 32311820Sjulian{ 32411820Sjulian register struct iftrace *t; 32511820Sjulian char *cp = !strcmp(dir, "to") ? "Output" : "Input"; 32611820Sjulian 32711820Sjulian if (ifd->ifd_front == ifd->ifd_records && 32811820Sjulian ifd->ifd_front->ift_size == 0) { 32911820Sjulian fprintf(fd, "%s: no packets.\n", cp); 33011820Sjulian return; 33111820Sjulian } 33211820Sjulian fprintf(fd, "%s trace:\n", cp); 33311820Sjulian t = ifd->ifd_front - ifd->ifd_count; 33411820Sjulian if (t < ifd->ifd_records) 33511820Sjulian t += NRECORDS; 33611820Sjulian for ( ; ifd->ifd_count; ifd->ifd_count--, t++) { 33711820Sjulian if (t >= ifd->ifd_records + NRECORDS) 33811820Sjulian t = ifd->ifd_records; 33911820Sjulian if (t->ift_size == 0) 34011820Sjulian continue; 34111820Sjulian fprintf(fd, "%.24s: metric=%d\n", ctime(&t->ift_stamp), 34211820Sjulian t->ift_metric); 34311820Sjulian dumppacket(fd, dir, &t->ift_who, t->ift_packet, t->ift_size); 34411820Sjulian } 34511820Sjulian} 34611820Sjulian 34711820Sjulianvoid 34811820Sjuliandumppacket(fd, dir, source, cp, size) 34911820Sjulian FILE *fd; 35011820Sjulian char *dir; 35111820Sjulian struct sockaddr *source; 35211820Sjulian char *cp; 35311820Sjulian register int size; 35411820Sjulian{ 35511820Sjulian register struct rip *msg = (struct rip *)cp; 35611820Sjulian register struct netinfo *n; 35711820Sjulian struct sockaddr_ipx *who = (struct sockaddr_ipx *)source; 35811820Sjulian 35911820Sjulian if (msg->rip_cmd && ntohs(msg->rip_cmd) < RIPCMD_MAX) 36011820Sjulian fprintf(fd, "%s %s %s#%x", ripcmds[ntohs(msg->rip_cmd)], 36111820Sjulian dir, ipxdp_ntoa(&who->sipx_addr), 36211820Sjulian ntohs(who->sipx_addr.x_port)); 36311820Sjulian else { 36411820Sjulian fprintf(fd, "Bad cmd 0x%x %s %s#%x\n", ntohs(msg->rip_cmd), 36511820Sjulian dir, ipxdp_ntoa(&who->sipx_addr), 36611820Sjulian ntohs(who->sipx_addr.x_port)); 367121552Speter fprintf(fd, "size=%d cp=%lx packet=%x\n", size, 368121552Speter (u_long)cp, (u_int)packet); 36911820Sjulian return; 37011820Sjulian } 37111820Sjulian switch (ntohs(msg->rip_cmd)) { 37211820Sjulian 37311820Sjulian case RIPCMD_REQUEST: 37411820Sjulian case RIPCMD_RESPONSE: 37511820Sjulian fprintf(fd, ":\n"); 37611820Sjulian size -= sizeof (u_short); 37711820Sjulian n = msg->rip_nets; 37811820Sjulian for (; size > 0; n++, size -= sizeof (struct netinfo)) { 37911820Sjulian if (size < sizeof (struct netinfo)) 38011820Sjulian break; 38111820Sjulian fprintf(fd, "\tnet %s metric %d ticks %d\n", 38211820Sjulian ipxdp_nettoa(n->rip_dst), 38311820Sjulian ntohs(n->rip_metric), 38411820Sjulian ntohs(n->rip_ticks)); 38511820Sjulian } 38611820Sjulian break; 38711820Sjulian 38811820Sjulian } 38911820Sjulian} 39011820Sjulian 39111820Sjulianvoid 39211820Sjuliandumpsappacket(fd, dir, source, cp, size) 39311820Sjulian FILE *fd; 39411820Sjulian char *dir; 39511820Sjulian struct sockaddr *source; 39611820Sjulian char *cp; 39711820Sjulian register int size; 39811820Sjulian{ 39911820Sjulian register struct sap_packet *msg = (struct sap_packet *)cp; 40011820Sjulian register struct sap_info *n; 40111820Sjulian struct sockaddr_ipx *who = (struct sockaddr_ipx *)source; 40211820Sjulian 40311820Sjulian if (msg->sap_cmd && ntohs(msg->sap_cmd) < SAPCMD_MAX) 40411820Sjulian fprintf(fd, "%s %s %s#%x", sapcmds[ntohs(msg->sap_cmd)], 40511820Sjulian dir, ipxdp_ntoa(&who->sipx_addr), 40611820Sjulian ntohs(who->sipx_addr.x_port)); 40711820Sjulian else { 40811820Sjulian fprintf(fd, "Bad cmd 0x%x %s %s#%x\n", ntohs(msg->sap_cmd), 40911820Sjulian dir, ipxdp_ntoa(&who->sipx_addr), 41011820Sjulian ntohs(who->sipx_addr.x_port)); 411121552Speter fprintf(fd, "size=%d cp=%lx packet=%x\n", size, 412121552Speter (u_long)cp, (u_int)packet); 41311820Sjulian return; 41411820Sjulian } 41511820Sjulian switch (ntohs(msg->sap_cmd)) { 41611820Sjulian 41711820Sjulian case SAP_REQ: 41811820Sjulian case SAP_RESP: 41911820Sjulian case SAP_REQ_NEAR: 42011820Sjulian case SAP_RESP_NEAR: 42111820Sjulian fprintf(fd, ":\n"); 42211820Sjulian size -= sizeof (u_short); 42311820Sjulian n = msg->sap; 42411820Sjulian for (; size > 0; n++, size -= sizeof (struct sap_info)) { 42511820Sjulian if (size < sizeof (struct sap_info)) 42611820Sjulian break; 42711820Sjulian fprintf(fd, " service %04X %-20.20s " 42811820Sjulian "addr %s.%04X metric %d\n", 42911820Sjulian ntohs(n->ServType), 43011820Sjulian n->ServName, 43111820Sjulian ipxdp_ntoa(&n->ipx), 43211820Sjulian ntohs(n->ipx.x_port), 43311820Sjulian ntohs(n->hops)); 43411820Sjulian } 43511820Sjulian break; 43611820Sjulian 43711820Sjulian } 43811820Sjulian} 43911820Sjulian 44011820Sjulianvoid 44111820Sjuliandumpsaptable(fd, sh) 44211820Sjulian FILE *fd; 44311820Sjulian struct sap_hash *sh; 44411820Sjulian{ 44511820Sjulian register struct sap_entry *sap; 44611820Sjulian struct sap_hash *hash; 44711820Sjulian int x = 0; 44811820Sjulian 44911820Sjulian fprintf(fd, "------- SAP table dump. -------\n"); 45011820Sjulian for (hash = sh; hash < &sh[SAPHASHSIZ]; hash++, x++) { 45111820Sjulian fprintf(fd, "HASH %d\n", x); 45211820Sjulian sap = hash->forw; 45311820Sjulian for (; sap != (struct sap_entry *)hash; sap = sap->forw) { 45411820Sjulian fprintf(fd, " service %04X %-20.20s " 45511820Sjulian "addr %s.%04X %c metric %d\n", 45611820Sjulian ntohs(sap->sap.ServType), 45711820Sjulian sap->sap.ServName, 45811820Sjulian ipxdp_ntoa(&sap->sap.ipx), 45911820Sjulian ntohs(sap->sap.ipx.x_port), 46011820Sjulian (sap->clone ? 'C' : ' '), 46111820Sjulian ntohs(sap->sap.hops)); 46211820Sjulian } 46311820Sjulian } 46411820Sjulian fprintf(fd, "\n"); 46511820Sjulian} 46611820Sjulian 46715248Sjhayvoid 46815248Sjhaydumpriptable(fd) 46915248Sjhay FILE *fd; 47015248Sjhay{ 47115248Sjhay register struct rt_entry *rip; 47215248Sjhay struct rthash *hash; 47315248Sjhay int x; 47415248Sjhay struct rthash *rh = nethash; 47515248Sjhay 47615248Sjhay fprintf(fd, "------- RIP table dump. -------\n"); 47715248Sjhay x = 0; 47815248Sjhay fprintf(fd, "Network table.\n"); 47915248Sjhay 48015248Sjhay for (hash = rh; hash < &rh[ROUTEHASHSIZ]; hash++, x++) { 48115248Sjhay fprintf(fd, "HASH %d\n", x); 48215248Sjhay rip = hash->rt_forw; 48315248Sjhay for (; rip != (struct rt_entry *)hash; rip = rip->rt_forw) { 48415248Sjhay fprintf(fd, " dest %s\t", 48515248Sjhay ipxdp_ntoa(&satoipx_addr(rip->rt_dst))); 48615248Sjhay fprintf(fd, "%s metric %d, ticks %d\n", 48715248Sjhay ipxdp_ntoa(&satoipx_addr(rip->rt_router)), 48815248Sjhay rip->rt_metric, 48915248Sjhay rip->rt_ticks); 49015248Sjhay } 49115248Sjhay } 49215248Sjhay fprintf(fd, "\n"); 49315248Sjhay} 49415248Sjhay 49511820Sjulianunion ipx_net_u net; 49611820Sjulian 49711820Sjulianchar * 49811820Sjulianipxdp_nettoa(val) 49911820Sjulianunion ipx_net val; 50011820Sjulian{ 50111820Sjulian static char buf[100]; 50211820Sjulian net.net_e = val; 503122760Strhodes (void)sprintf(buf, "%u", ntohl(net.long_e)); 50411820Sjulian return (buf); 50511820Sjulian} 50611820Sjulian 50711820Sjulian 50811820Sjulianchar * 50911820Sjulianipxdp_ntoa(addr) 51011820Sjulianstruct ipx_addr *addr; 51111820Sjulian{ 51211820Sjulian static char buf[100]; 51311820Sjulian 51411820Sjulian (void)sprintf(buf, "%s#%x:%x:%x:%x:%x:%x", 51511820Sjulian ipxdp_nettoa(addr->x_net), 51611820Sjulian addr->x_host.c_host[0], addr->x_host.c_host[1], 51711820Sjulian addr->x_host.c_host[2], addr->x_host.c_host[3], 51811820Sjulian addr->x_host.c_host[4], addr->x_host.c_host[5]); 51911820Sjulian 52011820Sjulian return(buf); 52111820Sjulian} 522