Changeset eaa5529
- Timestamp:
- 10/12/05 14:13:39 (16 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 2cc187b
- Parents:
- 57bbf89
- Location:
- lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/dagformat.h
rb5cd711 reaa5529 11 11 /* GPP Type 1 */ 12 12 typedef struct pos_rec { 13 u nsignedhdlc;14 u nsigned charpload[1];13 uint32_t hdlc; 14 uint8_t pload[1]; 15 15 } pos_rec_t; 16 16 17 17 /* GPP Type 2 */ 18 18 typedef struct eth_rec { 19 u nsigned charoffset;20 u nsigned charpad;21 u nsigned chardst[6];22 u nsigned charsrc[6];23 u nsigned shortetype;24 u nsigned charpload[1];19 uint8_t offset; 20 uint8_t pad; 21 uint8_t dst[6]; 22 uint8_t src[6]; 23 uint16_t etype; 24 uint8_t pload[1]; 25 25 } eth_rec_t; 26 26 27 27 /* GPP Type 3 */ 28 28 typedef struct atm_rec { 29 u nsignedheader;30 u nsigned charpload[1];29 uint32_t header; 30 uint8_t pload[1]; 31 31 } atm_rec_t; 32 32 33 33 /* GPP Type 4 */ 34 34 typedef struct aal5_rec { 35 u nsignedheader;36 u nsigned charpload[1];35 uint32_t header; 36 uint8_t pload[1]; 37 37 } aal5_rec_t; 38 38 39 39 typedef struct flags { 40 u nsigned chariface:2;41 u nsigned charvlen:1;42 u nsigned chartrunc:1;43 u nsigned charrxerror:1;44 u nsigned chardserror:1;45 u nsigned charpad:2;40 uint8_t iface:2; 41 uint8_t vlen:1; 42 uint8_t trunc:1; 43 uint8_t rxerror:1; 44 uint8_t dserror:1; 45 uint8_t pad:2; 46 46 } __attribute__((packed)) flags_t; 47 47 48 48 /* GPP Global type */ 49 49 typedef struct dag_record { 50 u nsigned long longts;51 u nsigned chartype;52 flags_t 53 u nsigned shortrlen;54 u nsigned shortlctr;55 u nsigned shortwlen;50 uint64_t ts; 51 uint8_t type; 52 flags_t flags; 53 uint16_t rlen; 54 uint16_t lctr; 55 uint16_t wlen; 56 56 union { 57 57 pos_rec_t pos; … … 65 65 typedef struct duck_inf 66 66 { 67 u nsigned longCommand, Config, Clock_Inc, Clock_Wrap, DDS_Rate;68 u nsigned longCrystal_Freq;69 u nsigned longSynth_Freq, Sync_Rate;70 u nsigned long longLast_Ticks;71 u nsigned longResyncs;72 u nsigned longBad_Diffs, Bad_Offs, Bad_Pulses;73 u nsigned longWorst_Error, Worst_Off;74 u nsigned longOff_Limit, Off_Damp;75 u nsigned longPulses, Single_Pulses_Missing, Longest_Pulse_Missing;76 u nsigned longHealth, Sickness;77 longError, Offset;78 longStat_Start, Stat_End; /* these are really time_t's */79 u nsigned longSet_Duck_Field;67 uint32_t Command, Config, Clock_Inc, Clock_Wrap, DDS_Rate; 68 uint32_t Crystal_Freq; 69 uint32_t Synth_Freq, Sync_Rate; 70 uint64_t Last_Ticks; 71 uint32_t Resyncs; 72 uint32_t Bad_Diffs, Bad_Offs, Bad_Pulses; 73 uint32_t Worst_Error, Worst_Off; 74 uint32_t Off_Limit, Off_Damp; 75 uint32_t Pulses, Single_Pulses_Missing, Longest_Pulse_Missing; 76 uint32_t Health, Sickness; 77 int32_t Error, Offset; 78 int32_t Stat_Start, Stat_End; /* these are really time_t's */ 79 uint32_t Set_Duck_Field; 80 80 } duck_inf; 81 81 82 82 #define dag_record_size 16 83 83 84 /* 85 typedef struct legacy_cell { 86 uint64_t ts; 87 uint32_t crc; 88 } legacy_cell_t; 89 90 typedef struct legacy_ether { 91 uint64_t ts; 92 uint16_t wlen; 93 } legacy_ether_t; 94 95 typedef struct legacy_pos { 96 uint64_t ts; 97 uint32_t slen; 98 uint32_t wlen; 99 } legacy_pos_t; 100 */ 84 101 85 102 #endif // _DAGFORMAT_H_ -
lib/format_erf.c
r9c6aa95 reaa5529 72 72 static struct libtrace_format_t *dag_ptr = 0; 73 73 #endif 74 static struct libtrace_format_t *legacypos_ptr = 0; 75 static struct libtrace_format_t *legacyeth_ptr = 0; 76 static struct libtrace_format_t *legacyatm_ptr = 0; 74 77 75 78 #define CONNINFO libtrace->format_data->conn_info … … 439 442 440 443 if ( size > LIBTRACE_PACKET_BUFSIZE) { 441 printf("%d\n",size);442 444 assert( size < LIBTRACE_PACKET_BUFSIZE); 443 445 } … … 457 459 #endif 458 460 461 static int legacy_read_packet(struct libtrace_t *libtrace, struct libtrace_packet_t *packet) { 462 int numbytes; 463 int size; 464 void *buffer = packet->buffer; 465 void *buffer2 = buffer; 466 dag_record_t *erfptr = (dag_record_t *)buffer; 467 int rlen; 468 469 #if HAVE_ZLIB 470 if ((numbytes=gzread(INPUT.file, 471 buffer, 472 dag_record_size)) == -1) { 473 perror("gzread"); 474 return -1; 475 } 476 #else 477 if ((numbytes = read(INPUT.file, buffer, dag_record_size)) == -1) { 478 perror("read"); 479 return -1; 480 } 481 #endif 482 if (numbytes == 0) { 483 return 0; 484 } 485 486 // legacy - 64byte captures 487 // type is TYPE_LEGACY 488 rlen = 64; 489 size = rlen - dag_record_size; 490 buffer2 = buffer + dag_record_size; 491 492 #ifdef HAVE_ZLIB 493 if ((numbytes=gzread(INPUT.file, 494 buffer2, 495 size)) == -1) { 496 perror("gzread"); 497 return -1; 498 } 499 #else 500 if ((numbytes = read(INPUT.file,buffer2,size)) == -1) { 501 perror("gzread"); 502 return -1; 503 } 504 #endif 505 packet->status = 0; 506 packet->size = rlen; 507 return rlen; 508 } 459 509 static int erf_read_packet(struct libtrace_t *libtrace, struct libtrace_packet_t *packet) { 460 510 int numbytes; … … 485 535 486 536 // read in the rest of the packet 537 #ifdef HAVE_ZLIB 487 538 if ((numbytes=gzread(INPUT.file, 488 539 buffer2, … … 491 542 return -1; 492 543 } 544 #else 545 if ((numbytes = read(INPUT.file,buffer2,size)) == -1) { 546 perror("gzread"); 547 return -1; 548 } 549 #endif 493 550 packet->status = 0; 494 551 packet->size = rlen; … … 650 707 651 708 709 static void *legacy_get_link(const struct libtrace_packet_t *packet) { 710 const void *posptr = 0; 711 posptr = ((uint8_t *)packet->buffer); 712 return (void *)posptr; 713 } 714 715 static libtrace_linktype_t legacy_get_link_type(const struct libtrace_packet_t *packet) { 716 return TRACE_TYPE_LEGACY; 717 } 718 719 static libtrace_linktype_t legacyeth_get_link_type(const struct libtrace_packet_t *packet) { 720 return TRACE_TYPE_LEGACY_ETH; 721 } 722 723 static libtrace_linktype_t legacyatm_get_link_type(const struct libtrace_packet_t *packet) { 724 return TRACE_TYPE_LEGACY_ATM; 725 } 726 727 static libtrace_linktype_t legacypos_get_link_type(const struct libtrace_packet_t *packet) { 728 return TRACE_TYPE_LEGACY_POS; 729 } 730 652 731 static void *erf_get_link(const struct libtrace_packet_t *packet) { 653 732 const void *ethptr = 0; … … 693 772 } 694 773 774 static int legacy_get_capture_length(const struct libtrace_packet_t *packet __attribute__((unused))) { 775 return 64; 776 } 777 778 static int legacypos_get_wire_length(const struct libtrace_packet_t *packet) { 779 780 } 695 781 static int erf_get_capture_length(const struct libtrace_packet_t *packet) { 696 782 dag_record_t *erfptr = 0; … … 740 826 #endif 741 827 828 static void legacypos_help() { 829 printf("legacypos format module: $Revision$\n"); 830 printf("Supported input URIs:\n"); 831 printf("\tlegacypos:/path/to/file\t(uncompressed)\n"); 832 printf("\tlegacypos:/path/to/file.gz\t(gzip-compressed)\n"); 833 printf("\tlegacypos:-\t(stdin, either compressed or not)\n"); 834 printf("\n"); 835 printf("\te.g.: legacypos:/tmp/trace.gz\n"); 836 printf("\n"); 837 } 838 839 static void legacyatm_help() { 840 printf("legacyatm format module: $Revision$\n"); 841 printf("Supported input URIs:\n"); 842 printf("\tlegacyatm:/path/to/file\t(uncompressed)\n"); 843 printf("\tlegacyatm:/path/to/file.gz\t(gzip-compressed)\n"); 844 printf("\tlegacyatm:-\t(stdin, either compressed or not)\n"); 845 printf("\n"); 846 printf("\te.g.: legacyatm:/tmp/trace.gz\n"); 847 printf("\n"); 848 } 849 850 static void legacyeth_help() { 851 printf("legacyeth format module: $Revision$\n"); 852 printf("Supported input URIs:\n"); 853 printf("\tlegacyeth:/path/to/file\t(uncompressed)\n"); 854 printf("\tlegacyeth:/path/to/file.gz\t(gzip-compressed)\n"); 855 printf("\tlegacyeth:-\t(stdin, either compressed or not)\n"); 856 printf("\n"); 857 printf("\te.g.: legacyeth:/tmp/trace.gz\n"); 858 printf("\n"); 859 } 742 860 743 861 static void erf_help() { … … 784 902 785 903 } 904 905 static struct libtrace_format_t legacyatm = { 906 "legacyatm", 907 "$Id$", 908 "legacyatm", 909 erf_init_input, /* init_input */ 910 NULL, /* init_output */ 911 NULL, /* config_output */ 912 erf_fin_input, /* fin_input */ 913 NULL, /* fin_output */ 914 legacy_read_packet, /* read_packet */ 915 NULL, /* write_packet */ 916 legacy_get_link, /* get_link */ 917 legacyatm_get_link_type, /* get_link_type */ 918 NULL, /* get_direction */ 919 NULL, /* set_direction */ 920 erf_get_erf_timestamp, /* get_erf_timestamp */ 921 NULL, /* get_timeval */ 922 NULL, /* get_seconds */ 923 legacy_get_capture_length, /* get_capture_length */ 924 NULL, /* get_wire_length */ 925 NULL, /* set_capture_length */ 926 NULL, /* get_fd */ 927 trace_event_trace, /* trace_event */ 928 legacyatm_help /* help */ 929 }; 930 931 static struct libtrace_format_t legacyeth = { 932 "legacyeth", 933 "$Id$", 934 "legacyeth", 935 erf_init_input, /* init_input */ 936 NULL, /* init_output */ 937 NULL, /* config_output */ 938 erf_fin_input, /* fin_input */ 939 NULL, /* fin_output */ 940 legacy_read_packet, /* read_packet */ 941 NULL, /* write_packet */ 942 legacy_get_link, /* get_link */ 943 legacyeth_get_link_type, /* get_link_type */ 944 NULL, /* get_direction */ 945 NULL, /* set_direction */ 946 erf_get_erf_timestamp, /* get_erf_timestamp */ 947 NULL, /* get_timeval */ 948 NULL, /* get_seconds */ 949 legacy_get_capture_length, /* get_capture_length */ 950 NULL, /* get_wire_length */ 951 NULL, /* set_capture_length */ 952 NULL, /* get_fd */ 953 trace_event_trace, /* trace_event */ 954 legacyatm_help /* help */ 955 }; 956 957 static struct libtrace_format_t legacypos = { 958 "legacypos", 959 "$Id$", 960 "legacypos", 961 erf_init_input, /* init_input */ 962 NULL, /* init_output */ 963 NULL, /* config_output */ 964 erf_fin_input, /* fin_input */ 965 NULL, /* fin_output */ 966 legacy_read_packet, /* read_packet */ 967 NULL, /* write_packet */ 968 legacy_get_link, /* get_link */ 969 legacypos_get_link_type, /* get_link_type */ 970 NULL, /* get_direction */ 971 NULL, /* set_direction */ 972 erf_get_erf_timestamp, /* get_erf_timestamp */ 973 NULL, /* get_timeval */ 974 NULL, /* get_seconds */ 975 legacy_get_capture_length, /* get_capture_length */ 976 NULL, /* get_wire_length */ 977 NULL, /* set_capture_length */ 978 NULL, /* get_fd */ 979 trace_event_trace, /* trace_event */ 980 legacypos_help /* help */ 981 }; 786 982 787 983 … … 875 1071 rtclient_ptr = &rtclient; 876 1072 register_format(rtclient_ptr); 877 } 1073 1074 legacypos_ptr = &legacypos; 1075 register_format(legacypos_ptr); 1076 1077 legacyeth_ptr = &legacyeth; 1078 register_format(legacyeth_ptr); 1079 1080 legacyatm_ptr = &legacyatm; 1081 register_format(legacyatm_ptr); 1082 1083 } -
lib/libtrace.h
r8283f05 reaa5529 474 474 TRACE_TYPE_NONE, 475 475 TRACE_TYPE_LINUX_SLL, 476 TRACE_TYPE_PFLOG 476 TRACE_TYPE_PFLOG, 477 TRACE_TYPE_LEGACY_DEFAULT, 478 TRACE_TYPE_LEGACY_POS, 479 TRACE_TYPE_LEGACY_ATM, 480 TRACE_TYPE_LEGACY_ETH 477 481 } libtrace_linktype_t; 478 482 -
lib/trace.c
r9c6aa95 reaa5529 528 528 return (void *)ethptr; 529 529 } 530 531 typedef struct legacy_framing { 532 uint64_t ts; 533 uint32_t crc; 534 uint32_t header; 535 uint32_t data[12]; /* pad to 64 bytes */ 536 } legacy_framing_t; 530 537 531 538 /* get a pointer to the IP header (if any) … … 636 643 break; 637 644 } 645 case TRACE_TYPE_LEGACY_POS: 646 { 647 // 64 byte capture. 648 legacy_framing_t *cell = 649 trace_get_link(packet); 650 // check ethertype 651 uint16_t *etype = (uint16_t *)cell->data + 1; 652 if (*etype == 0x0008) { 653 ipptr = (void *)&cell->data[1]; 654 } else { 655 ipptr = NULL; 656 } 657 break; 658 659 } 660 case TRACE_TYPE_LEGACY_ATM: 661 case TRACE_TYPE_LEGACY_ETH: 662 case TRACE_TYPE_LEGACY: 663 { 664 // 64 byte capture. 665 legacy_framing_t *cell = 666 trace_get_link(packet); 667 uint16_t *etype = (uint16_t *)cell->data + 3; 668 if (*etype == 0x0008) { 669 ipptr = (void *)&cell->data[2]; 670 } else { 671 ipptr = NULL; 672 } 673 } 638 674 default: 639 675 fprintf(stderr,"Don't understand link layer type %i in trace_get_ip()\n",
Note: See TracChangeset
for help on using the changeset viewer.