print-bootp.c (147904) | print-bootp.c (172686) |
---|---|
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 --- 6 unchanged lines hidden (view full) --- 15 * or promote products derived from this software without specific prior 16 * written permission. 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 * Format and print bootp packets. 22 * | 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 --- 6 unchanged lines hidden (view full) --- 15 * or promote products derived from this software without specific prior 16 * written permission. 17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 * 21 * Format and print bootp packets. 22 * |
23 * $FreeBSD: head/contrib/tcpdump/print-bootp.c 147904 2005-07-11 04:14:02Z sam $ | 23 * $FreeBSD: head/contrib/tcpdump/print-bootp.c 172686 2007-10-16 02:31:48Z mlaier $ |
24 */ 25#ifndef lint 26static const char rcsid[] _U_ = | 24 */ 25#ifndef lint 26static const char rcsid[] _U_ = |
27 "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.78.2.2 2005/05/06 04:19:39 guy Exp $ (LBL)"; | 27 "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.78.2.9 2007/08/21 22:02:08 guy Exp $ (LBL)"; |
28#endif 29 30#ifdef HAVE_CONFIG_H 31#include "config.h" 32#endif 33 34#include <tcpdump-stdinc.h> 35 36#include <stdio.h> 37#include <string.h> 38 39#include "interface.h" 40#include "addrtoname.h" 41#include "extract.h" 42#include "ether.h" 43#include "bootp.h" 44 45static void rfc1048_print(const u_char *); 46static void cmu_print(const u_char *); | 28#endif 29 30#ifdef HAVE_CONFIG_H 31#include "config.h" 32#endif 33 34#include <tcpdump-stdinc.h> 35 36#include <stdio.h> 37#include <string.h> 38 39#include "interface.h" 40#include "addrtoname.h" 41#include "extract.h" 42#include "ether.h" 43#include "bootp.h" 44 45static void rfc1048_print(const u_char *); 46static void cmu_print(const u_char *); |
47static char *client_fqdn_flags(u_int flags); |
|
47 48static char tstr[] = " [|bootp]"; 49 50static const struct tok bootp_flag_values[] = { 51 { 0x8000, "Broadcast" }, 52 { 0, NULL} 53}; 54 --- 19 unchanged lines hidden (view full) --- 74 printf("BOOTP/DHCP, %s", 75 tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op)); 76 77 if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) { 78 TCHECK2(bp->bp_chaddr[0], 6); 79 printf(" from %s", etheraddr_string(bp->bp_chaddr)); 80 } 81 | 48 49static char tstr[] = " [|bootp]"; 50 51static const struct tok bootp_flag_values[] = { 52 { 0x8000, "Broadcast" }, 53 { 0, NULL} 54}; 55 --- 19 unchanged lines hidden (view full) --- 75 printf("BOOTP/DHCP, %s", 76 tok2str(bootp_op_values, "unknown (0x%02x)", bp->bp_op)); 77 78 if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) { 79 TCHECK2(bp->bp_chaddr[0], 6); 80 printf(" from %s", etheraddr_string(bp->bp_chaddr)); 81 } 82 |
82 printf(", length: %u", length); | 83 printf(", length %u", length); |
83 84 if (!vflag) 85 return; 86 87 TCHECK(bp->bp_secs); 88 89 /* The usual hardware address type is 1 (10Mb Ethernet) */ 90 if (bp->bp_htype != 1) | 84 85 if (!vflag) 86 return; 87 88 TCHECK(bp->bp_secs); 89 90 /* The usual hardware address type is 1 (10Mb Ethernet) */ 91 if (bp->bp_htype != 1) |
91 printf(", htype-#%d", bp->bp_htype); | 92 printf(", htype %d", bp->bp_htype); |
92 93 /* The usual length for 10Mb Ethernet address is 6 bytes */ 94 if (bp->bp_htype != 1 || bp->bp_hlen != 6) | 93 94 /* The usual length for 10Mb Ethernet address is 6 bytes */ 95 if (bp->bp_htype != 1 || bp->bp_hlen != 6) |
95 printf(", hlen:%d", bp->bp_hlen); | 96 printf(", hlen %d", bp->bp_hlen); |
96 97 /* Only print interesting fields */ 98 if (bp->bp_hops) | 97 98 /* Only print interesting fields */ 99 if (bp->bp_hops) |
99 printf(", hops:%d", bp->bp_hops); | 100 printf(", hops %d", bp->bp_hops); |
100 if (bp->bp_xid) | 101 if (bp->bp_xid) |
101 printf(", xid:0x%x", EXTRACT_32BITS(&bp->bp_xid)); | 102 printf(", xid 0x%x", EXTRACT_32BITS(&bp->bp_xid)); |
102 if (bp->bp_secs) | 103 if (bp->bp_secs) |
103 printf(", secs:%d", EXTRACT_16BITS(&bp->bp_secs)); | 104 printf(", secs %d", EXTRACT_16BITS(&bp->bp_secs)); |
104 | 105 |
105 printf(", flags: [%s]", 106 bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags))); 107 if (vflag>1) 108 printf( " (0x%04x)", EXTRACT_16BITS(&bp->bp_flags)); | 106 printf(", Flags [%s]", 107 bittok2str(bootp_flag_values, "none", EXTRACT_16BITS(&bp->bp_flags))); 108 if (vflag > 1) 109 printf(" (0x%04x)", EXTRACT_16BITS(&bp->bp_flags)); |
109 110 /* Client's ip address */ 111 TCHECK(bp->bp_ciaddr); 112 if (bp->bp_ciaddr.s_addr) | 110 111 /* Client's ip address */ 112 TCHECK(bp->bp_ciaddr); 113 if (bp->bp_ciaddr.s_addr) |
113 printf("\n\t Client IP: %s", ipaddr_string(&bp->bp_ciaddr)); | 114 printf("\n\t Client-IP %s", ipaddr_string(&bp->bp_ciaddr)); |
114 115 /* 'your' ip address (bootp client) */ 116 TCHECK(bp->bp_yiaddr); 117 if (bp->bp_yiaddr.s_addr) | 115 116 /* 'your' ip address (bootp client) */ 117 TCHECK(bp->bp_yiaddr); 118 if (bp->bp_yiaddr.s_addr) |
118 printf("\n\t Your IP: %s", ipaddr_string(&bp->bp_yiaddr)); | 119 printf("\n\t Your-IP %s", ipaddr_string(&bp->bp_yiaddr)); |
119 120 /* Server's ip address */ 121 TCHECK(bp->bp_siaddr); 122 if (bp->bp_siaddr.s_addr) | 120 121 /* Server's ip address */ 122 TCHECK(bp->bp_siaddr); 123 if (bp->bp_siaddr.s_addr) |
123 printf("\n\t Server IP: %s", ipaddr_string(&bp->bp_siaddr)); | 124 printf("\n\t Server-IP %s", ipaddr_string(&bp->bp_siaddr)); |
124 125 /* Gateway's ip address */ 126 TCHECK(bp->bp_giaddr); 127 if (bp->bp_giaddr.s_addr) | 125 126 /* Gateway's ip address */ 127 TCHECK(bp->bp_giaddr); 128 if (bp->bp_giaddr.s_addr) |
128 printf("\n\t Gateway IP: %s", ipaddr_string(&bp->bp_giaddr)); | 129 printf("\n\t Gateway-IP %s", ipaddr_string(&bp->bp_giaddr)); |
129 130 /* Client's Ethernet address */ 131 if (bp->bp_htype == 1 && bp->bp_hlen == 6) { 132 TCHECK2(bp->bp_chaddr[0], 6); | 130 131 /* Client's Ethernet address */ 132 if (bp->bp_htype == 1 && bp->bp_hlen == 6) { 133 TCHECK2(bp->bp_chaddr[0], 6); |
133 printf("\n\t Client Ethernet Address: %s", etheraddr_string(bp->bp_chaddr)); | 134 printf("\n\t Client-Ethernet-Address %s", etheraddr_string(bp->bp_chaddr)); |
134 } 135 136 TCHECK2(bp->bp_sname[0], 1); /* check first char only */ 137 if (*bp->bp_sname) { 138 printf("\n\t sname \""); 139 if (fn_print(bp->bp_sname, snapend)) { 140 putchar('"'); 141 fputs(tstr + 1, stdout); --- 44 unchanged lines hidden (view full) --- 186 * x - colon-seperated hex bytes (variable length) 187 * a - ascii string (variable length) 188 * B - on/off (8 bits) 189 * $ - special (explicit code to handle) 190 */ 191static struct tok tag2str[] = { 192/* RFC1048 tags */ 193 { TAG_PAD, " PAD" }, | 135 } 136 137 TCHECK2(bp->bp_sname[0], 1); /* check first char only */ 138 if (*bp->bp_sname) { 139 printf("\n\t sname \""); 140 if (fn_print(bp->bp_sname, snapend)) { 141 putchar('"'); 142 fputs(tstr + 1, stdout); --- 44 unchanged lines hidden (view full) --- 187 * x - colon-seperated hex bytes (variable length) 188 * a - ascii string (variable length) 189 * B - on/off (8 bits) 190 * $ - special (explicit code to handle) 191 */ 192static struct tok tag2str[] = { 193/* RFC1048 tags */ 194 { TAG_PAD, " PAD" }, |
194 { TAG_SUBNET_MASK, "iSM" }, /* subnet mask (RFC950) */ 195 { TAG_TIME_OFFSET, "LTZ" }, /* seconds from UTC */ 196 { TAG_GATEWAY, "iDG" }, /* default gateway */ 197 { TAG_TIME_SERVER, "iTS" }, /* time servers (RFC868) */ 198 { TAG_NAME_SERVER, "iIEN" }, /* IEN name servers (IEN116) */ 199 { TAG_DOMAIN_SERVER, "iNS" }, /* domain name (RFC1035) */ | 195 { TAG_SUBNET_MASK, "iSubnet-Mask" }, /* subnet mask (RFC950) */ 196 { TAG_TIME_OFFSET, "LTime-Zone" }, /* seconds from UTC */ 197 { TAG_GATEWAY, "iDefault-Gateway" }, /* default gateway */ 198 { TAG_TIME_SERVER, "iTime-Server" }, /* time servers (RFC868) */ 199 { TAG_NAME_SERVER, "iIEN-Name-Server" }, /* IEN name servers (IEN116) */ 200 { TAG_DOMAIN_SERVER, "iDomain-Name-Server" }, /* domain name (RFC1035) */ |
200 { TAG_LOG_SERVER, "iLOG" }, /* MIT log servers */ 201 { TAG_COOKIE_SERVER, "iCS" }, /* cookie servers (RFC865) */ | 201 { TAG_LOG_SERVER, "iLOG" }, /* MIT log servers */ 202 { TAG_COOKIE_SERVER, "iCS" }, /* cookie servers (RFC865) */ |
202 { TAG_LPR_SERVER, "iLPR" }, /* lpr server (RFC1179) */ | 203 { TAG_LPR_SERVER, "iLPR-Server" }, /* lpr server (RFC1179) */ |
203 { TAG_IMPRESS_SERVER, "iIM" }, /* impress servers (Imagen) */ 204 { TAG_RLP_SERVER, "iRL" }, /* resource location (RFC887) */ | 204 { TAG_IMPRESS_SERVER, "iIM" }, /* impress servers (Imagen) */ 205 { TAG_RLP_SERVER, "iRL" }, /* resource location (RFC887) */ |
205 { TAG_HOSTNAME, "aHN" }, /* ascii hostname */ | 206 { TAG_HOSTNAME, "aHostname" }, /* ascii hostname */ |
206 { TAG_BOOTSIZE, "sBS" }, /* 512 byte blocks */ 207 { TAG_END, " END" }, 208/* RFC1497 tags */ 209 { TAG_DUMPPATH, "aDP" }, | 207 { TAG_BOOTSIZE, "sBS" }, /* 512 byte blocks */ 208 { TAG_END, " END" }, 209/* RFC1497 tags */ 210 { TAG_DUMPPATH, "aDP" }, |
210 { TAG_DOMAINNAME, "aDN" }, | 211 { TAG_DOMAINNAME, "aDomain-Name" }, |
211 { TAG_SWAP_SERVER, "iSS" }, 212 { TAG_ROOTPATH, "aRP" }, 213 { TAG_EXTPATH, "aEP" }, 214/* RFC2132 tags */ 215 { TAG_IP_FORWARD, "BIPF" }, 216 { TAG_NL_SRCRT, "BSRT" }, 217 { TAG_PFILTERS, "pPF" }, 218 { TAG_REASS_SIZE, "sRSZ" }, 219 { TAG_DEF_TTL, "bTTL" }, | 212 { TAG_SWAP_SERVER, "iSS" }, 213 { TAG_ROOTPATH, "aRP" }, 214 { TAG_EXTPATH, "aEP" }, 215/* RFC2132 tags */ 216 { TAG_IP_FORWARD, "BIPF" }, 217 { TAG_NL_SRCRT, "BSRT" }, 218 { TAG_PFILTERS, "pPF" }, 219 { TAG_REASS_SIZE, "sRSZ" }, 220 { TAG_DEF_TTL, "bTTL" }, |
220 { TAG_MTU_TIMEOUT, "lMA" }, 221 { TAG_MTU_TABLE, "sMT" }, | 221 { TAG_MTU_TIMEOUT, "lMTU-Timeout" }, 222 { TAG_MTU_TABLE, "sMTU-Table" }, |
222 { TAG_INT_MTU, "sMTU" }, 223 { TAG_LOCAL_SUBNETS, "BLSN" }, 224 { TAG_BROAD_ADDR, "iBR" }, 225 { TAG_DO_MASK_DISC, "BMD" }, 226 { TAG_SUPPLY_MASK, "BMS" }, | 223 { TAG_INT_MTU, "sMTU" }, 224 { TAG_LOCAL_SUBNETS, "BLSN" }, 225 { TAG_BROAD_ADDR, "iBR" }, 226 { TAG_DO_MASK_DISC, "BMD" }, 227 { TAG_SUPPLY_MASK, "BMS" }, |
227 { TAG_DO_RDISC, "BRD" }, | 228 { TAG_DO_RDISC, "BRouter-Discovery" }, |
228 { TAG_RTR_SOL_ADDR, "iRSA" }, | 229 { TAG_RTR_SOL_ADDR, "iRSA" }, |
229 { TAG_STATIC_ROUTE, "pSR" }, | 230 { TAG_STATIC_ROUTE, "pStatic-Route" }, |
230 { TAG_USE_TRAILERS, "BUT" }, 231 { TAG_ARP_TIMEOUT, "lAT" }, 232 { TAG_ETH_ENCAP, "BIE" }, 233 { TAG_TCP_TTL, "bTT" }, 234 { TAG_TCP_KEEPALIVE, "lKI" }, 235 { TAG_KEEPALIVE_GO, "BKG" }, 236 { TAG_NIS_DOMAIN, "aYD" }, 237 { TAG_NIS_SERVERS, "iYS" }, 238 { TAG_NTP_SERVERS, "iNTP" }, | 231 { TAG_USE_TRAILERS, "BUT" }, 232 { TAG_ARP_TIMEOUT, "lAT" }, 233 { TAG_ETH_ENCAP, "BIE" }, 234 { TAG_TCP_TTL, "bTT" }, 235 { TAG_TCP_KEEPALIVE, "lKI" }, 236 { TAG_KEEPALIVE_GO, "BKG" }, 237 { TAG_NIS_DOMAIN, "aYD" }, 238 { TAG_NIS_SERVERS, "iYS" }, 239 { TAG_NTP_SERVERS, "iNTP" }, |
239 { TAG_VENDOR_OPTS, "bVO" }, 240 { TAG_NETBIOS_NS, "iWNS" }, | 240 { TAG_VENDOR_OPTS, "bVendor-Option" }, 241 { TAG_NETBIOS_NS, "iNetbios-Name-Server" }, |
241 { TAG_NETBIOS_DDS, "iWDD" }, | 242 { TAG_NETBIOS_DDS, "iWDD" }, |
242 { TAG_NETBIOS_NODE, "$WNT" }, 243 { TAG_NETBIOS_SCOPE, "aWSC" }, | 243 { TAG_NETBIOS_NODE, "$Netbios-Node" }, 244 { TAG_NETBIOS_SCOPE, "aNetbios-Scope" }, |
244 { TAG_XWIN_FS, "iXFS" }, 245 { TAG_XWIN_DM, "iXDM" }, 246 { TAG_NIS_P_DOMAIN, "sN+D" }, 247 { TAG_NIS_P_SERVERS, "iN+S" }, 248 { TAG_MOBILE_HOME, "iMH" }, 249 { TAG_SMPT_SERVER, "iSMTP" }, 250 { TAG_POP3_SERVER, "iPOP3" }, 251 { TAG_NNTP_SERVER, "iNNTP" }, 252 { TAG_WWW_SERVER, "iWWW" }, 253 { TAG_FINGER_SERVER, "iFG" }, 254 { TAG_IRC_SERVER, "iIRC" }, 255 { TAG_STREETTALK_SRVR, "iSTS" }, 256 { TAG_STREETTALK_STDA, "iSTDA" }, | 245 { TAG_XWIN_FS, "iXFS" }, 246 { TAG_XWIN_DM, "iXDM" }, 247 { TAG_NIS_P_DOMAIN, "sN+D" }, 248 { TAG_NIS_P_SERVERS, "iN+S" }, 249 { TAG_MOBILE_HOME, "iMH" }, 250 { TAG_SMPT_SERVER, "iSMTP" }, 251 { TAG_POP3_SERVER, "iPOP3" }, 252 { TAG_NNTP_SERVER, "iNNTP" }, 253 { TAG_WWW_SERVER, "iWWW" }, 254 { TAG_FINGER_SERVER, "iFG" }, 255 { TAG_IRC_SERVER, "iIRC" }, 256 { TAG_STREETTALK_SRVR, "iSTS" }, 257 { TAG_STREETTALK_STDA, "iSTDA" }, |
257 { TAG_REQUESTED_IP, "iRQ" }, 258 { TAG_IP_LEASE, "lLT" }, | 258 { TAG_REQUESTED_IP, "iRequested-IP" }, 259 { TAG_IP_LEASE, "lLease-Time" }, |
259 { TAG_OPT_OVERLOAD, "$OO" }, 260 { TAG_TFTP_SERVER, "aTFTP" }, 261 { TAG_BOOTFILENAME, "aBF" }, | 260 { TAG_OPT_OVERLOAD, "$OO" }, 261 { TAG_TFTP_SERVER, "aTFTP" }, 262 { TAG_BOOTFILENAME, "aBF" }, |
262 { TAG_DHCP_MESSAGE, " DHCP" }, 263 { TAG_SERVER_ID, "iSID" }, 264 { TAG_PARM_REQUEST, "bPR" }, | 263 { TAG_DHCP_MESSAGE, " DHCP-Message" }, 264 { TAG_SERVER_ID, "iServer-ID" }, 265 { TAG_PARM_REQUEST, "bParameter-Request" }, |
265 { TAG_MESSAGE, "aMSG" }, 266 { TAG_MAX_MSG_SIZE, "sMSZ" }, 267 { TAG_RENEWAL_TIME, "lRN" }, 268 { TAG_REBIND_TIME, "lRB" }, | 266 { TAG_MESSAGE, "aMSG" }, 267 { TAG_MAX_MSG_SIZE, "sMSZ" }, 268 { TAG_RENEWAL_TIME, "lRN" }, 269 { TAG_REBIND_TIME, "lRB" }, |
269 { TAG_VENDOR_CLASS, "aVC" }, 270 { TAG_CLIENT_ID, "$CID" }, | 270 { TAG_VENDOR_CLASS, "aVendor-Class" }, 271 { TAG_CLIENT_ID, "$Client-ID" }, |
271/* RFC 2485 */ 272 { TAG_OPEN_GROUP_UAP, "aUAP" }, 273/* RFC 2563 */ 274 { TAG_DISABLE_AUTOCONF, "BNOAUTO" }, 275/* RFC 2610 */ 276 { TAG_SLP_DA, "bSLP-DA" }, /*"b" is a little wrong */ 277 { TAG_SLP_SCOPE, "bSLP-SCOPE" }, /*"b" is a little wrong */ 278/* RFC 2937 */ 279 { TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */ 280/* RFC 3011 */ 281 { TAG_IP4_SUBNET_SELECT, "iSUBNET" }, | 272/* RFC 2485 */ 273 { TAG_OPEN_GROUP_UAP, "aUAP" }, 274/* RFC 2563 */ 275 { TAG_DISABLE_AUTOCONF, "BNOAUTO" }, 276/* RFC 2610 */ 277 { TAG_SLP_DA, "bSLP-DA" }, /*"b" is a little wrong */ 278 { TAG_SLP_SCOPE, "bSLP-SCOPE" }, /*"b" is a little wrong */ 279/* RFC 2937 */ 280 { TAG_NS_SEARCH, "sNSSEARCH" }, /* XXX 's' */ 281/* RFC 3011 */ 282 { TAG_IP4_SUBNET_SELECT, "iSUBNET" }, |
283/* RFC 3442 */ 284 { TAG_CLASSLESS_STATIC_RT, "$Classless-Static-Route" }, 285 { TAG_CLASSLESS_STA_RT_MS, "$Classless-Static-Route-Microsoft" }, |
|
282/* http://www.iana.org/assignments/bootp-dhcp-extensions/index.htm */ 283 { TAG_USER_CLASS, "aCLASS" }, 284 { TAG_SLP_NAMING_AUTH, "aSLP-NA" }, 285 { TAG_CLIENT_FQDN, "$FQDN" }, | 286/* http://www.iana.org/assignments/bootp-dhcp-extensions/index.htm */ 287 { TAG_USER_CLASS, "aCLASS" }, 288 { TAG_SLP_NAMING_AUTH, "aSLP-NA" }, 289 { TAG_CLIENT_FQDN, "$FQDN" }, |
286 { TAG_AGENT_CIRCUIT, "bACKT" }, | 290 { TAG_AGENT_CIRCUIT, "$Agent-Information" }, |
287 { TAG_AGENT_REMOTE, "bARMT" }, 288 { TAG_AGENT_MASK, "bAMSK" }, 289 { TAG_TZ_STRING, "aTZSTR" }, 290 { TAG_FQDN_OPTION, "bFQDNS" }, /* XXX 'b' */ 291 { TAG_AUTH, "bAUTH" }, /* XXX 'b' */ 292 { TAG_VINES_SERVERS, "iVINES" }, 293 { TAG_SERVER_RANK, "sRANK" }, 294 { TAG_CLIENT_ARCH, "sARCH" }, --- 38 unchanged lines hidden (view full) --- 333 { 0x6, "ieee802" }, 334 { 0x7, "arcnet" }, 335 { 0xf, "frelay" }, 336 { 0x17, "strip" }, 337 { 0x18, "ieee1394" }, 338 { 0, NULL } 339}; 340 | 291 { TAG_AGENT_REMOTE, "bARMT" }, 292 { TAG_AGENT_MASK, "bAMSK" }, 293 { TAG_TZ_STRING, "aTZSTR" }, 294 { TAG_FQDN_OPTION, "bFQDNS" }, /* XXX 'b' */ 295 { TAG_AUTH, "bAUTH" }, /* XXX 'b' */ 296 { TAG_VINES_SERVERS, "iVINES" }, 297 { TAG_SERVER_RANK, "sRANK" }, 298 { TAG_CLIENT_ARCH, "sARCH" }, --- 38 unchanged lines hidden (view full) --- 337 { 0x6, "ieee802" }, 338 { 0x7, "arcnet" }, 339 { 0xf, "frelay" }, 340 { 0x17, "strip" }, 341 { 0x18, "ieee1394" }, 342 { 0, NULL } 343}; 344 |
345static struct tok dhcp_msg_values[] = { 346 { DHCPDISCOVER, "Discover" }, 347 { DHCPOFFER, "Offer" }, 348 { DHCPREQUEST, "Request" }, 349 { DHCPDECLINE, "Decline" }, 350 { DHCPACK, "ACK" }, 351 { DHCPNAK, "NACK" }, 352 { DHCPRELEASE, "Release" }, 353 { DHCPINFORM, "Inform" }, 354 { 0, NULL } 355}; 356 357#define AGENT_SUBOPTION_CIRCUIT_ID 1 358static struct tok agent_suboption_values[] = { 359 { AGENT_SUBOPTION_CIRCUIT_ID, "Circuit-ID" }, 360 { 0, NULL } 361}; 362 363 |
|
341static void 342rfc1048_print(register const u_char *bp) 343{ 344 register u_int16_t tag; | 364static void 365rfc1048_print(register const u_char *bp) 366{ 367 register u_int16_t tag; |
345 register u_int len, size; | 368 register u_int len; |
346 register const char *cp; 347 register char c; | 369 register const char *cp; 370 register char c; |
348 int first; | 371 int first, idx; |
349 u_int32_t ul; 350 u_int16_t us; | 372 u_int32_t ul; 373 u_int16_t us; |
351 u_int8_t uc; | 374 u_int8_t uc, subopt, suboptlen; |
352 | 375 |
353 printf("\n\t Vendor-rfc1048:"); | 376 printf("\n\t Vendor-rfc1048 Extensions"); |
354 355 /* Step over magic cookie */ | 377 378 /* Step over magic cookie */ |
379 printf("\n\t Magic Cookie 0x%08x", EXTRACT_32BITS(bp)); |
|
356 bp += sizeof(int32_t); 357 358 /* Loop while we there is a tag left in the buffer */ | 380 bp += sizeof(int32_t); 381 382 /* Loop while we there is a tag left in the buffer */ |
359 while (bp + 1 < snapend) { | 383 while (TTEST2(*bp, 1)) { |
360 tag = *bp++; | 384 tag = *bp++; |
361 if (tag == TAG_PAD) | 385 if (tag == TAG_PAD && vflag < 3) |
362 continue; | 386 continue; |
363 if (tag == TAG_END) | 387 if (tag == TAG_END && vflag < 3) |
364 return; 365 if (tag == TAG_EXTENDED_OPTION) { 366 TCHECK2(*(bp + 1), 2); 367 tag = EXTRACT_16BITS(bp + 1); 368 /* XXX we don't know yet if the IANA will 369 * preclude overlap of 1-byte and 2-byte spaces. 370 * If not, we need to offset tag after this step. 371 */ 372 cp = tok2str(xtag2str, "?xT%u", tag); 373 } else 374 cp = tok2str(tag2str, "?T%u", tag); 375 c = *cp++; | 388 return; 389 if (tag == TAG_EXTENDED_OPTION) { 390 TCHECK2(*(bp + 1), 2); 391 tag = EXTRACT_16BITS(bp + 1); 392 /* XXX we don't know yet if the IANA will 393 * preclude overlap of 1-byte and 2-byte spaces. 394 * If not, we need to offset tag after this step. 395 */ 396 cp = tok2str(xtag2str, "?xT%u", tag); 397 } else 398 cp = tok2str(tag2str, "?T%u", tag); 399 c = *cp++; |
376 printf("\n\t %s:", cp); | |
377 | 400 |
378 /* Get the length; check for truncation */ 379 if (bp + 1 >= snapend) { 380 fputs(tstr, stdout); 381 return; | 401 if (tag == TAG_PAD || tag == TAG_END) 402 len = 0; 403 else { 404 /* Get the length; check for truncation */ 405 TCHECK2(*bp, 1); 406 len = *bp++; |
382 } | 407 } |
383 len = *bp++; 384 if (bp + len >= snapend) { 385 printf("[|bootp %u]", len); | 408 409 printf("\n\t %s Option %u, length %u%s", cp, tag, len, 410 len > 0 ? ": " : ""); 411 412 if (tag == TAG_PAD && vflag > 2) { 413 u_int ntag = 1; 414 while (TTEST2(*bp, 1) && *bp == TAG_PAD) { 415 bp++; 416 ntag++; 417 } 418 if (ntag > 1) 419 printf(", occurs %u", ntag); 420 } 421 422 if (!TTEST2(*bp, len)) { 423 printf("[|rfc1048 %u]", len); |
386 return; 387 } 388 389 if (tag == TAG_DHCP_MESSAGE && len == 1) { 390 uc = *bp++; | 424 return; 425 } 426 427 if (tag == TAG_DHCP_MESSAGE && len == 1) { 428 uc = *bp++; |
391 switch (uc) { 392 case DHCPDISCOVER: printf("DISCOVER"); break; 393 case DHCPOFFER: printf("OFFER"); break; 394 case DHCPREQUEST: printf("REQUEST"); break; 395 case DHCPDECLINE: printf("DECLINE"); break; 396 case DHCPACK: printf("ACK"); break; 397 case DHCPNAK: printf("NACK"); break; 398 case DHCPRELEASE: printf("RELEASE"); break; 399 case DHCPINFORM: printf("INFORM"); break; 400 default: printf("%u", uc); break; 401 } 402 continue; | 429 printf("%s", tok2str(dhcp_msg_values, "Unknown (%u)", uc)); 430 continue; |
403 } 404 405 if (tag == TAG_PARM_REQUEST) { | 431 } 432 433 if (tag == TAG_PARM_REQUEST) { |
406 first = 1; | 434 idx = 0; |
407 while (len-- > 0) { 408 uc = *bp++; | 435 while (len-- > 0) { 436 uc = *bp++; |
409 cp = tok2str(tag2str, "?T%u", uc); 410 if (!first) 411 putchar('+'); | 437 cp = tok2str(tag2str, "?Option %u", uc); 438 if (idx % 4 == 0) 439 printf("\n\t "); 440 else 441 printf(", "); |
412 printf("%s", cp + 1); | 442 printf("%s", cp + 1); |
413 first = 0; | 443 idx++; |
414 } 415 continue; 416 } | 444 } 445 continue; 446 } |
447 |
|
417 if (tag == TAG_EXTENDED_REQUEST) { 418 first = 1; 419 while (len > 1) { 420 len -= 2; 421 us = EXTRACT_16BITS(bp); 422 bp += 2; 423 cp = tok2str(xtag2str, "?xT%u", us); 424 if (!first) 425 putchar('+'); 426 printf("%s", cp + 1); 427 first = 0; 428 } 429 continue; 430 } 431 432 /* Print data */ | 448 if (tag == TAG_EXTENDED_REQUEST) { 449 first = 1; 450 while (len > 1) { 451 len -= 2; 452 us = EXTRACT_16BITS(bp); 453 bp += 2; 454 cp = tok2str(xtag2str, "?xT%u", us); 455 if (!first) 456 putchar('+'); 457 printf("%s", cp + 1); 458 first = 0; 459 } 460 continue; 461 } 462 463 /* Print data */ |
433 size = len; | |
434 if (c == '?') { 435 /* Base default formats for unknown tags on data size */ | 464 if (c == '?') { 465 /* Base default formats for unknown tags on data size */ |
436 if (size & 1) | 466 if (len & 1) |
437 c = 'b'; | 467 c = 'b'; |
438 else if (size & 2) | 468 else if (len & 2) |
439 c = 's'; 440 else 441 c = 'l'; 442 } 443 first = 1; 444 switch (c) { 445 446 case 'a': 447 /* ascii strings */ 448 putchar('"'); | 469 c = 's'; 470 else 471 c = 'l'; 472 } 473 first = 1; 474 switch (c) { 475 476 case 'a': 477 /* ascii strings */ 478 putchar('"'); |
449 if (fn_printn(bp, size, snapend)) { | 479 if (fn_printn(bp, len, snapend)) { |
450 putchar('"'); 451 goto trunc; 452 } 453 putchar('"'); | 480 putchar('"'); 481 goto trunc; 482 } 483 putchar('"'); |
454 bp += size; 455 size = 0; | 484 bp += len; 485 len = 0; |
456 break; 457 458 case 'i': 459 case 'l': 460 case 'L': 461 /* ip addresses/32-bit words */ | 486 break; 487 488 case 'i': 489 case 'l': 490 case 'L': 491 /* ip addresses/32-bit words */ |
462 while (size >= sizeof(ul)) { | 492 while (len >= sizeof(ul)) { |
463 if (!first) 464 putchar(','); 465 ul = EXTRACT_32BITS(bp); 466 if (c == 'i') { 467 ul = htonl(ul); 468 printf("%s", ipaddr_string(&ul)); 469 } else if (c == 'L') 470 printf("%d", ul); 471 else 472 printf("%u", ul); 473 bp += sizeof(ul); | 493 if (!first) 494 putchar(','); 495 ul = EXTRACT_32BITS(bp); 496 if (c == 'i') { 497 ul = htonl(ul); 498 printf("%s", ipaddr_string(&ul)); 499 } else if (c == 'L') 500 printf("%d", ul); 501 else 502 printf("%u", ul); 503 bp += sizeof(ul); |
474 size -= sizeof(ul); | 504 len -= sizeof(ul); |
475 first = 0; 476 } 477 break; 478 479 case 'p': 480 /* IP address pairs */ | 505 first = 0; 506 } 507 break; 508 509 case 'p': 510 /* IP address pairs */ |
481 while (size >= 2*sizeof(ul)) { | 511 while (len >= 2*sizeof(ul)) { |
482 if (!first) 483 putchar(','); 484 memcpy((char *)&ul, (const char *)bp, sizeof(ul)); 485 printf("(%s:", ipaddr_string(&ul)); 486 bp += sizeof(ul); 487 memcpy((char *)&ul, (const char *)bp, sizeof(ul)); 488 printf("%s)", ipaddr_string(&ul)); 489 bp += sizeof(ul); | 512 if (!first) 513 putchar(','); 514 memcpy((char *)&ul, (const char *)bp, sizeof(ul)); 515 printf("(%s:", ipaddr_string(&ul)); 516 bp += sizeof(ul); 517 memcpy((char *)&ul, (const char *)bp, sizeof(ul)); 518 printf("%s)", ipaddr_string(&ul)); 519 bp += sizeof(ul); |
490 size -= 2*sizeof(ul); | 520 len -= 2*sizeof(ul); |
491 first = 0; 492 } 493 break; 494 495 case 's': 496 /* shorts */ | 521 first = 0; 522 } 523 break; 524 525 case 's': 526 /* shorts */ |
497 while (size >= sizeof(us)) { | 527 while (len >= sizeof(us)) { |
498 if (!first) 499 putchar(','); 500 us = EXTRACT_16BITS(bp); 501 printf("%u", us); 502 bp += sizeof(us); | 528 if (!first) 529 putchar(','); 530 us = EXTRACT_16BITS(bp); 531 printf("%u", us); 532 bp += sizeof(us); |
503 size -= sizeof(us); | 533 len -= sizeof(us); |
504 first = 0; 505 } 506 break; 507 508 case 'B': 509 /* boolean */ | 534 first = 0; 535 } 536 break; 537 538 case 'B': 539 /* boolean */ |
510 while (size > 0) { | 540 while (len > 0) { |
511 if (!first) 512 putchar(','); 513 switch (*bp) { 514 case 0: 515 putchar('N'); 516 break; 517 case 1: 518 putchar('Y'); 519 break; 520 default: 521 printf("%u?", *bp); 522 break; 523 } 524 ++bp; | 541 if (!first) 542 putchar(','); 543 switch (*bp) { 544 case 0: 545 putchar('N'); 546 break; 547 case 1: 548 putchar('Y'); 549 break; 550 default: 551 printf("%u?", *bp); 552 break; 553 } 554 ++bp; |
525 --size; | 555 --len; |
526 first = 0; 527 } 528 break; 529 530 case 'b': 531 case 'x': 532 default: 533 /* Bytes */ | 556 first = 0; 557 } 558 break; 559 560 case 'b': 561 case 'x': 562 default: 563 /* Bytes */ |
534 while (size > 0) { | 564 while (len > 0) { |
535 if (!first) 536 putchar(c == 'x' ? ':' : '.'); 537 if (c == 'x') 538 printf("%02x", *bp); 539 else 540 printf("%u", *bp); 541 ++bp; | 565 if (!first) 566 putchar(c == 'x' ? ':' : '.'); 567 if (c == 'x') 568 printf("%02x", *bp); 569 else 570 printf("%u", *bp); 571 ++bp; |
542 --size; | 572 --len; |
543 first = 0; 544 } 545 break; 546 547 case '$': 548 /* Guys we can't handle with one of the usual cases */ 549 switch (tag) { 550 551 case TAG_NETBIOS_NODE: | 573 first = 0; 574 } 575 break; 576 577 case '$': 578 /* Guys we can't handle with one of the usual cases */ 579 switch (tag) { 580 581 case TAG_NETBIOS_NODE: |
582 /* this option should be at least 1 byte long */ 583 if (len < 1) { 584 printf("ERROR: option %u len %u < 1 bytes", 585 TAG_NETBIOS_NODE, len); 586 bp += len; 587 len = 0; 588 break; 589 } |
|
552 tag = *bp++; | 590 tag = *bp++; |
553 --size; | 591 --len; |
554 fputs(tok2str(nbo2str, NULL, tag), stdout); 555 break; 556 557 case TAG_OPT_OVERLOAD: | 592 fputs(tok2str(nbo2str, NULL, tag), stdout); 593 break; 594 595 case TAG_OPT_OVERLOAD: |
596 /* this option should be at least 1 byte long */ 597 if (len < 1) { 598 printf("ERROR: option %u len %u < 1 bytes", 599 TAG_OPT_OVERLOAD, len); 600 bp += len; 601 len = 0; 602 break; 603 } |
|
558 tag = *bp++; | 604 tag = *bp++; |
559 --size; | 605 --len; |
560 fputs(tok2str(oo2str, NULL, tag), stdout); 561 break; 562 563 case TAG_CLIENT_FQDN: | 606 fputs(tok2str(oo2str, NULL, tag), stdout); 607 break; 608 609 case TAG_CLIENT_FQDN: |
564 /* option 81 should be at least 4 bytes long */ 565 if (len < 4) { 566 printf("ERROR: options 81 len %u < 4 bytes", len); | 610 /* this option should be at least 3 bytes long */ 611 if (len < 3) { 612 printf("ERROR: option %u len %u < 3 bytes", 613 TAG_CLIENT_FQDN, len); 614 bp += len; 615 len = 0; |
567 break; 568 } | 616 break; 617 } |
569 if (*bp++) 570 printf("[svrreg]"); | |
571 if (*bp) | 618 if (*bp) |
572 printf("%u/%u/", *bp, *(bp+1)); | 619 printf("[%s] ", client_fqdn_flags(*bp)); 620 bp++; 621 if (*bp || *(bp+1)) 622 printf("%u/%u ", *bp, *(bp+1)); |
573 bp += 2; 574 putchar('"'); | 623 bp += 2; 624 putchar('"'); |
575 if (fn_printn(bp, size - 3, snapend)) { | 625 if (fn_printn(bp, len - 3, snapend)) { |
576 putchar('"'); 577 goto trunc; 578 } 579 putchar('"'); | 626 putchar('"'); 627 goto trunc; 628 } 629 putchar('"'); |
580 bp += size - 3; 581 size = 0; | 630 bp += len - 3; 631 len = 0; |
582 break; 583 584 case TAG_CLIENT_ID: | 632 break; 633 634 case TAG_CLIENT_ID: |
585 { int type = *bp++; 586 size--; | 635 { int type; 636 637 /* this option should be at least 1 byte long */ 638 if (len < 1) { 639 printf("ERROR: option %u len %u < 1 bytes", 640 TAG_CLIENT_ID, len); 641 bp += len; 642 len = 0; 643 break; 644 } 645 type = *bp++; 646 len--; |
587 if (type == 0) { 588 putchar('"'); | 647 if (type == 0) { 648 putchar('"'); |
589 if (fn_printn(bp, size, snapend)) { | 649 if (fn_printn(bp, len, snapend)) { |
590 putchar('"'); 591 goto trunc; 592 } 593 putchar('"'); | 650 putchar('"'); 651 goto trunc; 652 } 653 putchar('"'); |
594 bp += size; 595 size = 0; | 654 bp += len; 655 len = 0; |
596 break; 597 } else { | 656 break; 657 } else { |
598 printf("[%s]", tok2str(arp2str, "type-%d", type)); | 658 printf("%s ", tok2str(arp2str, "hardware-type %u,", type)); 659 while (len > 0) { 660 if (!first) 661 putchar(':'); 662 printf("%02x", *bp); 663 ++bp; 664 --len; 665 first = 0; 666 } |
599 } | 667 } |
600 while (size > 0) { | 668 break; 669 } 670 671 case TAG_AGENT_CIRCUIT: 672 while (len >= 2) { 673 subopt = *bp++; 674 suboptlen = *bp++; 675 len -= 2; 676 if (suboptlen > len) { 677 printf("\n\t %s SubOption %u, length %u: length goes past end of option", 678 tok2str(agent_suboption_values, "Unknown", subopt), 679 subopt, 680 suboptlen); 681 bp += len; 682 len = 0; 683 break; 684 } 685 printf("\n\t %s SubOption %u, length %u: ", 686 tok2str(agent_suboption_values, "Unknown", subopt), 687 subopt, 688 suboptlen); 689 switch (subopt) { 690 691 case AGENT_SUBOPTION_CIRCUIT_ID: 692 fn_printn(bp, suboptlen, NULL); 693 break; 694 695 default: 696 print_unknown_data(bp, "\n\t\t", suboptlen); 697 } 698 699 len -= suboptlen; 700 bp += suboptlen; 701 } 702 break; 703 704 case TAG_CLASSLESS_STATIC_RT: 705 case TAG_CLASSLESS_STA_RT_MS: 706 { 707 u_int mask_width, significant_octets, i; 708 709 /* this option should be at least 5 bytes long */ 710 if (len < 5) { 711 printf("ERROR: option %u len %u < 5 bytes", 712 TAG_CLASSLESS_STATIC_RT, len); 713 bp += len; 714 len = 0; 715 break; 716 } 717 while (len > 0) { |
601 if (!first) | 718 if (!first) |
602 putchar(':'); 603 printf("%02x", *bp); 604 ++bp; 605 --size; | 719 putchar(','); 720 mask_width = *bp++; 721 len--; 722 /* mask_width <= 32 */ 723 if (mask_width > 32) { 724 printf("[ERROR: Mask width (%d) > 32]", mask_width); 725 bp += len; 726 len = 0; 727 break; 728 } 729 significant_octets = (mask_width + 7) / 8; 730 /* significant octets + router(4) */ 731 if (len < significant_octets + 4) { 732 printf("[ERROR: Remaining length (%u) < %u bytes]", len, significant_octets + 4); 733 bp += len; 734 len = 0; 735 break; 736 } 737 putchar('('); 738 if (mask_width == 0) 739 printf("default"); 740 else { 741 for (i = 0; i < significant_octets ; i++) { 742 if (i > 0) 743 putchar('.'); 744 printf("%d", *bp++); 745 } 746 for (i = significant_octets ; i < 4 ; i++) 747 printf(".0"); 748 printf("/%d", mask_width); 749 } 750 memcpy((char *)&ul, (const char *)bp, sizeof(ul)); 751 printf(":%s)", ipaddr_string(&ul)); 752 bp += sizeof(ul); 753 len -= (significant_octets + 4); |
606 first = 0; 607 } | 754 first = 0; 755 } |
608 break; 609 } | 756 } 757 break; |
610 611 default: 612 printf("[unknown special tag %u, size %u]", | 758 759 default: 760 printf("[unknown special tag %u, size %u]", |
613 tag, size); 614 bp += size; 615 size = 0; | 761 tag, len); 762 bp += len; 763 len = 0; |
616 break; 617 } 618 break; 619 } 620 /* Data left over? */ | 764 break; 765 } 766 break; 767 } 768 /* Data left over? */ |
621 if (size) { 622 printf("[len %u]", len); 623 bp += size; | 769 if (len) { 770 printf("\n\t trailing data length %u", len); 771 bp += len; |
624 } 625 } 626 return; 627trunc: 628 printf("|[rfc1048]"); 629} 630 631static void --- 21 unchanged lines hidden (view full) --- 653 PRINTCMUADDR(v_ts1, "TS1"); 654 PRINTCMUADDR(v_ts2, "TS2"); 655 return; 656 657trunc: 658 fputs(tstr, stdout); 659#undef PRINTCMUADDR 660} | 772 } 773 } 774 return; 775trunc: 776 printf("|[rfc1048]"); 777} 778 779static void --- 21 unchanged lines hidden (view full) --- 801 PRINTCMUADDR(v_ts1, "TS1"); 802 PRINTCMUADDR(v_ts2, "TS2"); 803 return; 804 805trunc: 806 fputs(tstr, stdout); 807#undef PRINTCMUADDR 808} |
809 810static char * 811client_fqdn_flags(u_int flags) 812{ 813 static char buf[8+1]; 814 int i = 0; 815 816 if (flags & CLIENT_FQDN_FLAGS_S) 817 buf[i++] = 'S'; 818 if (flags & CLIENT_FQDN_FLAGS_O) 819 buf[i++] = 'O'; 820 if (flags & CLIENT_FQDN_FLAGS_E) 821 buf[i++] = 'E'; 822 if (flags & CLIENT_FQDN_FLAGS_N) 823 buf[i++] = 'N'; 824 buf[i] = '\0'; 825 826 return buf; 827} |
|