Home | History | Annotate | Line # | Download | only in bootptest
print-bootp.c revision 1.8.10.1
      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.4    lukem 
     27       1.4    lukem #include <sys/cdefs.h>
     28       1.1      gwr #ifndef lint
     29  1.8.10.1     yamt __RCSID("$NetBSD: print-bootp.c,v 1.8.10.1 2008/05/18 12:36:14 yamt Exp $");
     30       1.2      gwr /* 93/10/10 <gwr (at) mc.com> New data-driven option print routine. */
     31       1.1      gwr #endif
     32       1.1      gwr 
     33       1.1      gwr #include <stdio.h>
     34       1.1      gwr 
     35       1.1      gwr #include <sys/param.h>
     36       1.1      gwr #include <sys/types.h>
     37       1.1      gwr #include <sys/socket.h>
     38       1.1      gwr #include <net/if.h>
     39       1.1      gwr #include <netinet/in.h>
     40       1.1      gwr #include <string.h>
     41       1.8      tls #include <strings.h>
     42       1.1      gwr #include <ctype.h>
     43       1.1      gwr 
     44       1.1      gwr #include "bootp.h"
     45       1.1      gwr #include "bootptest.h"
     46       1.1      gwr 
     47       1.1      gwr /* These decode the vendor data. */
     48       1.6      wiz static void cmu_print(u_char *, int);
     49       1.6      wiz static void dump_hex(u_char *, int);
     50       1.6      wiz static void other_print(u_char *, int);
     51       1.6      wiz static void rfc1048_print(u_char *, int);
     52       1.1      gwr 
     53       1.1      gwr /*
     54       1.1      gwr  * Print bootp requests
     55       1.1      gwr  */
     56       1.1      gwr void
     57       1.6      wiz bootp_print(struct bootp *bp, int length, u_short sport, u_short 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.7      wiz 		struct ether_header *eh;
    103       1.7      wiz 		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.8.10.1     yamt  */
    199       1.1      gwr const 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.7      wiz static void
    276       1.1      gwr rfc1048_print(u_char *bp, int length)
    277       1.1      gwr {
    278       1.1      gwr 	u_char tag;
    279       1.7      wiz 	u_char *ep;
    280       1.1      gwr 	int len;
    281       1.1      gwr 	u_int32 ul;
    282       1.1      gwr 	u_short us;
    283  1.8.10.1     yamt 	struct in_addr ia;
    284       1.1      gwr 	const char *optstr;
    285       1.1      gwr 
    286       1.1      gwr 	printf("-rfc1395");
    287       1.1      gwr 
    288       1.1      gwr 	/* Step over magic cookie */
    289       1.1      gwr 	bp += sizeof(int32);
    290       1.1      gwr 	/* Setup end pointer */
    291       1.1      gwr 	ep = bp + length;
    292       1.1      gwr 	while (bp < ep) {
    293       1.1      gwr 		tag = *bp++;
    294       1.1      gwr 		/* Check for tags with no data first. */
    295       1.1      gwr 		if (tag == TAG_PAD)
    296       1.1      gwr 			continue;
    297       1.1      gwr 		if (tag == TAG_END)
    298       1.1      gwr 			return;
    299       1.1      gwr 		if (tag < KNOWN_OPTIONS) {
    300       1.1      gwr 			optstr = rfc1048_opts[tag];
    301       1.1      gwr 			printf(" %s:", optstr + 1);
    302       1.1      gwr 		} else {
    303       1.1      gwr 			printf(" T%d:", tag);
    304       1.1      gwr 			optstr = "?";
    305       1.1      gwr 		}
    306       1.1      gwr 		/* Now scan the length byte. */
    307       1.1      gwr 		len = *bp++;
    308       1.1      gwr 		if (bp + len > ep) {
    309       1.5  thorpej 			/* truncated option */
    310       1.1      gwr 			printf(" |(%d>%ld)", len, (long)(ep - bp));
    311       1.1      gwr 			return;
    312       1.1      gwr 		}
    313       1.1      gwr 		/* Print the option value(s). */
    314       1.1      gwr 		switch (optstr[0]) {
    315       1.1      gwr 
    316       1.1      gwr 		case 'a':				/* ASCII string */
    317       1.1      gwr 			printfn(bp, bp + len);
    318       1.1      gwr 			bp += len;
    319       1.1      gwr 			len = 0;
    320       1.1      gwr 			break;
    321       1.1      gwr 
    322       1.1      gwr 		case 's':				/* Word formats */
    323       1.1      gwr 			while (len >= 2) {
    324       1.1      gwr 				bcopy((char *) bp, (char *) &us, 2);
    325       1.1      gwr 				printf("%d", ntohs(us));
    326       1.1      gwr 				bp += 2;
    327       1.1      gwr 				len -= 2;
    328       1.1      gwr 				if (len) printf(",");
    329       1.1      gwr 			}
    330       1.1      gwr 			if (len) printf("(junk=%d)", len);
    331       1.1      gwr 			break;
    332       1.1      gwr 
    333       1.1      gwr 		case 'l':				/* Long words */
    334       1.1      gwr 			while (len >= 4) {
    335       1.1      gwr 				bcopy((char *) bp, (char *) &ul, 4);
    336       1.1      gwr 				printf("%d", ntohl(ul));
    337       1.1      gwr 				bp += 4;
    338       1.1      gwr 				len -= 4;
    339       1.1      gwr 				if (len) printf(",");
    340       1.1      gwr 			}
    341       1.1      gwr 			if (len) printf("(junk=%d)", len);
    342       1.1      gwr 			break;
    343       1.1      gwr 
    344       1.1      gwr 		case 'i':				/* INET addresses */
    345       1.1      gwr 			while (len >= 4) {
    346       1.1      gwr 				bcopy((char *) bp, (char *) &ia, 4);
    347       1.1      gwr 				printf("%s", ipaddr_string(&ia));
    348       1.1      gwr 				bp += 4;
    349       1.1      gwr 				len -= 4;
    350       1.1      gwr 				if (len) printf(",");
    351       1.1      gwr 			}
    352       1.1      gwr 			if (len) printf("(junk=%d)", len);
    353       1.1      gwr 			break;
    354       1.1      gwr 
    355       1.1      gwr 		case 'b':
    356       1.1      gwr 		default:
    357       1.1      gwr 			break;
    358       1.1      gwr 
    359       1.1      gwr 		}						/* switch */
    360       1.1      gwr 
    361       1.1      gwr 		/* Print as characters, if appropriate. */
    362       1.1      gwr 		if (len) {
    363       1.1      gwr 			dump_hex(bp, len);
    364       1.1      gwr 			if (isascii(*bp) && isprint(*bp)) {
    365       1.1      gwr 				printf("(");
    366       1.1      gwr 				printfn(bp, bp + len);
    367       1.1      gwr 				printf(")");
    368       1.1      gwr 			}
    369       1.1      gwr 			bp += len;
    370       1.1      gwr 			len = 0;
    371       1.1      gwr 		}
    372       1.1      gwr 	} /* while bp < ep */
    373       1.1      gwr }
    374       1.1      gwr 
    375       1.7      wiz static void
    376       1.1      gwr cmu_print(u_char *bp, int length)
    377       1.1      gwr {
    378       1.1      gwr 	struct cmu_vend *v;
    379       1.1      gwr 	u_char *ep;
    380       1.1      gwr 
    381       1.1      gwr 	printf("-cmu");
    382       1.1      gwr 
    383       1.1      gwr 	v = (struct cmu_vend *) bp;
    384       1.1      gwr 	if (length < sizeof(*v)) {
    385       1.1      gwr 		printf(" |L=%d", length);
    386       1.1      gwr 		return;
    387       1.1      gwr 	}
    388       1.1      gwr 	/* Setup end pointer */
    389       1.1      gwr 	ep = bp + length;
    390       1.1      gwr 
    391       1.1      gwr 	/* Subnet mask */
    392       1.1      gwr 	if (v->v_flags & VF_SMASK) {
    393       1.1      gwr 		printf(" SM:%s", ipaddr_string(&v->v_smask));
    394       1.1      gwr 	}
    395       1.1      gwr 	/* Default gateway */
    396       1.1      gwr 	if (v->v_dgate.s_addr)
    397       1.1      gwr 		printf(" GW:%s", ipaddr_string(&v->v_dgate));
    398       1.1      gwr 
    399       1.1      gwr 	/* Domain name servers */
    400       1.1      gwr 	if (v->v_dns1.s_addr)
    401       1.1      gwr 		printf(" DNS1:%s", ipaddr_string(&v->v_dns1));
    402       1.1      gwr 	if (v->v_dns2.s_addr)
    403       1.1      gwr 		printf(" DNS2:%s", ipaddr_string(&v->v_dns2));
    404       1.1      gwr 
    405       1.1      gwr 	/* IEN-116 name servers */
    406       1.1      gwr 	if (v->v_ins1.s_addr)
    407       1.1      gwr 		printf(" INS1:%s", ipaddr_string(&v->v_ins1));
    408       1.1      gwr 	if (v->v_ins2.s_addr)
    409       1.1      gwr 		printf(" INS2:%s", ipaddr_string(&v->v_ins2));
    410       1.1      gwr 
    411       1.1      gwr 	/* Time servers */
    412       1.1      gwr 	if (v->v_ts1.s_addr)
    413       1.1      gwr 		printf(" TS1:%s", ipaddr_string(&v->v_ts1));
    414       1.1      gwr 	if (v->v_ts2.s_addr)
    415       1.1      gwr 		printf(" TS2:%s", ipaddr_string(&v->v_ts2));
    416       1.1      gwr 
    417       1.1      gwr }
    418       1.1      gwr 
    419       1.1      gwr 
    420       1.1      gwr /*
    421       1.1      gwr  * Print out arbitrary, unknown vendor data.
    422       1.1      gwr  */
    423       1.1      gwr 
    424       1.7      wiz static void
    425       1.1      gwr other_print(u_char *bp, int length)
    426       1.1      gwr {
    427       1.1      gwr 	u_char *ep;					/* end pointer */
    428       1.1      gwr 	u_char *zp;					/* points one past last non-zero byte */
    429       1.1      gwr 
    430       1.1      gwr 	/* Setup end pointer */
    431       1.1      gwr 	ep = bp + length;
    432       1.1      gwr 
    433       1.1      gwr 	/* Find the last non-zero byte. */
    434       1.1      gwr 	for (zp = ep; zp > bp; zp--) {
    435       1.1      gwr 		if (zp[-1] != 0)
    436       1.1      gwr 			break;
    437       1.1      gwr 	}
    438       1.1      gwr 
    439       1.1      gwr 	/* Print the all-zero case in a compact representation. */
    440       1.1      gwr 	if (zp == bp) {
    441       1.1      gwr 		printf("-all-zero");
    442       1.1      gwr 		return;
    443       1.1      gwr 	}
    444       1.1      gwr 	printf("-unknown");
    445       1.1      gwr 
    446       1.1      gwr 	/* Are there enough trailing zeros to make "00..." worthwhile? */
    447       1.1      gwr 	if (zp + 2 > ep)
    448       1.1      gwr 		zp = ep;				/* print them all normally */
    449       1.1      gwr 
    450       1.1      gwr 	/* Now just print all the non-zero data. */
    451       1.1      gwr 	while (bp < zp) {
    452       1.1      gwr 		printf(".%02X", *bp);
    453       1.1      gwr 		bp++;
    454       1.1      gwr 	}
    455       1.1      gwr 
    456       1.1      gwr 	if (zp < ep)
    457       1.1      gwr 		printf(".00...");
    458       1.1      gwr 
    459       1.1      gwr 	return;
    460       1.1      gwr }
    461       1.1      gwr 
    462       1.6      wiz static void
    463       1.1      gwr dump_hex(u_char *bp, int len)
    464       1.1      gwr {
    465       1.1      gwr 	while (len > 0) {
    466       1.1      gwr 		printf("%02X", *bp);
    467       1.1      gwr 		bp++;
    468       1.1      gwr 		len--;
    469       1.1      gwr 		if (len) printf(".");
    470       1.1      gwr 	}
    471       1.1      gwr }
    472       1.1      gwr 
    473       1.1      gwr /*
    474       1.1      gwr  * Local Variables:
    475       1.1      gwr  * tab-width: 4
    476       1.1      gwr  * c-indent-level: 4
    477       1.1      gwr  * c-argdecl-indent: 4
    478       1.1      gwr  * c-continued-statement-offset: 4
    479       1.1      gwr  * c-continued-brace-offset: -4
    480       1.1      gwr  * c-label-offset: -4
    481       1.1      gwr  * c-brace-offset: 0
    482       1.1      gwr  * End:
    483                     */
    484