- Timestamp:
- 02/22/07 11:31:14 (15 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:
- 013d3692
- Parents:
- 2d99bd2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/tracereport/tcpopt_report.c
r2d99bd2 rf7953ac 6 6 #include "tracereport.h" 7 7 8 static stat_t tcpopt_stat[4][256] = {{{0,0}}}; 9 /* Suppressing things seems a little pointless to me */ 10 static bool suppress[4] = {true,true,true,true}; 8 static stat_t tcpopt_stat[3][256] = {{{0,0}}}; 11 9 12 10 void tcpopt_per_packet(struct libtrace_packet_t *packet) … … 40 38 } 41 39 42 suppress[dir] = false;43 40 } 44 41 45 void tcpopt_suppress()46 {47 int i;48 printf("%-20s","Direction:");49 for(i=0;i<4;i++){50 if(!suppress[i]){51 switch(i){52 case 0:53 printf("\t%24s", "Outbound ");54 break;55 case 1:56 printf("\t%24s", "Inbound ");57 break;58 case 2:59 printf("\t%24s", "Undefined ");60 break;61 default:62 break;63 }64 }65 }66 printf("\n");67 printf("%-20s","TCP OPTIONS");68 for(i=0;i<4;i++){69 if(!suppress[i]){70 printf("\t%12s\t%12s", "bytes","packets");71 }72 }73 printf("\n");74 }75 42 76 43 void tcpopt_report(void) 77 44 { 45 78 46 int i,j; 79 printf("# TCP OPTION breakdown:\n"); 80 tcpopt_suppress(); 47 48 FILE *out = fopen("tcpopt.out", "w"); 49 if (!out) { 50 perror("fopen"); 51 return; 52 } 53 54 /* Put some headings up for human-readability */ 55 fprintf(out, "%-12s\t%8s\t%12s\t%12s\n", 56 "OPTION", 57 "DIRECTION", 58 "BYTES", 59 "PACKETS"); 81 60 82 61 for(i=0;i<256;++i) { … … 87 66 switch(i) { 88 67 case 1: 89 printf("%20s", "NOP:");68 fprintf(out, "%12s", "NOP |"); 90 69 break; 91 70 case 2: 92 printf("%20s", "MSS:");71 fprintf(out, "%12s", "MSS |"); 93 72 break; 94 73 case 3: 95 printf("%20s", "Winscale:");74 fprintf(out, "%12s", "Winscale |"); 96 75 break; 97 76 case 4: 98 printf("%20s", "SACK Permitted:");77 fprintf(out, "%12s", "SACK Perm |"); 99 78 break; 100 79 case 5: 101 printf("%20s", "SACK Information:");80 fprintf(out, "%12s", "SACK Info |"); 102 81 break; 103 82 case 8: 104 printf("%20s", "Timestamp:");83 fprintf(out, "%12s", "Timestamp |"); 105 84 break; 106 85 case 19: 107 printf("%20s", "MD5:");86 fprintf(out, "%12s", "MD5 |"); 108 87 default: 109 printf("%20i:",i);88 fprintf(out, "%12i |",i); 110 89 } 111 90 112 for(j=0;j<4;j++){ 113 if (tcpopt_stat[j][i].count==0){ 114 if(!suppress[j]) 115 printf("\t%24s"," "); 116 continue; 91 for(j=0;j<3;j++){ 92 if (j != 0) { 93 fprintf(out, "%12s", " |"); 117 94 } 118 printf("\t%12" PRIu64 "\t%12" PRIu64, 95 96 switch (j) { 97 case 0: 98 fprintf(out, "\t%8s", "Outbound"); 99 break; 100 case 1: 101 fprintf(out, "\t%8s", "Inbound"); 102 break; 103 case 2: 104 fprintf(out, "\t%8s", "Unknown"); 105 break; 106 } 107 108 fprintf(out, "\t%12llu %12llu\n", 119 109 tcpopt_stat[j][i].bytes, 120 110 tcpopt_stat[j][i].count); 121 111 } 122 printf("\n");123 112 } 113 fclose(out); 124 114 }
Note: See TracChangeset
for help on using the changeset viewer.