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