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