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