Home | History | Annotate | Line # | Download | only in dist
print-bootp.c revision 1.5
      1  1.1  christos /*
      2  1.1  christos  * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
      3  1.1  christos  *	The Regents of the University of California.  All rights reserved.
      4  1.1  christos  *
      5  1.1  christos  * Redistribution and use in source and binary forms, with or without
      6  1.1  christos  * modification, are permitted provided that: (1) source code distributions
      7  1.1  christos  * retain the above copyright notice and this paragraph in its entirety, (2)
      8  1.1  christos  * distributions including binary code include the above copyright notice and
      9  1.1  christos  * this paragraph in its entirety in the documentation or other materials
     10  1.1  christos  * provided with the distribution, and (3) all advertising materials mentioning
     11  1.1  christos  * features or use of this software display the following acknowledgement:
     12  1.1  christos  * ``This product includes software developed by the University of California,
     13  1.1  christos  * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
     14  1.1  christos  * the University nor the names of its contributors may be used to endorse
     15  1.1  christos  * or promote products derived from this software without specific prior
     16  1.1  christos  * written permission.
     17  1.1  christos  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
     18  1.1  christos  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
     19  1.1  christos  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
     20  1.1  christos  *
     21  1.1  christos  * Format and print bootp packets.
     22  1.1  christos  */
     23  1.5  christos 
     24  1.2  christos #include <sys/cdefs.h>
     25  1.1  christos #ifndef lint
     26  1.5  christos __RCSID("$NetBSD: print-bootp.c,v 1.5 2014/11/20 03:05:03 christos Exp $");
     27  1.1  christos #endif
     28  1.1  christos 
     29  1.5  christos #define NETDISSECT_REWORKED
     30  1.1  christos #ifdef HAVE_CONFIG_H
     31  1.1  christos #include "config.h"
     32  1.1  christos #endif
     33  1.1  christos 
     34  1.1  christos #include <tcpdump-stdinc.h>
     35  1.1  christos 
     36  1.1  christos #include <string.h>
     37  1.1  christos 
     38  1.1  christos #include "interface.h"
     39  1.1  christos #include "addrtoname.h"
     40  1.1  christos #include "extract.h"
     41  1.1  christos #include "bootp.h"
     42  1.1  christos 
     43  1.5  christos static const char tstr[] = " [|bootp]";
     44  1.5  christos 
     45  1.5  christos static void rfc1048_print(netdissect_options *, const u_char *);
     46  1.5  christos static void cmu_print(netdissect_options *, const u_char *);
     47  1.1  christos static char *client_fqdn_flags(u_int flags);
     48  1.1  christos 
     49  1.1  christos static const struct tok bootp_flag_values[] = {
     50  1.1  christos     { 0x8000,                   "Broadcast" },
     51  1.1  christos     { 0, NULL}
     52  1.1  christos };
     53  1.1  christos 
     54  1.1  christos static const struct tok bootp_op_values[] = {
     55  1.1  christos     { BOOTPREQUEST,             "Request" },
     56  1.1  christos     { BOOTPREPLY,               "Reply" },
     57  1.1  christos     { 0, NULL}
     58  1.1  christos };
     59  1.1  christos 
     60  1.1  christos /*
     61  1.1  christos  * Print bootp requests
     62  1.1  christos  */
     63  1.1  christos void
     64  1.5  christos bootp_print(netdissect_options *ndo,
     65  1.5  christos             register const u_char *cp, u_int length)
     66  1.1  christos {
     67  1.1  christos 	register const struct bootp *bp;
     68  1.1  christos 	static const u_char vm_cmu[4] = VM_CMU;
     69  1.1  christos 	static const u_char vm_rfc1048[4] = VM_RFC1048;
     70  1.1  christos 
     71  1.1  christos 	bp = (const struct bootp *)cp;
     72  1.5  christos 	ND_TCHECK(bp->bp_op);
     73  1.1  christos 
     74  1.5  christos 	ND_PRINT((ndo, "BOOTP/DHCP, %s",
     75  1.5  christos 	          tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op)));
     76  1.1  christos 
     77  1.1  christos 	if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) {
     78  1.5  christos 		ND_TCHECK2(bp->bp_chaddr[0], 6);
     79  1.5  christos 		ND_PRINT((ndo, " from %s", etheraddr_string(ndo, bp->bp_chaddr)));
     80  1.1  christos 	}
     81  1.1  christos 
     82  1.5  christos 	ND_PRINT((ndo, ", length %u", length));
     83  1.1  christos 
     84  1.5  christos 	if (!ndo->ndo_vflag)
     85  1.5  christos 		return;
     86  1.1  christos 
     87  1.5  christos 	ND_TCHECK(bp->bp_secs);
     88  1.1  christos 
     89  1.1  christos 	/* The usual hardware address type is 1 (10Mb Ethernet) */
     90  1.1  christos 	if (bp->bp_htype != 1)
     91  1.5  christos 		ND_PRINT((ndo, ", htype %d", bp->bp_htype));
     92  1.1  christos 
     93  1.1  christos 	/* The usual length for 10Mb Ethernet address is 6 bytes */
     94  1.1  christos 	if (bp->bp_htype != 1 || bp->bp_hlen != 6)
     95  1.5  christos 		ND_PRINT((ndo, ", hlen %d", bp->bp_hlen));
     96  1.1  christos 
     97  1.1  christos 	/* Only print interesting fields */
     98  1.1  christos 	if (bp->bp_hops)
     99  1.5  christos 		ND_PRINT((ndo, ", hops %d", bp->bp_hops));
    100  1.5  christos 	if (EXTRACT_32BITS(&bp->bp_xid))
    101  1.5  christos 		ND_PRINT((ndo, ", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid)));
    102  1.5  christos 	if (EXTRACT_16BITS(&bp->bp_secs))
    103  1.5  christos 		ND_PRINT((ndo, ", secs %d", EXTRACT_16BITS(&bp->bp_secs)));
    104  1.5  christos 
    105  1.5  christos 	ND_PRINT((ndo, ", Flags [%s]",
    106  1.5  christos 		bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags))));
    107  1.5  christos 	if (ndo->ndo_vflag > 1)
    108  1.5  christos 		ND_PRINT((ndo, " (0x%04x)", EXTRACT_16BITS(&bp->bp_flags)));
    109  1.1  christos 
    110  1.1  christos 	/* Client's ip address */
    111  1.5  christos 	ND_TCHECK(bp->bp_ciaddr);
    112  1.5  christos 	if (EXTRACT_32BITS(&bp->bp_ciaddr.s_addr))
    113  1.5  christos 		ND_PRINT((ndo, "\n\t  Client-IP %s", ipaddr_string(ndo, &bp->bp_ciaddr)));
    114  1.1  christos 
    115  1.1  christos 	/* 'your' ip address (bootp client) */
    116  1.5  christos 	ND_TCHECK(bp->bp_yiaddr);
    117  1.5  christos 	if (EXTRACT_32BITS(&bp->bp_yiaddr.s_addr))
    118  1.5  christos 		ND_PRINT((ndo, "\n\t  Your-IP %s", ipaddr_string(ndo, &bp->bp_yiaddr)));
    119  1.1  christos 
    120  1.1  christos 	/* Server's ip address */
    121  1.5  christos 	ND_TCHECK(bp->bp_siaddr);
    122  1.5  christos 	if (EXTRACT_32BITS(&bp->bp_siaddr.s_addr))
    123  1.5  christos 		ND_PRINT((ndo, "\n\t  Server-IP %s", ipaddr_string(ndo, &bp->bp_siaddr)));
    124  1.1  christos 
    125  1.1  christos 	/* Gateway's ip address */
    126  1.5  christos 	ND_TCHECK(bp->bp_giaddr);
    127  1.5  christos 	if (EXTRACT_32BITS(&bp->bp_giaddr.s_addr))
    128  1.5  christos 		ND_PRINT((ndo, "\n\t  Gateway-IP %s", ipaddr_string(ndo, &bp->bp_giaddr)));
    129  1.1  christos 
    130  1.1  christos 	/* Client's Ethernet address */
    131  1.1  christos 	if (bp->bp_htype == 1 && bp->bp_hlen == 6) {
    132  1.5  christos 		ND_TCHECK2(bp->bp_chaddr[0], 6);
    133  1.5  christos 		ND_PRINT((ndo, "\n\t  Client-Ethernet-Address %s", etheraddr_string(ndo, bp->bp_chaddr)));
    134  1.1  christos 	}
    135  1.1  christos 
    136  1.5  christos 	ND_TCHECK2(bp->bp_sname[0], 1);		/* check first char only */
    137  1.1  christos 	if (*bp->bp_sname) {
    138  1.5  christos 		ND_PRINT((ndo, "\n\t  sname \""));
    139  1.5  christos 		if (fn_print(ndo, bp->bp_sname, ndo->ndo_snapend)) {
    140  1.5  christos 			ND_PRINT((ndo, "\""));
    141  1.5  christos 			ND_PRINT((ndo, "%s", tstr + 1));
    142  1.1  christos 			return;
    143  1.1  christos 		}
    144  1.5  christos 		ND_PRINT((ndo, "\""));
    145  1.1  christos 	}
    146  1.5  christos 	ND_TCHECK2(bp->bp_file[0], 1);		/* check first char only */
    147  1.1  christos 	if (*bp->bp_file) {
    148  1.5  christos 		ND_PRINT((ndo, "\n\t  file \""));
    149  1.5  christos 		if (fn_print(ndo, bp->bp_file, ndo->ndo_snapend)) {
    150  1.5  christos 			ND_PRINT((ndo, "\""));
    151  1.5  christos 			ND_PRINT((ndo, "%s", tstr + 1));
    152  1.1  christos 			return;
    153  1.1  christos 		}
    154  1.5  christos 		ND_PRINT((ndo, "\""));
    155  1.1  christos 	}
    156  1.1  christos 
    157  1.1  christos 	/* Decode the vendor buffer */
    158  1.5  christos 	ND_TCHECK(bp->bp_vend[0]);
    159  1.1  christos 	if (memcmp((const char *)bp->bp_vend, vm_rfc1048,
    160  1.5  christos 		 sizeof(uint32_t)) == 0)
    161  1.5  christos 		rfc1048_print(ndo, bp->bp_vend);
    162  1.1  christos 	else if (memcmp((const char *)bp->bp_vend, vm_cmu,
    163  1.5  christos 		      sizeof(uint32_t)) == 0)
    164  1.5  christos 		cmu_print(ndo, bp->bp_vend);
    165  1.1  christos 	else {
    166  1.5  christos 		uint32_t ul;
    167  1.1  christos 
    168  1.1  christos 		ul = EXTRACT_32BITS(&bp->bp_vend);
    169  1.1  christos 		if (ul != 0)
    170  1.5  christos 			ND_PRINT((ndo, "\n\t  Vendor-#0x%x", ul));
    171  1.1  christos 	}
    172  1.1  christos 
    173  1.1  christos 	return;
    174  1.1  christos trunc:
    175  1.5  christos 	ND_PRINT((ndo, "%s", tstr));
    176  1.1  christos }
    177  1.1  christos 
    178  1.1  christos /*
    179  1.1  christos  * The first character specifies the format to print:
    180  1.1  christos  *     i - ip address (32 bits)
    181  1.1  christos  *     p - ip address pairs (32 bits + 32 bits)
    182  1.1  christos  *     l - long (32 bits)
    183  1.1  christos  *     L - unsigned long (32 bits)
    184  1.1  christos  *     s - short (16 bits)
    185  1.1  christos  *     b - period-seperated decimal bytes (variable length)
    186  1.1  christos  *     x - colon-seperated hex bytes (variable length)
    187  1.1  christos  *     a - ascii string (variable length)
    188  1.1  christos  *     B - on/off (8 bits)
    189  1.1  christos  *     $ - special (explicit code to handle)
    190  1.1  christos  */
    191  1.4  christos static const struct tok tag2str[] = {
    192  1.1  christos /* RFC1048 tags */
    193  1.1  christos 	{ TAG_PAD,		" PAD" },
    194  1.1  christos 	{ TAG_SUBNET_MASK,	"iSubnet-Mask" },	/* subnet mask (RFC950) */
    195  1.1  christos 	{ TAG_TIME_OFFSET,	"LTime-Zone" },	/* seconds from UTC */
    196  1.1  christos 	{ TAG_GATEWAY,		"iDefault-Gateway" },	/* default gateway */
    197  1.1  christos 	{ TAG_TIME_SERVER,	"iTime-Server" },	/* time servers (RFC868) */
    198  1.1  christos 	{ TAG_NAME_SERVER,	"iIEN-Name-Server" },	/* IEN name servers (IEN116) */
    199  1.1  christos 	{ TAG_DOMAIN_SERVER,	"iDomain-Name-Server" },	/* domain name (RFC1035) */
    200  1.1  christos 	{ TAG_LOG_SERVER,	"iLOG" },	/* MIT log servers */
    201  1.1  christos 	{ TAG_COOKIE_SERVER,	"iCS" },	/* cookie servers (RFC865) */
    202  1.1  christos 	{ TAG_LPR_SERVER,	"iLPR-Server" },	/* lpr server (RFC1179) */
    203  1.1  christos 	{ TAG_IMPRESS_SERVER,	"iIM" },	/* impress servers (Imagen) */
    204  1.1  christos 	{ TAG_RLP_SERVER,	"iRL" },	/* resource location (RFC887) */
    205  1.1  christos 	{ TAG_HOSTNAME,		"aHostname" },	/* ascii hostname */
    206  1.1  christos 	{ TAG_BOOTSIZE,		"sBS" },	/* 512 byte blocks */
    207  1.1  christos 	{ TAG_END,		" END" },
    208  1.1  christos /* RFC1497 tags */
    209  1.1  christos 	{ TAG_DUMPPATH,		"aDP" },
    210  1.1  christos 	{ TAG_DOMAINNAME,	"aDomain-Name" },
    211  1.1  christos 	{ TAG_SWAP_SERVER,	"iSS" },
    212  1.1  christos 	{ TAG_ROOTPATH,		"aRP" },
    213  1.1  christos 	{ TAG_EXTPATH,		"aEP" },
    214  1.1  christos /* RFC2132 tags */
    215  1.1  christos 	{ TAG_IP_FORWARD,	"BIPF" },
    216  1.1  christos 	{ TAG_NL_SRCRT,		"BSRT" },
    217  1.1  christos 	{ TAG_PFILTERS,		"pPF" },
    218  1.1  christos 	{ TAG_REASS_SIZE,	"sRSZ" },
    219  1.1  christos 	{ TAG_DEF_TTL,		"bTTL" },
    220  1.1  christos 	{ TAG_MTU_TIMEOUT,	"lMTU-Timeout" },
    221  1.1  christos 	{ TAG_MTU_TABLE,	"sMTU-Table" },
    222  1.1  christos 	{ TAG_INT_MTU,		"sMTU" },
    223  1.1  christos 	{ TAG_LOCAL_SUBNETS,	"BLSN" },
    224  1.1  christos 	{ TAG_BROAD_ADDR,	"iBR" },
    225  1.1  christos 	{ TAG_DO_MASK_DISC,	"BMD" },
    226  1.1  christos 	{ TAG_SUPPLY_MASK,	"BMS" },
    227  1.1  christos 	{ TAG_DO_RDISC,		"BRouter-Discovery" },
    228  1.1  christos 	{ TAG_RTR_SOL_ADDR,	"iRSA" },
    229  1.1  christos 	{ TAG_STATIC_ROUTE,	"pStatic-Route" },
    230  1.1  christos 	{ TAG_USE_TRAILERS,	"BUT" },
    231  1.1  christos 	{ TAG_ARP_TIMEOUT,	"lAT" },
    232  1.1  christos 	{ TAG_ETH_ENCAP,	"BIE" },
    233  1.1  christos 	{ TAG_TCP_TTL,		"bTT" },
    234  1.1  christos 	{ TAG_TCP_KEEPALIVE,	"lKI" },
    235  1.1  christos 	{ TAG_KEEPALIVE_GO,	"BKG" },
    236  1.1  christos 	{ TAG_NIS_DOMAIN,	"aYD" },
    237  1.1  christos 	{ TAG_NIS_SERVERS,	"iYS" },
    238  1.1  christos 	{ TAG_NTP_SERVERS,	"iNTP" },
    239  1.1  christos 	{ TAG_VENDOR_OPTS,	"bVendor-Option" },
    240  1.1  christos 	{ TAG_NETBIOS_NS,	"iNetbios-Name-Server" },
    241  1.1  christos 	{ TAG_NETBIOS_DDS,	"iWDD" },
    242  1.1  christos 	{ TAG_NETBIOS_NODE,	"$Netbios-Node" },
    243  1.1  christos 	{ TAG_NETBIOS_SCOPE,	"aNetbios-Scope" },
    244  1.1  christos 	{ TAG_XWIN_FS,		"iXFS" },
    245  1.1  christos 	{ TAG_XWIN_DM,		"iXDM" },
    246  1.1  christos 	{ TAG_NIS_P_DOMAIN,	"sN+D" },
    247  1.1  christos 	{ TAG_NIS_P_SERVERS,	"iN+S" },
    248  1.1  christos 	{ TAG_MOBILE_HOME,	"iMH" },
    249  1.1  christos 	{ TAG_SMPT_SERVER,	"iSMTP" },
    250  1.1  christos 	{ TAG_POP3_SERVER,	"iPOP3" },
    251  1.1  christos 	{ TAG_NNTP_SERVER,	"iNNTP" },
    252  1.1  christos 	{ TAG_WWW_SERVER,	"iWWW" },
    253  1.1  christos 	{ TAG_FINGER_SERVER,	"iFG" },
    254  1.1  christos 	{ TAG_IRC_SERVER,	"iIRC" },
    255  1.1  christos 	{ TAG_STREETTALK_SRVR,	"iSTS" },
    256  1.1  christos 	{ TAG_STREETTALK_STDA,	"iSTDA" },
    257  1.1  christos 	{ TAG_REQUESTED_IP,	"iRequested-IP" },
    258  1.1  christos 	{ TAG_IP_LEASE,		"lLease-Time" },
    259  1.1  christos 	{ TAG_OPT_OVERLOAD,	"$OO" },
    260  1.1  christos 	{ TAG_TFTP_SERVER,	"aTFTP" },
    261  1.1  christos 	{ TAG_BOOTFILENAME,	"aBF" },
    262  1.1  christos 	{ TAG_DHCP_MESSAGE,	" DHCP-Message" },
    263  1.1  christos 	{ TAG_SERVER_ID,	"iServer-ID" },
    264  1.1  christos 	{ TAG_PARM_REQUEST,	"bParameter-Request" },
    265  1.1  christos 	{ TAG_MESSAGE,		"aMSG" },
    266  1.1  christos 	{ TAG_MAX_MSG_SIZE,	"sMSZ" },
    267  1.1  christos 	{ TAG_RENEWAL_TIME,	"lRN" },
    268  1.1  christos 	{ TAG_REBIND_TIME,	"lRB" },
    269  1.1  christos 	{ TAG_VENDOR_CLASS,	"aVendor-Class" },
    270  1.1  christos 	{ TAG_CLIENT_ID,	"$Client-ID" },
    271  1.1  christos /* RFC 2485 */
    272  1.1  christos 	{ TAG_OPEN_GROUP_UAP,	"aUAP" },
    273  1.1  christos /* RFC 2563 */
    274  1.1  christos 	{ TAG_DISABLE_AUTOCONF,	"BNOAUTO" },
    275  1.1  christos /* RFC 2610 */
    276  1.1  christos 	{ TAG_SLP_DA,		"bSLP-DA" },	/*"b" is a little wrong */
    277  1.1  christos 	{ TAG_SLP_SCOPE,	"bSLP-SCOPE" },	/*"b" is a little wrong */
    278  1.1  christos /* RFC 2937 */
    279  1.1  christos 	{ TAG_NS_SEARCH,	"sNSSEARCH" },	/* XXX 's' */
    280  1.1  christos /* RFC 3011 */
    281  1.1  christos 	{ TAG_IP4_SUBNET_SELECT, "iSUBNET" },
    282  1.1  christos /* RFC 3442 */
    283  1.1  christos 	{ TAG_CLASSLESS_STATIC_RT, "$Classless-Static-Route" },
    284  1.1  christos 	{ TAG_CLASSLESS_STA_RT_MS, "$Classless-Static-Route-Microsoft" },
    285  1.1  christos /* http://www.iana.org/assignments/bootp-dhcp-extensions/index.htm */
    286  1.1  christos 	{ TAG_USER_CLASS,	"aCLASS" },
    287  1.1  christos 	{ TAG_SLP_NAMING_AUTH,	"aSLP-NA" },
    288  1.1  christos 	{ TAG_CLIENT_FQDN,	"$FQDN" },
    289  1.1  christos 	{ TAG_AGENT_CIRCUIT,	"$Agent-Information" },
    290  1.1  christos 	{ TAG_AGENT_REMOTE,	"bARMT" },
    291  1.1  christos 	{ TAG_AGENT_MASK,	"bAMSK" },
    292  1.1  christos 	{ TAG_TZ_STRING,	"aTZSTR" },
    293  1.1  christos 	{ TAG_FQDN_OPTION,	"bFQDNS" },	/* XXX 'b' */
    294  1.1  christos 	{ TAG_AUTH,		"bAUTH" },	/* XXX 'b' */
    295  1.1  christos 	{ TAG_VINES_SERVERS,	"iVINES" },
    296  1.1  christos 	{ TAG_SERVER_RANK,	"sRANK" },
    297  1.1  christos 	{ TAG_CLIENT_ARCH,	"sARCH" },
    298  1.1  christos 	{ TAG_CLIENT_NDI,	"bNDI" },	/* XXX 'b' */
    299  1.1  christos 	{ TAG_CLIENT_GUID,	"bGUID" },	/* XXX 'b' */
    300  1.1  christos 	{ TAG_LDAP_URL,		"aLDAP" },
    301  1.1  christos 	{ TAG_6OVER4,		"i6o4" },
    302  1.1  christos 	{ TAG_PRINTER_NAME,	"aPRTR" },
    303  1.1  christos 	{ TAG_MDHCP_SERVER,	"bMDHCP" },	/* XXX 'b' */
    304  1.1  christos 	{ TAG_IPX_COMPAT,	"bIPX" },	/* XXX 'b' */
    305  1.1  christos 	{ TAG_NETINFO_PARENT,	"iNI" },
    306  1.1  christos 	{ TAG_NETINFO_PARENT_TAG, "aNITAG" },
    307  1.1  christos 	{ TAG_URL,		"aURL" },
    308  1.1  christos 	{ TAG_FAILOVER,		"bFAIL" },	/* XXX 'b' */
    309  1.1  christos 	{ 0,			NULL }
    310  1.1  christos };
    311  1.1  christos /* 2-byte extended tags */
    312  1.4  christos static const struct tok xtag2str[] = {
    313  1.1  christos 	{ 0,			NULL }
    314  1.1  christos };
    315  1.1  christos 
    316  1.1  christos /* DHCP "options overload" types */
    317  1.4  christos static const struct tok oo2str[] = {
    318  1.1  christos 	{ 1,			"file" },
    319  1.1  christos 	{ 2,			"sname" },
    320  1.1  christos 	{ 3,			"file+sname" },
    321  1.1  christos 	{ 0,			NULL }
    322  1.1  christos };
    323  1.1  christos 
    324  1.1  christos /* NETBIOS over TCP/IP node type options */
    325  1.4  christos static const struct tok nbo2str[] = {
    326  1.1  christos 	{ 0x1,			"b-node" },
    327  1.1  christos 	{ 0x2,			"p-node" },
    328  1.1  christos 	{ 0x4,			"m-node" },
    329  1.1  christos 	{ 0x8,			"h-node" },
    330  1.1  christos 	{ 0,			NULL }
    331  1.1  christos };
    332  1.1  christos 
    333  1.1  christos /* ARP Hardware types, for Client-ID option */
    334  1.4  christos static const struct tok arp2str[] = {
    335  1.1  christos 	{ 0x1,			"ether" },
    336  1.1  christos 	{ 0x6,			"ieee802" },
    337  1.1  christos 	{ 0x7,			"arcnet" },
    338  1.1  christos 	{ 0xf,			"frelay" },
    339  1.1  christos 	{ 0x17,			"strip" },
    340  1.1  christos 	{ 0x18,			"ieee1394" },
    341  1.1  christos 	{ 0,			NULL }
    342  1.1  christos };
    343  1.1  christos 
    344  1.4  christos static const struct tok dhcp_msg_values[] = {
    345  1.1  christos         { DHCPDISCOVER, "Discover" },
    346  1.1  christos         { DHCPOFFER, "Offer" },
    347  1.1  christos         { DHCPREQUEST, "Request" },
    348  1.1  christos         { DHCPDECLINE, "Decline" },
    349  1.1  christos         { DHCPACK, "ACK" },
    350  1.1  christos         { DHCPNAK, "NACK" },
    351  1.1  christos         { DHCPRELEASE, "Release" },
    352  1.1  christos         { DHCPINFORM, "Inform" },
    353  1.1  christos         { 0,			NULL }
    354  1.1  christos };
    355  1.1  christos 
    356  1.1  christos #define AGENT_SUBOPTION_CIRCUIT_ID 	1	/* RFC 3046 */
    357  1.1  christos #define AGENT_SUBOPTION_REMOTE_ID  	2	/* RFC 3046 */
    358  1.1  christos #define AGENT_SUBOPTION_SUBSCRIBER_ID 	6	/* RFC 3993 */
    359  1.4  christos static const struct tok agent_suboption_values[] = {
    360  1.1  christos         { AGENT_SUBOPTION_CIRCUIT_ID, "Circuit-ID" },
    361  1.1  christos         { AGENT_SUBOPTION_REMOTE_ID, "Remote-ID" },
    362  1.1  christos         { AGENT_SUBOPTION_SUBSCRIBER_ID, "Subscriber-ID" },
    363  1.1  christos         { 0,			NULL }
    364  1.1  christos };
    365  1.1  christos 
    366  1.1  christos 
    367  1.1  christos static void
    368  1.5  christos rfc1048_print(netdissect_options *ndo,
    369  1.5  christos               register const u_char *bp)
    370  1.1  christos {
    371  1.5  christos 	register uint16_t tag;
    372  1.1  christos 	register u_int len;
    373  1.1  christos 	register const char *cp;
    374  1.1  christos 	register char c;
    375  1.1  christos 	int first, idx;
    376  1.5  christos 	uint32_t ul;
    377  1.5  christos 	uint16_t us;
    378  1.5  christos 	uint8_t uc, subopt, suboptlen;
    379  1.1  christos 
    380  1.5  christos 	ND_PRINT((ndo, "\n\t  Vendor-rfc1048 Extensions"));
    381  1.1  christos 
    382  1.1  christos 	/* Step over magic cookie */
    383  1.5  christos 	ND_PRINT((ndo, "\n\t    Magic Cookie 0x%08x", EXTRACT_32BITS(bp)));
    384  1.1  christos 	bp += sizeof(int32_t);
    385  1.1  christos 
    386  1.1  christos 	/* Loop while we there is a tag left in the buffer */
    387  1.5  christos 	while (ND_TTEST2(*bp, 1)) {
    388  1.1  christos 		tag = *bp++;
    389  1.5  christos 		if (tag == TAG_PAD && ndo->ndo_vflag < 3)
    390  1.1  christos 			continue;
    391  1.5  christos 		if (tag == TAG_END && ndo->ndo_vflag < 3)
    392  1.1  christos 			return;
    393  1.1  christos 		if (tag == TAG_EXTENDED_OPTION) {
    394  1.5  christos 			ND_TCHECK2(*(bp + 1), 2);
    395  1.1  christos 			tag = EXTRACT_16BITS(bp + 1);
    396  1.1  christos 			/* XXX we don't know yet if the IANA will
    397  1.1  christos 			 * preclude overlap of 1-byte and 2-byte spaces.
    398  1.1  christos 			 * If not, we need to offset tag after this step.
    399  1.1  christos 			 */
    400  1.1  christos 			cp = tok2str(xtag2str, "?xT%u", tag);
    401  1.1  christos 		} else
    402  1.1  christos 			cp = tok2str(tag2str, "?T%u", tag);
    403  1.1  christos 		c = *cp++;
    404  1.1  christos 
    405  1.1  christos 		if (tag == TAG_PAD || tag == TAG_END)
    406  1.1  christos 			len = 0;
    407  1.1  christos 		else {
    408  1.1  christos 			/* Get the length; check for truncation */
    409  1.5  christos 			ND_TCHECK2(*bp, 1);
    410  1.1  christos 			len = *bp++;
    411  1.1  christos 		}
    412  1.1  christos 
    413  1.5  christos 		ND_PRINT((ndo, "\n\t    %s Option %u, length %u%s", cp, tag, len,
    414  1.5  christos 		    len > 0 ? ": " : ""));
    415  1.1  christos 
    416  1.5  christos 		if (tag == TAG_PAD && ndo->ndo_vflag > 2) {
    417  1.1  christos 			u_int ntag = 1;
    418  1.5  christos 			while (ND_TTEST2(*bp, 1) && *bp == TAG_PAD) {
    419  1.1  christos 				bp++;
    420  1.1  christos 				ntag++;
    421  1.1  christos 			}
    422  1.1  christos 			if (ntag > 1)
    423  1.5  christos 				ND_PRINT((ndo, ", occurs %u", ntag));
    424  1.1  christos 		}
    425  1.1  christos 
    426  1.5  christos 		if (!ND_TTEST2(*bp, len)) {
    427  1.5  christos 			ND_PRINT((ndo, "[|rfc1048 %u]", len));
    428  1.1  christos 			return;
    429  1.1  christos 		}
    430  1.1  christos 
    431  1.1  christos 		if (tag == TAG_DHCP_MESSAGE && len == 1) {
    432  1.1  christos 			uc = *bp++;
    433  1.5  christos 			ND_PRINT((ndo, "%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc)));
    434  1.5  christos 			continue;
    435  1.1  christos 		}
    436  1.1  christos 
    437  1.1  christos 		if (tag == TAG_PARM_REQUEST) {
    438  1.1  christos 			idx = 0;
    439  1.1  christos 			while (len-- > 0) {
    440  1.1  christos 				uc = *bp++;
    441  1.1  christos 				cp = tok2str(tag2str, "?Option %u", uc);
    442  1.1  christos 				if (idx % 4 == 0)
    443  1.5  christos 					ND_PRINT((ndo, "\n\t      "));
    444  1.1  christos 				else
    445  1.5  christos 					ND_PRINT((ndo, ", "));
    446  1.5  christos 				ND_PRINT((ndo, "%s", cp + 1));
    447  1.1  christos 				idx++;
    448  1.1  christos 			}
    449  1.1  christos 			continue;
    450  1.1  christos 		}
    451  1.1  christos 
    452  1.1  christos 		if (tag == TAG_EXTENDED_REQUEST) {
    453  1.1  christos 			first = 1;
    454  1.1  christos 			while (len > 1) {
    455  1.1  christos 				len -= 2;
    456  1.1  christos 				us = EXTRACT_16BITS(bp);
    457  1.1  christos 				bp += 2;
    458  1.1  christos 				cp = tok2str(xtag2str, "?xT%u", us);
    459  1.1  christos 				if (!first)
    460  1.5  christos 					ND_PRINT((ndo, "+"));
    461  1.5  christos 				ND_PRINT((ndo, "%s", cp + 1));
    462  1.1  christos 				first = 0;
    463  1.1  christos 			}
    464  1.1  christos 			continue;
    465  1.1  christos 		}
    466  1.1  christos 
    467  1.1  christos 		/* Print data */
    468  1.1  christos 		if (c == '?') {
    469  1.1  christos 			/* Base default formats for unknown tags on data size */
    470  1.1  christos 			if (len & 1)
    471  1.1  christos 				c = 'b';
    472  1.1  christos 			else if (len & 2)
    473  1.1  christos 				c = 's';
    474  1.1  christos 			else
    475  1.1  christos 				c = 'l';
    476  1.1  christos 		}
    477  1.1  christos 		first = 1;
    478  1.1  christos 		switch (c) {
    479  1.1  christos 
    480  1.1  christos 		case 'a':
    481  1.1  christos 			/* ascii strings */
    482  1.5  christos 			ND_PRINT((ndo, "\""));
    483  1.5  christos 			if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) {
    484  1.5  christos 				ND_PRINT((ndo, "\""));
    485  1.1  christos 				goto trunc;
    486  1.1  christos 			}
    487  1.5  christos 			ND_PRINT((ndo, "\""));
    488  1.1  christos 			bp += len;
    489  1.1  christos 			len = 0;
    490  1.1  christos 			break;
    491  1.1  christos 
    492  1.1  christos 		case 'i':
    493  1.1  christos 		case 'l':
    494  1.1  christos 		case 'L':
    495  1.1  christos 			/* ip addresses/32-bit words */
    496  1.1  christos 			while (len >= sizeof(ul)) {
    497  1.1  christos 				if (!first)
    498  1.5  christos 					ND_PRINT((ndo, ","));
    499  1.1  christos 				ul = EXTRACT_32BITS(bp);
    500  1.1  christos 				if (c == 'i') {
    501  1.1  christos 					ul = htonl(ul);
    502  1.5  christos 					ND_PRINT((ndo, "%s", ipaddr_string(ndo, &ul)));
    503  1.1  christos 				} else if (c == 'L')
    504  1.5  christos 					ND_PRINT((ndo, "%d", ul));
    505  1.1  christos 				else
    506  1.5  christos 					ND_PRINT((ndo, "%u", ul));
    507  1.1  christos 				bp += sizeof(ul);
    508  1.1  christos 				len -= sizeof(ul);
    509  1.1  christos 				first = 0;
    510  1.1  christos 			}
    511  1.1  christos 			break;
    512  1.1  christos 
    513  1.1  christos 		case 'p':
    514  1.1  christos 			/* IP address pairs */
    515  1.1  christos 			while (len >= 2*sizeof(ul)) {
    516  1.1  christos 				if (!first)
    517  1.5  christos 					ND_PRINT((ndo, ","));
    518  1.1  christos 				memcpy((char *)&ul, (const char *)bp, sizeof(ul));
    519  1.5  christos 				ND_PRINT((ndo, "(%s:", ipaddr_string(ndo, &ul)));
    520  1.1  christos 				bp += sizeof(ul);
    521  1.1  christos 				memcpy((char *)&ul, (const char *)bp, sizeof(ul));
    522  1.5  christos 				ND_PRINT((ndo, "%s)", ipaddr_string(ndo, &ul)));
    523  1.1  christos 				bp += sizeof(ul);
    524  1.1  christos 				len -= 2*sizeof(ul);
    525  1.1  christos 				first = 0;
    526  1.1  christos 			}
    527  1.1  christos 			break;
    528  1.1  christos 
    529  1.1  christos 		case 's':
    530  1.1  christos 			/* shorts */
    531  1.1  christos 			while (len >= sizeof(us)) {
    532  1.1  christos 				if (!first)
    533  1.5  christos 					ND_PRINT((ndo, ","));
    534  1.1  christos 				us = EXTRACT_16BITS(bp);
    535  1.5  christos 				ND_PRINT((ndo, "%u", us));
    536  1.1  christos 				bp += sizeof(us);
    537  1.1  christos 				len -= sizeof(us);
    538  1.1  christos 				first = 0;
    539  1.1  christos 			}
    540  1.1  christos 			break;
    541  1.1  christos 
    542  1.1  christos 		case 'B':
    543  1.1  christos 			/* boolean */
    544  1.1  christos 			while (len > 0) {
    545  1.1  christos 				if (!first)
    546  1.5  christos 					ND_PRINT((ndo, ","));
    547  1.1  christos 				switch (*bp) {
    548  1.1  christos 				case 0:
    549  1.5  christos 					ND_PRINT((ndo, "N"));
    550  1.1  christos 					break;
    551  1.1  christos 				case 1:
    552  1.5  christos 					ND_PRINT((ndo, "Y"));
    553  1.1  christos 					break;
    554  1.1  christos 				default:
    555  1.5  christos 					ND_PRINT((ndo, "%u?", *bp));
    556  1.1  christos 					break;
    557  1.1  christos 				}
    558  1.1  christos 				++bp;
    559  1.1  christos 				--len;
    560  1.1  christos 				first = 0;
    561  1.1  christos 			}
    562  1.1  christos 			break;
    563  1.1  christos 
    564  1.1  christos 		case 'b':
    565  1.1  christos 		case 'x':
    566  1.1  christos 		default:
    567  1.1  christos 			/* Bytes */
    568  1.1  christos 			while (len > 0) {
    569  1.1  christos 				if (!first)
    570  1.5  christos 					ND_PRINT((ndo, c == 'x' ? ":" : "."));
    571  1.1  christos 				if (c == 'x')
    572  1.5  christos 					ND_PRINT((ndo, "%02x", *bp));
    573  1.1  christos 				else
    574  1.5  christos 					ND_PRINT((ndo, "%u", *bp));
    575  1.1  christos 				++bp;
    576  1.1  christos 				--len;
    577  1.1  christos 				first = 0;
    578  1.1  christos 			}
    579  1.1  christos 			break;
    580  1.1  christos 
    581  1.1  christos 		case '$':
    582  1.1  christos 			/* Guys we can't handle with one of the usual cases */
    583  1.1  christos 			switch (tag) {
    584  1.1  christos 
    585  1.1  christos 			case TAG_NETBIOS_NODE:
    586  1.1  christos 				/* this option should be at least 1 byte long */
    587  1.1  christos 				if (len < 1)  {
    588  1.5  christos 					ND_PRINT((ndo, "ERROR: option %u len %u < 1 bytes",
    589  1.5  christos 					    TAG_NETBIOS_NODE, len));
    590  1.1  christos 					break;
    591  1.1  christos 				}
    592  1.1  christos 				tag = *bp++;
    593  1.1  christos 				--len;
    594  1.5  christos 				ND_PRINT((ndo, "%s", tok2str(nbo2str, NULL, tag)));
    595  1.1  christos 				break;
    596  1.1  christos 
    597  1.1  christos 			case TAG_OPT_OVERLOAD:
    598  1.1  christos 				/* this option should be at least 1 byte long */
    599  1.1  christos 				if (len < 1)  {
    600  1.5  christos 					ND_PRINT((ndo, "ERROR: option %u len %u < 1 bytes",
    601  1.5  christos 					    TAG_OPT_OVERLOAD, len));
    602  1.1  christos 					break;
    603  1.1  christos 				}
    604  1.1  christos 				tag = *bp++;
    605  1.1  christos 				--len;
    606  1.5  christos 				ND_PRINT((ndo, "%s", tok2str(oo2str, NULL, tag)));
    607  1.1  christos 				break;
    608  1.1  christos 
    609  1.1  christos 			case TAG_CLIENT_FQDN:
    610  1.1  christos 				/* this option should be at least 3 bytes long */
    611  1.1  christos 				if (len < 3)  {
    612  1.5  christos 					ND_PRINT((ndo, "ERROR: option %u len %u < 3 bytes",
    613  1.5  christos 					    TAG_CLIENT_FQDN, len));
    614  1.1  christos 					bp += len;
    615  1.1  christos 					len = 0;
    616  1.1  christos 					break;
    617  1.1  christos 				}
    618  1.1  christos 				if (*bp)
    619  1.5  christos 					ND_PRINT((ndo, "[%s] ", client_fqdn_flags(*bp)));
    620  1.1  christos 				bp++;
    621  1.1  christos 				if (*bp || *(bp+1))
    622  1.5  christos 					ND_PRINT((ndo, "%u/%u ", *bp, *(bp+1)));
    623  1.1  christos 				bp += 2;
    624  1.5  christos 				ND_PRINT((ndo, "\""));
    625  1.5  christos 				if (fn_printn(ndo, bp, len - 3, ndo->ndo_snapend)) {
    626  1.5  christos 					ND_PRINT((ndo, "\""));
    627  1.1  christos 					goto trunc;
    628  1.1  christos 				}
    629  1.5  christos 				ND_PRINT((ndo, "\""));
    630  1.1  christos 				bp += len - 3;
    631  1.1  christos 				len = 0;
    632  1.1  christos 				break;
    633  1.1  christos 
    634  1.1  christos 			case TAG_CLIENT_ID:
    635  1.1  christos 			    {	int type;
    636  1.1  christos 
    637  1.1  christos 				/* this option should be at least 1 byte long */
    638  1.1  christos 				if (len < 1)  {
    639  1.5  christos 					ND_PRINT((ndo, "ERROR: option %u len %u < 1 bytes",
    640  1.5  christos 					    TAG_CLIENT_ID, len));
    641  1.1  christos 					break;
    642  1.1  christos 				}
    643  1.1  christos 				type = *bp++;
    644  1.1  christos 				len--;
    645  1.1  christos 				if (type == 0) {
    646  1.5  christos 					ND_PRINT((ndo, "\""));
    647  1.5  christos 					if (fn_printn(ndo, bp, len, ndo->ndo_snapend)) {
    648  1.5  christos 						ND_PRINT((ndo, "\""));
    649  1.1  christos 						goto trunc;
    650  1.1  christos 					}
    651  1.5  christos 					ND_PRINT((ndo, "\""));
    652  1.1  christos 					bp += len;
    653  1.1  christos 					len = 0;
    654  1.1  christos 					break;
    655  1.1  christos 				} else {
    656  1.5  christos 					ND_PRINT((ndo, "%s ", tok2str(arp2str, "hardware-type %u,", type)));
    657  1.1  christos 					while (len > 0) {
    658  1.1  christos 						if (!first)
    659  1.5  christos 							ND_PRINT((ndo, ":"));
    660  1.5  christos 						ND_PRINT((ndo, "%02x", *bp));
    661  1.1  christos 						++bp;
    662  1.1  christos 						--len;
    663  1.1  christos 						first = 0;
    664  1.1  christos 					}
    665  1.1  christos 				}
    666  1.1  christos 				break;
    667  1.1  christos 			    }
    668  1.1  christos 
    669  1.1  christos 			case TAG_AGENT_CIRCUIT:
    670  1.1  christos 				while (len >= 2) {
    671  1.1  christos 					subopt = *bp++;
    672  1.1  christos 					suboptlen = *bp++;
    673  1.1  christos 					len -= 2;
    674  1.1  christos 					if (suboptlen > len) {
    675  1.5  christos 						ND_PRINT((ndo, "\n\t      %s SubOption %u, length %u: length goes past end of option",
    676  1.1  christos 						   tok2str(agent_suboption_values, "Unknown", subopt),
    677  1.1  christos 						   subopt,
    678  1.5  christos 						   suboptlen));
    679  1.1  christos 						bp += len;
    680  1.1  christos 						len = 0;
    681  1.1  christos 						break;
    682  1.1  christos 					}
    683  1.5  christos 					ND_PRINT((ndo, "\n\t      %s SubOption %u, length %u: ",
    684  1.1  christos 					   tok2str(agent_suboption_values, "Unknown", subopt),
    685  1.1  christos 					   subopt,
    686  1.5  christos 					   suboptlen));
    687  1.1  christos 					switch (subopt) {
    688  1.1  christos 
    689  1.5  christos 					case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */
    690  1.5  christos 					case AGENT_SUBOPTION_REMOTE_ID:
    691  1.5  christos 					case AGENT_SUBOPTION_SUBSCRIBER_ID:
    692  1.5  christos 						fn_printn(ndo, bp, suboptlen, NULL);
    693  1.5  christos 						break;
    694  1.1  christos 
    695  1.1  christos 					default:
    696  1.5  christos 						print_unknown_data(ndo, bp, "\n\t\t", suboptlen);
    697  1.1  christos 					}
    698  1.1  christos 
    699  1.1  christos 					len -= suboptlen;
    700  1.1  christos 					bp += suboptlen;
    701  1.1  christos 			    }
    702  1.1  christos 			    break;
    703  1.1  christos 
    704  1.1  christos 			case TAG_CLASSLESS_STATIC_RT:
    705  1.1  christos 			case TAG_CLASSLESS_STA_RT_MS:
    706  1.5  christos 			{
    707  1.1  christos 				u_int mask_width, significant_octets, i;
    708  1.1  christos 
    709  1.1  christos 				/* this option should be at least 5 bytes long */
    710  1.1  christos 				if (len < 5)  {
    711  1.5  christos 					ND_PRINT((ndo, "ERROR: option %u len %u < 5 bytes",
    712  1.5  christos 					    TAG_CLASSLESS_STATIC_RT, len));
    713  1.1  christos 					bp += len;
    714  1.1  christos 					len = 0;
    715  1.1  christos 					break;
    716  1.1  christos 				}
    717  1.1  christos 				while (len > 0) {
    718  1.1  christos 					if (!first)
    719  1.5  christos 						ND_PRINT((ndo, ","));
    720  1.1  christos 					mask_width = *bp++;
    721  1.1  christos 					len--;
    722  1.1  christos 					/* mask_width <= 32 */
    723  1.1  christos 					if (mask_width > 32) {
    724  1.5  christos 						ND_PRINT((ndo, "[ERROR: Mask width (%d) > 32]",  mask_width));
    725  1.1  christos 						bp += len;
    726  1.1  christos 						len = 0;
    727  1.1  christos 						break;
    728  1.1  christos 					}
    729  1.1  christos 					significant_octets = (mask_width + 7) / 8;
    730  1.1  christos 					/* significant octets + router(4) */
    731  1.1  christos 					if (len < significant_octets + 4) {
    732  1.5  christos 						ND_PRINT((ndo, "[ERROR: Remaining length (%u) < %u bytes]",  len, significant_octets + 4));
    733  1.1  christos 						bp += len;
    734  1.1  christos 						len = 0;
    735  1.1  christos 						break;
    736  1.1  christos 					}
    737  1.5  christos 					ND_PRINT((ndo, "("));
    738  1.1  christos 					if (mask_width == 0)
    739  1.5  christos 						ND_PRINT((ndo, "default"));
    740  1.1  christos 					else {
    741  1.1  christos 						for (i = 0; i < significant_octets ; i++) {
    742  1.1  christos 							if (i > 0)
    743  1.5  christos 								ND_PRINT((ndo, "."));
    744  1.5  christos 							ND_PRINT((ndo, "%d", *bp++));
    745  1.1  christos 						}
    746  1.1  christos 						for (i = significant_octets ; i < 4 ; i++)
    747  1.5  christos 							ND_PRINT((ndo, ".0"));
    748  1.5  christos 						ND_PRINT((ndo, "/%d", mask_width));
    749  1.1  christos 					}
    750  1.1  christos 					memcpy((char *)&ul, (const char *)bp, sizeof(ul));
    751  1.5  christos 					ND_PRINT((ndo, ":%s)", ipaddr_string(ndo, &ul)));
    752  1.1  christos 					bp += sizeof(ul);
    753  1.1  christos 					len -= (significant_octets + 4);
    754  1.1  christos 					first = 0;
    755  1.1  christos 				}
    756  1.1  christos 			}
    757  1.1  christos 			break;
    758  1.1  christos 
    759  1.1  christos 			default:
    760  1.5  christos 				ND_PRINT((ndo, "[unknown special tag %u, size %u]",
    761  1.5  christos 				    tag, len));
    762  1.1  christos 				bp += len;
    763  1.1  christos 				len = 0;
    764  1.1  christos 				break;
    765  1.1  christos 			}
    766  1.1  christos 			break;
    767  1.1  christos 		}
    768  1.1  christos 		/* Data left over? */
    769  1.1  christos 		if (len) {
    770  1.5  christos 			ND_PRINT((ndo, "\n\t  trailing data length %u", len));
    771  1.1  christos 			bp += len;
    772  1.1  christos 		}
    773  1.1  christos 	}
    774  1.1  christos 	return;
    775  1.1  christos trunc:
    776  1.5  christos 	ND_PRINT((ndo, "|[rfc1048]"));
    777  1.1  christos }
    778  1.1  christos 
    779  1.1  christos static void
    780  1.5  christos cmu_print(netdissect_options *ndo,
    781  1.5  christos           register const u_char *bp)
    782  1.1  christos {
    783  1.1  christos 	register const struct cmu_vend *cmu;
    784  1.1  christos 
    785  1.5  christos #define PRINTCMUADDR(m, s) { ND_TCHECK(cmu->m); \
    786  1.1  christos     if (cmu->m.s_addr != 0) \
    787  1.5  christos 	ND_PRINT((ndo, " %s:%s", s, ipaddr_string(ndo, &cmu->m.s_addr))); }
    788  1.1  christos 
    789  1.5  christos 	ND_PRINT((ndo, " vend-cmu"));
    790  1.1  christos 	cmu = (const struct cmu_vend *)bp;
    791  1.1  christos 
    792  1.1  christos 	/* Only print if there are unknown bits */
    793  1.5  christos 	ND_TCHECK(cmu->v_flags);
    794  1.1  christos 	if ((cmu->v_flags & ~(VF_SMASK)) != 0)
    795  1.5  christos 		ND_PRINT((ndo, " F:0x%x", cmu->v_flags));
    796  1.1  christos 	PRINTCMUADDR(v_dgate, "DG");
    797  1.1  christos 	PRINTCMUADDR(v_smask, cmu->v_flags & VF_SMASK ? "SM" : "SM*");
    798  1.1  christos 	PRINTCMUADDR(v_dns1, "NS1");
    799  1.1  christos 	PRINTCMUADDR(v_dns2, "NS2");
    800  1.1  christos 	PRINTCMUADDR(v_ins1, "IEN1");
    801  1.1  christos 	PRINTCMUADDR(v_ins2, "IEN2");
    802  1.1  christos 	PRINTCMUADDR(v_ts1, "TS1");
    803  1.1  christos 	PRINTCMUADDR(v_ts2, "TS2");
    804  1.1  christos 	return;
    805  1.1  christos 
    806  1.1  christos trunc:
    807  1.5  christos 	ND_PRINT((ndo, "%s", tstr));
    808  1.1  christos #undef PRINTCMUADDR
    809  1.1  christos }
    810  1.1  christos 
    811  1.1  christos static char *
    812  1.1  christos client_fqdn_flags(u_int flags)
    813  1.1  christos {
    814  1.1  christos 	static char buf[8+1];
    815  1.1  christos 	int i = 0;
    816  1.1  christos 
    817  1.1  christos 	if (flags & CLIENT_FQDN_FLAGS_S)
    818  1.1  christos 		buf[i++] = 'S';
    819  1.1  christos 	if (flags & CLIENT_FQDN_FLAGS_O)
    820  1.1  christos 		buf[i++] = 'O';
    821  1.1  christos 	if (flags & CLIENT_FQDN_FLAGS_E)
    822  1.1  christos 		buf[i++] = 'E';
    823  1.1  christos 	if (flags & CLIENT_FQDN_FLAGS_N)
    824  1.1  christos 		buf[i++] = 'N';
    825  1.1  christos 	buf[i] = '\0';
    826  1.1  christos 
    827  1.1  christos 	return buf;
    828  1.1  christos }
    829