print-sflow.c (276788) | print-sflow.c (285275) |
---|---|
1/* 2 * Copyright (c) 1998-2007 The TCPDUMP project 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that: (1) source code 6 * distributions retain the above copyright notice and this paragraph 7 * in its entirety, and (2) distributions including binary code include 8 * the above copyright notice and this paragraph in its entirety in --- 283 unchanged lines hidden (view full) --- 292 uint8_t unicast_pkt[4]; 293 uint8_t multicast_pkt[4]; 294 uint8_t broadcast_pkt[4]; 295 uint8_t discards[4]; 296}; 297 298static int 299print_sflow_counter_generic(netdissect_options *ndo, | 1/* 2 * Copyright (c) 1998-2007 The TCPDUMP project 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that: (1) source code 6 * distributions retain the above copyright notice and this paragraph 7 * in its entirety, and (2) distributions including binary code include 8 * the above copyright notice and this paragraph in its entirety in --- 283 unchanged lines hidden (view full) --- 292 uint8_t unicast_pkt[4]; 293 uint8_t multicast_pkt[4]; 294 uint8_t broadcast_pkt[4]; 295 uint8_t discards[4]; 296}; 297 298static int 299print_sflow_counter_generic(netdissect_options *ndo, |
300 const u_char *pointer, u_int len) { 301 | 300 const u_char *pointer, u_int len) 301{ |
302 const struct sflow_generic_counter_t *sflow_gen_counter; 303 304 if (len < sizeof(struct sflow_generic_counter_t)) 305 return 1; 306 307 308 sflow_gen_counter = (const struct sflow_generic_counter_t *)pointer; 309 ND_PRINT((ndo, "\n\t ifindex %u, iftype %u, ifspeed %" PRIu64 ", ifdirection %u (%s)", --- 28 unchanged lines hidden (view full) --- 338 EXTRACT_32BITS(sflow_gen_counter->ifouterrors), 339 EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode))); 340 341 return 0; 342} 343 344static int 345print_sflow_counter_ethernet(netdissect_options *ndo, | 302 const struct sflow_generic_counter_t *sflow_gen_counter; 303 304 if (len < sizeof(struct sflow_generic_counter_t)) 305 return 1; 306 307 308 sflow_gen_counter = (const struct sflow_generic_counter_t *)pointer; 309 ND_PRINT((ndo, "\n\t ifindex %u, iftype %u, ifspeed %" PRIu64 ", ifdirection %u (%s)", --- 28 unchanged lines hidden (view full) --- 338 EXTRACT_32BITS(sflow_gen_counter->ifouterrors), 339 EXTRACT_32BITS(sflow_gen_counter->ifpromiscmode))); 340 341 return 0; 342} 343 344static int 345print_sflow_counter_ethernet(netdissect_options *ndo, |
346 const u_char *pointer, u_int len){ 347 | 346 const u_char *pointer, u_int len) 347{ |
348 const struct sflow_ethernet_counter_t *sflow_eth_counter; 349 350 if (len < sizeof(struct sflow_ethernet_counter_t)) 351 return 1; 352 353 sflow_eth_counter = (const struct sflow_ethernet_counter_t *)pointer; 354 ND_PRINT((ndo, "\n\t align errors %u, fcs errors %u, single collision %u, multiple collision %u, test error %u", 355 EXTRACT_32BITS(sflow_eth_counter->alignerrors), --- 12 unchanged lines hidden (view full) --- 368 EXTRACT_32BITS(sflow_eth_counter->mac_receive_errors), 369 EXTRACT_32BITS(sflow_eth_counter->symbol_errors))); 370 371 return 0; 372} 373 374static int 375print_sflow_counter_token_ring(netdissect_options *ndo _U_, | 348 const struct sflow_ethernet_counter_t *sflow_eth_counter; 349 350 if (len < sizeof(struct sflow_ethernet_counter_t)) 351 return 1; 352 353 sflow_eth_counter = (const struct sflow_ethernet_counter_t *)pointer; 354 ND_PRINT((ndo, "\n\t align errors %u, fcs errors %u, single collision %u, multiple collision %u, test error %u", 355 EXTRACT_32BITS(sflow_eth_counter->alignerrors), --- 12 unchanged lines hidden (view full) --- 368 EXTRACT_32BITS(sflow_eth_counter->mac_receive_errors), 369 EXTRACT_32BITS(sflow_eth_counter->symbol_errors))); 370 371 return 0; 372} 373 374static int 375print_sflow_counter_token_ring(netdissect_options *ndo _U_, |
376 const u_char *pointer _U_, u_int len _U_) { 377 | 376 const u_char *pointer _U_, u_int len _U_) 377{ |
378 return 0; 379} 380 381static int 382print_sflow_counter_basevg(netdissect_options *ndo, | 378 return 0; 379} 380 381static int 382print_sflow_counter_basevg(netdissect_options *ndo, |
383 const u_char *pointer, u_int len) { 384 | 383 const u_char *pointer, u_int len) 384{ |
385 const struct sflow_100basevg_counter_t *sflow_100basevg_counter; 386 387 if (len < sizeof(struct sflow_100basevg_counter_t)) 388 return 1; 389 390 sflow_100basevg_counter = (const struct sflow_100basevg_counter_t *)pointer; 391 ND_PRINT((ndo, "\n\t in high prio frames %u, in high prio octets %" PRIu64, 392 EXTRACT_32BITS(sflow_100basevg_counter->in_highpriority_frames), --- 18 unchanged lines hidden (view full) --- 411 EXTRACT_64BITS(sflow_100basevg_counter->hc_in_normpriority_octets), 412 EXTRACT_64BITS(sflow_100basevg_counter->hc_out_highpriority_octets))); 413 414 return 0; 415} 416 417static int 418print_sflow_counter_vlan(netdissect_options *ndo, | 385 const struct sflow_100basevg_counter_t *sflow_100basevg_counter; 386 387 if (len < sizeof(struct sflow_100basevg_counter_t)) 388 return 1; 389 390 sflow_100basevg_counter = (const struct sflow_100basevg_counter_t *)pointer; 391 ND_PRINT((ndo, "\n\t in high prio frames %u, in high prio octets %" PRIu64, 392 EXTRACT_32BITS(sflow_100basevg_counter->in_highpriority_frames), --- 18 unchanged lines hidden (view full) --- 411 EXTRACT_64BITS(sflow_100basevg_counter->hc_in_normpriority_octets), 412 EXTRACT_64BITS(sflow_100basevg_counter->hc_out_highpriority_octets))); 413 414 return 0; 415} 416 417static int 418print_sflow_counter_vlan(netdissect_options *ndo, |
419 const u_char *pointer, u_int len) { 420 | 419 const u_char *pointer, u_int len) 420{ |
421 const struct sflow_vlan_counter_t *sflow_vlan_counter; 422 423 if (len < sizeof(struct sflow_vlan_counter_t)) 424 return 1; 425 426 sflow_vlan_counter = (const struct sflow_vlan_counter_t *)pointer; 427 ND_PRINT((ndo, "\n\t vlan_id %u, octets %" PRIu64 428 ", unicast_pkt %u, multicast_pkt %u, broadcast_pkt %u, discards %u", --- 12 unchanged lines hidden (view full) --- 441 uint8_t one_min_util[4]; 442 uint8_t five_min_util[4]; 443 uint8_t total_memory[8]; 444 uint8_t free_memory[8]; 445}; 446 447static int 448print_sflow_counter_processor(netdissect_options *ndo, | 421 const struct sflow_vlan_counter_t *sflow_vlan_counter; 422 423 if (len < sizeof(struct sflow_vlan_counter_t)) 424 return 1; 425 426 sflow_vlan_counter = (const struct sflow_vlan_counter_t *)pointer; 427 ND_PRINT((ndo, "\n\t vlan_id %u, octets %" PRIu64 428 ", unicast_pkt %u, multicast_pkt %u, broadcast_pkt %u, discards %u", --- 12 unchanged lines hidden (view full) --- 441 uint8_t one_min_util[4]; 442 uint8_t five_min_util[4]; 443 uint8_t total_memory[8]; 444 uint8_t free_memory[8]; 445}; 446 447static int 448print_sflow_counter_processor(netdissect_options *ndo, |
449 const u_char *pointer, u_int len) { 450 | 449 const u_char *pointer, u_int len) 450{ |
451 const struct sflow_processor_counter_t *sflow_processor_counter; 452 453 if (len < sizeof(struct sflow_processor_counter_t)) 454 return 1; 455 456 sflow_processor_counter = (const struct sflow_processor_counter_t *)pointer; 457 ND_PRINT((ndo, "\n\t 5sec %u, 1min %u, 5min %u, total_mem %" PRIu64 458 ", total_mem %" PRIu64, 459 EXTRACT_32BITS(sflow_processor_counter->five_sec_util), 460 EXTRACT_32BITS(sflow_processor_counter->one_min_util), 461 EXTRACT_32BITS(sflow_processor_counter->five_min_util), 462 EXTRACT_64BITS(sflow_processor_counter->total_memory), 463 EXTRACT_64BITS(sflow_processor_counter->free_memory))); 464 465 return 0; 466} 467 468static int 469sflow_print_counter_records(netdissect_options *ndo, | 451 const struct sflow_processor_counter_t *sflow_processor_counter; 452 453 if (len < sizeof(struct sflow_processor_counter_t)) 454 return 1; 455 456 sflow_processor_counter = (const struct sflow_processor_counter_t *)pointer; 457 ND_PRINT((ndo, "\n\t 5sec %u, 1min %u, 5min %u, total_mem %" PRIu64 458 ", total_mem %" PRIu64, 459 EXTRACT_32BITS(sflow_processor_counter->five_sec_util), 460 EXTRACT_32BITS(sflow_processor_counter->one_min_util), 461 EXTRACT_32BITS(sflow_processor_counter->five_min_util), 462 EXTRACT_64BITS(sflow_processor_counter->total_memory), 463 EXTRACT_64BITS(sflow_processor_counter->free_memory))); 464 465 return 0; 466} 467 468static int 469sflow_print_counter_records(netdissect_options *ndo, |
470 const u_char *pointer, u_int len, u_int records) { 471 | 470 const u_char *pointer, u_int len, u_int records) 471{ |
472 u_int nrecords; 473 const u_char *tptr; 474 u_int tlen; 475 u_int counter_type; 476 u_int counter_len; 477 u_int enterprise; 478 const struct sflow_counter_record_t *sflow_counter_record; 479 --- 58 unchanged lines hidden (view full) --- 538 tlen -= counter_len; 539 nrecords--; 540 541 } 542 543 return 0; 544} 545 | 472 u_int nrecords; 473 const u_char *tptr; 474 u_int tlen; 475 u_int counter_type; 476 u_int counter_len; 477 u_int enterprise; 478 const struct sflow_counter_record_t *sflow_counter_record; 479 --- 58 unchanged lines hidden (view full) --- 538 tlen -= counter_len; 539 nrecords--; 540 541 } 542 543 return 0; 544} 545 |
546 | |
547static int 548sflow_print_counter_sample(netdissect_options *ndo, | 546static int 547sflow_print_counter_sample(netdissect_options *ndo, |
549 const u_char *pointer, u_int len) { 550 | 548 const u_char *pointer, u_int len) 549{ |
551 const struct sflow_counter_sample_t *sflow_counter_sample; 552 u_int nrecords; 553 u_int typesource; 554 u_int type; 555 u_int index; 556 557 558 if (len < sizeof(struct sflow_counter_sample_t)) --- 15 unchanged lines hidden (view full) --- 574 return sflow_print_counter_records(ndo, pointer + sizeof(struct sflow_counter_sample_t), 575 len - sizeof(struct sflow_counter_sample_t), 576 nrecords); 577 578} 579 580static int 581sflow_print_expanded_counter_sample(netdissect_options *ndo, | 550 const struct sflow_counter_sample_t *sflow_counter_sample; 551 u_int nrecords; 552 u_int typesource; 553 u_int type; 554 u_int index; 555 556 557 if (len < sizeof(struct sflow_counter_sample_t)) --- 15 unchanged lines hidden (view full) --- 573 return sflow_print_counter_records(ndo, pointer + sizeof(struct sflow_counter_sample_t), 574 len - sizeof(struct sflow_counter_sample_t), 575 nrecords); 576 577} 578 579static int 580sflow_print_expanded_counter_sample(netdissect_options *ndo, |
582 const u_char *pointer, u_int len) { 583 | 581 const u_char *pointer, u_int len) 582{ |
584 const struct sflow_expanded_counter_sample_t *sflow_expanded_counter_sample; 585 u_int nrecords; 586 587 588 if (len < sizeof(struct sflow_expanded_counter_sample_t)) 589 return 1; 590 591 sflow_expanded_counter_sample = (const struct sflow_expanded_counter_sample_t *)pointer; --- 9 unchanged lines hidden (view full) --- 601 return sflow_print_counter_records(ndo, pointer + sizeof(struct sflow_expanded_counter_sample_t), 602 len - sizeof(struct sflow_expanded_counter_sample_t), 603 nrecords); 604 605} 606 607static int 608print_sflow_raw_packet(netdissect_options *ndo, | 583 const struct sflow_expanded_counter_sample_t *sflow_expanded_counter_sample; 584 u_int nrecords; 585 586 587 if (len < sizeof(struct sflow_expanded_counter_sample_t)) 588 return 1; 589 590 sflow_expanded_counter_sample = (const struct sflow_expanded_counter_sample_t *)pointer; --- 9 unchanged lines hidden (view full) --- 600 return sflow_print_counter_records(ndo, pointer + sizeof(struct sflow_expanded_counter_sample_t), 601 len - sizeof(struct sflow_expanded_counter_sample_t), 602 nrecords); 603 604} 605 606static int 607print_sflow_raw_packet(netdissect_options *ndo, |
609 const u_char *pointer, u_int len) { 610 | 608 const u_char *pointer, u_int len) 609{ |
611 const struct sflow_expanded_flow_raw_t *sflow_flow_raw; 612 613 if (len < sizeof(struct sflow_expanded_flow_raw_t)) 614 return 1; 615 616 sflow_flow_raw = (const struct sflow_expanded_flow_raw_t *)pointer; 617 ND_PRINT((ndo, "\n\t protocol %s (%u), length %u, stripped bytes %u, header_size %u", 618 tok2str(sflow_flow_raw_protocol_values,"Unknown",EXTRACT_32BITS(sflow_flow_raw->protocol)), --- 5 unchanged lines hidden (view full) --- 624 /* QUESTION - should we attempt to print the raw header itself? 625 assuming of course there is wnough data present to do so... */ 626 627 return 0; 628} 629 630static int 631print_sflow_ethernet_frame(netdissect_options *ndo, | 610 const struct sflow_expanded_flow_raw_t *sflow_flow_raw; 611 612 if (len < sizeof(struct sflow_expanded_flow_raw_t)) 613 return 1; 614 615 sflow_flow_raw = (const struct sflow_expanded_flow_raw_t *)pointer; 616 ND_PRINT((ndo, "\n\t protocol %s (%u), length %u, stripped bytes %u, header_size %u", 617 tok2str(sflow_flow_raw_protocol_values,"Unknown",EXTRACT_32BITS(sflow_flow_raw->protocol)), --- 5 unchanged lines hidden (view full) --- 623 /* QUESTION - should we attempt to print the raw header itself? 624 assuming of course there is wnough data present to do so... */ 625 626 return 0; 627} 628 629static int 630print_sflow_ethernet_frame(netdissect_options *ndo, |
632 const u_char *pointer, u_int len) { 633 | 631 const u_char *pointer, u_int len) 632{ |
634 const struct sflow_ethernet_frame_t *sflow_ethernet_frame; 635 636 if (len < sizeof(struct sflow_ethernet_frame_t)) 637 return 1; 638 639 sflow_ethernet_frame = (const struct sflow_ethernet_frame_t *)pointer; 640 641 ND_PRINT((ndo, "\n\t frame len %u, type %u", 642 EXTRACT_32BITS(sflow_ethernet_frame->length), 643 EXTRACT_32BITS(sflow_ethernet_frame->type))); 644 645 return 0; 646} 647 648static int 649print_sflow_extended_switch_data(netdissect_options *ndo, | 633 const struct sflow_ethernet_frame_t *sflow_ethernet_frame; 634 635 if (len < sizeof(struct sflow_ethernet_frame_t)) 636 return 1; 637 638 sflow_ethernet_frame = (const struct sflow_ethernet_frame_t *)pointer; 639 640 ND_PRINT((ndo, "\n\t frame len %u, type %u", 641 EXTRACT_32BITS(sflow_ethernet_frame->length), 642 EXTRACT_32BITS(sflow_ethernet_frame->type))); 643 644 return 0; 645} 646 647static int 648print_sflow_extended_switch_data(netdissect_options *ndo, |
650 const u_char *pointer, u_int len) { 651 | 649 const u_char *pointer, u_int len) 650{ |
652 const struct sflow_extended_switch_data_t *sflow_extended_sw_data; 653 654 if (len < sizeof(struct sflow_extended_switch_data_t)) 655 return 1; 656 657 sflow_extended_sw_data = (const struct sflow_extended_switch_data_t *)pointer; 658 ND_PRINT((ndo, "\n\t src vlan %u, src pri %u, dst vlan %u, dst pri %u", 659 EXTRACT_32BITS(sflow_extended_sw_data->src_vlan), 660 EXTRACT_32BITS(sflow_extended_sw_data->src_pri), 661 EXTRACT_32BITS(sflow_extended_sw_data->dst_vlan), 662 EXTRACT_32BITS(sflow_extended_sw_data->dst_pri))); 663 664 return 0; 665} 666 667static int 668sflow_print_flow_records(netdissect_options *ndo, | 651 const struct sflow_extended_switch_data_t *sflow_extended_sw_data; 652 653 if (len < sizeof(struct sflow_extended_switch_data_t)) 654 return 1; 655 656 sflow_extended_sw_data = (const struct sflow_extended_switch_data_t *)pointer; 657 ND_PRINT((ndo, "\n\t src vlan %u, src pri %u, dst vlan %u, dst pri %u", 658 EXTRACT_32BITS(sflow_extended_sw_data->src_vlan), 659 EXTRACT_32BITS(sflow_extended_sw_data->src_pri), 660 EXTRACT_32BITS(sflow_extended_sw_data->dst_vlan), 661 EXTRACT_32BITS(sflow_extended_sw_data->dst_pri))); 662 663 return 0; 664} 665 666static int 667sflow_print_flow_records(netdissect_options *ndo, |
669 const u_char *pointer, u_int len, u_int records) { 670 | 668 const u_char *pointer, u_int len, u_int records) 669{ |
671 u_int nrecords; 672 const u_char *tptr; 673 u_int tlen; 674 u_int flow_type; 675 u_int enterprise; 676 u_int flow_len; 677 const struct sflow_flow_record_t *sflow_flow_record; 678 --- 68 unchanged lines hidden (view full) --- 747 748 } 749 750 return 0; 751} 752 753static int 754sflow_print_flow_sample(netdissect_options *ndo, | 670 u_int nrecords; 671 const u_char *tptr; 672 u_int tlen; 673 u_int flow_type; 674 u_int enterprise; 675 u_int flow_len; 676 const struct sflow_flow_record_t *sflow_flow_record; 677 --- 68 unchanged lines hidden (view full) --- 746 747 } 748 749 return 0; 750} 751 752static int 753sflow_print_flow_sample(netdissect_options *ndo, |
755 const u_char *pointer, u_int len) { 756 | 754 const u_char *pointer, u_int len) 755{ |
757 const struct sflow_flow_sample_t *sflow_flow_sample; 758 u_int nrecords; 759 u_int typesource; 760 u_int type; 761 u_int index; 762 763 if (len < sizeof(struct sflow_flow_sample_t)) 764 return 1; --- 19 unchanged lines hidden (view full) --- 784 return sflow_print_flow_records(ndo, pointer + sizeof(struct sflow_flow_sample_t), 785 len - sizeof(struct sflow_flow_sample_t), 786 nrecords); 787 788} 789 790static int 791sflow_print_expanded_flow_sample(netdissect_options *ndo, | 756 const struct sflow_flow_sample_t *sflow_flow_sample; 757 u_int nrecords; 758 u_int typesource; 759 u_int type; 760 u_int index; 761 762 if (len < sizeof(struct sflow_flow_sample_t)) 763 return 1; --- 19 unchanged lines hidden (view full) --- 783 return sflow_print_flow_records(ndo, pointer + sizeof(struct sflow_flow_sample_t), 784 len - sizeof(struct sflow_flow_sample_t), 785 nrecords); 786 787} 788 789static int 790sflow_print_expanded_flow_sample(netdissect_options *ndo, |
792 const u_char *pointer, u_int len) { 793 | 791 const u_char *pointer, u_int len) 792{ |
794 const struct sflow_expanded_flow_sample_t *sflow_expanded_flow_sample; 795 u_int nrecords; 796 797 if (len < sizeof(struct sflow_expanded_flow_sample_t)) 798 return 1; 799 800 sflow_expanded_flow_sample = (const struct sflow_expanded_flow_sample_t *)pointer; 801 --- 11 unchanged lines hidden (view full) --- 813 return sflow_print_flow_records(ndo, pointer + sizeof(struct sflow_expanded_flow_sample_t), 814 len - sizeof(struct sflow_expanded_flow_sample_t), 815 nrecords); 816 817} 818 819void 820sflow_print(netdissect_options *ndo, | 793 const struct sflow_expanded_flow_sample_t *sflow_expanded_flow_sample; 794 u_int nrecords; 795 796 if (len < sizeof(struct sflow_expanded_flow_sample_t)) 797 return 1; 798 799 sflow_expanded_flow_sample = (const struct sflow_expanded_flow_sample_t *)pointer; 800 --- 11 unchanged lines hidden (view full) --- 812 return sflow_print_flow_records(ndo, pointer + sizeof(struct sflow_expanded_flow_sample_t), 813 len - sizeof(struct sflow_expanded_flow_sample_t), 814 nrecords); 815 816} 817 818void 819sflow_print(netdissect_options *ndo, |
821 const u_char *pptr, u_int len) { 822 | 820 const u_char *pptr, u_int len) 821{ |
823 const struct sflow_datagram_t *sflow_datagram; 824 const struct sflow_sample_header *sflow_sample; 825 826 const u_char *tptr; 827 u_int tlen; 828 uint32_t sflow_sample_type, sflow_sample_len; 829 uint32_t nsamples; 830 --- 112 unchanged lines hidden --- | 822 const struct sflow_datagram_t *sflow_datagram; 823 const struct sflow_sample_header *sflow_sample; 824 825 const u_char *tptr; 826 u_int tlen; 827 uint32_t sflow_sample_type, sflow_sample_len; 828 uint32_t nsamples; 829 --- 112 unchanged lines hidden --- |