14edb46e9SPaul Traina /* 2699fc314SBill Fenner * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997 34edb46e9SPaul Traina * The Regents of the University of California. All rights reserved. 44edb46e9SPaul Traina * 54edb46e9SPaul Traina * Redistribution and use in source and binary forms, with or without 64edb46e9SPaul Traina * modification, are permitted provided that: (1) source code distributions 74edb46e9SPaul Traina * retain the above copyright notice and this paragraph in its entirety, (2) 84edb46e9SPaul Traina * distributions including binary code include the above copyright notice and 94edb46e9SPaul Traina * this paragraph in its entirety in the documentation or other materials 104edb46e9SPaul Traina * provided with the distribution, and (3) all advertising materials mentioning 114edb46e9SPaul Traina * features or use of this software display the following acknowledgement: 124edb46e9SPaul Traina * ``This product includes software developed by the University of California, 134edb46e9SPaul Traina * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 144edb46e9SPaul Traina * the University nor the names of its contributors may be used to endorse 154edb46e9SPaul Traina * or promote products derived from this software without specific prior 164edb46e9SPaul Traina * written permission. 174edb46e9SPaul Traina * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 184edb46e9SPaul Traina * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 194edb46e9SPaul Traina * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 204edb46e9SPaul Traina */ 21a88113a8SBill Fenner 223340d773SGleb Smirnoff /* \summary: BOOTP and IPv4 DHCP printer */ 233340d773SGleb Smirnoff 24a88113a8SBill Fenner #ifdef HAVE_CONFIG_H 25*ee67461eSJoseph Mingrone #include <config.h> 264edb46e9SPaul Traina #endif 274edb46e9SPaul Traina 28*ee67461eSJoseph Mingrone #include "netdissect-stdinc.h" 294edb46e9SPaul Traina 304edb46e9SPaul Traina #include <string.h> 314edb46e9SPaul Traina 323340d773SGleb Smirnoff #include "netdissect.h" 334edb46e9SPaul Traina #include "addrtoname.h" 34943ee2b1SBill Fenner #include "extract.h" 354edb46e9SPaul Traina 364edb46e9SPaul Traina 378bdc5a62SPatrick Kelsey /* 388bdc5a62SPatrick Kelsey * Bootstrap Protocol (BOOTP). RFC951 and RFC1048. 398bdc5a62SPatrick Kelsey * 408bdc5a62SPatrick Kelsey * This file specifies the "implementation-independent" BOOTP protocol 418bdc5a62SPatrick Kelsey * information which is common to both client and server. 428bdc5a62SPatrick Kelsey * 438bdc5a62SPatrick Kelsey * Copyright 1988 by Carnegie Mellon. 448bdc5a62SPatrick Kelsey * 458bdc5a62SPatrick Kelsey * Permission to use, copy, modify, and distribute this program for any 468bdc5a62SPatrick Kelsey * purpose and without fee is hereby granted, provided that this copyright 478bdc5a62SPatrick Kelsey * and permission notice appear on all copies and supporting documentation, 488bdc5a62SPatrick Kelsey * the name of Carnegie Mellon not be used in advertising or publicity 498bdc5a62SPatrick Kelsey * pertaining to distribution of the program without specific prior 508bdc5a62SPatrick Kelsey * permission, and notice be given in supporting documentation that copying 518bdc5a62SPatrick Kelsey * and distribution is by permission of Carnegie Mellon and Stanford 528bdc5a62SPatrick Kelsey * University. Carnegie Mellon makes no representations about the 538bdc5a62SPatrick Kelsey * suitability of this software for any purpose. It is provided "as is" 548bdc5a62SPatrick Kelsey * without express or implied warranty. 558bdc5a62SPatrick Kelsey */ 568bdc5a62SPatrick Kelsey 578bdc5a62SPatrick Kelsey struct bootp { 58*ee67461eSJoseph Mingrone nd_uint8_t bp_op; /* packet opcode type */ 59*ee67461eSJoseph Mingrone nd_uint8_t bp_htype; /* hardware addr type */ 60*ee67461eSJoseph Mingrone nd_uint8_t bp_hlen; /* hardware addr length */ 61*ee67461eSJoseph Mingrone nd_uint8_t bp_hops; /* gateway hops */ 62*ee67461eSJoseph Mingrone nd_uint32_t bp_xid; /* transaction ID */ 63*ee67461eSJoseph Mingrone nd_uint16_t bp_secs; /* seconds since boot began */ 64*ee67461eSJoseph Mingrone nd_uint16_t bp_flags; /* flags - see bootp_flag_values[] 658bdc5a62SPatrick Kelsey in print-bootp.c */ 66*ee67461eSJoseph Mingrone nd_ipv4 bp_ciaddr; /* client IP address */ 67*ee67461eSJoseph Mingrone nd_ipv4 bp_yiaddr; /* 'your' IP address */ 68*ee67461eSJoseph Mingrone nd_ipv4 bp_siaddr; /* server IP address */ 69*ee67461eSJoseph Mingrone nd_ipv4 bp_giaddr; /* gateway IP address */ 70*ee67461eSJoseph Mingrone nd_byte bp_chaddr[16]; /* client hardware address */ 71*ee67461eSJoseph Mingrone nd_byte bp_sname[64]; /* server host name */ 72*ee67461eSJoseph Mingrone nd_byte bp_file[128]; /* boot file name */ 73*ee67461eSJoseph Mingrone nd_byte bp_vend[64]; /* vendor-specific area */ 74*ee67461eSJoseph Mingrone }; 758bdc5a62SPatrick Kelsey 768bdc5a62SPatrick Kelsey #define BOOTPREPLY 2 778bdc5a62SPatrick Kelsey #define BOOTPREQUEST 1 788bdc5a62SPatrick Kelsey 798bdc5a62SPatrick Kelsey /* 808bdc5a62SPatrick Kelsey * Vendor magic cookie (v_magic) for CMU 818bdc5a62SPatrick Kelsey */ 828bdc5a62SPatrick Kelsey #define VM_CMU "CMU" 838bdc5a62SPatrick Kelsey 848bdc5a62SPatrick Kelsey /* 858bdc5a62SPatrick Kelsey * Vendor magic cookie (v_magic) for RFC1048 868bdc5a62SPatrick Kelsey */ 878bdc5a62SPatrick Kelsey #define VM_RFC1048 { 99, 130, 83, 99 } 888bdc5a62SPatrick Kelsey 898bdc5a62SPatrick Kelsey /* 908bdc5a62SPatrick Kelsey * RFC1048 tag values used to specify what information is being supplied in 918bdc5a62SPatrick Kelsey * the vendor field of the packet. 928bdc5a62SPatrick Kelsey */ 938bdc5a62SPatrick Kelsey 948bdc5a62SPatrick Kelsey #define TAG_PAD ((uint8_t) 0) 958bdc5a62SPatrick Kelsey #define TAG_SUBNET_MASK ((uint8_t) 1) 968bdc5a62SPatrick Kelsey #define TAG_TIME_OFFSET ((uint8_t) 2) 978bdc5a62SPatrick Kelsey #define TAG_GATEWAY ((uint8_t) 3) 988bdc5a62SPatrick Kelsey #define TAG_TIME_SERVER ((uint8_t) 4) 998bdc5a62SPatrick Kelsey #define TAG_NAME_SERVER ((uint8_t) 5) 1008bdc5a62SPatrick Kelsey #define TAG_DOMAIN_SERVER ((uint8_t) 6) 1018bdc5a62SPatrick Kelsey #define TAG_LOG_SERVER ((uint8_t) 7) 1028bdc5a62SPatrick Kelsey #define TAG_COOKIE_SERVER ((uint8_t) 8) 1038bdc5a62SPatrick Kelsey #define TAG_LPR_SERVER ((uint8_t) 9) 1048bdc5a62SPatrick Kelsey #define TAG_IMPRESS_SERVER ((uint8_t) 10) 1058bdc5a62SPatrick Kelsey #define TAG_RLP_SERVER ((uint8_t) 11) 1068bdc5a62SPatrick Kelsey #define TAG_HOSTNAME ((uint8_t) 12) 1078bdc5a62SPatrick Kelsey #define TAG_BOOTSIZE ((uint8_t) 13) 1088bdc5a62SPatrick Kelsey #define TAG_END ((uint8_t) 255) 1098bdc5a62SPatrick Kelsey /* RFC1497 tags */ 1108bdc5a62SPatrick Kelsey #define TAG_DUMPPATH ((uint8_t) 14) 1118bdc5a62SPatrick Kelsey #define TAG_DOMAINNAME ((uint8_t) 15) 1128bdc5a62SPatrick Kelsey #define TAG_SWAP_SERVER ((uint8_t) 16) 1138bdc5a62SPatrick Kelsey #define TAG_ROOTPATH ((uint8_t) 17) 1148bdc5a62SPatrick Kelsey #define TAG_EXTPATH ((uint8_t) 18) 1158bdc5a62SPatrick Kelsey /* RFC2132 */ 1168bdc5a62SPatrick Kelsey #define TAG_IP_FORWARD ((uint8_t) 19) 1178bdc5a62SPatrick Kelsey #define TAG_NL_SRCRT ((uint8_t) 20) 1188bdc5a62SPatrick Kelsey #define TAG_PFILTERS ((uint8_t) 21) 1198bdc5a62SPatrick Kelsey #define TAG_REASS_SIZE ((uint8_t) 22) 1208bdc5a62SPatrick Kelsey #define TAG_DEF_TTL ((uint8_t) 23) 1218bdc5a62SPatrick Kelsey #define TAG_MTU_TIMEOUT ((uint8_t) 24) 1228bdc5a62SPatrick Kelsey #define TAG_MTU_TABLE ((uint8_t) 25) 1238bdc5a62SPatrick Kelsey #define TAG_INT_MTU ((uint8_t) 26) 1248bdc5a62SPatrick Kelsey #define TAG_LOCAL_SUBNETS ((uint8_t) 27) 1258bdc5a62SPatrick Kelsey #define TAG_BROAD_ADDR ((uint8_t) 28) 1268bdc5a62SPatrick Kelsey #define TAG_DO_MASK_DISC ((uint8_t) 29) 1278bdc5a62SPatrick Kelsey #define TAG_SUPPLY_MASK ((uint8_t) 30) 1288bdc5a62SPatrick Kelsey #define TAG_DO_RDISC ((uint8_t) 31) 1298bdc5a62SPatrick Kelsey #define TAG_RTR_SOL_ADDR ((uint8_t) 32) 1308bdc5a62SPatrick Kelsey #define TAG_STATIC_ROUTE ((uint8_t) 33) 1318bdc5a62SPatrick Kelsey #define TAG_USE_TRAILERS ((uint8_t) 34) 1328bdc5a62SPatrick Kelsey #define TAG_ARP_TIMEOUT ((uint8_t) 35) 1338bdc5a62SPatrick Kelsey #define TAG_ETH_ENCAP ((uint8_t) 36) 1348bdc5a62SPatrick Kelsey #define TAG_TCP_TTL ((uint8_t) 37) 1358bdc5a62SPatrick Kelsey #define TAG_TCP_KEEPALIVE ((uint8_t) 38) 1368bdc5a62SPatrick Kelsey #define TAG_KEEPALIVE_GO ((uint8_t) 39) 1378bdc5a62SPatrick Kelsey #define TAG_NIS_DOMAIN ((uint8_t) 40) 1388bdc5a62SPatrick Kelsey #define TAG_NIS_SERVERS ((uint8_t) 41) 1398bdc5a62SPatrick Kelsey #define TAG_NTP_SERVERS ((uint8_t) 42) 1408bdc5a62SPatrick Kelsey #define TAG_VENDOR_OPTS ((uint8_t) 43) 1418bdc5a62SPatrick Kelsey #define TAG_NETBIOS_NS ((uint8_t) 44) 1428bdc5a62SPatrick Kelsey #define TAG_NETBIOS_DDS ((uint8_t) 45) 1438bdc5a62SPatrick Kelsey #define TAG_NETBIOS_NODE ((uint8_t) 46) 1448bdc5a62SPatrick Kelsey #define TAG_NETBIOS_SCOPE ((uint8_t) 47) 1458bdc5a62SPatrick Kelsey #define TAG_XWIN_FS ((uint8_t) 48) 1468bdc5a62SPatrick Kelsey #define TAG_XWIN_DM ((uint8_t) 49) 1478bdc5a62SPatrick Kelsey #define TAG_NIS_P_DOMAIN ((uint8_t) 64) 1488bdc5a62SPatrick Kelsey #define TAG_NIS_P_SERVERS ((uint8_t) 65) 1498bdc5a62SPatrick Kelsey #define TAG_MOBILE_HOME ((uint8_t) 68) 1508bdc5a62SPatrick Kelsey #define TAG_SMPT_SERVER ((uint8_t) 69) 1518bdc5a62SPatrick Kelsey #define TAG_POP3_SERVER ((uint8_t) 70) 1528bdc5a62SPatrick Kelsey #define TAG_NNTP_SERVER ((uint8_t) 71) 1538bdc5a62SPatrick Kelsey #define TAG_WWW_SERVER ((uint8_t) 72) 1548bdc5a62SPatrick Kelsey #define TAG_FINGER_SERVER ((uint8_t) 73) 1558bdc5a62SPatrick Kelsey #define TAG_IRC_SERVER ((uint8_t) 74) 1568bdc5a62SPatrick Kelsey #define TAG_STREETTALK_SRVR ((uint8_t) 75) 1578bdc5a62SPatrick Kelsey #define TAG_STREETTALK_STDA ((uint8_t) 76) 1588bdc5a62SPatrick Kelsey /* DHCP options */ 1598bdc5a62SPatrick Kelsey #define TAG_REQUESTED_IP ((uint8_t) 50) 1608bdc5a62SPatrick Kelsey #define TAG_IP_LEASE ((uint8_t) 51) 1618bdc5a62SPatrick Kelsey #define TAG_OPT_OVERLOAD ((uint8_t) 52) 1628bdc5a62SPatrick Kelsey #define TAG_TFTP_SERVER ((uint8_t) 66) 1638bdc5a62SPatrick Kelsey #define TAG_BOOTFILENAME ((uint8_t) 67) 1648bdc5a62SPatrick Kelsey #define TAG_DHCP_MESSAGE ((uint8_t) 53) 1658bdc5a62SPatrick Kelsey #define TAG_SERVER_ID ((uint8_t) 54) 1668bdc5a62SPatrick Kelsey #define TAG_PARM_REQUEST ((uint8_t) 55) 1678bdc5a62SPatrick Kelsey #define TAG_MESSAGE ((uint8_t) 56) 1688bdc5a62SPatrick Kelsey #define TAG_MAX_MSG_SIZE ((uint8_t) 57) 1698bdc5a62SPatrick Kelsey #define TAG_RENEWAL_TIME ((uint8_t) 58) 1708bdc5a62SPatrick Kelsey #define TAG_REBIND_TIME ((uint8_t) 59) 1718bdc5a62SPatrick Kelsey #define TAG_VENDOR_CLASS ((uint8_t) 60) 1728bdc5a62SPatrick Kelsey #define TAG_CLIENT_ID ((uint8_t) 61) 1738bdc5a62SPatrick Kelsey /* RFC 2241 */ 1748bdc5a62SPatrick Kelsey #define TAG_NDS_SERVERS ((uint8_t) 85) 1758bdc5a62SPatrick Kelsey #define TAG_NDS_TREE_NAME ((uint8_t) 86) 1768bdc5a62SPatrick Kelsey #define TAG_NDS_CONTEXT ((uint8_t) 87) 1778bdc5a62SPatrick Kelsey /* RFC 2242 */ 1788bdc5a62SPatrick Kelsey #define TAG_NDS_IPDOMAIN ((uint8_t) 62) 1798bdc5a62SPatrick Kelsey #define TAG_NDS_IPINFO ((uint8_t) 63) 1808bdc5a62SPatrick Kelsey /* RFC 2485 */ 1818bdc5a62SPatrick Kelsey #define TAG_OPEN_GROUP_UAP ((uint8_t) 98) 1828bdc5a62SPatrick Kelsey /* RFC 2563 */ 1838bdc5a62SPatrick Kelsey #define TAG_DISABLE_AUTOCONF ((uint8_t) 116) 1848bdc5a62SPatrick Kelsey /* RFC 2610 */ 1858bdc5a62SPatrick Kelsey #define TAG_SLP_DA ((uint8_t) 78) 1868bdc5a62SPatrick Kelsey #define TAG_SLP_SCOPE ((uint8_t) 79) 1878bdc5a62SPatrick Kelsey /* RFC 2937 */ 1888bdc5a62SPatrick Kelsey #define TAG_NS_SEARCH ((uint8_t) 117) 1898bdc5a62SPatrick Kelsey /* RFC 3004 - The User Class Option for DHCP */ 1908bdc5a62SPatrick Kelsey #define TAG_USER_CLASS ((uint8_t) 77) 1918bdc5a62SPatrick Kelsey /* RFC 3011 */ 1928bdc5a62SPatrick Kelsey #define TAG_IP4_SUBNET_SELECT ((uint8_t) 118) 1938bdc5a62SPatrick Kelsey /* RFC 3442 */ 1948bdc5a62SPatrick Kelsey #define TAG_CLASSLESS_STATIC_RT ((uint8_t) 121) 1958bdc5a62SPatrick Kelsey #define TAG_CLASSLESS_STA_RT_MS ((uint8_t) 249) 1968bdc5a62SPatrick Kelsey /* RFC 5859 - TFTP Server Address Option for DHCPv4 */ 1978bdc5a62SPatrick Kelsey #define TAG_TFTP_SERVER_ADDRESS ((uint8_t) 150) 198*ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml */ 1998bdc5a62SPatrick Kelsey #define TAG_SLP_NAMING_AUTH ((uint8_t) 80) 2008bdc5a62SPatrick Kelsey #define TAG_CLIENT_FQDN ((uint8_t) 81) 2018bdc5a62SPatrick Kelsey #define TAG_AGENT_CIRCUIT ((uint8_t) 82) 2028bdc5a62SPatrick Kelsey #define TAG_AGENT_REMOTE ((uint8_t) 83) 2038bdc5a62SPatrick Kelsey #define TAG_TZ_STRING ((uint8_t) 88) 2048bdc5a62SPatrick Kelsey #define TAG_FQDN_OPTION ((uint8_t) 89) 2058bdc5a62SPatrick Kelsey #define TAG_AUTH ((uint8_t) 90) 206*ee67461eSJoseph Mingrone #define TAG_CLIENT_LAST_TRANSACTION_TIME ((uint8_t) 91) 207*ee67461eSJoseph Mingrone #define TAG_ASSOCIATED_IP ((uint8_t) 92) 2088bdc5a62SPatrick Kelsey #define TAG_CLIENT_ARCH ((uint8_t) 93) 2098bdc5a62SPatrick Kelsey #define TAG_CLIENT_NDI ((uint8_t) 94) 2108bdc5a62SPatrick Kelsey #define TAG_CLIENT_GUID ((uint8_t) 97) 2118bdc5a62SPatrick Kelsey #define TAG_LDAP_URL ((uint8_t) 95) 2123340d773SGleb Smirnoff /* RFC 4833, TZ codes */ 2133340d773SGleb Smirnoff #define TAG_TZ_PCODE ((uint8_t) 100) 2143340d773SGleb Smirnoff #define TAG_TZ_TCODE ((uint8_t) 101) 2158bdc5a62SPatrick Kelsey #define TAG_NETINFO_PARENT ((uint8_t) 112) 2168bdc5a62SPatrick Kelsey #define TAG_NETINFO_PARENT_TAG ((uint8_t) 113) 2178bdc5a62SPatrick Kelsey #define TAG_URL ((uint8_t) 114) 2183340d773SGleb Smirnoff #define TAG_MUDURL ((uint8_t) 161) 2198bdc5a62SPatrick Kelsey 2208bdc5a62SPatrick Kelsey /* DHCP Message types (values for TAG_DHCP_MESSAGE option) */ 2218bdc5a62SPatrick Kelsey #define DHCPDISCOVER 1 2228bdc5a62SPatrick Kelsey #define DHCPOFFER 2 2238bdc5a62SPatrick Kelsey #define DHCPREQUEST 3 2248bdc5a62SPatrick Kelsey #define DHCPDECLINE 4 2258bdc5a62SPatrick Kelsey #define DHCPACK 5 2268bdc5a62SPatrick Kelsey #define DHCPNAK 6 2278bdc5a62SPatrick Kelsey #define DHCPRELEASE 7 2288bdc5a62SPatrick Kelsey #define DHCPINFORM 8 229*ee67461eSJoseph Mingrone /* Defined in RFC4388 */ 230*ee67461eSJoseph Mingrone #define DHCPLEASEQUERY 10 231*ee67461eSJoseph Mingrone #define DHCPLEASEUNASSIGNED 11 232*ee67461eSJoseph Mingrone #define DHCPLEASEUNKNOWN 12 233*ee67461eSJoseph Mingrone #define DHCPLEASEACTIVE 13 234*ee67461eSJoseph Mingrone 2358bdc5a62SPatrick Kelsey 2368bdc5a62SPatrick Kelsey /* 2378bdc5a62SPatrick Kelsey * "vendor" data permitted for CMU bootp clients. 2388bdc5a62SPatrick Kelsey */ 2398bdc5a62SPatrick Kelsey 2408bdc5a62SPatrick Kelsey struct cmu_vend { 241*ee67461eSJoseph Mingrone nd_byte v_magic[4]; /* magic number */ 242*ee67461eSJoseph Mingrone nd_uint32_t v_flags; /* flags/opcodes, etc. */ 243*ee67461eSJoseph Mingrone nd_ipv4 v_smask; /* Subnet mask */ 244*ee67461eSJoseph Mingrone nd_ipv4 v_dgate; /* Default gateway */ 245*ee67461eSJoseph Mingrone nd_ipv4 v_dns1, v_dns2; /* Domain name servers */ 246*ee67461eSJoseph Mingrone nd_ipv4 v_ins1, v_ins2; /* IEN-116 name servers */ 247*ee67461eSJoseph Mingrone nd_ipv4 v_ts1, v_ts2; /* Time servers */ 248*ee67461eSJoseph Mingrone nd_byte v_unused[24]; /* currently unused */ 249*ee67461eSJoseph Mingrone }; 2508bdc5a62SPatrick Kelsey 2518bdc5a62SPatrick Kelsey 2528bdc5a62SPatrick Kelsey /* v_flags values */ 2538bdc5a62SPatrick Kelsey #define VF_SMASK 1 /* Subnet mask field contains valid data */ 2548bdc5a62SPatrick Kelsey 2558bdc5a62SPatrick Kelsey /* RFC 4702 DHCP Client FQDN Option */ 2568bdc5a62SPatrick Kelsey 2578bdc5a62SPatrick Kelsey #define CLIENT_FQDN_FLAGS_S 0x01 2588bdc5a62SPatrick Kelsey #define CLIENT_FQDN_FLAGS_O 0x02 2598bdc5a62SPatrick Kelsey #define CLIENT_FQDN_FLAGS_E 0x04 2608bdc5a62SPatrick Kelsey #define CLIENT_FQDN_FLAGS_N 0x08 2618bdc5a62SPatrick Kelsey /* end of original bootp.h */ 2628bdc5a62SPatrick Kelsey 2633c602fabSXin LI static void rfc1048_print(netdissect_options *, const u_char *); 2643c602fabSXin LI static void cmu_print(netdissect_options *, const u_char *); 2653c602fabSXin LI static char *client_fqdn_flags(u_int flags); 2664edb46e9SPaul Traina 267cc391cceSBruce M Simpson static const struct tok bootp_flag_values[] = { 268cc391cceSBruce M Simpson { 0x8000, "Broadcast" }, 269cc391cceSBruce M Simpson { 0, NULL} 270cc391cceSBruce M Simpson }; 271cc391cceSBruce M Simpson 272cc391cceSBruce M Simpson static const struct tok bootp_op_values[] = { 273cc391cceSBruce M Simpson { BOOTPREQUEST, "Request" }, 274cc391cceSBruce M Simpson { BOOTPREPLY, "Reply" }, 275cc391cceSBruce M Simpson { 0, NULL} 276cc391cceSBruce M Simpson }; 277cc391cceSBruce M Simpson 2784edb46e9SPaul Traina /* 2794edb46e9SPaul Traina * Print bootp requests 2804edb46e9SPaul Traina */ 2814edb46e9SPaul Traina void 2823c602fabSXin LI bootp_print(netdissect_options *ndo, 283*ee67461eSJoseph Mingrone const u_char *cp, u_int length) 2844edb46e9SPaul Traina { 285*ee67461eSJoseph Mingrone const struct bootp *bp; 286a1c2090eSBill Fenner static const u_char vm_cmu[4] = VM_CMU; 287a1c2090eSBill Fenner static const u_char vm_rfc1048[4] = VM_RFC1048; 288*ee67461eSJoseph Mingrone uint8_t bp_op, bp_htype, bp_hlen; 2894edb46e9SPaul Traina 290*ee67461eSJoseph Mingrone ndo->ndo_protocol = "bootp"; 291a1c2090eSBill Fenner bp = (const struct bootp *)cp; 292*ee67461eSJoseph Mingrone bp_op = GET_U_1(bp->bp_op); 293*ee67461eSJoseph Mingrone ND_PRINT("BOOTP/DHCP, %s", 294*ee67461eSJoseph Mingrone tok2str(bootp_op_values, "unknown (0x%02x)", bp_op)); 2954edb46e9SPaul Traina 296*ee67461eSJoseph Mingrone bp_htype = GET_U_1(bp->bp_htype); 297*ee67461eSJoseph Mingrone bp_hlen = GET_U_1(bp->bp_hlen); 298*ee67461eSJoseph Mingrone if (bp_htype == 1 && bp_hlen == MAC_ADDR_LEN && bp_op == BOOTPREQUEST) { 299*ee67461eSJoseph Mingrone ND_PRINT(" from %s", GET_ETHERADDR_STRING(bp->bp_chaddr)); 3004edb46e9SPaul Traina } 3014edb46e9SPaul Traina 302*ee67461eSJoseph Mingrone ND_PRINT(", length %u", length); 303cc391cceSBruce M Simpson 3043c602fabSXin LI if (!ndo->ndo_vflag) 305cc391cceSBruce M Simpson return; 306cc391cceSBruce M Simpson 307*ee67461eSJoseph Mingrone ND_TCHECK_2(bp->bp_secs); 3084edb46e9SPaul Traina 3094edb46e9SPaul Traina /* The usual hardware address type is 1 (10Mb Ethernet) */ 310*ee67461eSJoseph Mingrone if (bp_htype != 1) 311*ee67461eSJoseph Mingrone ND_PRINT(", htype %u", bp_htype); 3124edb46e9SPaul Traina 3134edb46e9SPaul Traina /* The usual length for 10Mb Ethernet address is 6 bytes */ 314*ee67461eSJoseph Mingrone if (bp_htype != 1 || bp_hlen != MAC_ADDR_LEN) 315*ee67461eSJoseph Mingrone ND_PRINT(", hlen %u", bp_hlen); 3164edb46e9SPaul Traina 3174edb46e9SPaul Traina /* Only print interesting fields */ 318*ee67461eSJoseph Mingrone if (GET_U_1(bp->bp_hops)) 319*ee67461eSJoseph Mingrone ND_PRINT(", hops %u", GET_U_1(bp->bp_hops)); 320*ee67461eSJoseph Mingrone if (GET_BE_U_4(bp->bp_xid)) 321*ee67461eSJoseph Mingrone ND_PRINT(", xid 0x%x", GET_BE_U_4(bp->bp_xid)); 322*ee67461eSJoseph Mingrone if (GET_BE_U_2(bp->bp_secs)) 323*ee67461eSJoseph Mingrone ND_PRINT(", secs %u", GET_BE_U_2(bp->bp_secs)); 324cc391cceSBruce M Simpson 325*ee67461eSJoseph Mingrone ND_PRINT(", Flags [%s]", 326*ee67461eSJoseph Mingrone bittok2str(bootp_flag_values, "none", GET_BE_U_2(bp->bp_flags))); 3273c602fabSXin LI if (ndo->ndo_vflag > 1) 328*ee67461eSJoseph Mingrone ND_PRINT(" (0x%04x)", GET_BE_U_2(bp->bp_flags)); 3294edb46e9SPaul Traina 3304edb46e9SPaul Traina /* Client's ip address */ 331*ee67461eSJoseph Mingrone if (GET_IPV4_TO_NETWORK_ORDER(bp->bp_ciaddr)) 332*ee67461eSJoseph Mingrone ND_PRINT("\n\t Client-IP %s", GET_IPADDR_STRING(bp->bp_ciaddr)); 3334edb46e9SPaul Traina 3344edb46e9SPaul Traina /* 'your' ip address (bootp client) */ 335*ee67461eSJoseph Mingrone if (GET_IPV4_TO_NETWORK_ORDER(bp->bp_yiaddr)) 336*ee67461eSJoseph Mingrone ND_PRINT("\n\t Your-IP %s", GET_IPADDR_STRING(bp->bp_yiaddr)); 3374edb46e9SPaul Traina 3384edb46e9SPaul Traina /* Server's ip address */ 339*ee67461eSJoseph Mingrone if (GET_IPV4_TO_NETWORK_ORDER(bp->bp_siaddr)) 340*ee67461eSJoseph Mingrone ND_PRINT("\n\t Server-IP %s", GET_IPADDR_STRING(bp->bp_siaddr)); 3414edb46e9SPaul Traina 3424edb46e9SPaul Traina /* Gateway's ip address */ 343*ee67461eSJoseph Mingrone if (GET_IPV4_TO_NETWORK_ORDER(bp->bp_giaddr)) 344*ee67461eSJoseph Mingrone ND_PRINT("\n\t Gateway-IP %s", GET_IPADDR_STRING(bp->bp_giaddr)); 3454edb46e9SPaul Traina 3464edb46e9SPaul Traina /* Client's Ethernet address */ 347*ee67461eSJoseph Mingrone if (bp_htype == 1 && bp_hlen == MAC_ADDR_LEN) { 348*ee67461eSJoseph Mingrone ND_PRINT("\n\t Client-Ethernet-Address %s", GET_ETHERADDR_STRING(bp->bp_chaddr)); 3494edb46e9SPaul Traina } 3504edb46e9SPaul Traina 351*ee67461eSJoseph Mingrone if (GET_U_1(bp->bp_sname)) { /* get first char only */ 352*ee67461eSJoseph Mingrone ND_PRINT("\n\t sname \""); 353*ee67461eSJoseph Mingrone if (nd_printztn(ndo, bp->bp_sname, (u_int)sizeof(bp->bp_sname), 35439e421e8SCy Schubert ndo->ndo_snapend) == 0) { 355*ee67461eSJoseph Mingrone ND_PRINT("\""); 356*ee67461eSJoseph Mingrone nd_print_trunc(ndo); 3574edb46e9SPaul Traina return; 3584edb46e9SPaul Traina } 359*ee67461eSJoseph Mingrone ND_PRINT("\""); 3604edb46e9SPaul Traina } 361*ee67461eSJoseph Mingrone if (GET_U_1(bp->bp_file)) { /* get first char only */ 362*ee67461eSJoseph Mingrone ND_PRINT("\n\t file \""); 363*ee67461eSJoseph Mingrone if (nd_printztn(ndo, bp->bp_file, (u_int)sizeof(bp->bp_file), 36439e421e8SCy Schubert ndo->ndo_snapend) == 0) { 365*ee67461eSJoseph Mingrone ND_PRINT("\""); 366*ee67461eSJoseph Mingrone nd_print_trunc(ndo); 3674edb46e9SPaul Traina return; 3684edb46e9SPaul Traina } 369*ee67461eSJoseph Mingrone ND_PRINT("\""); 3704edb46e9SPaul Traina } 3714edb46e9SPaul Traina 3724edb46e9SPaul Traina /* Decode the vendor buffer */ 373*ee67461eSJoseph Mingrone ND_TCHECK_4(bp->bp_vend); 374a1c2090eSBill Fenner if (memcmp((const char *)bp->bp_vend, vm_rfc1048, 3753c602fabSXin LI sizeof(uint32_t)) == 0) 3763c602fabSXin LI rfc1048_print(ndo, bp->bp_vend); 377a1c2090eSBill Fenner else if (memcmp((const char *)bp->bp_vend, vm_cmu, 3783c602fabSXin LI sizeof(uint32_t)) == 0) 3793c602fabSXin LI cmu_print(ndo, bp->bp_vend); 3804edb46e9SPaul Traina else { 3813c602fabSXin LI uint32_t ul; 3824edb46e9SPaul Traina 383*ee67461eSJoseph Mingrone ul = GET_BE_U_4(bp->bp_vend); 3844edb46e9SPaul Traina if (ul != 0) 385*ee67461eSJoseph Mingrone ND_PRINT("\n\t Vendor-#0x%x", ul); 3864edb46e9SPaul Traina } 3874edb46e9SPaul Traina 3884edb46e9SPaul Traina return; 3894edb46e9SPaul Traina trunc: 390*ee67461eSJoseph Mingrone nd_print_trunc(ndo); 3914edb46e9SPaul Traina } 3924edb46e9SPaul Traina 393a1c2090eSBill Fenner /* 394a1c2090eSBill Fenner * The first character specifies the format to print: 395a1c2090eSBill Fenner * i - ip address (32 bits) 396a1c2090eSBill Fenner * p - ip address pairs (32 bits + 32 bits) 397a1c2090eSBill Fenner * l - long (32 bits) 398a1c2090eSBill Fenner * L - unsigned long (32 bits) 399a1c2090eSBill Fenner * s - short (16 bits) 400*ee67461eSJoseph Mingrone * b - period-separated decimal bytes (variable length) 401*ee67461eSJoseph Mingrone * x - colon-separated hex bytes (variable length) 402*ee67461eSJoseph Mingrone * a - ASCII string (variable length) 403a1c2090eSBill Fenner * B - on/off (8 bits) 404a1c2090eSBill Fenner * $ - special (explicit code to handle) 405a1c2090eSBill Fenner */ 4063c602fabSXin LI static const struct tok tag2str[] = { 4074edb46e9SPaul Traina /* RFC1048 tags */ 4084edb46e9SPaul Traina { TAG_PAD, " PAD" }, 409abf25193SMax Laier { TAG_SUBNET_MASK, "iSubnet-Mask" }, /* subnet mask (RFC950) */ 410abf25193SMax Laier { TAG_TIME_OFFSET, "LTime-Zone" }, /* seconds from UTC */ 411abf25193SMax Laier { TAG_GATEWAY, "iDefault-Gateway" }, /* default gateway */ 412abf25193SMax Laier { TAG_TIME_SERVER, "iTime-Server" }, /* time servers (RFC868) */ 413abf25193SMax Laier { TAG_NAME_SERVER, "iIEN-Name-Server" }, /* IEN name servers (IEN116) */ 414abf25193SMax Laier { TAG_DOMAIN_SERVER, "iDomain-Name-Server" }, /* domain name (RFC1035) */ 4154edb46e9SPaul Traina { TAG_LOG_SERVER, "iLOG" }, /* MIT log servers */ 4164edb46e9SPaul Traina { TAG_COOKIE_SERVER, "iCS" }, /* cookie servers (RFC865) */ 417abf25193SMax Laier { TAG_LPR_SERVER, "iLPR-Server" }, /* lpr server (RFC1179) */ 4184edb46e9SPaul Traina { TAG_IMPRESS_SERVER, "iIM" }, /* impress servers (Imagen) */ 4194edb46e9SPaul Traina { TAG_RLP_SERVER, "iRL" }, /* resource location (RFC887) */ 420*ee67461eSJoseph Mingrone { TAG_HOSTNAME, "aHostname" }, /* ASCII hostname */ 4214edb46e9SPaul Traina { TAG_BOOTSIZE, "sBS" }, /* 512 byte blocks */ 4224edb46e9SPaul Traina { TAG_END, " END" }, 4234edb46e9SPaul Traina /* RFC1497 tags */ 4244edb46e9SPaul Traina { TAG_DUMPPATH, "aDP" }, 425abf25193SMax Laier { TAG_DOMAINNAME, "aDomain-Name" }, 4264edb46e9SPaul Traina { TAG_SWAP_SERVER, "iSS" }, 4274edb46e9SPaul Traina { TAG_ROOTPATH, "aRP" }, 4284edb46e9SPaul Traina { TAG_EXTPATH, "aEP" }, 429a88113a8SBill Fenner /* RFC2132 tags */ 430a88113a8SBill Fenner { TAG_IP_FORWARD, "BIPF" }, 431a88113a8SBill Fenner { TAG_NL_SRCRT, "BSRT" }, 432a88113a8SBill Fenner { TAG_PFILTERS, "pPF" }, 433a88113a8SBill Fenner { TAG_REASS_SIZE, "sRSZ" }, 434a88113a8SBill Fenner { TAG_DEF_TTL, "bTTL" }, 435abf25193SMax Laier { TAG_MTU_TIMEOUT, "lMTU-Timeout" }, 436abf25193SMax Laier { TAG_MTU_TABLE, "sMTU-Table" }, 437a88113a8SBill Fenner { TAG_INT_MTU, "sMTU" }, 438a88113a8SBill Fenner { TAG_LOCAL_SUBNETS, "BLSN" }, 439a88113a8SBill Fenner { TAG_BROAD_ADDR, "iBR" }, 440a88113a8SBill Fenner { TAG_DO_MASK_DISC, "BMD" }, 441a88113a8SBill Fenner { TAG_SUPPLY_MASK, "BMS" }, 442abf25193SMax Laier { TAG_DO_RDISC, "BRouter-Discovery" }, 443a88113a8SBill Fenner { TAG_RTR_SOL_ADDR, "iRSA" }, 444abf25193SMax Laier { TAG_STATIC_ROUTE, "pStatic-Route" }, 445a88113a8SBill Fenner { TAG_USE_TRAILERS, "BUT" }, 446a88113a8SBill Fenner { TAG_ARP_TIMEOUT, "lAT" }, 447a88113a8SBill Fenner { TAG_ETH_ENCAP, "BIE" }, 448a88113a8SBill Fenner { TAG_TCP_TTL, "bTT" }, 449a88113a8SBill Fenner { TAG_TCP_KEEPALIVE, "lKI" }, 450a88113a8SBill Fenner { TAG_KEEPALIVE_GO, "BKG" }, 451a88113a8SBill Fenner { TAG_NIS_DOMAIN, "aYD" }, 452a88113a8SBill Fenner { TAG_NIS_SERVERS, "iYS" }, 453a88113a8SBill Fenner { TAG_NTP_SERVERS, "iNTP" }, 454abf25193SMax Laier { TAG_VENDOR_OPTS, "bVendor-Option" }, 455abf25193SMax Laier { TAG_NETBIOS_NS, "iNetbios-Name-Server" }, 456a88113a8SBill Fenner { TAG_NETBIOS_DDS, "iWDD" }, 457abf25193SMax Laier { TAG_NETBIOS_NODE, "$Netbios-Node" }, 458abf25193SMax Laier { TAG_NETBIOS_SCOPE, "aNetbios-Scope" }, 459a88113a8SBill Fenner { TAG_XWIN_FS, "iXFS" }, 460a88113a8SBill Fenner { TAG_XWIN_DM, "iXDM" }, 461a88113a8SBill Fenner { TAG_NIS_P_DOMAIN, "sN+D" }, 462a88113a8SBill Fenner { TAG_NIS_P_SERVERS, "iN+S" }, 463a88113a8SBill Fenner { TAG_MOBILE_HOME, "iMH" }, 464a88113a8SBill Fenner { TAG_SMPT_SERVER, "iSMTP" }, 465a88113a8SBill Fenner { TAG_POP3_SERVER, "iPOP3" }, 466a88113a8SBill Fenner { TAG_NNTP_SERVER, "iNNTP" }, 467a88113a8SBill Fenner { TAG_WWW_SERVER, "iWWW" }, 468a88113a8SBill Fenner { TAG_FINGER_SERVER, "iFG" }, 469a88113a8SBill Fenner { TAG_IRC_SERVER, "iIRC" }, 470a88113a8SBill Fenner { TAG_STREETTALK_SRVR, "iSTS" }, 471a88113a8SBill Fenner { TAG_STREETTALK_STDA, "iSTDA" }, 472abf25193SMax Laier { TAG_REQUESTED_IP, "iRequested-IP" }, 473abf25193SMax Laier { TAG_IP_LEASE, "lLease-Time" }, 474a1c2090eSBill Fenner { TAG_OPT_OVERLOAD, "$OO" }, 475a88113a8SBill Fenner { TAG_TFTP_SERVER, "aTFTP" }, 476a88113a8SBill Fenner { TAG_BOOTFILENAME, "aBF" }, 477abf25193SMax Laier { TAG_DHCP_MESSAGE, " DHCP-Message" }, 478abf25193SMax Laier { TAG_SERVER_ID, "iServer-ID" }, 479abf25193SMax Laier { TAG_PARM_REQUEST, "bParameter-Request" }, 480a88113a8SBill Fenner { TAG_MESSAGE, "aMSG" }, 481a88113a8SBill Fenner { TAG_MAX_MSG_SIZE, "sMSZ" }, 482a88113a8SBill Fenner { TAG_RENEWAL_TIME, "lRN" }, 483a88113a8SBill Fenner { TAG_REBIND_TIME, "lRB" }, 484abf25193SMax Laier { TAG_VENDOR_CLASS, "aVendor-Class" }, 485abf25193SMax Laier { TAG_CLIENT_ID, "$Client-ID" }, 486943ee2b1SBill Fenner /* RFC 2485 */ 487943ee2b1SBill Fenner { TAG_OPEN_GROUP_UAP, "aUAP" }, 488943ee2b1SBill Fenner /* RFC 2563 */ 489943ee2b1SBill Fenner { TAG_DISABLE_AUTOCONF, "BNOAUTO" }, 490943ee2b1SBill Fenner /* RFC 2610 */ 491943ee2b1SBill Fenner { TAG_SLP_DA, "bSLP-DA" }, /*"b" is a little wrong */ 492943ee2b1SBill Fenner { TAG_SLP_SCOPE, "bSLP-SCOPE" }, /*"b" is a little wrong */ 493943ee2b1SBill Fenner /* RFC 2937 */ 494943ee2b1SBill Fenner { TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */ 4958bdc5a62SPatrick Kelsey /* RFC 3004 - The User Class Option for DHCP */ 4968bdc5a62SPatrick Kelsey { TAG_USER_CLASS, "$User-Class" }, 497943ee2b1SBill Fenner /* RFC 3011 */ 498943ee2b1SBill Fenner { TAG_IP4_SUBNET_SELECT, "iSUBNET" }, 499abf25193SMax Laier /* RFC 3442 */ 500abf25193SMax Laier { TAG_CLASSLESS_STATIC_RT, "$Classless-Static-Route" }, 501abf25193SMax Laier { TAG_CLASSLESS_STA_RT_MS, "$Classless-Static-Route-Microsoft" }, 5028bdc5a62SPatrick Kelsey /* RFC 5859 - TFTP Server Address Option for DHCPv4 */ 5038bdc5a62SPatrick Kelsey { TAG_TFTP_SERVER_ADDRESS, "iTFTP-Server-Address" }, 504*ee67461eSJoseph Mingrone /* https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml#options */ 505943ee2b1SBill Fenner { TAG_SLP_NAMING_AUTH, "aSLP-NA" }, 506a1c2090eSBill Fenner { TAG_CLIENT_FQDN, "$FQDN" }, 507abf25193SMax Laier { TAG_AGENT_CIRCUIT, "$Agent-Information" }, 508943ee2b1SBill Fenner { TAG_AGENT_REMOTE, "bARMT" }, 509943ee2b1SBill Fenner { TAG_TZ_STRING, "aTZSTR" }, 510943ee2b1SBill Fenner { TAG_FQDN_OPTION, "bFQDNS" }, /* XXX 'b' */ 511943ee2b1SBill Fenner { TAG_AUTH, "bAUTH" }, /* XXX 'b' */ 512*ee67461eSJoseph Mingrone { TAG_CLIENT_LAST_TRANSACTION_TIME, "LLast-Transaction-Time" }, 513*ee67461eSJoseph Mingrone { TAG_ASSOCIATED_IP, "iAssociated-IP" }, 514943ee2b1SBill Fenner { TAG_CLIENT_ARCH, "sARCH" }, 515943ee2b1SBill Fenner { TAG_CLIENT_NDI, "bNDI" }, /* XXX 'b' */ 516943ee2b1SBill Fenner { TAG_CLIENT_GUID, "bGUID" }, /* XXX 'b' */ 517943ee2b1SBill Fenner { TAG_LDAP_URL, "aLDAP" }, 5183340d773SGleb Smirnoff { TAG_TZ_PCODE, "aPOSIX-TZ" }, 5193340d773SGleb Smirnoff { TAG_TZ_TCODE, "aTZ-Name" }, 520943ee2b1SBill Fenner { TAG_NETINFO_PARENT, "iNI" }, 521943ee2b1SBill Fenner { TAG_NETINFO_PARENT_TAG, "aNITAG" }, 522943ee2b1SBill Fenner { TAG_URL, "aURL" }, 5233340d773SGleb Smirnoff { TAG_MUDURL, "aMUD-URL" }, 524943ee2b1SBill Fenner { 0, NULL } 525943ee2b1SBill Fenner }; 5264edb46e9SPaul Traina 527a1c2090eSBill Fenner /* DHCP "options overload" types */ 5283c602fabSXin LI static const struct tok oo2str[] = { 529a1c2090eSBill Fenner { 1, "file" }, 530a1c2090eSBill Fenner { 2, "sname" }, 531a1c2090eSBill Fenner { 3, "file+sname" }, 532a1c2090eSBill Fenner { 0, NULL } 533a1c2090eSBill Fenner }; 534a1c2090eSBill Fenner 535a1c2090eSBill Fenner /* NETBIOS over TCP/IP node type options */ 5363c602fabSXin LI static const struct tok nbo2str[] = { 537a1c2090eSBill Fenner { 0x1, "b-node" }, 538a1c2090eSBill Fenner { 0x2, "p-node" }, 539a1c2090eSBill Fenner { 0x4, "m-node" }, 540a1c2090eSBill Fenner { 0x8, "h-node" }, 541a1c2090eSBill Fenner { 0, NULL } 542a1c2090eSBill Fenner }; 543a1c2090eSBill Fenner 544a1c2090eSBill Fenner /* ARP Hardware types, for Client-ID option */ 5453c602fabSXin LI static const struct tok arp2str[] = { 546a1c2090eSBill Fenner { 0x1, "ether" }, 547a1c2090eSBill Fenner { 0x6, "ieee802" }, 548a1c2090eSBill Fenner { 0x7, "arcnet" }, 549a1c2090eSBill Fenner { 0xf, "frelay" }, 550a1c2090eSBill Fenner { 0x17, "strip" }, 551a1c2090eSBill Fenner { 0x18, "ieee1394" }, 552a1c2090eSBill Fenner { 0, NULL } 553a1c2090eSBill Fenner }; 554a1c2090eSBill Fenner 5553c602fabSXin LI static const struct tok dhcp_msg_values[] = { 556abf25193SMax Laier { DHCPDISCOVER, "Discover" }, 557abf25193SMax Laier { DHCPOFFER, "Offer" }, 558abf25193SMax Laier { DHCPREQUEST, "Request" }, 559abf25193SMax Laier { DHCPDECLINE, "Decline" }, 560abf25193SMax Laier { DHCPACK, "ACK" }, 561abf25193SMax Laier { DHCPNAK, "NACK" }, 562abf25193SMax Laier { DHCPRELEASE, "Release" }, 563abf25193SMax Laier { DHCPINFORM, "Inform" }, 564*ee67461eSJoseph Mingrone { DHCPLEASEQUERY, "LeaseQuery" }, 565*ee67461eSJoseph Mingrone { DHCPLEASEUNASSIGNED, "LeaseUnassigned" }, 566*ee67461eSJoseph Mingrone { DHCPLEASEUNKNOWN, "LeaseUnknown" }, 567*ee67461eSJoseph Mingrone { DHCPLEASEACTIVE, "LeaseActive" }, 568abf25193SMax Laier { 0, NULL } 569abf25193SMax Laier }; 570abf25193SMax Laier 571a5779b6eSRui Paulo #define AGENT_SUBOPTION_CIRCUIT_ID 1 /* RFC 3046 */ 572a5779b6eSRui Paulo #define AGENT_SUBOPTION_REMOTE_ID 2 /* RFC 3046 */ 573a5779b6eSRui Paulo #define AGENT_SUBOPTION_SUBSCRIBER_ID 6 /* RFC 3993 */ 5743c602fabSXin LI static const struct tok agent_suboption_values[] = { 575abf25193SMax Laier { AGENT_SUBOPTION_CIRCUIT_ID, "Circuit-ID" }, 576a5779b6eSRui Paulo { AGENT_SUBOPTION_REMOTE_ID, "Remote-ID" }, 577a5779b6eSRui Paulo { AGENT_SUBOPTION_SUBSCRIBER_ID, "Subscriber-ID" }, 578abf25193SMax Laier { 0, NULL } 579abf25193SMax Laier }; 580abf25193SMax Laier 581abf25193SMax Laier 5824edb46e9SPaul Traina static void 5833c602fabSXin LI rfc1048_print(netdissect_options *ndo, 584*ee67461eSJoseph Mingrone const u_char *bp) 5854edb46e9SPaul Traina { 586*ee67461eSJoseph Mingrone uint16_t tag; 587*ee67461eSJoseph Mingrone u_int len; 588*ee67461eSJoseph Mingrone const char *cp; 589*ee67461eSJoseph Mingrone char c; 590abf25193SMax Laier int first, idx; 591*ee67461eSJoseph Mingrone uint8_t subopt, suboptlen; 5924edb46e9SPaul Traina 593*ee67461eSJoseph Mingrone ND_PRINT("\n\t Vendor-rfc1048 Extensions"); 5944edb46e9SPaul Traina 5954edb46e9SPaul Traina /* Step over magic cookie */ 596*ee67461eSJoseph Mingrone ND_PRINT("\n\t Magic Cookie 0x%08x", GET_BE_U_4(bp)); 5974edb46e9SPaul Traina bp += sizeof(int32_t); 5984edb46e9SPaul Traina 5994edb46e9SPaul Traina /* Loop while we there is a tag left in the buffer */ 600*ee67461eSJoseph Mingrone while (ND_TTEST_1(bp)) { 601*ee67461eSJoseph Mingrone tag = GET_U_1(bp); 602*ee67461eSJoseph Mingrone bp++; 6033c602fabSXin LI if (tag == TAG_PAD && ndo->ndo_vflag < 3) 6044edb46e9SPaul Traina continue; 6053c602fabSXin LI if (tag == TAG_END && ndo->ndo_vflag < 3) 6064edb46e9SPaul Traina return; 607*ee67461eSJoseph Mingrone cp = tok2str(tag2str, "?Unknown", tag); 6084edb46e9SPaul Traina c = *cp++; 6094edb46e9SPaul Traina 610abf25193SMax Laier if (tag == TAG_PAD || tag == TAG_END) 611abf25193SMax Laier len = 0; 612abf25193SMax Laier else { 6134edb46e9SPaul Traina /* Get the length; check for truncation */ 614*ee67461eSJoseph Mingrone len = GET_U_1(bp); 615*ee67461eSJoseph Mingrone bp++; 616abf25193SMax Laier } 617abf25193SMax Laier 618*ee67461eSJoseph Mingrone ND_PRINT("\n\t %s (%u), length %u%s", cp, tag, len, 619*ee67461eSJoseph Mingrone len > 0 ? ": " : ""); 620abf25193SMax Laier 6213c602fabSXin LI if (tag == TAG_PAD && ndo->ndo_vflag > 2) { 622abf25193SMax Laier u_int ntag = 1; 623*ee67461eSJoseph Mingrone while (ND_TTEST_1(bp) && 624*ee67461eSJoseph Mingrone GET_U_1(bp) == TAG_PAD) { 625abf25193SMax Laier bp++; 626abf25193SMax Laier ntag++; 627abf25193SMax Laier } 628abf25193SMax Laier if (ntag > 1) 629*ee67461eSJoseph Mingrone ND_PRINT(", occurs %u", ntag); 630abf25193SMax Laier } 631abf25193SMax Laier 632*ee67461eSJoseph Mingrone ND_TCHECK_LEN(bp, len); 6334edb46e9SPaul Traina 634a88113a8SBill Fenner if (tag == TAG_DHCP_MESSAGE && len == 1) { 635*ee67461eSJoseph Mingrone ND_PRINT("%s", 636*ee67461eSJoseph Mingrone tok2str(dhcp_msg_values, "Unknown (%u)", GET_U_1(bp))); 637*ee67461eSJoseph Mingrone bp++; 638a88113a8SBill Fenner continue; 639a88113a8SBill Fenner } 640a88113a8SBill Fenner 641a88113a8SBill Fenner if (tag == TAG_PARM_REQUEST) { 642abf25193SMax Laier idx = 0; 643*ee67461eSJoseph Mingrone while (len > 0) { 644*ee67461eSJoseph Mingrone uint8_t innertag = GET_U_1(bp); 645*ee67461eSJoseph Mingrone bp++; 646*ee67461eSJoseph Mingrone len--; 647*ee67461eSJoseph Mingrone cp = tok2str(tag2str, "?Unknown", innertag); 648abf25193SMax Laier if (idx % 4 == 0) 649*ee67461eSJoseph Mingrone ND_PRINT("\n\t "); 650abf25193SMax Laier else 651*ee67461eSJoseph Mingrone ND_PRINT(", "); 652*ee67461eSJoseph Mingrone ND_PRINT("%s (%u)", cp + 1, innertag); 653abf25193SMax Laier idx++; 654943ee2b1SBill Fenner } 655943ee2b1SBill Fenner continue; 656943ee2b1SBill Fenner } 657abf25193SMax Laier 6584edb46e9SPaul Traina /* Print data */ 6594edb46e9SPaul Traina if (c == '?') { 6604edb46e9SPaul Traina /* Base default formats for unknown tags on data size */ 661abf25193SMax Laier if (len & 1) 6624edb46e9SPaul Traina c = 'b'; 663abf25193SMax Laier else if (len & 2) 6644edb46e9SPaul Traina c = 's'; 6654edb46e9SPaul Traina else 6664edb46e9SPaul Traina c = 'l'; 6674edb46e9SPaul Traina } 6684edb46e9SPaul Traina first = 1; 6694edb46e9SPaul Traina switch (c) { 6704edb46e9SPaul Traina 6714edb46e9SPaul Traina case 'a': 672*ee67461eSJoseph Mingrone /* ASCII strings */ 673*ee67461eSJoseph Mingrone ND_PRINT("\""); 674*ee67461eSJoseph Mingrone if (nd_printn(ndo, bp, len, ndo->ndo_snapend)) { 675*ee67461eSJoseph Mingrone ND_PRINT("\""); 67629292c17SSam Leffler goto trunc; 67729292c17SSam Leffler } 678*ee67461eSJoseph Mingrone ND_PRINT("\""); 679abf25193SMax Laier bp += len; 680abf25193SMax Laier len = 0; 6814edb46e9SPaul Traina break; 6824edb46e9SPaul Traina 6834edb46e9SPaul Traina case 'i': 6844edb46e9SPaul Traina case 'l': 685943ee2b1SBill Fenner case 'L': 6864edb46e9SPaul Traina /* ip addresses/32-bit words */ 687*ee67461eSJoseph Mingrone while (len >= 4) { 6884edb46e9SPaul Traina if (!first) 689*ee67461eSJoseph Mingrone ND_PRINT(","); 690*ee67461eSJoseph Mingrone if (c == 'i') 691*ee67461eSJoseph Mingrone ND_PRINT("%s", GET_IPADDR_STRING(bp)); 692*ee67461eSJoseph Mingrone else if (c == 'L') 693*ee67461eSJoseph Mingrone ND_PRINT("%d", GET_BE_S_4(bp)); 6944edb46e9SPaul Traina else 695*ee67461eSJoseph Mingrone ND_PRINT("%u", GET_BE_U_4(bp)); 696*ee67461eSJoseph Mingrone bp += 4; 697*ee67461eSJoseph Mingrone len -= 4; 6984edb46e9SPaul Traina first = 0; 6994edb46e9SPaul Traina } 7004edb46e9SPaul Traina break; 7014edb46e9SPaul Traina 702a88113a8SBill Fenner case 'p': 703a88113a8SBill Fenner /* IP address pairs */ 704*ee67461eSJoseph Mingrone while (len >= 2*4) { 705a88113a8SBill Fenner if (!first) 706*ee67461eSJoseph Mingrone ND_PRINT(","); 707*ee67461eSJoseph Mingrone ND_PRINT("(%s:", GET_IPADDR_STRING(bp)); 708*ee67461eSJoseph Mingrone bp += 4; 709*ee67461eSJoseph Mingrone len -= 4; 710*ee67461eSJoseph Mingrone ND_PRINT("%s)", GET_IPADDR_STRING(bp)); 711*ee67461eSJoseph Mingrone bp += 4; 712*ee67461eSJoseph Mingrone len -= 4; 713a88113a8SBill Fenner first = 0; 714a88113a8SBill Fenner } 715a88113a8SBill Fenner break; 716a88113a8SBill Fenner 7174edb46e9SPaul Traina case 's': 7184edb46e9SPaul Traina /* shorts */ 719*ee67461eSJoseph Mingrone while (len >= 2) { 7204edb46e9SPaul Traina if (!first) 721*ee67461eSJoseph Mingrone ND_PRINT(","); 722*ee67461eSJoseph Mingrone ND_PRINT("%u", GET_BE_U_2(bp)); 723*ee67461eSJoseph Mingrone bp += 2; 724*ee67461eSJoseph Mingrone len -= 2; 7254edb46e9SPaul Traina first = 0; 7264edb46e9SPaul Traina } 7274edb46e9SPaul Traina break; 7284edb46e9SPaul Traina 729a88113a8SBill Fenner case 'B': 730a88113a8SBill Fenner /* boolean */ 731abf25193SMax Laier while (len > 0) { 732*ee67461eSJoseph Mingrone uint8_t bool_value; 733a88113a8SBill Fenner if (!first) 734*ee67461eSJoseph Mingrone ND_PRINT(","); 735*ee67461eSJoseph Mingrone bool_value = GET_U_1(bp); 736*ee67461eSJoseph Mingrone switch (bool_value) { 737a88113a8SBill Fenner case 0: 738*ee67461eSJoseph Mingrone ND_PRINT("N"); 739a88113a8SBill Fenner break; 740a88113a8SBill Fenner case 1: 741*ee67461eSJoseph Mingrone ND_PRINT("Y"); 742a88113a8SBill Fenner break; 743a88113a8SBill Fenner default: 744*ee67461eSJoseph Mingrone ND_PRINT("%u?", bool_value); 745a88113a8SBill Fenner break; 746a88113a8SBill Fenner } 747a88113a8SBill Fenner ++bp; 748abf25193SMax Laier --len; 749a88113a8SBill Fenner first = 0; 750a88113a8SBill Fenner } 751a88113a8SBill Fenner break; 752a88113a8SBill Fenner 7534edb46e9SPaul Traina case 'b': 754943ee2b1SBill Fenner case 'x': 7554edb46e9SPaul Traina default: 7564edb46e9SPaul Traina /* Bytes */ 757abf25193SMax Laier while (len > 0) { 758*ee67461eSJoseph Mingrone uint8_t byte_value; 7594edb46e9SPaul Traina if (!first) 760*ee67461eSJoseph Mingrone ND_PRINT(c == 'x' ? ":" : "."); 761*ee67461eSJoseph Mingrone byte_value = GET_U_1(bp); 762a1c2090eSBill Fenner if (c == 'x') 763*ee67461eSJoseph Mingrone ND_PRINT("%02x", byte_value); 764a1c2090eSBill Fenner else 765*ee67461eSJoseph Mingrone ND_PRINT("%u", byte_value); 7664edb46e9SPaul Traina ++bp; 767abf25193SMax Laier --len; 7684edb46e9SPaul Traina first = 0; 7694edb46e9SPaul Traina } 7704edb46e9SPaul Traina break; 771a1c2090eSBill Fenner 772a1c2090eSBill Fenner case '$': 773a1c2090eSBill Fenner /* Guys we can't handle with one of the usual cases */ 774a1c2090eSBill Fenner switch (tag) { 775a1c2090eSBill Fenner 776a1c2090eSBill Fenner case TAG_NETBIOS_NODE: 777abf25193SMax Laier /* this option should be at least 1 byte long */ 778abf25193SMax Laier if (len < 1) { 779*ee67461eSJoseph Mingrone ND_PRINT("[ERROR: length < 1 bytes]"); 780abf25193SMax Laier break; 781abf25193SMax Laier } 782*ee67461eSJoseph Mingrone tag = GET_U_1(bp); 783*ee67461eSJoseph Mingrone ++bp; 784abf25193SMax Laier --len; 785*ee67461eSJoseph Mingrone ND_PRINT("%s", tok2str(nbo2str, NULL, tag)); 786a1c2090eSBill Fenner break; 787a1c2090eSBill Fenner 788a1c2090eSBill Fenner case TAG_OPT_OVERLOAD: 789abf25193SMax Laier /* this option should be at least 1 byte long */ 790abf25193SMax Laier if (len < 1) { 791*ee67461eSJoseph Mingrone ND_PRINT("[ERROR: length < 1 bytes]"); 792abf25193SMax Laier break; 793abf25193SMax Laier } 794*ee67461eSJoseph Mingrone tag = GET_U_1(bp); 795*ee67461eSJoseph Mingrone ++bp; 796abf25193SMax Laier --len; 797*ee67461eSJoseph Mingrone ND_PRINT("%s", tok2str(oo2str, NULL, tag)); 798a1c2090eSBill Fenner break; 799a1c2090eSBill Fenner 800a1c2090eSBill Fenner case TAG_CLIENT_FQDN: 801abf25193SMax Laier /* this option should be at least 3 bytes long */ 802abf25193SMax Laier if (len < 3) { 803*ee67461eSJoseph Mingrone ND_PRINT("[ERROR: length < 3 bytes]"); 804abf25193SMax Laier bp += len; 805abf25193SMax Laier len = 0; 806cc391cceSBruce M Simpson break; 80729292c17SSam Leffler } 808*ee67461eSJoseph Mingrone if (GET_U_1(bp) & 0xf0) { 809*ee67461eSJoseph Mingrone ND_PRINT("[ERROR: MBZ nibble 0x%x != 0] ", 810*ee67461eSJoseph Mingrone (GET_U_1(bp) & 0xf0) >> 4); 811*ee67461eSJoseph Mingrone } 812*ee67461eSJoseph Mingrone if (GET_U_1(bp) & 0x0f) 813*ee67461eSJoseph Mingrone ND_PRINT("[%s] ", 814*ee67461eSJoseph Mingrone client_fqdn_flags(GET_U_1(bp))); 815abf25193SMax Laier bp++; 816*ee67461eSJoseph Mingrone if (GET_U_1(bp) || GET_U_1(bp + 1)) 817*ee67461eSJoseph Mingrone ND_PRINT("%u/%u ", GET_U_1(bp), 818*ee67461eSJoseph Mingrone GET_U_1(bp + 1)); 819a1c2090eSBill Fenner bp += 2; 820*ee67461eSJoseph Mingrone ND_PRINT("\""); 821*ee67461eSJoseph Mingrone if (nd_printn(ndo, bp, len - 3, ndo->ndo_snapend)) { 822*ee67461eSJoseph Mingrone ND_PRINT("\""); 82329292c17SSam Leffler goto trunc; 82429292c17SSam Leffler } 825*ee67461eSJoseph Mingrone ND_PRINT("\""); 826abf25193SMax Laier bp += len - 3; 827abf25193SMax Laier len = 0; 828a1c2090eSBill Fenner break; 829a1c2090eSBill Fenner 830a1c2090eSBill Fenner case TAG_CLIENT_ID: 8318bdc5a62SPatrick Kelsey { 8328bdc5a62SPatrick Kelsey int type; 833abf25193SMax Laier 834abf25193SMax Laier /* this option should be at least 1 byte long */ 835abf25193SMax Laier if (len < 1) { 836*ee67461eSJoseph Mingrone ND_PRINT("[ERROR: length < 1 bytes]"); 837abf25193SMax Laier break; 838abf25193SMax Laier } 839*ee67461eSJoseph Mingrone type = GET_U_1(bp); 840*ee67461eSJoseph Mingrone bp++; 841abf25193SMax Laier len--; 842a1c2090eSBill Fenner if (type == 0) { 843*ee67461eSJoseph Mingrone ND_PRINT("\""); 844*ee67461eSJoseph Mingrone if (nd_printn(ndo, bp, len, ndo->ndo_snapend)) { 845*ee67461eSJoseph Mingrone ND_PRINT("\""); 84629292c17SSam Leffler goto trunc; 84729292c17SSam Leffler } 848*ee67461eSJoseph Mingrone ND_PRINT("\""); 849abf25193SMax Laier bp += len; 850abf25193SMax Laier len = 0; 851a1c2090eSBill Fenner break; 852a1c2090eSBill Fenner } else { 853*ee67461eSJoseph Mingrone ND_PRINT("%s ", tok2str(arp2str, "hardware-type %u,", type)); 854abf25193SMax Laier while (len > 0) { 855a1c2090eSBill Fenner if (!first) 856*ee67461eSJoseph Mingrone ND_PRINT(":"); 857*ee67461eSJoseph Mingrone ND_PRINT("%02x", GET_U_1(bp)); 858a1c2090eSBill Fenner ++bp; 859abf25193SMax Laier --len; 860a1c2090eSBill Fenner first = 0; 861a1c2090eSBill Fenner } 862abf25193SMax Laier } 863a1c2090eSBill Fenner break; 864a1c2090eSBill Fenner } 865a1c2090eSBill Fenner 866abf25193SMax Laier case TAG_AGENT_CIRCUIT: 867abf25193SMax Laier while (len >= 2) { 868*ee67461eSJoseph Mingrone subopt = GET_U_1(bp); 869*ee67461eSJoseph Mingrone suboptlen = GET_U_1(bp + 1); 870*ee67461eSJoseph Mingrone bp += 2; 871abf25193SMax Laier len -= 2; 872abf25193SMax Laier if (suboptlen > len) { 873*ee67461eSJoseph Mingrone ND_PRINT("\n\t %s SubOption %u, length %u: length goes past end of option", 874abf25193SMax Laier tok2str(agent_suboption_values, "Unknown", subopt), 875abf25193SMax Laier subopt, 876*ee67461eSJoseph Mingrone suboptlen); 877abf25193SMax Laier bp += len; 878abf25193SMax Laier len = 0; 879abf25193SMax Laier break; 880abf25193SMax Laier } 881*ee67461eSJoseph Mingrone ND_PRINT("\n\t %s SubOption %u, length %u: ", 882abf25193SMax Laier tok2str(agent_suboption_values, "Unknown", subopt), 883abf25193SMax Laier subopt, 884*ee67461eSJoseph Mingrone suboptlen); 885abf25193SMax Laier switch (subopt) { 886abf25193SMax Laier 887a5779b6eSRui Paulo case AGENT_SUBOPTION_CIRCUIT_ID: /* fall through */ 888a5779b6eSRui Paulo case AGENT_SUBOPTION_REMOTE_ID: 889a5779b6eSRui Paulo case AGENT_SUBOPTION_SUBSCRIBER_ID: 890*ee67461eSJoseph Mingrone if (nd_printn(ndo, bp, suboptlen, ndo->ndo_snapend)) 8918bdc5a62SPatrick Kelsey goto trunc; 892abf25193SMax Laier break; 893abf25193SMax Laier 894abf25193SMax Laier default: 8953c602fabSXin LI print_unknown_data(ndo, bp, "\n\t\t", suboptlen); 896abf25193SMax Laier } 897abf25193SMax Laier 898abf25193SMax Laier len -= suboptlen; 899abf25193SMax Laier bp += suboptlen; 900abf25193SMax Laier } 901abf25193SMax Laier break; 902abf25193SMax Laier 903abf25193SMax Laier case TAG_CLASSLESS_STATIC_RT: 904abf25193SMax Laier case TAG_CLASSLESS_STA_RT_MS: 905abf25193SMax Laier { 906abf25193SMax Laier u_int mask_width, significant_octets, i; 907abf25193SMax Laier 908abf25193SMax Laier /* this option should be at least 5 bytes long */ 909abf25193SMax Laier if (len < 5) { 910*ee67461eSJoseph Mingrone ND_PRINT("[ERROR: length < 5 bytes]"); 911abf25193SMax Laier bp += len; 912abf25193SMax Laier len = 0; 913abf25193SMax Laier break; 914abf25193SMax Laier } 915abf25193SMax Laier while (len > 0) { 916abf25193SMax Laier if (!first) 917*ee67461eSJoseph Mingrone ND_PRINT(","); 918*ee67461eSJoseph Mingrone mask_width = GET_U_1(bp); 919*ee67461eSJoseph Mingrone bp++; 920abf25193SMax Laier len--; 921abf25193SMax Laier /* mask_width <= 32 */ 922abf25193SMax Laier if (mask_width > 32) { 923*ee67461eSJoseph Mingrone ND_PRINT("[ERROR: Mask width (%u) > 32]", mask_width); 924abf25193SMax Laier bp += len; 925abf25193SMax Laier len = 0; 926abf25193SMax Laier break; 927abf25193SMax Laier } 928abf25193SMax Laier significant_octets = (mask_width + 7) / 8; 929abf25193SMax Laier /* significant octets + router(4) */ 930abf25193SMax Laier if (len < significant_octets + 4) { 931*ee67461eSJoseph Mingrone ND_PRINT("[ERROR: Remaining length (%u) < %u bytes]", len, significant_octets + 4); 932abf25193SMax Laier bp += len; 933abf25193SMax Laier len = 0; 934abf25193SMax Laier break; 935abf25193SMax Laier } 936*ee67461eSJoseph Mingrone ND_PRINT("("); 937abf25193SMax Laier if (mask_width == 0) 938*ee67461eSJoseph Mingrone ND_PRINT("default"); 939abf25193SMax Laier else { 940abf25193SMax Laier for (i = 0; i < significant_octets ; i++) { 941abf25193SMax Laier if (i > 0) 942*ee67461eSJoseph Mingrone ND_PRINT("."); 943*ee67461eSJoseph Mingrone ND_PRINT("%u", 944*ee67461eSJoseph Mingrone GET_U_1(bp)); 945*ee67461eSJoseph Mingrone bp++; 946abf25193SMax Laier } 947abf25193SMax Laier for (i = significant_octets ; i < 4 ; i++) 948*ee67461eSJoseph Mingrone ND_PRINT(".0"); 949*ee67461eSJoseph Mingrone ND_PRINT("/%u", mask_width); 950abf25193SMax Laier } 951*ee67461eSJoseph Mingrone ND_PRINT(":%s)", GET_IPADDR_STRING(bp)); 952*ee67461eSJoseph Mingrone bp += 4; 953abf25193SMax Laier len -= (significant_octets + 4); 954abf25193SMax Laier first = 0; 955abf25193SMax Laier } 9568bdc5a62SPatrick Kelsey break; 9578bdc5a62SPatrick Kelsey } 9588bdc5a62SPatrick Kelsey 9598bdc5a62SPatrick Kelsey case TAG_USER_CLASS: 9608bdc5a62SPatrick Kelsey { 9618bdc5a62SPatrick Kelsey u_int suboptnumber = 1; 9628bdc5a62SPatrick Kelsey 9638bdc5a62SPatrick Kelsey first = 1; 9648bdc5a62SPatrick Kelsey if (len < 2) { 965*ee67461eSJoseph Mingrone ND_PRINT("[ERROR: length < 2 bytes]"); 9668bdc5a62SPatrick Kelsey bp += len; 9678bdc5a62SPatrick Kelsey len = 0; 9688bdc5a62SPatrick Kelsey break; 9698bdc5a62SPatrick Kelsey } 9708bdc5a62SPatrick Kelsey while (len > 0) { 971*ee67461eSJoseph Mingrone suboptlen = GET_U_1(bp); 972*ee67461eSJoseph Mingrone bp++; 9738bdc5a62SPatrick Kelsey len--; 974*ee67461eSJoseph Mingrone ND_PRINT("\n\t "); 975*ee67461eSJoseph Mingrone ND_PRINT("instance#%u: ", suboptnumber); 9768bdc5a62SPatrick Kelsey if (suboptlen == 0) { 977*ee67461eSJoseph Mingrone ND_PRINT("[ERROR: suboption length must be non-zero]"); 9788bdc5a62SPatrick Kelsey bp += len; 9798bdc5a62SPatrick Kelsey len = 0; 9808bdc5a62SPatrick Kelsey break; 9818bdc5a62SPatrick Kelsey } 9828bdc5a62SPatrick Kelsey if (len < suboptlen) { 983*ee67461eSJoseph Mingrone ND_PRINT("[ERROR: invalid option]"); 9848bdc5a62SPatrick Kelsey bp += len; 9858bdc5a62SPatrick Kelsey len = 0; 9868bdc5a62SPatrick Kelsey break; 9878bdc5a62SPatrick Kelsey } 988*ee67461eSJoseph Mingrone ND_PRINT("\""); 989*ee67461eSJoseph Mingrone if (nd_printn(ndo, bp, suboptlen, ndo->ndo_snapend)) { 990*ee67461eSJoseph Mingrone ND_PRINT("\""); 9918bdc5a62SPatrick Kelsey goto trunc; 9928bdc5a62SPatrick Kelsey } 993*ee67461eSJoseph Mingrone ND_PRINT("\""); 994*ee67461eSJoseph Mingrone ND_PRINT(", length %u", suboptlen); 9958bdc5a62SPatrick Kelsey suboptnumber++; 9968bdc5a62SPatrick Kelsey len -= suboptlen; 9978bdc5a62SPatrick Kelsey bp += suboptlen; 998abf25193SMax Laier } 999abf25193SMax Laier break; 10008bdc5a62SPatrick Kelsey } 1001abf25193SMax Laier 1002a1c2090eSBill Fenner default: 1003*ee67461eSJoseph Mingrone ND_PRINT("[unknown special tag %u, size %u]", 1004*ee67461eSJoseph Mingrone tag, len); 1005abf25193SMax Laier bp += len; 1006abf25193SMax Laier len = 0; 1007a1c2090eSBill Fenner break; 1008a1c2090eSBill Fenner } 1009a1c2090eSBill Fenner break; 10104edb46e9SPaul Traina } 10114edb46e9SPaul Traina /* Data left over? */ 1012abf25193SMax Laier if (len) { 1013*ee67461eSJoseph Mingrone ND_PRINT("\n\t trailing data length %u", len); 1014abf25193SMax Laier bp += len; 1015cc391cceSBruce M Simpson } 10164edb46e9SPaul Traina } 1017943ee2b1SBill Fenner return; 1018943ee2b1SBill Fenner trunc: 1019*ee67461eSJoseph Mingrone nd_print_trunc(ndo); 10204edb46e9SPaul Traina } 10214edb46e9SPaul Traina 1022*ee67461eSJoseph Mingrone #define PRINTCMUADDR(m, s) { ND_TCHECK_4(cmu->m); \ 1023*ee67461eSJoseph Mingrone if (GET_IPV4_TO_NETWORK_ORDER(cmu->m) != 0) \ 1024*ee67461eSJoseph Mingrone ND_PRINT(" %s:%s", s, GET_IPADDR_STRING(cmu->m)); } 1025*ee67461eSJoseph Mingrone 10264edb46e9SPaul Traina static void 10273c602fabSXin LI cmu_print(netdissect_options *ndo, 1028*ee67461eSJoseph Mingrone const u_char *bp) 10294edb46e9SPaul Traina { 1030*ee67461eSJoseph Mingrone const struct cmu_vend *cmu; 1031*ee67461eSJoseph Mingrone uint8_t v_flags; 10324edb46e9SPaul Traina 1033*ee67461eSJoseph Mingrone ND_PRINT(" vend-cmu"); 1034a1c2090eSBill Fenner cmu = (const struct cmu_vend *)bp; 10354edb46e9SPaul Traina 10364edb46e9SPaul Traina /* Only print if there are unknown bits */ 1037*ee67461eSJoseph Mingrone ND_TCHECK_4(cmu->v_flags); 1038*ee67461eSJoseph Mingrone v_flags = GET_U_1(cmu->v_flags); 1039*ee67461eSJoseph Mingrone if ((v_flags & ~(VF_SMASK)) != 0) 1040*ee67461eSJoseph Mingrone ND_PRINT(" F:0x%x", v_flags); 10414edb46e9SPaul Traina PRINTCMUADDR(v_dgate, "DG"); 1042*ee67461eSJoseph Mingrone PRINTCMUADDR(v_smask, v_flags & VF_SMASK ? "SM" : "SM*"); 10434edb46e9SPaul Traina PRINTCMUADDR(v_dns1, "NS1"); 10444edb46e9SPaul Traina PRINTCMUADDR(v_dns2, "NS2"); 10454edb46e9SPaul Traina PRINTCMUADDR(v_ins1, "IEN1"); 10464edb46e9SPaul Traina PRINTCMUADDR(v_ins2, "IEN2"); 10474edb46e9SPaul Traina PRINTCMUADDR(v_ts1, "TS1"); 10484edb46e9SPaul Traina PRINTCMUADDR(v_ts2, "TS2"); 10494edb46e9SPaul Traina return; 10504edb46e9SPaul Traina 10514edb46e9SPaul Traina trunc: 1052*ee67461eSJoseph Mingrone nd_print_trunc(ndo); 10534edb46e9SPaul Traina } 1054abf25193SMax Laier 1055*ee67461eSJoseph Mingrone #undef PRINTCMUADDR 1056*ee67461eSJoseph Mingrone 1057abf25193SMax Laier static char * 1058abf25193SMax Laier client_fqdn_flags(u_int flags) 1059abf25193SMax Laier { 1060abf25193SMax Laier static char buf[8+1]; 1061abf25193SMax Laier int i = 0; 1062abf25193SMax Laier 1063abf25193SMax Laier if (flags & CLIENT_FQDN_FLAGS_S) 1064abf25193SMax Laier buf[i++] = 'S'; 1065abf25193SMax Laier if (flags & CLIENT_FQDN_FLAGS_O) 1066abf25193SMax Laier buf[i++] = 'O'; 1067abf25193SMax Laier if (flags & CLIENT_FQDN_FLAGS_E) 1068abf25193SMax Laier buf[i++] = 'E'; 1069abf25193SMax Laier if (flags & CLIENT_FQDN_FLAGS_N) 1070abf25193SMax Laier buf[i++] = 'N'; 1071abf25193SMax Laier buf[i] = '\0'; 1072abf25193SMax Laier 1073abf25193SMax Laier return buf; 1074abf25193SMax Laier } 1075