print-bootp.c 30 KB

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