print-bootp.c (39300) | print-bootp.c (56896) |
---|---|
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 --- 5 unchanged lines hidden (view full) --- 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 * Format and print bootp packets. | 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 --- 5 unchanged lines hidden (view full) --- 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 * Format and print bootp packets. |
22 * 23 * $FreeBSD: head/contrib/tcpdump/print-bootp.c 56896 2000-01-30 01:05:24Z fenner $ |
|
22 */ 23#ifndef lint 24static const char rcsid[] = | 24 */ 25#ifndef lint 26static const char rcsid[] = |
25 "@(#) $Header: print-bootp.c,v 1.46 98/07/18 13:33:58 leres Exp $ (LBL)"; | 27 "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.48 1999/11/21 09:36:49 fenner Exp $ (LBL)"; |
26#endif 27 | 28#endif 29 |
30#ifdef HAVE_CONFIG_H 31#include "config.h" 32#endif 33 |
|
28#include <sys/param.h> 29#include <sys/time.h> 30#include <sys/socket.h> 31 32#if __STDC__ 33struct mbuf; 34struct rtentry; 35#endif --- 61 unchanged lines hidden (view full) --- 97 98 /* Only print interesting fields */ 99 if (bp->bp_hops) 100 printf(" hops:%d", bp->bp_hops); 101 if (bp->bp_xid) 102 printf(" xid:0x%x", (u_int32_t)ntohl(bp->bp_xid)); 103 if (bp->bp_secs) 104 printf(" secs:%d", ntohs(bp->bp_secs)); | 34#include <sys/param.h> 35#include <sys/time.h> 36#include <sys/socket.h> 37 38#if __STDC__ 39struct mbuf; 40struct rtentry; 41#endif --- 61 unchanged lines hidden (view full) --- 103 104 /* Only print interesting fields */ 105 if (bp->bp_hops) 106 printf(" hops:%d", bp->bp_hops); 107 if (bp->bp_xid) 108 printf(" xid:0x%x", (u_int32_t)ntohl(bp->bp_xid)); 109 if (bp->bp_secs) 110 printf(" secs:%d", ntohs(bp->bp_secs)); |
111 if (bp->bp_flags) 112 printf(" flags:0x%x", ntohs(bp->bp_flags)); |
|
105 106 /* Client's ip address */ 107 TCHECK(bp->bp_ciaddr); 108 if (bp->bp_ciaddr.s_addr) 109 printf(" C:%s", ipaddr_string(&bp->bp_ciaddr)); 110 111 /* 'your' ip address (bootp client) */ 112 TCHECK(bp->bp_yiaddr); --- 89 unchanged lines hidden (view full) --- 202 { TAG_BOOTSIZE, "sBS" }, /* 512 byte blocks */ 203 { TAG_END, " END" }, 204/* RFC1497 tags */ 205 { TAG_DUMPPATH, "aDP" }, 206 { TAG_DOMAINNAME, "aDN" }, 207 { TAG_SWAP_SERVER, "iSS" }, 208 { TAG_ROOTPATH, "aRP" }, 209 { TAG_EXTPATH, "aEP" }, | 113 114 /* Client's ip address */ 115 TCHECK(bp->bp_ciaddr); 116 if (bp->bp_ciaddr.s_addr) 117 printf(" C:%s", ipaddr_string(&bp->bp_ciaddr)); 118 119 /* 'your' ip address (bootp client) */ 120 TCHECK(bp->bp_yiaddr); --- 89 unchanged lines hidden (view full) --- 210 { TAG_BOOTSIZE, "sBS" }, /* 512 byte blocks */ 211 { TAG_END, " END" }, 212/* RFC1497 tags */ 213 { TAG_DUMPPATH, "aDP" }, 214 { TAG_DOMAINNAME, "aDN" }, 215 { TAG_SWAP_SERVER, "iSS" }, 216 { TAG_ROOTPATH, "aRP" }, 217 { TAG_EXTPATH, "aEP" }, |
218/* RFC2132 tags */ 219 { TAG_IP_FORWARD, "BIPF" }, 220 { TAG_NL_SRCRT, "BSRT" }, 221 { TAG_PFILTERS, "pPF" }, 222 { TAG_REASS_SIZE, "sRSZ" }, 223 { TAG_DEF_TTL, "bTTL" }, 224 { TAG_MTU_TIMEOUT, "lMA" }, 225 { TAG_MTU_TABLE, "sMT" }, 226 { TAG_INT_MTU, "sMTU" }, 227 { TAG_LOCAL_SUBNETS, "BLSN" }, 228 { TAG_BROAD_ADDR, "iBR" }, 229 { TAG_DO_MASK_DISC, "BMD" }, 230 { TAG_SUPPLY_MASK, "BMS" }, 231 { TAG_DO_RDISC, "BRD" }, 232 { TAG_RTR_SOL_ADDR, "iRSA" }, 233 { TAG_STATIC_ROUTE, "pSR" }, 234 { TAG_USE_TRAILERS, "BUT" }, 235 { TAG_ARP_TIMEOUT, "lAT" }, 236 { TAG_ETH_ENCAP, "BIE" }, 237 { TAG_TCP_TTL, "bTT" }, 238 { TAG_TCP_KEEPALIVE, "lKI" }, 239 { TAG_KEEPALIVE_GO, "BKG" }, 240 { TAG_NIS_DOMAIN, "aYD" }, 241 { TAG_NIS_SERVERS, "iYS" }, 242 { TAG_NTP_SERVERS, "iNTP" }, 243 { TAG_VENDOR_OPTS, "bVO" }, 244 { TAG_NETBIOS_NS, "iWNS" }, 245 { TAG_NETBIOS_DDS, "iWDD" }, 246 { TAG_NETBIOS_NODE, "bWNT" }, 247 { TAG_NETBIOS_SCOPE, "aWSC" }, 248 { TAG_XWIN_FS, "iXFS" }, 249 { TAG_XWIN_DM, "iXDM" }, 250 { TAG_NIS_P_DOMAIN, "sN+D" }, 251 { TAG_NIS_P_SERVERS, "iN+S" }, 252 { TAG_MOBILE_HOME, "iMH" }, 253 { TAG_SMPT_SERVER, "iSMTP" }, 254 { TAG_POP3_SERVER, "iPOP3" }, 255 { TAG_NNTP_SERVER, "iNNTP" }, 256 { TAG_WWW_SERVER, "iWWW" }, 257 { TAG_FINGER_SERVER, "iFG" }, 258 { TAG_IRC_SERVER, "iIRC" }, 259 { TAG_STREETTALK_SRVR, "iSTS" }, 260 { TAG_STREETTALK_STDA, "iSTDA" }, 261 { TAG_REQUESTED_IP, "iRQ" }, 262 { TAG_IP_LEASE, "lLT" }, 263 { TAG_OPT_OVERLOAD, "bOO" }, 264 { TAG_TFTP_SERVER, "aTFTP" }, 265 { TAG_BOOTFILENAME, "aBF" }, 266 { TAG_DHCP_MESSAGE, " DHCP" }, 267 { TAG_SERVER_ID, "iSID" }, 268 { TAG_PARM_REQUEST, "bPR" }, 269 { TAG_MESSAGE, "aMSG" }, 270 { TAG_MAX_MSG_SIZE, "sMSZ" }, 271 { TAG_RENEWAL_TIME, "lRN" }, 272 { TAG_REBIND_TIME, "lRB" }, 273 { TAG_VENDOR_CLASS, "bVC" }, 274 { TAG_CLIENT_ID, "bCID" }, |
|
210 { 0, NULL } 211}; 212 213static void 214rfc1048_print(register const u_char *bp, register u_int length) 215{ 216 register u_char tag; 217 register u_int len, size; --- 25 unchanged lines hidden (view full) --- 243 return; 244 } 245 len = *bp++; 246 if (bp + len >= snapend) { 247 fputs(tstr, stdout); 248 return; 249 } 250 | 275 { 0, NULL } 276}; 277 278static void 279rfc1048_print(register const u_char *bp, register u_int length) 280{ 281 register u_char tag; 282 register u_int len, size; --- 25 unchanged lines hidden (view full) --- 308 return; 309 } 310 len = *bp++; 311 if (bp + len >= snapend) { 312 fputs(tstr, stdout); 313 return; 314 } 315 |
316 if (tag == TAG_DHCP_MESSAGE && len == 1) { 317 c = *bp++; 318 switch (c) { 319 case DHCPDISCOVER: printf("DISCOVER"); break; 320 case DHCPOFFER: printf("OFFER"); break; 321 case DHCPREQUEST: printf("REQUEST"); break; 322 case DHCPDECLINE: printf("DECLINE"); break; 323 case DHCPACK: printf("ACK"); break; 324 case DHCPNAK: printf("NACK"); break; 325 case DHCPRELEASE: printf("RELEASE"); break; 326 case DHCPINFORM: printf("INFORM"); break; 327 default: printf("%u", c); break; 328 } 329 continue; 330 } 331 332 if (tag == TAG_PARM_REQUEST) { 333 first = 1; 334 while (len-- > 0) { 335 c = *bp++; 336 cp = tok2str(tag2str, "?%d", c); 337 if (!first) 338 putchar('+'); 339 printf("%s", cp + 1); 340 first = 0; 341 } 342 continue; 343 } 344 |
|
251 /* Print data */ 252 size = len; 253 if (c == '?') { 254 /* Base default formats for unknown tags on data size */ 255 if (size & 1) 256 c = 'b'; 257 else if (size & 2) 258 c = 's'; --- 24 unchanged lines hidden (view full) --- 283 else 284 printf("%u", ul); 285 bp += sizeof(ul); 286 size -= sizeof(ul); 287 first = 0; 288 } 289 break; 290 | 345 /* Print data */ 346 size = len; 347 if (c == '?') { 348 /* Base default formats for unknown tags on data size */ 349 if (size & 1) 350 c = 'b'; 351 else if (size & 2) 352 c = 's'; --- 24 unchanged lines hidden (view full) --- 377 else 378 printf("%u", ul); 379 bp += sizeof(ul); 380 size -= sizeof(ul); 381 first = 0; 382 } 383 break; 384 |
385 case 'p': 386 /* IP address pairs */ 387 while (size >= 2*sizeof(ul)) { 388 if (!first) 389 putchar(','); 390 memcpy((char *)&ul, (char *)bp, sizeof(ul)); 391 printf("(%s:", ipaddr_string(&ul)); 392 bp += sizeof(ul); 393 memcpy((char *)&ul, (char *)bp, sizeof(ul)); 394 printf("%s)", ipaddr_string(&ul)); 395 bp += sizeof(ul); 396 size -= 2*sizeof(ul); 397 first = 0; 398 } 399 break; 400 |
|
291 case 's': 292 /* shorts */ 293 while (size >= sizeof(us)) { 294 if (!first) 295 putchar(','); 296 memcpy((char *)&us, (char *)bp, sizeof(us)); 297 printf("%d", us); 298 bp += sizeof(us); 299 size -= sizeof(us); 300 first = 0; 301 } 302 break; 303 | 401 case 's': 402 /* shorts */ 403 while (size >= sizeof(us)) { 404 if (!first) 405 putchar(','); 406 memcpy((char *)&us, (char *)bp, sizeof(us)); 407 printf("%d", us); 408 bp += sizeof(us); 409 size -= sizeof(us); 410 first = 0; 411 } 412 break; 413 |
414 case 'B': 415 /* boolean */ 416 while (size > 0) { 417 if (!first) 418 putchar(','); 419 switch (*bp) { 420 case 0: 421 putchar('N'); 422 break; 423 case 1: 424 putchar('Y'); 425 break; 426 default: 427 printf("%d?", *bp); 428 break; 429 } 430 ++bp; 431 --size; 432 first = 0; 433 } 434 break; 435 |
|
304 case 'b': 305 default: 306 /* Bytes */ 307 while (size > 0) { 308 if (!first) 309 putchar('.'); 310 printf("%d", *bp); 311 ++bp; --- 42 unchanged lines hidden --- | 436 case 'b': 437 default: 438 /* Bytes */ 439 while (size > 0) { 440 if (!first) 441 putchar('.'); 442 printf("%d", *bp); 443 ++bp; --- 42 unchanged lines hidden --- |