Changeset 1204
- Timestamp:
- 04/27/07 14:47:30 (6 years ago)
- Location:
- trunk/tools/tracereport
- Files:
-
- 9 edited
-
ecn_report.c (modified) (1 diff)
-
misc_report.c (modified) (1 diff)
-
nlp_report.c (modified) (1 diff)
-
port_report.c (modified) (4 diffs)
-
protocol_report.c (modified) (1 diff)
-
tcpopt_report.c (modified) (1 diff)
-
tcpsegment_report.c (modified) (1 diff)
-
tos_report.c (modified) (1 diff)
-
ttl_report.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/tracereport/ecn_report.c
r1203 r1204 76 76 break; 77 77 } 78 fprintf(out, "\t%16 llu %16llu\n",78 fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 79 79 ecn_stat[j][i].bytes, 80 80 ecn_stat[j][i].count); -
trunk/tools/tracereport/misc_report.c
r1191 r1204 69 69 void misc_report(void) 70 70 { 71 printf("# Misc\n"); 72 printf("Start time: %.04f (%s)\n",starttime,ts_to_date(starttime)); 73 printf("End time: %.04f (%s)\n",endtime,ts_to_date(endtime)); 74 printf("Duration: %.04f (%s)\n",endtime-starttime, 71 FILE *out = fopen("misc.rpt", "w"); 72 if (!out) { 73 perror("fopen"); 74 return; 75 } 76 fprintf(out, "Start time: %.04f (%s)\n",starttime,ts_to_date(starttime)); 77 fprintf(out, "End time: %.04f (%s)\n",endtime,ts_to_date(endtime)); 78 fprintf(out, "Duration: %.04f (%s)\n",endtime-starttime, 75 79 duration(endtime-starttime)); 76 printf("Total Packets: %" PRIu64 "\n",packets);77 printf("Average packet rate: %.02f packets/sec\n",80 fprintf(out, "Total Packets: %" PRIu64 "\n",packets); 81 fprintf(out, "Average packet rate: %.02f packets/sec\n", 78 82 packets/(endtime-starttime)); 79 83 } -
trunk/tools/tracereport/nlp_report.c
r1203 r1204 79 79 } 80 80 81 fprintf(out, "\t%16 llu %16llu\n",81 fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 82 82 nlp_stat[j][i].bytes, 83 83 nlp_stat[j][i].count); -
trunk/tools/tracereport/port_report.c
r1184 r1204 39 39 } 40 40 41 void port_suppress()42 {43 int i;44 printf("%-20s","Direction:");45 for(i=0;i<3;i++){46 if(!suppress[i]){47 switch(i){48 case 0:49 printf("\t%24s", "Outbound ");50 break;51 case 1:52 printf("\t%24s", "Inbound ");53 break;54 case 2:55 printf("\t%24s", "Undefined ");56 break;57 default:58 break;59 }60 }61 }62 printf("\n");63 printf("%-20s","Port");64 for(i=0;i<3;i++){65 if(!suppress[i]){66 printf("\t%12s\t%12s", "bytes","packets");67 }68 }69 printf("\n");70 }71 41 72 void port_port(int i,char *prot, int j )42 void port_port(int i,char *prot, int j, FILE *out) 73 43 { 74 44 struct servent *ent = getservbyport(htons(j),prot); … … 76 46 77 47 if(ent){ 78 printf("%20s:",ent->s_name); 79 for(k=0;k<3;k++){ 80 if (!ports[k][i] || ports[k][i][j].count==0){ 81 if(!suppress[k]) 82 printf("\t%24s"," "); 83 continue; 84 } 85 printf("\t%12" PRIu64 "\t%12" PRIu64, 86 ports[k][i][j].bytes, 87 ports[k][i][j].count 88 ); 89 } 48 fprintf(out,"%16s:",ent->s_name); 90 49 } 91 50 else{ 92 printf("%20i:",j); 93 for(k=0;k<3;k++){ 94 if (!ports[k][i] || ports[k][i][j].count==0){ 95 if(!suppress[k]) 96 printf("\t%24s"," "); 97 continue; 98 } 99 printf("\t%12" PRIu64 "\t%12" PRIu64, 100 ports[k][i][j].bytes, 101 ports[k][i][j].count 102 ); 51 fprintf(out,"%16i:",j); 52 } 53 54 for (k = 0; k < 3; k++) { 55 if (!ports[k][i]) 56 continue; 57 if (k != 0) { 58 fprintf(out, "%16s", " "); 103 59 } 60 switch (k) { 61 case 0: 62 fprintf(out, "\t%10s", "Outbound"); 63 break; 64 case 1: 65 fprintf(out, "\t%10s", "Inbound"); 66 break; 67 case 2: 68 fprintf(out, "\t%10s", "Unknown"); 69 break; 70 } 71 fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 72 ports[k][i][j].bytes, 73 ports[k][i][j].count); 104 74 } 105 printf("\n");106 75 } 107 76 108 void port_protocol(int i )77 void port_protocol(int i, FILE *out) 109 78 { 110 79 int j,k; 111 80 struct protoent *ent = getprotobynumber(i); 112 printf("Protocol: %i %s%s%s\n",i,81 fprintf(out, "Protocol: %i %s%s%s\n",i, 113 82 ent?"(":"",ent?ent->p_name:"",ent?")":""); 114 83 for(j=0;j<65536;++j) { 115 84 for(k=0;k<3;k++){ 116 85 if (ports[k][i] && ports[k][i][j].count) { 117 port_port(i,ent?ent->p_name:"",j );86 port_port(i,ent?ent->p_name:"",j, out); 118 87 break; 119 88 } … … 125 94 { 126 95 int i; 127 printf("# Port breakdown:\n"); 128 port_suppress(); 96 FILE *out = fopen("ports.rpt", "w"); 97 if (!out) { 98 perror("fopen"); 99 return; 100 } 101 fprintf(out, "%-16s\t%10s\t%16s %16s\n", 102 "PORT", 103 "DIRECTION", 104 "BYTES", 105 "PACKETS"); 106 129 107 setservent(1); 130 108 setprotoent(1); 131 109 for(i=0;i<256;++i) { 132 110 if (protn[i]) { 133 port_protocol(i );111 port_protocol(i, out); 134 112 free(ports[0][i]); 135 113 free(ports[1][i]); … … 139 117 endprotoent(); 140 118 endservent(); 119 fclose(out); 141 120 } -
trunk/tools/tracereport/protocol_report.c
r1203 r1204 69 69 } 70 70 71 fprintf(out, "\t%16 llu %16llu\n",71 fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 72 72 prot_stat[j][i].bytes, 73 73 prot_stat[j][i].count); -
trunk/tools/tracereport/tcpopt_report.c
r1203 r1204 110 110 } 111 111 112 fprintf(out, "\t%16 llu %16llu\n",112 fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 113 113 tcpopt_stat[j][i].bytes, 114 114 tcpopt_stat[j][i].count); -
trunk/tools/tracereport/tcpsegment_report.c
r1203 r1204 96 96 break; 97 97 } 98 fprintf(out, "\t%16 llu %16llu\n",98 fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 99 99 tcpseg_stat[j][i].bytes, 100 100 tcpseg_stat[j][i].count); -
trunk/tools/tracereport/tos_report.c
r1203 r1204 62 62 break; 63 63 } 64 fprintf(out, "\t%16 llu %16llu\n",64 fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 65 65 tos_stat[j][i].bytes, 66 66 tos_stat[j][i].count); -
trunk/tools/tracereport/ttl_report.c
r1203 r1204 8 8 static stat_t ttl_stat[3][256] = {{{0,0}}} ; 9 9 static bool suppress[3] = {true,true,true}; 10 11 FILE *out = NULL;12 10 13 11 void ttl_per_packet(struct libtrace_packet_t *packet) … … 32 30 { 33 31 int i,j; 34 out = fopen("ttl.rpt", "w");32 FILE *out = fopen("ttl.rpt", "w"); 35 33 if (!out) { 36 34 perror("fopen"); … … 63 61 } 64 62 65 fprintf(out, "\t%16 llu %16llu\n",63 fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 66 64 ttl_stat[j][i].bytes, 67 65 ttl_stat[j][i].count);
Note: See TracChangeset
for help on using the changeset viewer.
