Home | History | Annotate | Line # | Download | only in bootptest
print-bootp.c revision 1.2
      1  1.1  gwr /*
      2  1.1  gwr  * Copyright (c) 1988-1990 The Regents of the University of California.
      3  1.1  gwr  * All rights reserved.
      4  1.1  gwr  *
      5  1.1  gwr  * Redistribution and use in source and binary forms, with or without
      6  1.1  gwr  * modification, are permitted provided that: (1) source code distributions
      7  1.1  gwr  * retain the above copyright notice and this paragraph in its entirety, (2)
      8  1.1  gwr  * distributions including binary code include the above copyright notice and
      9  1.1  gwr  * this paragraph in its entirety in the documentation or other materials
     10  1.1  gwr  * provided with the distribution, and (3) all advertising materials mentioning
     11  1.1  gwr  * features or use of this software display the following acknowledgement:
     12  1.1  gwr  * ``This product includes software developed by the University of California,
     13  1.1  gwr  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
     14  1.1  gwr  * the University nor the names of its contributors may be used to endorse
     15  1.1  gwr  * or promote products derived from this software without specific prior
     16  1.1  gwr  * written permission.
     17  1.1  gwr  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
     18  1.1  gwr  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
     19  1.1  gwr  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
     20  1.1  gwr  *
     21  1.1  gwr  * Format and print bootp packets.
     22  1.1  gwr  *
     23  1.1  gwr  * This file was copied from tcpdump-2.1.1 and modified.
     24  1.1  gwr  * There is an e-mail list for tcpdump: <tcpdump (at) ee.lbl.gov>
     25  1.1  gwr  */
     26  1.1  gwr #ifndef lint
     27  1.2  gwr static char rcsid[] = "$Id: print-bootp.c,v 1.2 1994/08/22 22:15:01 gwr Exp $";
     28  1.2  gwr /* 93/10/10 <gwr (at) mc.com> New data-driven option print routine. */
     29  1.1  gwr #endif
     30  1.1  gwr 
     31  1.1  gwr #include <stdio.h>
     32  1.1  gwr 
     33  1.1  gwr #include <sys/param.h>
     34  1.1  gwr #include <sys/types.h>
     35  1.1  gwr #include <sys/socket.h>
     36  1.1  gwr #include <net/if.h>
     37  1.1  gwr #include <netinet/in.h>
     38  1.1  gwr #include <string.h>
     39  1.1  gwr #include <ctype.h>
     40  1.1  gwr 
     41  1.1  gwr #include "bootp.h"
     42  1.1  gwr #include "bootptest.h"
     43  1.1  gwr 
     44  1.1  gwr /* These decode the vendor data. */
     45  1.1  gwr static void rfc1048_print();
     46  1.1  gwr static void cmu_print();
     47  1.1  gwr static void other_print();
     48  1.1  gwr static void dump_hex();
     49  1.1  gwr 
     50  1.1  gwr /*
     51  1.1  gwr  * Print bootp requests
     52  1.1  gwr  */
     53  1.1  gwr void
     54  1.1  gwr bootp_print(bp, length, sport, dport)
     55  1.1  gwr 	struct bootp *bp;
     56  1.1  gwr 	int length;
     57  1.1  gwr 	u_short sport, dport;
     58  1.1  gwr {
     59  1.1  gwr 	static char tstr[] = " [|bootp]";
     60  1.1  gwr 	static unsigned char vm_cmu[4] = VM_CMU;
     61  1.1  gwr 	static unsigned char vm_rfc1048[4] = VM_RFC1048;
     62  1.1  gwr 	u_char *ep;
     63  1.1  gwr 	int vdlen;
     64  1.1  gwr 
     65  1.1  gwr #define TCHECK(var, l) if ((u_char *)&(var) > ep - l) goto trunc
     66  1.1  gwr 
     67  1.1  gwr 	/* Note funny sized packets */
     68  1.1  gwr 	if (length != sizeof(struct bootp))
     69  1.1  gwr 		(void) printf(" [len=%d]", length);
     70  1.1  gwr 
     71  1.1  gwr 	/* 'ep' points to the end of avaible data. */
     72  1.1  gwr 	ep = (u_char *) snapend;
     73  1.1  gwr 
     74  1.1  gwr 	switch (bp->bp_op) {
     75  1.1  gwr 
     76  1.1  gwr 	case BOOTREQUEST:
     77  1.1  gwr 		/* Usually, a request goes from a client to a server */
     78  1.1  gwr 		if (sport != IPPORT_BOOTPC || dport != IPPORT_BOOTPS)
     79  1.1  gwr 			printf(" (request)");
     80  1.1  gwr 		break;
     81  1.1  gwr 
     82  1.1  gwr 	case BOOTREPLY:
     83  1.1  gwr 		/* Usually, a reply goes from a server to a client */
     84  1.1  gwr 		if (sport != IPPORT_BOOTPS || dport != IPPORT_BOOTPC)
     85  1.1  gwr 			printf(" (reply)");
     86  1.1  gwr 		break;
     87  1.1  gwr 
     88  1.1  gwr 	default:
     89  1.1  gwr 		printf(" bootp-#%d", bp->bp_op);
     90  1.1  gwr 	}
     91  1.1  gwr 
     92  1.1  gwr 	/* The usual hardware address type is 1 (10Mb Ethernet) */
     93  1.1  gwr 	if (bp->bp_htype != 1)
     94  1.1  gwr 		printf(" htype:%d", bp->bp_htype);
     95  1.1  gwr 
     96  1.1  gwr 	/* The usual length for 10Mb Ethernet address is 6 bytes */
     97  1.1  gwr 	if (bp->bp_hlen != 6)
     98  1.1  gwr 		printf(" hlen:%d", bp->bp_hlen);
     99  1.1  gwr 
    100  1.1  gwr 	/* Client's Hardware address */
    101  1.1  gwr 	if (bp->bp_hlen) {
    102  1.1  gwr 		register struct ether_header *eh;
    103  1.1  gwr 		register char *e;
    104  1.1  gwr 
    105  1.1  gwr 		TCHECK(bp->bp_chaddr[0], 6);
    106  1.1  gwr 		eh = (struct ether_header *) packetp;
    107  1.1  gwr 		if (bp->bp_op == BOOTREQUEST)
    108  1.1  gwr 			e = (char *) ESRC(eh);
    109  1.1  gwr 		else if (bp->bp_op == BOOTREPLY)
    110  1.1  gwr 			e = (char *) EDST(eh);
    111  1.1  gwr 		else
    112  1.1  gwr 			e = 0;
    113  1.1  gwr 		if (e == 0 || bcmp((char *) bp->bp_chaddr, e, 6))
    114  1.1  gwr 			dump_hex(bp->bp_chaddr, bp->bp_hlen);
    115  1.1  gwr 	}
    116  1.1  gwr 	/* Only print interesting fields */
    117  1.1  gwr 	if (bp->bp_hops)
    118  1.1  gwr 		printf(" hops:%d", bp->bp_hops);
    119  1.1  gwr 
    120  1.1  gwr 	if (bp->bp_xid)
    121  1.1  gwr 		printf(" xid:%d", ntohl(bp->bp_xid));
    122  1.1  gwr 
    123  1.1  gwr 	if (bp->bp_secs)
    124  1.1  gwr 		printf(" secs:%d", ntohs(bp->bp_secs));
    125  1.1  gwr 
    126  1.1  gwr 	/* Client's ip address */
    127  1.1  gwr 	TCHECK(bp->bp_ciaddr, sizeof(bp->bp_ciaddr));
    128  1.1  gwr 	if (bp->bp_ciaddr.s_addr)
    129  1.1  gwr 		printf(" C:%s", ipaddr_string(&bp->bp_ciaddr));
    130  1.1  gwr 
    131  1.1  gwr 	/* 'your' ip address (bootp client) */
    132  1.1  gwr 	TCHECK(bp->bp_yiaddr, sizeof(bp->bp_yiaddr));
    133  1.1  gwr 	if (bp->bp_yiaddr.s_addr)
    134  1.1  gwr 		printf(" Y:%s", ipaddr_string(&bp->bp_yiaddr));
    135  1.1  gwr 
    136  1.1  gwr 	/* Server's ip address */
    137  1.1  gwr 	TCHECK(bp->bp_siaddr, sizeof(bp->bp_siaddr));
    138  1.1  gwr 	if (bp->bp_siaddr.s_addr)
    139  1.1  gwr 		printf(" S:%s", ipaddr_string(&bp->bp_siaddr));
    140  1.1  gwr 
    141  1.1  gwr 	/* Gateway's ip address */
    142  1.1  gwr 	TCHECK(bp->bp_giaddr, sizeof(bp->bp_giaddr));
    143  1.1  gwr 	if (bp->bp_giaddr.s_addr)
    144  1.1  gwr 		printf(" G:%s", ipaddr_string(&bp->bp_giaddr));
    145  1.1  gwr 
    146  1.1  gwr 	TCHECK(bp->bp_sname[0], sizeof(bp->bp_sname));
    147  1.1  gwr 	if (*bp->bp_sname) {
    148  1.1  gwr 		printf(" sname:");
    149  1.1  gwr 		if (printfn(bp->bp_sname, ep)) {
    150  1.1  gwr 			fputs(tstr + 1, stdout);
    151  1.1  gwr 			return;
    152  1.1  gwr 		}
    153  1.1  gwr 	}
    154  1.1  gwr 	TCHECK(bp->bp_file[0], sizeof(bp->bp_file));
    155  1.1  gwr 	if (*bp->bp_file) {
    156  1.1  gwr 		printf(" file:");
    157  1.1  gwr 		if (printfn(bp->bp_file, ep)) {
    158  1.1  gwr 			fputs(tstr + 1, stdout);
    159  1.1  gwr 			return;
    160  1.1  gwr 		}
    161  1.1  gwr 	}
    162  1.1  gwr 	/* Don't try to decode the vendor buffer unless we're verbose */
    163  1.1  gwr 	if (vflag <= 0)
    164  1.1  gwr 		return;
    165  1.1  gwr 
    166  1.1  gwr 	vdlen = sizeof(bp->bp_vend);
    167  1.1  gwr 	/* Vendor data can extend to the end of the packet. */
    168  1.1  gwr 	if (vdlen < (ep - bp->bp_vend))
    169  1.1  gwr 		vdlen = (ep - bp->bp_vend);
    170  1.1  gwr 
    171  1.1  gwr 	TCHECK(bp->bp_vend[0], vdlen);
    172  1.1  gwr 	printf(" vend");
    173  1.1  gwr 	if (!bcmp(bp->bp_vend, vm_rfc1048, sizeof(u_int32)))
    174  1.1  gwr 		rfc1048_print(bp->bp_vend, vdlen);
    175  1.1  gwr 	else if (!bcmp(bp->bp_vend, vm_cmu, sizeof(u_int32)))
    176  1.1  gwr 		cmu_print(bp->bp_vend, vdlen);
    177  1.1  gwr 	else
    178  1.1  gwr 		other_print(bp->bp_vend, vdlen);
    179  1.1  gwr 
    180  1.1  gwr 	return;
    181  1.1  gwr  trunc:
    182  1.1  gwr 	fputs(tstr, stdout);
    183  1.1  gwr #undef TCHECK
    184  1.1  gwr }
    185  1.1  gwr 
    186  1.1  gwr /*
    188  1.1  gwr  * Option description data follows.
    189  1.1  gwr  * These are decribed in: RFC-1048, RFC-1395, RFC-1497, RFC-1533
    190  1.1  gwr  *
    191  1.1  gwr  * The first char of each option string encodes the data format:
    192  1.1  gwr  * ?: unknown
    193  1.1  gwr  * a: ASCII
    194  1.1  gwr  * b: byte (8-bit)
    195  1.1  gwr  * i: inet address
    196  1.1  gwr  * l: int32
    197  1.1  gwr  * s: short (16-bit)
    198  1.1  gwr  */
    199  1.1  gwr char *
    200  1.1  gwr rfc1048_opts[] = {
    201  1.1  gwr 	/* Originally from RFC-1048: */
    202  1.1  gwr 	"?PAD",				/*  0: Padding - special, no data. */
    203  1.1  gwr 	"iSM",				/*  1: subnet mask (RFC950)*/
    204  1.1  gwr 	"lTZ",				/*  2: time offset, seconds from UTC */
    205  1.1  gwr 	"iGW",				/*  3: gateways (or routers) */
    206  1.1  gwr 	"iTS",				/*  4: time servers (RFC868) */
    207  1.1  gwr 	"iINS",				/*  5: IEN name servers (IEN116) */
    208  1.1  gwr 	"iDNS",				/*  6: domain name servers (RFC1035)(1034?) */
    209  1.1  gwr 	"iLOG",				/*  7: MIT log servers */
    210  1.1  gwr 	"iCS",				/*  8: cookie servers (RFC865) */
    211  1.1  gwr 	"iLPR",				/*  9: lpr server (RFC1179) */
    212  1.1  gwr 	"iIPS",				/* 10: impress servers (Imagen) */
    213  1.1  gwr 	"iRLP",				/* 11: resource location servers (RFC887) */
    214  1.1  gwr 	"aHN",				/* 12: host name (ASCII) */
    215  1.1  gwr 	"sBFS",				/* 13: boot file size (in 512 byte blocks) */
    216  1.1  gwr 
    217  1.1  gwr 	/* Added by RFC-1395: */
    218  1.1  gwr 	"aDUMP",			/* 14: Merit Dump File */
    219  1.1  gwr 	"aDNAM",			/* 15: Domain Name (for DNS) */
    220  1.1  gwr 	"iSWAP",			/* 16: Swap Server */
    221  1.1  gwr 	"aROOT",			/* 17: Root Path */
    222  1.1  gwr 
    223  1.1  gwr 	/* Added by RFC-1497: */
    224  1.1  gwr 	"aEXTF",			/* 18: Extensions Path (more options) */
    225  1.1  gwr 
    226  1.1  gwr 	/* Added by RFC-1533: (many, many options...) */
    227  1.1  gwr #if 1	/* These might not be worth recognizing by name. */
    228  1.1  gwr 
    229  1.1  gwr 	/* IP Layer Parameters, per-host (RFC-1533, sect. 4) */
    230  1.1  gwr 	"bIP-forward",		/* 19: IP Forwarding flag */
    231  1.1  gwr 	"bIP-srcroute",		/* 20: IP Source Routing Enable flag */
    232  1.1  gwr 	"iIP-filters",		/* 21: IP Policy Filter (addr pairs) */
    233  1.1  gwr 	"sIP-maxudp",		/* 22: IP Max-UDP reassembly size */
    234  1.1  gwr 	"bIP-ttlive",		/* 23: IP Time to Live */
    235  1.1  gwr 	"lIP-pmtuage",		/* 24: IP Path MTU aging timeout */
    236  1.1  gwr 	"sIP-pmtutab",		/* 25: IP Path MTU plateau table */
    237  1.1  gwr 
    238  1.1  gwr 	/* IP parameters, per-interface (RFC-1533, sect. 5) */
    239  1.1  gwr 	"sIP-mtu-sz",		/* 26: IP MTU size */
    240  1.1  gwr 	"bIP-mtu-sl",		/* 27: IP MTU all subnets local */
    241  1.1  gwr 	"bIP-bcast1",		/* 28: IP Broadcast Addr ones flag */
    242  1.1  gwr 	"bIP-mask-d",		/* 29: IP do mask discovery */
    243  1.1  gwr 	"bIP-mask-s",		/* 30: IP do mask supplier */
    244  1.1  gwr 	"bIP-rt-dsc",		/* 31: IP do router discovery */
    245  1.1  gwr 	"iIP-rt-sa",		/* 32: IP router solicitation addr */
    246  1.1  gwr 	"iIP-routes",		/* 33: IP static routes (dst,router) */
    247  1.1  gwr 
    248  1.1  gwr 	/* Link Layer parameters, per-interface (RFC-1533, sect. 6) */
    249  1.1  gwr 	"bLL-trailer",		/* 34: do tralier encapsulation */
    250  1.1  gwr 	"lLL-arp-tmo",		/* 35: ARP cache timeout */
    251  1.1  gwr 	"bLL-ether2",		/* 36: Ethernet version 2 (IEEE 802.3) */
    252  1.1  gwr 
    253  1.1  gwr 	/* TCP parameters (RFC-1533, sect. 7) */
    254  1.1  gwr 	"bTCP-def-ttl",		/* 37: default time to live */
    255  1.1  gwr 	"lTCP-KA-tmo",		/* 38: keepalive time interval */
    256  1.1  gwr 	"bTCP-KA-junk",		/* 39: keepalive sends extra junk */
    257  1.1  gwr 
    258  1.1  gwr 	/* Application and Service Parameters (RFC-1533, sect. 8) */
    259  1.1  gwr 	"aNISDOM",			/* 40: NIS Domain (Sun YP) */
    260  1.1  gwr 	"iNISSRV",			/* 41: NIS Servers */
    261  1.1  gwr 	"iNTPSRV",			/* 42: NTP (time) Servers (RFC 1129) */
    262  1.1  gwr 	"?VSINFO",			/* 43: Vendor Specific Info (encapsulated) */
    263  1.1  gwr 	"iNBiosNS",			/* 44: NetBIOS Name Server (RFC-1001,1..2) */
    264  1.1  gwr 	"iNBiosDD",			/* 45: NetBIOS Datagram Dist. Server. */
    265  1.1  gwr 	"bNBiosNT",			/* 46: NetBIOS Note Type */
    266  1.1  gwr 	"?NBiosS",			/* 47: NetBIOS Scope */
    267  1.1  gwr 	"iXW-FS",			/* 48: X Window System Font Servers */
    268  1.1  gwr 	"iXW-DM",			/* 49: X Window System Display Managers */
    269  1.1  gwr 
    270  1.1  gwr 	/* DHCP extensions (RFC-1533, sect. 9) */
    271  1.1  gwr #endif
    272  1.1  gwr };
    273  1.1  gwr #define	KNOWN_OPTIONS (sizeof(rfc1048_opts) / sizeof(rfc1048_opts[0]))
    274  1.1  gwr 
    275  1.1  gwr static void print_string();
    276  1.1  gwr 
    277  1.1  gwr static void
    278  1.1  gwr rfc1048_print(bp, length)
    279  1.1  gwr 	register u_char *bp;
    280  1.1  gwr 	int length;
    281  1.1  gwr {
    282  1.1  gwr 	u_char tag;
    283  1.1  gwr 	u_char *ep;
    284  1.1  gwr 	register int len, j;
    285  1.1  gwr 	u_int32 ul;
    286  1.1  gwr 	u_short us;
    287  1.1  gwr 	struct in_addr ia;
    288  1.1  gwr 	char *optstr;
    289  1.1  gwr 
    290  1.1  gwr 	printf("-rfc1395");
    291  1.1  gwr 
    292  1.1  gwr 	/* Step over magic cookie */
    293  1.1  gwr 	bp += sizeof(int32);
    294  1.1  gwr 	/* Setup end pointer */
    295  1.1  gwr 	ep = bp + length;
    296  1.1  gwr 	while (bp < ep) {
    297  1.1  gwr 		tag = *bp++;
    298  1.1  gwr 		/* Check for tags with no data first. */
    299  1.1  gwr 		if (tag == TAG_PAD)
    300  1.1  gwr 			continue;
    301  1.1  gwr 		if (tag == TAG_END)
    302  1.1  gwr 			return;
    303  1.1  gwr 		if (tag < KNOWN_OPTIONS) {
    304  1.1  gwr 			optstr = rfc1048_opts[tag];
    305  1.1  gwr 			printf(" %s:", optstr + 1);
    306  1.1  gwr 		} else {
    307  1.1  gwr 			printf(" T%d:", tag);
    308  1.1  gwr 			optstr = "?";
    309  1.1  gwr 		}
    310  1.1  gwr 		/* Now scan the length byte. */
    311  1.1  gwr 		len = *bp++;
    312  1.1  gwr 		if (bp + len > ep) {
    313  1.1  gwr 			/* truncated option */
    314  1.1  gwr 			printf(" |(%d>%d)", len, ep - bp);
    315  1.1  gwr 			return;
    316  1.1  gwr 		}
    317  1.1  gwr 		/* Print the option value(s). */
    318  1.1  gwr 		switch (optstr[0]) {
    319  1.1  gwr 
    320  1.1  gwr 		case 'a':				/* ASCII string */
    321  1.1  gwr 			printfn(bp, bp + len);
    322  1.1  gwr 			bp += len;
    323  1.1  gwr 			len = 0;
    324  1.1  gwr 			break;
    325  1.1  gwr 
    326  1.1  gwr 		case 's':				/* Word formats */
    327  1.1  gwr 			while (len >= 2) {
    328  1.1  gwr 				bcopy((char *) bp, (char *) &us, 2);
    329  1.1  gwr 				printf("%d", ntohs(us));
    330  1.1  gwr 				bp += 2;
    331  1.1  gwr 				len -= 2;
    332  1.1  gwr 				if (len) printf(",");
    333  1.1  gwr 			}
    334  1.1  gwr 			if (len) printf("(junk=%d)", len);
    335  1.1  gwr 			break;
    336  1.1  gwr 
    337  1.1  gwr 		case 'l':				/* Long words */
    338  1.1  gwr 			while (len >= 4) {
    339  1.1  gwr 				bcopy((char *) bp, (char *) &ul, 4);
    340  1.1  gwr 				printf("%d", ntohl(ul));
    341  1.1  gwr 				bp += 4;
    342  1.1  gwr 				len -= 4;
    343  1.1  gwr 				if (len) printf(",");
    344  1.1  gwr 			}
    345  1.1  gwr 			if (len) printf("(junk=%d)", len);
    346  1.1  gwr 			break;
    347  1.1  gwr 
    348  1.1  gwr 		case 'i':				/* INET addresses */
    349  1.1  gwr 			while (len >= 4) {
    350  1.1  gwr 				bcopy((char *) bp, (char *) &ia, 4);
    351  1.1  gwr 				printf("%s", ipaddr_string(&ia));
    352  1.1  gwr 				bp += 4;
    353  1.1  gwr 				len -= 4;
    354  1.1  gwr 				if (len) printf(",");
    355  1.1  gwr 			}
    356  1.1  gwr 			if (len) printf("(junk=%d)", len);
    357  1.1  gwr 			break;
    358  1.1  gwr 
    359  1.1  gwr 		case 'b':
    360  1.1  gwr 		default:
    361  1.1  gwr 			break;
    362  1.1  gwr 
    363  1.1  gwr 		}						/* switch */
    364  1.1  gwr 
    365  1.1  gwr 		/* Print as characters, if appropriate. */
    366  1.1  gwr 		if (len) {
    367  1.1  gwr 			dump_hex(bp, len);
    368  1.1  gwr 			if (isascii(*bp) && isprint(*bp)) {
    369  1.1  gwr 				printf("(");
    370  1.1  gwr 				printfn(bp, bp + len);
    371  1.1  gwr 				printf(")");
    372  1.1  gwr 			}
    373  1.1  gwr 			bp += len;
    374  1.1  gwr 			len = 0;
    375  1.1  gwr 		}
    376  1.1  gwr 	} /* while bp < ep */
    377  1.1  gwr }
    378  1.1  gwr 
    379  1.1  gwr static void
    380  1.1  gwr cmu_print(bp, length)
    381  1.1  gwr 	register u_char *bp;
    382  1.1  gwr 	int length;
    383  1.1  gwr {
    384  1.1  gwr 	struct cmu_vend *v;
    385  1.1  gwr 	u_char *ep;
    386  1.1  gwr 
    387  1.1  gwr 	printf("-cmu");
    388  1.1  gwr 
    389  1.1  gwr 	v = (struct cmu_vend *) bp;
    390  1.1  gwr 	if (length < sizeof(*v)) {
    391  1.1  gwr 		printf(" |L=%d", length);
    392  1.1  gwr 		return;
    393  1.1  gwr 	}
    394  1.1  gwr 	/* Setup end pointer */
    395  1.1  gwr 	ep = bp + length;
    396  1.1  gwr 
    397  1.1  gwr 	/* Subnet mask */
    398  1.1  gwr 	if (v->v_flags & VF_SMASK) {
    399  1.1  gwr 		printf(" SM:%s", ipaddr_string(&v->v_smask));
    400  1.1  gwr 	}
    401  1.1  gwr 	/* Default gateway */
    402  1.1  gwr 	if (v->v_dgate.s_addr)
    403  1.1  gwr 		printf(" GW:%s", ipaddr_string(&v->v_dgate));
    404  1.1  gwr 
    405  1.1  gwr 	/* Domain name servers */
    406  1.1  gwr 	if (v->v_dns1.s_addr)
    407  1.1  gwr 		printf(" DNS1:%s", ipaddr_string(&v->v_dns1));
    408  1.1  gwr 	if (v->v_dns2.s_addr)
    409  1.1  gwr 		printf(" DNS2:%s", ipaddr_string(&v->v_dns2));
    410  1.1  gwr 
    411  1.1  gwr 	/* IEN-116 name servers */
    412  1.1  gwr 	if (v->v_ins1.s_addr)
    413  1.1  gwr 		printf(" INS1:%s", ipaddr_string(&v->v_ins1));
    414  1.1  gwr 	if (v->v_ins2.s_addr)
    415  1.1  gwr 		printf(" INS2:%s", ipaddr_string(&v->v_ins2));
    416  1.1  gwr 
    417  1.1  gwr 	/* Time servers */
    418  1.1  gwr 	if (v->v_ts1.s_addr)
    419  1.1  gwr 		printf(" TS1:%s", ipaddr_string(&v->v_ts1));
    420  1.1  gwr 	if (v->v_ts2.s_addr)
    421  1.1  gwr 		printf(" TS2:%s", ipaddr_string(&v->v_ts2));
    422  1.1  gwr 
    423  1.1  gwr }
    424  1.1  gwr 
    425  1.1  gwr 
    426  1.1  gwr /*
    427  1.1  gwr  * Print out arbitrary, unknown vendor data.
    428  1.1  gwr  */
    429  1.1  gwr 
    430  1.1  gwr static void
    431  1.1  gwr other_print(bp, length)
    432  1.1  gwr 	register u_char *bp;
    433  1.1  gwr 	int length;
    434  1.1  gwr {
    435  1.1  gwr 	u_char *ep;					/* end pointer */
    436  1.1  gwr 	u_char *zp;					/* points one past last non-zero byte */
    437  1.1  gwr 	register int i, j;
    438  1.1  gwr 
    439  1.1  gwr 	/* Setup end pointer */
    440  1.1  gwr 	ep = bp + length;
    441  1.1  gwr 
    442  1.1  gwr 	/* Find the last non-zero byte. */
    443  1.1  gwr 	for (zp = ep; zp > bp; zp--) {
    444  1.1  gwr 		if (zp[-1] != 0)
    445  1.1  gwr 			break;
    446  1.1  gwr 	}
    447  1.1  gwr 
    448  1.1  gwr 	/* Print the all-zero case in a compact representation. */
    449  1.1  gwr 	if (zp == bp) {
    450  1.1  gwr 		printf("-all-zero");
    451  1.1  gwr 		return;
    452  1.1  gwr 	}
    453  1.1  gwr 	printf("-unknown");
    454  1.1  gwr 
    455  1.1  gwr 	/* Are there enough trailing zeros to make "00..." worthwhile? */
    456  1.1  gwr 	if (zp + 2 > ep)
    457  1.1  gwr 		zp = ep;				/* print them all normally */
    458  1.1  gwr 
    459  1.1  gwr 	/* Now just print all the non-zero data. */
    460  1.1  gwr 	while (bp < zp) {
    461  1.1  gwr 		printf(".%02X", *bp);
    462  1.1  gwr 		bp++;
    463  1.1  gwr 	}
    464  1.1  gwr 
    465  1.1  gwr 	if (zp < ep)
    466  1.1  gwr 		printf(".00...");
    467  1.1  gwr 
    468  1.1  gwr 	return;
    469  1.1  gwr }
    470  1.1  gwr 
    471  1.1  gwr static void
    472  1.1  gwr dump_hex(bp, len)
    473  1.1  gwr 	u_char *bp;
    474  1.1  gwr 	int len;
    475  1.1  gwr {
    476  1.1  gwr 	while (len > 0) {
    477  1.1  gwr 		printf("%02X", *bp);
    478  1.1  gwr 		bp++;
    479  1.1  gwr 		len--;
    480  1.1  gwr 		if (len) printf(".");
    481  1.1  gwr 	}
    482  1.1  gwr }
    483  1.1  gwr 
    484  1.1  gwr /*
    485  1.1  gwr  * Local Variables:
    486  1.1  gwr  * tab-width: 4
    487  1.1  gwr  * c-indent-level: 4
    488  1.1  gwr  * c-argdecl-indent: 4
    489  1.1  gwr  * c-continued-statement-offset: 4
    490  1.1  gwr  * c-continued-brace-offset: -4
    491  1.1  gwr  * c-label-offset: -4
    492  1.1  gwr  * c-brace-offset: 0
    493  1.1  gwr  * End:
    494            */
    495