print-bootp.c (98527) | print-bootp.c (111729) |
---|---|
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 98527 2002-06-21 00:49:02Z fenner $ | 23 * $FreeBSD: head/contrib/tcpdump/print-bootp.c 111729 2003-03-02 08:25:48Z fenner $ |
24 */ 25#ifndef lint 26static const char rcsid[] = | 24 */ 25#ifndef lint 26static const char rcsid[] = |
27 "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.60 2001/09/17 21:57:56 fenner Exp $ (LBL)"; | 27 "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.60.4.2 2002/06/01 23:51:11 guy Exp $ (LBL)"; |
28#endif 29 30#ifdef HAVE_CONFIG_H 31#include "config.h" 32#endif 33 34#include <sys/param.h> 35#include <sys/time.h> 36#include <sys/socket.h> 37 | 28#endif 29 30#ifdef HAVE_CONFIG_H 31#include "config.h" 32#endif 33 34#include <sys/param.h> 35#include <sys/time.h> 36#include <sys/socket.h> 37 |
38struct mbuf; 39struct rtentry; 40 | |
41#include <netinet/in.h> 42 43#include <ctype.h> 44#include <stdio.h> 45#include <string.h> 46 47#include "interface.h" 48#include "addrtoname.h" --- 297 unchanged lines hidden (view full) --- 346 { 0x17, "strip" }, 347 { 0x18, "ieee1394" }, 348 { 0, NULL } 349}; 350 351static void 352rfc1048_print(register const u_char *bp) 353{ | 38#include <netinet/in.h> 39 40#include <ctype.h> 41#include <stdio.h> 42#include <string.h> 43 44#include "interface.h" 45#include "addrtoname.h" --- 297 unchanged lines hidden (view full) --- 343 { 0x17, "strip" }, 344 { 0x18, "ieee1394" }, 345 { 0, NULL } 346}; 347 348static void 349rfc1048_print(register const u_char *bp) 350{ |
354 register u_char tag; | 351 register u_int16_t tag; |
355 register u_int len, size; 356 register const char *cp; 357 register char c; 358 int first; 359 u_int32_t ul; | 352 register u_int len, size; 353 register const char *cp; 354 register char c; 355 int first; 356 u_int32_t ul; |
360 u_short us; | 357 u_int16_t us; 358 u_int8_t uc; |
361 362 printf(" vend-rfc1048"); 363 364 /* Step over magic cookie */ 365 bp += sizeof(int32_t); 366 367 /* Loop while we there is a tag left in the buffer */ 368 while (bp + 1 < snapend) { --- 4 unchanged lines hidden (view full) --- 373 return; 374 if (tag == TAG_EXTENDED_OPTION) { 375 TCHECK2(*(bp + 1), 2); 376 tag = EXTRACT_16BITS(bp + 1); 377 /* XXX we don't know yet if the IANA will 378 * preclude overlap of 1-byte and 2-byte spaces. 379 * If not, we need to offset tag after this step. 380 */ | 359 360 printf(" vend-rfc1048"); 361 362 /* Step over magic cookie */ 363 bp += sizeof(int32_t); 364 365 /* Loop while we there is a tag left in the buffer */ 366 while (bp + 1 < snapend) { --- 4 unchanged lines hidden (view full) --- 371 return; 372 if (tag == TAG_EXTENDED_OPTION) { 373 TCHECK2(*(bp + 1), 2); 374 tag = EXTRACT_16BITS(bp + 1); 375 /* XXX we don't know yet if the IANA will 376 * preclude overlap of 1-byte and 2-byte spaces. 377 * If not, we need to offset tag after this step. 378 */ |
381 cp = tok2str(xtag2str, "?xT%d", tag); | 379 cp = tok2str(xtag2str, "?xT%u", tag); |
382 } else | 380 } else |
383 cp = tok2str(tag2str, "?T%d", tag); | 381 cp = tok2str(tag2str, "?T%u", tag); |
384 c = *cp++; 385 printf(" %s:", cp); 386 387 /* Get the length; check for truncation */ 388 if (bp + 1 >= snapend) { 389 fputs(tstr, stdout); 390 return; 391 } 392 len = *bp++; 393 if (bp + len >= snapend) { 394 fputs(tstr, stdout); 395 return; 396 } 397 398 if (tag == TAG_DHCP_MESSAGE && len == 1) { | 382 c = *cp++; 383 printf(" %s:", cp); 384 385 /* Get the length; check for truncation */ 386 if (bp + 1 >= snapend) { 387 fputs(tstr, stdout); 388 return; 389 } 390 len = *bp++; 391 if (bp + len >= snapend) { 392 fputs(tstr, stdout); 393 return; 394 } 395 396 if (tag == TAG_DHCP_MESSAGE && len == 1) { |
399 c = *bp++; 400 switch (c) { | 397 uc = *bp++; 398 switch (uc) { |
401 case DHCPDISCOVER: printf("DISCOVER"); break; 402 case DHCPOFFER: printf("OFFER"); break; 403 case DHCPREQUEST: printf("REQUEST"); break; 404 case DHCPDECLINE: printf("DECLINE"); break; 405 case DHCPACK: printf("ACK"); break; 406 case DHCPNAK: printf("NACK"); break; 407 case DHCPRELEASE: printf("RELEASE"); break; 408 case DHCPINFORM: printf("INFORM"); break; | 399 case DHCPDISCOVER: printf("DISCOVER"); break; 400 case DHCPOFFER: printf("OFFER"); break; 401 case DHCPREQUEST: printf("REQUEST"); break; 402 case DHCPDECLINE: printf("DECLINE"); break; 403 case DHCPACK: printf("ACK"); break; 404 case DHCPNAK: printf("NACK"); break; 405 case DHCPRELEASE: printf("RELEASE"); break; 406 case DHCPINFORM: printf("INFORM"); break; |
409 default: printf("%u", c); break; | 407 default: printf("%u", uc); break; |
410 } 411 continue; 412 } 413 414 if (tag == TAG_PARM_REQUEST) { 415 first = 1; 416 while (len-- > 0) { | 408 } 409 continue; 410 } 411 412 if (tag == TAG_PARM_REQUEST) { 413 first = 1; 414 while (len-- > 0) { |
417 c = *bp++; 418 cp = tok2str(tag2str, "?T%d", c); | 415 uc = *bp++; 416 cp = tok2str(tag2str, "?T%u", uc); |
419 if (!first) 420 putchar('+'); 421 printf("%s", cp + 1); 422 first = 0; 423 } 424 continue; 425 } 426 if (tag == TAG_EXTENDED_REQUEST) { 427 first = 1; 428 while (len > 1) { 429 len -= 2; | 417 if (!first) 418 putchar('+'); 419 printf("%s", cp + 1); 420 first = 0; 421 } 422 continue; 423 } 424 if (tag == TAG_EXTENDED_REQUEST) { 425 first = 1; 426 while (len > 1) { 427 len -= 2; |
430 c = EXTRACT_16BITS(bp); | 428 us = EXTRACT_16BITS(bp); |
431 bp += 2; | 429 bp += 2; |
432 cp = tok2str(xtag2str, "?xT%d", c); | 430 cp = tok2str(xtag2str, "?xT%u", us); |
433 if (!first) 434 putchar('+'); 435 printf("%s", cp + 1); 436 first = 0; 437 } 438 continue; 439 } 440 --- 58 unchanged lines hidden (view full) --- 499 break; 500 501 case 's': 502 /* shorts */ 503 while (size >= sizeof(us)) { 504 if (!first) 505 putchar(','); 506 us = EXTRACT_16BITS(bp); | 431 if (!first) 432 putchar('+'); 433 printf("%s", cp + 1); 434 first = 0; 435 } 436 continue; 437 } 438 --- 58 unchanged lines hidden (view full) --- 497 break; 498 499 case 's': 500 /* shorts */ 501 while (size >= sizeof(us)) { 502 if (!first) 503 putchar(','); 504 us = EXTRACT_16BITS(bp); |
507 printf("%d", us); | 505 printf("%u", us); |
508 bp += sizeof(us); 509 size -= sizeof(us); 510 first = 0; 511 } 512 break; 513 514 case 'B': 515 /* boolean */ 516 while (size > 0) { 517 if (!first) 518 putchar(','); 519 switch (*bp) { 520 case 0: 521 putchar('N'); 522 break; 523 case 1: 524 putchar('Y'); 525 break; 526 default: | 506 bp += sizeof(us); 507 size -= sizeof(us); 508 first = 0; 509 } 510 break; 511 512 case 'B': 513 /* boolean */ 514 while (size > 0) { 515 if (!first) 516 putchar(','); 517 switch (*bp) { 518 case 0: 519 putchar('N'); 520 break; 521 case 1: 522 putchar('Y'); 523 break; 524 default: |
527 printf("%d?", *bp); | 525 printf("%u?", *bp); |
528 break; 529 } 530 ++bp; 531 --size; 532 first = 0; 533 } 534 break; 535 536 case 'b': 537 case 'x': 538 default: 539 /* Bytes */ 540 while (size > 0) { 541 if (!first) 542 putchar(c == 'x' ? ':' : '.'); 543 if (c == 'x') 544 printf("%02x", *bp); 545 else | 526 break; 527 } 528 ++bp; 529 --size; 530 first = 0; 531 } 532 break; 533 534 case 'b': 535 case 'x': 536 default: 537 /* Bytes */ 538 while (size > 0) { 539 if (!first) 540 putchar(c == 'x' ? ':' : '.'); 541 if (c == 'x') 542 printf("%02x", *bp); 543 else |
546 printf("%d", *bp); | 544 printf("%u", *bp); |
547 ++bp; 548 --size; 549 first = 0; 550 } 551 break; 552 553 case '$': 554 /* Guys we can't handle with one of the usual cases */ --- 10 unchanged lines hidden (view full) --- 565 --size; 566 fputs(tok2str(oo2str, NULL, tag), stdout); 567 break; 568 569 case TAG_CLIENT_FQDN: 570 if (*bp++) 571 printf("[svrreg]"); 572 if (*bp) | 545 ++bp; 546 --size; 547 first = 0; 548 } 549 break; 550 551 case '$': 552 /* Guys we can't handle with one of the usual cases */ --- 10 unchanged lines hidden (view full) --- 563 --size; 564 fputs(tok2str(oo2str, NULL, tag), stdout); 565 break; 566 567 case TAG_CLIENT_FQDN: 568 if (*bp++) 569 printf("[svrreg]"); 570 if (*bp) |
573 printf("%d/%d/", *bp, *(bp+1)); | 571 printf("%u/%u/", *bp, *(bp+1)); |
574 bp += 2; 575 putchar('"'); 576 (void)fn_printn(bp, size - 3, NULL); 577 putchar('"'); 578 bp += size - 3; 579 size = 0; 580 break; 581 --- 15 unchanged lines hidden (view full) --- 597 ++bp; 598 --size; 599 first = 0; 600 } 601 break; 602 } 603 604 default: | 572 bp += 2; 573 putchar('"'); 574 (void)fn_printn(bp, size - 3, NULL); 575 putchar('"'); 576 bp += size - 3; 577 size = 0; 578 break; 579 --- 15 unchanged lines hidden (view full) --- 595 ++bp; 596 --size; 597 first = 0; 598 } 599 break; 600 } 601 602 default: |
605 printf("[unknown special tag %d, size %d]", | 603 printf("[unknown special tag %u, size %u]", |
606 tag, size); 607 bp += size; 608 size = 0; 609 break; 610 } 611 break; 612 } 613 /* Data left over? */ 614 if (size) | 604 tag, size); 605 bp += size; 606 size = 0; 607 break; 608 } 609 break; 610 } 611 /* Data left over? */ 612 if (size) |
615 printf("[len %d]", len); | 613 printf("[len %u]", len); |
616 } 617 return; 618trunc: 619 printf("|[rfc1048]"); 620} 621 622static void 623cmu_print(register const u_char *bp) --- 28 unchanged lines hidden --- | 614 } 615 return; 616trunc: 617 printf("|[rfc1048]"); 618} 619 620static void 621cmu_print(register const u_char *bp) --- 28 unchanged lines hidden --- |