xref: /netbsd-src/external/bsd/tcpdump/dist/print-bootp.c (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 /*
2  * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that: (1) source code distributions
7  * retain the above copyright notice and this paragraph in its entirety, (2)
8  * distributions including binary code include the above copyright notice and
9  * this paragraph in its entirety in the documentation or other materials
10  * provided with the distribution, and (3) all advertising materials mentioning
11  * features or use of this software display the following acknowledgement:
12  * ``This product includes software developed by the University of California,
13  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14  * the University nor the names of its contributors may be used to endorse
15  * or promote products derived from this software without specific prior
16  * written permission.
17  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20  */
21 
22 /* \summary: BOOTP and IPv4 DHCP printer */
23 
24 #include <sys/cdefs.h>
25 #ifndef lint
26 __RCSID("$NetBSD: print-bootp.c,v 1.9 2017/09/08 14:01:13 christos Exp $");
27 #endif
28 
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32 
33 #include <netdissect-stdinc.h>
34 
35 #include <string.h>
36 
37 #include "netdissect.h"
38 #include "addrtoname.h"
39 #include "extract.h"
40 
41 static const char tstr[] = " [|bootp]";
42 
43 /*
44  * Bootstrap Protocol (BOOTP).  RFC951 and RFC1048.
45  *
46  * This file specifies the "implementation-independent" BOOTP protocol
47  * information which is common to both client and server.
48  *
49  * Copyright 1988 by Carnegie Mellon.
50  *
51  * Permission to use, copy, modify, and distribute this program for any
52  * purpose and without fee is hereby granted, provided that this copyright
53  * and permission notice appear on all copies and supporting documentation,
54  * the name of Carnegie Mellon not be used in advertising or publicity
55  * pertaining to distribution of the program without specific prior
56  * permission, and notice be given in supporting documentation that copying
57  * and distribution is by permission of Carnegie Mellon and Stanford
58  * University.  Carnegie Mellon makes no representations about the
59  * suitability of this software for any purpose.  It is provided "as is"
60  * without express or implied warranty.
61  */
62 
63 struct bootp {
64 	uint8_t		bp_op;		/* packet opcode type */
65 	uint8_t		bp_htype;	/* hardware addr type */
66 	uint8_t		bp_hlen;	/* hardware addr length */
67 	uint8_t		bp_hops;	/* gateway hops */
68 	uint32_t	bp_xid;		/* transaction ID */
69 	uint16_t	bp_secs;	/* seconds since boot began */
70 	uint16_t	bp_flags;	/* flags - see bootp_flag_values[]
71 					   in print-bootp.c */
72 	struct in_addr	bp_ciaddr;	/* client IP address */
73 	struct in_addr	bp_yiaddr;	/* 'your' IP address */
74 	struct in_addr	bp_siaddr;	/* server IP address */
75 	struct in_addr	bp_giaddr;	/* gateway IP address */
76 	uint8_t		bp_chaddr[16];	/* client hardware address */
77 	uint8_t		bp_sname[64];	/* server host name */
78 	uint8_t		bp_file[128];	/* boot file name */
79 	uint8_t		bp_vend[64];	/* vendor-specific area */
80 } UNALIGNED;
81 
82 #define BOOTPREPLY	2
83 #define BOOTPREQUEST	1
84 
85 /*
86  * Vendor magic cookie (v_magic) for CMU
87  */
88 #define VM_CMU		"CMU"
89 
90 /*
91  * Vendor magic cookie (v_magic) for RFC1048
92  */
93 #define VM_RFC1048	{ 99, 130, 83, 99 }
94 
95 /*
96  * RFC1048 tag values used to specify what information is being supplied in
97  * the vendor field of the packet.
98  */
99 
100 #define TAG_PAD			((uint8_t)   0)
101 #define TAG_SUBNET_MASK		((uint8_t)   1)
102 #define TAG_TIME_OFFSET		((uint8_t)   2)
103 #define TAG_GATEWAY		((uint8_t)   3)
104 #define TAG_TIME_SERVER		((uint8_t)   4)
105 #define TAG_NAME_SERVER		((uint8_t)   5)
106 #define TAG_DOMAIN_SERVER	((uint8_t)   6)
107 #define TAG_LOG_SERVER		((uint8_t)   7)
108 #define TAG_COOKIE_SERVER	((uint8_t)   8)
109 #define TAG_LPR_SERVER		((uint8_t)   9)
110 #define TAG_IMPRESS_SERVER	((uint8_t)  10)
111 #define TAG_RLP_SERVER		((uint8_t)  11)
112 #define TAG_HOSTNAME		((uint8_t)  12)
113 #define TAG_BOOTSIZE		((uint8_t)  13)
114 #define TAG_END			((uint8_t) 255)
115 /* RFC1497 tags */
116 #define	TAG_DUMPPATH		((uint8_t)  14)
117 #define	TAG_DOMAINNAME		((uint8_t)  15)
118 #define	TAG_SWAP_SERVER		((uint8_t)  16)
119 #define	TAG_ROOTPATH		((uint8_t)  17)
120 #define	TAG_EXTPATH		((uint8_t)  18)
121 /* RFC2132 */
122 #define	TAG_IP_FORWARD		((uint8_t)  19)
123 #define	TAG_NL_SRCRT		((uint8_t)  20)
124 #define	TAG_PFILTERS		((uint8_t)  21)
125 #define	TAG_REASS_SIZE		((uint8_t)  22)
126 #define	TAG_DEF_TTL		((uint8_t)  23)
127 #define	TAG_MTU_TIMEOUT		((uint8_t)  24)
128 #define	TAG_MTU_TABLE		((uint8_t)  25)
129 #define	TAG_INT_MTU		((uint8_t)  26)
130 #define	TAG_LOCAL_SUBNETS	((uint8_t)  27)
131 #define	TAG_BROAD_ADDR		((uint8_t)  28)
132 #define	TAG_DO_MASK_DISC	((uint8_t)  29)
133 #define	TAG_SUPPLY_MASK		((uint8_t)  30)
134 #define	TAG_DO_RDISC		((uint8_t)  31)
135 #define	TAG_RTR_SOL_ADDR	((uint8_t)  32)
136 #define	TAG_STATIC_ROUTE	((uint8_t)  33)
137 #define	TAG_USE_TRAILERS	((uint8_t)  34)
138 #define	TAG_ARP_TIMEOUT		((uint8_t)  35)
139 #define	TAG_ETH_ENCAP		((uint8_t)  36)
140 #define	TAG_TCP_TTL		((uint8_t)  37)
141 #define	TAG_TCP_KEEPALIVE	((uint8_t)  38)
142 #define	TAG_KEEPALIVE_GO	((uint8_t)  39)
143 #define	TAG_NIS_DOMAIN		((uint8_t)  40)
144 #define	TAG_NIS_SERVERS		((uint8_t)  41)
145 #define	TAG_NTP_SERVERS		((uint8_t)  42)
146 #define	TAG_VENDOR_OPTS		((uint8_t)  43)
147 #define	TAG_NETBIOS_NS		((uint8_t)  44)
148 #define	TAG_NETBIOS_DDS		((uint8_t)  45)
149 #define	TAG_NETBIOS_NODE	((uint8_t)  46)
150 #define	TAG_NETBIOS_SCOPE	((uint8_t)  47)
151 #define	TAG_XWIN_FS		((uint8_t)  48)
152 #define	TAG_XWIN_DM		((uint8_t)  49)
153 #define	TAG_NIS_P_DOMAIN	((uint8_t)  64)
154 #define	TAG_NIS_P_SERVERS	((uint8_t)  65)
155 #define	TAG_MOBILE_HOME		((uint8_t)  68)
156 #define	TAG_SMPT_SERVER		((uint8_t)  69)
157 #define	TAG_POP3_SERVER		((uint8_t)  70)
158 #define	TAG_NNTP_SERVER		((uint8_t)  71)
159 #define	TAG_WWW_SERVER		((uint8_t)  72)
160 #define	TAG_FINGER_SERVER	((uint8_t)  73)
161 #define	TAG_IRC_SERVER		((uint8_t)  74)
162 #define	TAG_STREETTALK_SRVR	((uint8_t)  75)
163 #define	TAG_STREETTALK_STDA	((uint8_t)  76)
164 /* DHCP options */
165 #define	TAG_REQUESTED_IP	((uint8_t)  50)
166 #define	TAG_IP_LEASE		((uint8_t)  51)
167 #define	TAG_OPT_OVERLOAD	((uint8_t)  52)
168 #define	TAG_TFTP_SERVER		((uint8_t)  66)
169 #define	TAG_BOOTFILENAME	((uint8_t)  67)
170 #define	TAG_DHCP_MESSAGE	((uint8_t)  53)
171 #define	TAG_SERVER_ID		((uint8_t)  54)
172 #define	TAG_PARM_REQUEST	((uint8_t)  55)
173 #define	TAG_MESSAGE		((uint8_t)  56)
174 #define	TAG_MAX_MSG_SIZE	((uint8_t)  57)
175 #define	TAG_RENEWAL_TIME	((uint8_t)  58)
176 #define	TAG_REBIND_TIME		((uint8_t)  59)
177 #define	TAG_VENDOR_CLASS	((uint8_t)  60)
178 #define	TAG_CLIENT_ID		((uint8_t)  61)
179 /* RFC 2241 */
180 #define	TAG_NDS_SERVERS		((uint8_t)  85)
181 #define	TAG_NDS_TREE_NAME	((uint8_t)  86)
182 #define	TAG_NDS_CONTEXT		((uint8_t)  87)
183 /* RFC 2242 */
184 #define	TAG_NDS_IPDOMAIN	((uint8_t)  62)
185 #define	TAG_NDS_IPINFO		((uint8_t)  63)
186 /* RFC 2485 */
187 #define	TAG_OPEN_GROUP_UAP	((uint8_t)  98)
188 /* RFC 2563 */
189 #define	TAG_DISABLE_AUTOCONF	((uint8_t) 116)
190 /* RFC 2610 */
191 #define	TAG_SLP_DA		((uint8_t)  78)
192 #define	TAG_SLP_SCOPE		((uint8_t)  79)
193 /* RFC 2937 */
194 #define	TAG_NS_SEARCH		((uint8_t) 117)
195 /* RFC 3004 - The User Class Option for DHCP */
196 #define	TAG_USER_CLASS		((uint8_t)  77)
197 /* RFC 3011 */
198 #define	TAG_IP4_SUBNET_SELECT	((uint8_t) 118)
199 /* RFC 3442 */
200 #define TAG_CLASSLESS_STATIC_RT	((uint8_t) 121)
201 #define TAG_CLASSLESS_STA_RT_MS	((uint8_t) 249)
202 /* RFC 5859 - TFTP Server Address Option for DHCPv4 */
203 #define	TAG_TFTP_SERVER_ADDRESS	((uint8_t) 150)
204 /* ftp://ftp.isi.edu/.../assignments/bootp-dhcp-extensions */
205 #define	TAG_SLP_NAMING_AUTH	((uint8_t)  80)
206 #define	TAG_CLIENT_FQDN		((uint8_t)  81)
207 #define	TAG_AGENT_CIRCUIT	((uint8_t)  82)
208 #define	TAG_AGENT_REMOTE	((uint8_t)  83)
209 #define	TAG_AGENT_MASK		((uint8_t)  84)
210 #define	TAG_TZ_STRING		((uint8_t)  88)
211 #define	TAG_FQDN_OPTION		((uint8_t)  89)
212 #define	TAG_AUTH		((uint8_t)  90)
213 #define	TAG_VINES_SERVERS	((uint8_t)  91)
214 #define	TAG_SERVER_RANK		((uint8_t)  92)
215 #define	TAG_CLIENT_ARCH		((uint8_t)  93)
216 #define	TAG_CLIENT_NDI		((uint8_t)  94)
217 #define	TAG_CLIENT_GUID		((uint8_t)  97)
218 #define	TAG_LDAP_URL		((uint8_t)  95)
219 #define	TAG_6OVER4		((uint8_t)  96)
220 /* RFC 4833, TZ codes */
221 #define	TAG_TZ_PCODE    	((uint8_t) 100)
222 #define	TAG_TZ_TCODE    	((uint8_t) 101)
223 #define	TAG_IPX_COMPAT		((uint8_t) 110)
224 #define	TAG_NETINFO_PARENT	((uint8_t) 112)
225 #define	TAG_NETINFO_PARENT_TAG	((uint8_t) 113)
226 #define	TAG_URL			((uint8_t) 114)
227 #define	TAG_FAILOVER		((uint8_t) 115)
228 #define	TAG_EXTENDED_REQUEST	((uint8_t) 126)
229 #define	TAG_EXTENDED_OPTION	((uint8_t) 127)
230 #define TAG_MUDURL              ((uint8_t) 161)
231 
232 /* DHCP Message types (values for TAG_DHCP_MESSAGE option) */
233 #define DHCPDISCOVER	1
234 #define DHCPOFFER	2
235 #define DHCPREQUEST	3
236 #define DHCPDECLINE	4
237 #define DHCPACK		5
238 #define DHCPNAK		6
239 #define DHCPRELEASE	7
240 #define DHCPINFORM	8
241 
242 /*
243  * "vendor" data permitted for CMU bootp clients.
244  */
245 
246 struct cmu_vend {
247 	uint8_t		v_magic[4];	/* magic number */
248 	uint32_t	v_flags;	/* flags/opcodes, etc. */
249 	struct in_addr	v_smask;	/* Subnet mask */
250 	struct in_addr	v_dgate;	/* Default gateway */
251 	struct in_addr	v_dns1, v_dns2; /* Domain name servers */
252 	struct in_addr	v_ins1, v_ins2; /* IEN-116 name servers */
253 	struct in_addr	v_ts1, v_ts2;	/* Time servers */
254 	uint8_t		v_unused[24];	/* currently unused */
255 } UNALIGNED;
256 
257 
258 /* v_flags values */
259 #define VF_SMASK	1	/* Subnet mask field contains valid data */
260 
261 /* RFC 4702 DHCP Client FQDN Option */
262 
263 #define CLIENT_FQDN_FLAGS_S	0x01
264 #define CLIENT_FQDN_FLAGS_O	0x02
265 #define CLIENT_FQDN_FLAGS_E	0x04
266 #define CLIENT_FQDN_FLAGS_N	0x08
267 /* end of original bootp.h */
268 
269 static void rfc1048_print(netdissect_options *, const u_char *);
270 static void cmu_print(netdissect_options *, const u_char *);
271 static char *client_fqdn_flags(u_int flags);
272 
273 static const struct tok bootp_flag_values[] = {
274 	{ 0x8000,	"Broadcast" },
275 	{ 0, NULL}
276 };
277 
278 static const struct tok bootp_op_values[] = {
279 	{ BOOTPREQUEST,	"Request" },
280 	{ BOOTPREPLY,	"Reply" },
281 	{ 0, NULL}
282 };
283 
284 /*
285  * Print bootp requests
286  */
287 void
288 bootp_print(netdissect_options *ndo,
289 	    register const u_char *cp, u_int length)
290 {
291 	register const struct bootp *bp;
292 	static const u_char vm_cmu[4] = VM_CMU;
293 	static const u_char vm_rfc1048[4] = VM_RFC1048;
294 
295 	bp = (const struct bootp *)cp;
296 	ND_TCHECK(bp->bp_op);
297 
298 	ND_PRINT((ndo, "BOOTP/DHCP, %s",
299 		  tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op)));
300 
301 	ND_TCHECK(bp->bp_hlen);
302 	if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) {
303 		ND_TCHECK2(bp->bp_chaddr[0], 6);
304 		ND_PRINT((ndo, " from %s", etheraddr_string(ndo, bp->bp_chaddr)));
305 	}
306 
307 	ND_PRINT((ndo, ", length %u", length));
308 
309 	if (!ndo->ndo_vflag)
310 		return;
311 
312 	ND_TCHECK(bp->bp_secs);
313 
314 	/* The usual hardware address type is 1 (10Mb Ethernet) */
315 	if (bp->bp_htype != 1)
316 		ND_PRINT((ndo, ", htype %d", bp->bp_htype));
317 
318 	/* The usual length for 10Mb Ethernet address is 6 bytes */
319 	if (bp->bp_htype != 1 || bp->bp_hlen != 6)
320 		ND_PRINT((ndo, ", hlen %d", bp->bp_hlen));
321 
322 	/* Only print interesting fields */
323 	if (bp->bp_hops)
324 		ND_PRINT((ndo, ", hops %d", bp->bp_hops));
325 	if (EXTRACT_32BITS(&bp->bp_xid))
326 		ND_PRINT((ndo, ", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid)));
327 	if (EXTRACT_16BITS(&bp->bp_secs))
328 		ND_PRINT((ndo, ", secs %d", EXTRACT_16BITS(&bp->bp_secs)));
329 
330 	ND_TCHECK(bp->bp_flags);
331 	ND_PRINT((ndo, ", Flags [%s]",
332 		  bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags))));
333 	if (ndo->ndo_vflag > 1)
334 		ND_PRINT((ndo, " (0x%04x)", EXTRACT_16BITS(&bp->bp_flags)));
335 
336 	/* Client's ip address */
337 	ND_TCHECK(bp->bp_ciaddr);
338 	if (EXTRACT_32BITS(&bp->bp_ciaddr.s_addr))
339 		ND_PRINT((ndo, "\n\t  Client-IP %s", ipaddr_string(ndo, &bp->bp_ciaddr)));
340 
341 	/* 'your' ip address (bootp client) */
342 	ND_TCHECK(bp->bp_yiaddr);
343 	if (EXTRACT_32BITS(&bp->bp_yiaddr.s_addr))
344 		ND_PRINT((ndo, "\n\t  Your-IP %s", ipaddr_string(ndo, &bp->bp_yiaddr)));
345 
346 	/* Server's ip address */
347 	ND_TCHECK(bp->bp_siaddr);
348 	if (EXTRACT_32BITS(&bp->bp_siaddr.s_addr))
349 		ND_PRINT((ndo, "\n\t  Server-IP %s", ipaddr_string(ndo, &bp->bp_siaddr)));
350 
351 	/* Gateway's ip address */
352 	ND_TCHECK(bp->bp_giaddr);
353 	if (EXTRACT_32BITS(&bp->bp_giaddr.s_addr))
354 		ND_PRINT((ndo, "\n\t  Gateway-IP %s", ipaddr_string(ndo, &bp->bp_giaddr)));
355 
356 	/* Client's Ethernet address */
357 	if (bp->bp_htype == 1 && bp->bp_hlen == 6) {
358 		ND_TCHECK2(bp->bp_chaddr[0], 6);
359 		ND_PRINT((ndo, "\n\t  Client-Ethernet-Address %s", etheraddr_string(ndo, bp->bp_chaddr)));
360 	}
361 
362 	ND_TCHECK2(bp->bp_sname[0], 1);		/* check first char only */
363 	if (*bp->bp_sname) {
364 		ND_PRINT((ndo, "\n\t  sname \""));
365 		if (fn_printztn(ndo, bp->bp_sname, (u_int)sizeof bp->bp_sname,
366 		    ndo->ndo_snapend)) {
367 			ND_PRINT((ndo, "\""));
368 			ND_PRINT((ndo, "%s", tstr + 1));
369 			return;
370 		}
371 		ND_PRINT((ndo, "\""));
372 	}
373 	ND_TCHECK2(bp->bp_file[0], 1);		/* check first char only */
374 	if (*bp->bp_file) {
375 		ND_PRINT((ndo, "\n\t  file \""));
376 		if (fn_printztn(ndo, bp->bp_file, (u_int)sizeof bp->bp_file,
377 		    ndo->ndo_snapend)) {
378 			ND_PRINT((ndo, "\""));
379 			ND_PRINT((ndo, "%s", tstr + 1));
380 			return;
381 		}
382 		ND_PRINT((ndo, "\""));
383 	}
384 
385 	/* Decode the vendor buffer */
386 	ND_TCHECK(bp->bp_vend[0]);
387 	if (memcmp((const char *)bp->bp_vend, vm_rfc1048,
388 		    sizeof(uint32_t)) == 0)
389 		rfc1048_print(ndo, bp->bp_vend);
390 	else if (memcmp((const char *)bp->bp_vend, vm_cmu,
391 			sizeof(uint32_t)) == 0)
392 		cmu_print(ndo, bp->bp_vend);
393 	else {
394 		uint32_t ul;
395 
396 		ul = EXTRACT_32BITS(&bp->bp_vend);
397 		if (ul != 0)
398 			ND_PRINT((ndo, "\n\t  Vendor-#0x%x", ul));
399 	}
400 
401 	return;
402 trunc:
403 	ND_PRINT((ndo, "%s", tstr));
404 }
405 
406 /*
407  * The first character specifies the format to print:
408  *     i - ip address (32 bits)
409  *     p - ip address pairs (32 bits + 32 bits)
410  *     l - long (32 bits)
411  *     L - unsigned long (32 bits)
412  *     s - short (16 bits)
413  *     b - period-seperated decimal bytes (variable length)
414  *     x - colon-seperated hex bytes (variable length)
415  *     a - ascii string (variable length)
416  *     B - on/off (8 bits)
417  *     $ - special (explicit code to handle)
418  */
419 static const struct tok tag2str[] = {
420 /* RFC1048 tags */
421 	{ TAG_PAD,		" PAD" },
422 	{ TAG_SUBNET_MASK,	"iSubnet-Mask" },	/* subnet mask (RFC950) */
423 	{ TAG_TIME_OFFSET,	"LTime-Zone" },	/* seconds from UTC */
424 	{ TAG_GATEWAY,		"iDefault-Gateway" },	/* default gateway */
425 	{ TAG_TIME_SERVER,	"iTime-Server" },	/* time servers (RFC868) */
426 	{ TAG_NAME_SERVER,	"iIEN-Name-Server" },	/* IEN name servers (IEN116) */
427 	{ TAG_DOMAIN_SERVER,	"iDomain-Name-Server" },	/* domain name (RFC1035) */
428 	{ TAG_LOG_SERVER,	"iLOG" },	/* MIT log servers */
429 	{ TAG_COOKIE_SERVER,	"iCS" },	/* cookie servers (RFC865) */
430 	{ TAG_LPR_SERVER,	"iLPR-Server" },	/* lpr server (RFC1179) */
431 	{ TAG_IMPRESS_SERVER,	"iIM" },	/* impress servers (Imagen) */
432 	{ TAG_RLP_SERVER,	"iRL" },	/* resource location (RFC887) */
433 	{ TAG_HOSTNAME,		"aHostname" },	/* ascii hostname */
434 	{ TAG_BOOTSIZE,		"sBS" },	/* 512 byte blocks */
435 	{ TAG_END,		" END" },
436 /* RFC1497 tags */
437 	{ TAG_DUMPPATH,		"aDP" },
438 	{ TAG_DOMAINNAME,	"aDomain-Name" },
439 	{ TAG_SWAP_SERVER,	"iSS" },
440 	{ TAG_ROOTPATH,		"aRP" },
441 	{ TAG_EXTPATH,		"aEP" },
442 /* RFC2132 tags */
443 	{ TAG_IP_FORWARD,	"BIPF" },
444 	{ TAG_NL_SRCRT,		"BSRT" },
445 	{ TAG_PFILTERS,		"pPF" },
446 	{ TAG_REASS_SIZE,	"sRSZ" },
447 	{ TAG_DEF_TTL,		"bTTL" },
448 	{ TAG_MTU_TIMEOUT,	"lMTU-Timeout" },
449 	{ TAG_MTU_TABLE,	"sMTU-Table" },
450 	{ TAG_INT_MTU,		"sMTU" },
451 	{ TAG_LOCAL_SUBNETS,	"BLSN" },
452 	{ TAG_BROAD_ADDR,	"iBR" },
453 	{ TAG_DO_MASK_DISC,	"BMD" },
454 	{ TAG_SUPPLY_MASK,	"BMS" },
455 	{ TAG_DO_RDISC,		"BRouter-Discovery" },
456 	{ TAG_RTR_SOL_ADDR,	"iRSA" },
457 	{ TAG_STATIC_ROUTE,	"pStatic-Route" },
458 	{ TAG_USE_TRAILERS,	"BUT" },
459 	{ TAG_ARP_TIMEOUT,	"lAT" },
460 	{ TAG_ETH_ENCAP,	"BIE" },
461 	{ TAG_TCP_TTL,		"bTT" },
462 	{ TAG_TCP_KEEPALIVE,	"lKI" },
463 	{ TAG_KEEPALIVE_GO,	"BKG" },
464 	{ TAG_NIS_DOMAIN,	"aYD" },
465 	{ TAG_NIS_SERVERS,	"iYS" },
466 	{ TAG_NTP_SERVERS,	"iNTP" },
467 	{ TAG_VENDOR_OPTS,	"bVendor-Option" },
468 	{ TAG_NETBIOS_NS,	"iNetbios-Name-Server" },
469 	{ TAG_NETBIOS_DDS,	"iWDD" },
470 	{ TAG_NETBIOS_NODE,	"$Netbios-Node" },
471 	{ TAG_NETBIOS_SCOPE,	"aNetbios-Scope" },
472 	{ TAG_XWIN_FS,		"iXFS" },
473 	{ TAG_XWIN_DM,		"iXDM" },
474 	{ TAG_NIS_P_DOMAIN,	"sN+D" },
475 	{ TAG_NIS_P_SERVERS,	"iN+S" },
476 	{ TAG_MOBILE_HOME,	"iMH" },
477 	{ TAG_SMPT_SERVER,	"iSMTP" },
478 	{ TAG_POP3_SERVER,	"iPOP3" },
479 	{ TAG_NNTP_SERVER,	"iNNTP" },
480 	{ TAG_WWW_SERVER,	"iWWW" },
481 	{ TAG_FINGER_SERVER,	"iFG" },
482 	{ TAG_IRC_SERVER,	"iIRC" },
483 	{ TAG_STREETTALK_SRVR,	"iSTS" },
484 	{ TAG_STREETTALK_STDA,	"iSTDA" },
485 	{ TAG_REQUESTED_IP,	"iRequested-IP" },
486 	{ TAG_IP_LEASE,		"lLease-Time" },
487 	{ TAG_OPT_OVERLOAD,	"$OO" },
488 	{ TAG_TFTP_SERVER,	"aTFTP" },
489 	{ TAG_BOOTFILENAME,	"aBF" },
490 	{ TAG_DHCP_MESSAGE,	" DHCP-Message" },
491 	{ TAG_SERVER_ID,	"iServer-ID" },
492 	{ TAG_PARM_REQUEST,	"bParameter-Request" },
493 	{ TAG_MESSAGE,		"aMSG" },
494 	{ TAG_MAX_MSG_SIZE,	"sMSZ" },
495 	{ TAG_RENEWAL_TIME,	"lRN" },
496 	{ TAG_REBIND_TIME,	"lRB" },
497 	{ TAG_VENDOR_CLASS,	"aVendor-Class" },
498 	{ TAG_CLIENT_ID,	"$Client-ID" },
499 /* RFC 2485 */
500 	{ TAG_OPEN_GROUP_UAP,	"aUAP" },
501 /* RFC 2563 */
502 	{ TAG_DISABLE_AUTOCONF,	"BNOAUTO" },
503 /* RFC 2610 */
504 	{ TAG_SLP_DA,		"bSLP-DA" },	/*"b" is a little wrong */
505 	{ TAG_SLP_SCOPE,	"bSLP-SCOPE" },	/*"b" is a little wrong */
506 /* RFC 2937 */
507 	{ TAG_NS_SEARCH,	"sNSSEARCH" },	/* XXX 's' */
508 /* RFC 3004 - The User Class Option for DHCP */
509 	{ TAG_USER_CLASS,	"$User-Class" },
510 /* RFC 3011 */
511 	{ TAG_IP4_SUBNET_SELECT, "iSUBNET" },
512 /* RFC 3442 */
513 	{ TAG_CLASSLESS_STATIC_RT, "$Classless-Static-Route" },
514 	{ TAG_CLASSLESS_STA_RT_MS, "$Classless-Static-Route-Microsoft" },
515 /* RFC 5859 - TFTP Server Address Option for DHCPv4 */
516 	{ TAG_TFTP_SERVER_ADDRESS, "iTFTP-Server-Address" },
517 /* http://www.iana.org/assignments/bootp-dhcp-extensions/index.htm */
518 	{ TAG_SLP_NAMING_AUTH,	"aSLP-NA" },
519 	{ TAG_CLIENT_FQDN,	"$FQDN" },
520 	{ TAG_AGENT_CIRCUIT,	"$Agent-Information" },
521 	{ TAG_AGENT_REMOTE,	"bARMT" },
522 	{ TAG_AGENT_MASK,	"bAMSK" },
523 	{ TAG_TZ_STRING,	"aTZSTR" },
524 	{ TAG_FQDN_OPTION,	"bFQDNS" },	/* XXX 'b' */
525 	{ TAG_AUTH,		"bAUTH" },	/* XXX 'b' */
526 	{ TAG_VINES_SERVERS,	"iVINES" },
527 	{ TAG_SERVER_RANK,	"sRANK" },
528 	{ TAG_CLIENT_ARCH,	"sARCH" },
529 	{ TAG_CLIENT_NDI,	"bNDI" },	/* XXX 'b' */
530 	{ TAG_CLIENT_GUID,	"bGUID" },	/* XXX 'b' */
531 	{ TAG_LDAP_URL,		"aLDAP" },
532 	{ TAG_6OVER4,		"i6o4" },
533 	{ TAG_TZ_PCODE, 	"aPOSIX-TZ" },
534 	{ TAG_TZ_TCODE, 	"aTZ-Name" },
535 	{ TAG_IPX_COMPAT,	"bIPX" },	/* XXX 'b' */
536 	{ TAG_NETINFO_PARENT,	"iNI" },
537 	{ TAG_NETINFO_PARENT_TAG, "aNITAG" },
538 	{ TAG_URL,		"aURL" },
539 	{ TAG_FAILOVER,		"bFAIL" },	/* XXX 'b' */
540 	{ TAG_MUDURL,           "aMUD-URL" },
541 	{ 0, NULL }
542 };
543 /* 2-byte extended tags */
544 static const struct tok xtag2str[] = {
545 	{ 0, NULL }
546 };
547 
548 /* DHCP "options overload" types */
549 static const struct tok oo2str[] = {
550 	{ 1,	"file" },
551 	{ 2,	"sname" },
552 	{ 3,	"file+sname" },
553 	{ 0, NULL }
554 };
555 
556 /* NETBIOS over TCP/IP node type options */
557 static const struct tok nbo2str[] = {
558 	{ 0x1,	"b-node" },
559 	{ 0x2,	"p-node" },
560 	{ 0x4,	"m-node" },
561 	{ 0x8,	"h-node" },
562 	{ 0, NULL }
563 };
564 
565 /* ARP Hardware types, for Client-ID option */
566 static const struct tok arp2str[] = {
567 	{ 0x1,	"ether" },
568 	{ 0x6,	"ieee802" },
569 	{ 0x7,	"arcnet" },
570 	{ 0xf,	"frelay" },
571 	{ 0x17,	"strip" },
572 	{ 0x18,	"ieee1394" },
573 	{ 0, NULL }
574 };
575 
576 static const struct tok dhcp_msg_values[] = {
577 	{ DHCPDISCOVER,	"Discover" },
578 	{ DHCPOFFER,	"Offer" },
579 	{ DHCPREQUEST,	"Request" },
580 	{ DHCPDECLINE,	"Decline" },
581 	{ DHCPACK,	"ACK" },
582 	{ DHCPNAK,	"NACK" },
583 	{ DHCPRELEASE,	"Release" },
584 	{ DHCPINFORM,	"Inform" },
585 	{ 0, NULL }
586 };
587 
588 #define AGENT_SUBOPTION_CIRCUIT_ID	1	/* RFC 3046 */
589 #define AGENT_SUBOPTION_REMOTE_ID	2	/* RFC 3046 */
590 #define AGENT_SUBOPTION_SUBSCRIBER_ID	6	/* RFC 3993 */
591 static const struct tok agent_suboption_values[] = {
592 	{ AGENT_SUBOPTION_CIRCUIT_ID,    "Circuit-ID" },
593 	{ AGENT_SUBOPTION_REMOTE_ID,     "Remote-ID" },
594 	{ AGENT_SUBOPTION_SUBSCRIBER_ID, "Subscriber-ID" },
595 	{ 0, NULL }
596 };
597 
598 
599 static void
600 rfc1048_print(netdissect_options *ndo,
601 	      register const u_char *bp)
602 {
603 	register uint16_t tag;
604 	register u_int len;
605 	register const char *cp;
606 	register char c;
607 	int first, idx;
608 	uint32_t ul;
609 	uint16_t us;
610 	uint8_t uc, subopt, suboptlen;
611 
612 	ND_PRINT((ndo, "\n\t  Vendor-rfc1048 Extensions"));
613 
614 	/* Step over magic cookie */
615 	ND_PRINT((ndo, "\n\t    Magic Cookie 0x%08x", EXTRACT_32BITS(bp)));
616 	bp += sizeof(int32_t);
617 
618 	/* Loop while we there is a tag left in the buffer */
619 	while (ND_TTEST2(*bp, 1)) {
620 		tag = *bp++;
621 		if (tag == TAG_PAD && ndo->ndo_vflag < 3)
622 			continue;
623 		if (tag == TAG_END && ndo->ndo_vflag < 3)
624 			return;
625 		if (tag == TAG_EXTENDED_OPTION) {
626 			ND_TCHECK2(*(bp + 1), 2);
627 			tag = EXTRACT_16BITS(bp + 1);
628 			/* XXX we don't know yet if the IANA will
629 			 * preclude overlap of 1-byte and 2-byte spaces.
630 			 * If not, we need to offset tag after this step.
631 			 */
632 			cp = tok2str(xtag2str, "?xT%u", tag);
633 		} else
634 			cp = tok2str(tag2str, "?T%u", tag);
635 		c = *cp++;
636 
637 		if (tag == TAG_PAD || tag == TAG_END)
638 			len = 0;
639 		else {
640 			/* Get the length; check for truncation */
641 			ND_TCHECK2(*bp, 1);
642 			len = *bp++;
643 		}
644 
645 		ND_PRINT((ndo, "\n\t    %s Option %u, length %u%s", cp, tag, len,
646 			  len > 0 ? ": " : ""));
647 
648 		if (tag == TAG_PAD && ndo->ndo_vflag > 2) {
649 			u_int ntag = 1;
650 			while (ND_TTEST2(*bp, 1) && *bp == TAG_PAD) {
651 				bp++;
652 				ntag++;
653 			}
654 			if (ntag > 1)
655 				ND_PRINT((ndo, ", occurs %u", ntag));
656 		}
657 
658 		if (!ND_TTEST2(*bp, len)) {
659 			ND_PRINT((ndo, "[|rfc1048 %u]", len));
660 			return;
661 		}
662 
663 		if (tag == TAG_DHCP_MESSAGE && len == 1) {
664 			uc = *bp++;
665 			ND_PRINT((ndo, "%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc)));
666 			continue;
667 		}
668 
669 		if (tag == TAG_PARM_REQUEST) {
670 			idx = 0;
671 			while (len-- > 0) {
672 				uc = *bp++;
673 				cp = tok2str(tag2str, "?Option %u", uc);
674 				if (idx % 4 == 0)
675 					ND_PRINT((ndo, "\n\t      "));
676 				else
677 					ND_PRINT((ndo, ", "));
678 				ND_PRINT((ndo, "%s", cp + 1));
679 				idx++;
680 			}
681 			continue;
682 		}
683 
684 		if (tag == TAG_EXTENDED_REQUEST) {
685 			first = 1;
686 			while (len > 1) {
687 				len -= 2;
688 				us = EXTRACT_16BITS(bp);
689 				bp += 2;
690 				cp = tok2str(xtag2str, "?xT%u", us);
691 				if (!first)
692 					ND_PRINT((ndo, "+"));
693 				ND_PRINT((ndo, "%s", cp + 1));
694 				first = 0;
695 			}
696 			continue;
697 		}
698 
699 		/* Print data */
700 		if (c == '?') {
701 			/* Base default formats for unknown tags on data size */
702 			if (len & 1)
703 				c = 'b';
704 			else if (len & 2)
705 				c = 's';
706 			else
707 				c = 'l';
708 		}
709 		first = 1;
710 		switch (c) {
711 
712 		case 'a':
713 			/* ascii strings */
714 			ND_PRINT((ndo, "\""));
715 			if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) {
716 				ND_PRINT((ndo, "\""));
717 				goto trunc;
718 			}
719 			ND_PRINT((ndo, "\""));
720 			bp += len;
721 			len = 0;
722 			break;
723 
724 		case 'i':
725 		case 'l':
726 		case 'L':
727 			/* ip addresses/32-bit words */
728 			while (len >= sizeof(ul)) {
729 				if (!first)
730 					ND_PRINT((ndo, ","));
731 				ul = EXTRACT_32BITS(bp);
732 				if (c == 'i') {
733 					ul = htonl(ul);
734 					ND_PRINT((ndo, "%s", ipaddr_string(ndo, &ul)));
735 				} else if (c == 'L')
736 					ND_PRINT((ndo, "%d", ul));
737 				else
738 					ND_PRINT((ndo, "%u", ul));
739 				bp += sizeof(ul);
740 				len -= sizeof(ul);
741 				first = 0;
742 			}
743 			break;
744 
745 		case 'p':
746 			/* IP address pairs */
747 			while (len >= 2*sizeof(ul)) {
748 				if (!first)
749 					ND_PRINT((ndo, ","));
750 				memcpy((char *)&ul, (const char *)bp, sizeof(ul));
751 				ND_PRINT((ndo, "(%s:", ipaddr_string(ndo, &ul)));
752 				bp += sizeof(ul);
753 				memcpy((char *)&ul, (const char *)bp, sizeof(ul));
754 				ND_PRINT((ndo, "%s)", ipaddr_string(ndo, &ul)));
755 				bp += sizeof(ul);
756 				len -= 2*sizeof(ul);
757 				first = 0;
758 			}
759 			break;
760 
761 		case 's':
762 			/* shorts */
763 			while (len >= sizeof(us)) {
764 				if (!first)
765 					ND_PRINT((ndo, ","));
766 				us = EXTRACT_16BITS(bp);
767 				ND_PRINT((ndo, "%u", us));
768 				bp += sizeof(us);
769 				len -= sizeof(us);
770 				first = 0;
771 			}
772 			break;
773 
774 		case 'B':
775 			/* boolean */
776 			while (len > 0) {
777 				if (!first)
778 					ND_PRINT((ndo, ","));
779 				switch (*bp) {
780 				case 0:
781 					ND_PRINT((ndo, "N"));
782 					break;
783 				case 1:
784 					ND_PRINT((ndo, "Y"));
785 					break;
786 				default:
787 					ND_PRINT((ndo, "%u?", *bp));
788 					break;
789 				}
790 				++bp;
791 				--len;
792 				first = 0;
793 			}
794 			break;
795 
796 		case 'b':
797 		case 'x':
798 		default:
799 			/* Bytes */
800 			while (len > 0) {
801 				if (!first)
802 					ND_PRINT((ndo, c == 'x' ? ":" : "."));
803 				if (c == 'x')
804 					ND_PRINT((ndo, "%02x", *bp));
805 				else
806 					ND_PRINT((ndo, "%u", *bp));
807 				++bp;
808 				--len;
809 				first = 0;
810 			}
811 			break;
812 
813 		case '$':
814 			/* Guys we can't handle with one of the usual cases */
815 			switch (tag) {
816 
817 			case TAG_NETBIOS_NODE:
818 				/* this option should be at least 1 byte long */
819 				if (len < 1) {
820 					ND_PRINT((ndo, "ERROR: length < 1 bytes"));
821 					break;
822 				}
823 				tag = *bp++;
824 				--len;
825 				ND_PRINT((ndo, "%s", tok2str(nbo2str, NULL, tag)));
826 				break;
827 
828 			case TAG_OPT_OVERLOAD:
829 				/* this option should be at least 1 byte long */
830 				if (len < 1) {
831 					ND_PRINT((ndo, "ERROR: length < 1 bytes"));
832 					break;
833 				}
834 				tag = *bp++;
835 				--len;
836 				ND_PRINT((ndo, "%s", tok2str(oo2str, NULL, tag)));
837 				break;
838 
839 			case TAG_CLIENT_FQDN:
840 				/* this option should be at least 3 bytes long */
841 				if (len < 3) {
842 					ND_PRINT((ndo, "ERROR: length < 3 bytes"));
843 					bp += len;
844 					len = 0;
845 					break;
846 				}
847 				if (*bp)
848 					ND_PRINT((ndo, "[%s] ", client_fqdn_flags(*bp)));
849 				bp++;
850 				if (*bp || *(bp+1))
851 					ND_PRINT((ndo, "%u/%u ", *bp, *(bp+1)));
852 				bp += 2;
853 				ND_PRINT((ndo, "\""));
854 				if (fn_printn(ndo, bp, len - 3, ndo->ndo_snapend)) {
855 					ND_PRINT((ndo, "\""));
856 					goto trunc;
857 				}
858 				ND_PRINT((ndo, "\""));
859 				bp += len - 3;
860 				len = 0;
861 				break;
862 
863 			case TAG_CLIENT_ID:
864 			    {
865 				int type;
866 
867 				/* this option should be at least 1 byte long */
868 				if (len < 1) {
869 					ND_PRINT((ndo, "ERROR: length < 1 bytes"));
870 					break;
871 				}
872 				type = *bp++;
873 				len--;
874 				if (type == 0) {
875 					ND_PRINT((ndo, "\""));
876 					if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) {
877 						ND_PRINT((ndo, "\""));
878 						goto trunc;
879 					}
880 					ND_PRINT((ndo, "\""));
881 					bp += len;
882 					len = 0;
883 					break;
884 				} else {
885 					ND_PRINT((ndo, "%s ", tok2str(arp2str, "hardware-type %u,", type)));
886 					while (len > 0) {
887 						if (!first)
888 							ND_PRINT((ndo, ":"));
889 						ND_PRINT((ndo, "%02x", *bp));
890 						++bp;
891 						--len;
892 						first = 0;
893 					}
894 				}
895 				break;
896 			    }
897 
898 			case TAG_AGENT_CIRCUIT:
899 				while (len >= 2) {
900 					subopt = *bp++;
901 					suboptlen = *bp++;
902 					len -= 2;
903 					if (suboptlen > len) {
904 						ND_PRINT((ndo, "\n\t      %s SubOption %u, length %u: length goes past end of option",
905 							  tok2str(agent_suboption_values, "Unknown", subopt),
906 							  subopt,
907 							  suboptlen));
908 						bp += len;
909 						len = 0;
910 						break;
911 					}
912 					ND_PRINT((ndo, "\n\t      %s SubOption %u, length %u: ",
913 						  tok2str(agent_suboption_values, "Unknown", subopt),
914 						  subopt,
915 						  suboptlen));
916 					switch (subopt) {
917 
918 					case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */
919 					case AGENT_SUBOPTION_REMOTE_ID:
920 					case AGENT_SUBOPTION_SUBSCRIBER_ID:
921 						if (fn_printn(ndo, bp, suboptlen, ndo->ndo_snapend))
922 							goto trunc;
923 						break;
924 
925 					default:
926 						print_unknown_data(ndo, bp, "\n\t\t", suboptlen);
927 					}
928 
929 					len -= suboptlen;
930 					bp += suboptlen;
931 				}
932 				break;
933 
934 			case TAG_CLASSLESS_STATIC_RT:
935 			case TAG_CLASSLESS_STA_RT_MS:
936 			    {
937 				u_int mask_width, significant_octets, i;
938 
939 				/* this option should be at least 5 bytes long */
940 				if (len < 5) {
941 					ND_PRINT((ndo, "ERROR: length < 5 bytes"));
942 					bp += len;
943 					len = 0;
944 					break;
945 				}
946 				while (len > 0) {
947 					if (!first)
948 						ND_PRINT((ndo, ","));
949 					mask_width = *bp++;
950 					len--;
951 					/* mask_width <= 32 */
952 					if (mask_width > 32) {
953 						ND_PRINT((ndo, "[ERROR: Mask width (%d) > 32]", mask_width));
954 						bp += len;
955 						len = 0;
956 						break;
957 					}
958 					significant_octets = (mask_width + 7) / 8;
959 					/* significant octets + router(4) */
960 					if (len < significant_octets + 4) {
961 						ND_PRINT((ndo, "[ERROR: Remaining length (%u) < %u bytes]", len, significant_octets + 4));
962 						bp += len;
963 						len = 0;
964 						break;
965 					}
966 					ND_PRINT((ndo, "("));
967 					if (mask_width == 0)
968 						ND_PRINT((ndo, "default"));
969 					else {
970 						for (i = 0; i < significant_octets ; i++) {
971 							if (i > 0)
972 								ND_PRINT((ndo, "."));
973 							ND_PRINT((ndo, "%d", *bp++));
974 						}
975 						for (i = significant_octets ; i < 4 ; i++)
976 							ND_PRINT((ndo, ".0"));
977 						ND_PRINT((ndo, "/%d", mask_width));
978 					}
979 					memcpy((char *)&ul, (const char *)bp, sizeof(ul));
980 					ND_PRINT((ndo, ":%s)", ipaddr_string(ndo, &ul)));
981 					bp += sizeof(ul);
982 					len -= (significant_octets + 4);
983 					first = 0;
984 				}
985 				break;
986 			    }
987 
988 			case TAG_USER_CLASS:
989 			    {
990 				u_int suboptnumber = 1;
991 
992 				first = 1;
993 				if (len < 2) {
994 					ND_PRINT((ndo, "ERROR: length < 2 bytes"));
995 					bp += len;
996 					len = 0;
997 					break;
998 				}
999 				while (len > 0) {
1000 					suboptlen = *bp++;
1001 					len--;
1002 					ND_PRINT((ndo, "\n\t      "));
1003 					ND_PRINT((ndo, "instance#%u: ", suboptnumber));
1004 					if (suboptlen == 0) {
1005 						ND_PRINT((ndo, "ERROR: suboption length must be non-zero"));
1006 						bp += len;
1007 						len = 0;
1008 						break;
1009 					}
1010 					if (len < suboptlen) {
1011 						ND_PRINT((ndo, "ERROR: invalid option"));
1012 						bp += len;
1013 						len = 0;
1014 						break;
1015 					}
1016 					ND_PRINT((ndo, "\""));
1017 					if (fn_printn(ndo, bp, suboptlen, ndo->ndo_snapend)) {
1018 						ND_PRINT((ndo, "\""));
1019 						goto trunc;
1020 					}
1021 					ND_PRINT((ndo, "\""));
1022 					ND_PRINT((ndo, ", length %d", suboptlen));
1023 					suboptnumber++;
1024 					len -= suboptlen;
1025 					bp += suboptlen;
1026 				}
1027 				break;
1028 			    }
1029 
1030 			default:
1031 				ND_PRINT((ndo, "[unknown special tag %u, size %u]",
1032 					  tag, len));
1033 				bp += len;
1034 				len = 0;
1035 				break;
1036 			}
1037 			break;
1038 		}
1039 		/* Data left over? */
1040 		if (len) {
1041 			ND_PRINT((ndo, "\n\t  trailing data length %u", len));
1042 			bp += len;
1043 		}
1044 	}
1045 	return;
1046 trunc:
1047 	ND_PRINT((ndo, "|[rfc1048]"));
1048 }
1049 
1050 static void
1051 cmu_print(netdissect_options *ndo,
1052 	  register const u_char *bp)
1053 {
1054 	register const struct cmu_vend *cmu;
1055 
1056 #define PRINTCMUADDR(m, s) { ND_TCHECK(cmu->m); \
1057     if (cmu->m.s_addr != 0) \
1058 	ND_PRINT((ndo, " %s:%s", s, ipaddr_string(ndo, &cmu->m.s_addr))); }
1059 
1060 	ND_PRINT((ndo, " vend-cmu"));
1061 	cmu = (const struct cmu_vend *)bp;
1062 
1063 	/* Only print if there are unknown bits */
1064 	ND_TCHECK(cmu->v_flags);
1065 	if ((cmu->v_flags & ~(VF_SMASK)) != 0)
1066 		ND_PRINT((ndo, " F:0x%x", cmu->v_flags));
1067 	PRINTCMUADDR(v_dgate, "DG");
1068 	PRINTCMUADDR(v_smask, cmu->v_flags & VF_SMASK ? "SM" : "SM*");
1069 	PRINTCMUADDR(v_dns1, "NS1");
1070 	PRINTCMUADDR(v_dns2, "NS2");
1071 	PRINTCMUADDR(v_ins1, "IEN1");
1072 	PRINTCMUADDR(v_ins2, "IEN2");
1073 	PRINTCMUADDR(v_ts1, "TS1");
1074 	PRINTCMUADDR(v_ts2, "TS2");
1075 	return;
1076 
1077 trunc:
1078 	ND_PRINT((ndo, "%s", tstr));
1079 #undef PRINTCMUADDR
1080 }
1081 
1082 static char *
1083 client_fqdn_flags(u_int flags)
1084 {
1085 	static char buf[8+1];
1086 	int i = 0;
1087 
1088 	if (flags & CLIENT_FQDN_FLAGS_S)
1089 		buf[i++] = 'S';
1090 	if (flags & CLIENT_FQDN_FLAGS_O)
1091 		buf[i++] = 'O';
1092 	if (flags & CLIENT_FQDN_FLAGS_E)
1093 		buf[i++] = 'E';
1094 	if (flags & CLIENT_FQDN_FLAGS_N)
1095 		buf[i++] = 'N';
1096 	buf[i] = '\0';
1097 
1098 	return buf;
1099 }
1100