Changeset 1204


Ignore:
Timestamp:
04/27/07 14:47:30 (6 years ago)
Author:
spa1
Message:

misc and port reports now write to files - all reports now do so
Changed almost all the %llu format strings to use PRIu64 which should reduce the warnings on 64 bit machines

Location:
trunk/tools/tracereport
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/tracereport/ecn_report.c

    r1203 r1204  
    7676                                        break; 
    7777                        } 
    78                         fprintf(out, "\t%16llu %16llu\n", 
     78                        fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 
    7979                                ecn_stat[j][i].bytes, 
    8080                                ecn_stat[j][i].count); 
  • trunk/tools/tracereport/misc_report.c

    r1191 r1204  
    6969void misc_report(void) 
    7070{ 
    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, 
    7579                        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", 
    7882                        packets/(endtime-starttime)); 
    7983} 
  • trunk/tools/tracereport/nlp_report.c

    r1203 r1204  
    7979                        } 
    8080                         
    81                         fprintf(out, "\t%16llu %16llu\n", 
     81                        fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 
    8282                                nlp_stat[j][i].bytes, 
    8383                                nlp_stat[j][i].count); 
  • trunk/tools/tracereport/port_report.c

    r1184 r1204  
    3939} 
    4040 
    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 } 
    7141 
    72 void port_port(int i,char *prot, int j) 
     42void port_port(int i,char *prot, int j, FILE *out) 
    7343{ 
    7444        struct servent *ent = getservbyport(htons(j),prot); 
     
    7646         
    7747        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); 
    9049        } 
    9150        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", " "); 
    10359                } 
     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); 
    10474        } 
    105         printf("\n"); 
    10675} 
    10776 
    108 void port_protocol(int i) 
     77void port_protocol(int i, FILE *out) 
    10978{ 
    11079        int j,k; 
    11180        struct protoent *ent = getprotobynumber(i); 
    112         printf("Protocol: %i %s%s%s\n",i, 
     81        fprintf(out, "Protocol: %i %s%s%s\n",i, 
    11382                        ent?"(":"",ent?ent->p_name:"",ent?")":""); 
    11483        for(j=0;j<65536;++j) { 
    11584                for(k=0;k<3;k++){ 
    11685                        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); 
    11887                                break; 
    11988                        } 
     
    12594{ 
    12695        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 
    129107        setservent(1); 
    130108        setprotoent(1); 
    131109        for(i=0;i<256;++i) { 
    132110                if (protn[i]) { 
    133                         port_protocol(i); 
     111                        port_protocol(i, out); 
    134112                        free(ports[0][i]); 
    135113                        free(ports[1][i]); 
     
    139117        endprotoent(); 
    140118        endservent(); 
     119        fclose(out); 
    141120} 
  • trunk/tools/tracereport/protocol_report.c

    r1203 r1204  
    6969                        } 
    7070 
    71                         fprintf(out, "\t%16llu %16llu\n", 
     71                        fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 
    7272                                        prot_stat[j][i].bytes, 
    7373                                        prot_stat[j][i].count); 
  • trunk/tools/tracereport/tcpopt_report.c

    r1203 r1204  
    110110                        } 
    111111                         
    112                         fprintf(out, "\t%16llu %16llu\n", 
     112                        fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 
    113113                                tcpopt_stat[j][i].bytes, 
    114114                                tcpopt_stat[j][i].count); 
  • trunk/tools/tracereport/tcpsegment_report.c

    r1203 r1204  
    9696                                        break; 
    9797                        } 
    98                         fprintf(out, "\t%16llu %16llu\n", 
     98                        fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 
    9999                                tcpseg_stat[j][i].bytes, 
    100100                                tcpseg_stat[j][i].count);        
  • trunk/tools/tracereport/tos_report.c

    r1203 r1204  
    6262                                        break; 
    6363                        } 
    64                         fprintf(out, "\t%16llu %16llu\n", 
     64                        fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 
    6565                                tos_stat[j][i].bytes, 
    6666                                tos_stat[j][i].count); 
  • trunk/tools/tracereport/ttl_report.c

    r1203 r1204  
    88static stat_t ttl_stat[3][256] = {{{0,0}}} ; 
    99static bool suppress[3] = {true,true,true}; 
    10  
    11 FILE *out = NULL; 
    1210 
    1311void ttl_per_packet(struct libtrace_packet_t *packet) 
     
    3230{ 
    3331        int i,j; 
    34         out = fopen("ttl.rpt", "w"); 
     32        FILE *out = fopen("ttl.rpt", "w"); 
    3533        if (!out) { 
    3634                perror("fopen"); 
     
    6361                        } 
    6462                         
    65                         fprintf(out, "\t%16llu %16llu\n", 
     63                        fprintf(out, "\t%16" PRIu64 " %16" PRIu64 "\n", 
    6664                                        ttl_stat[j][i].bytes, 
    6765                                        ttl_stat[j][i].count); 
Note: See TracChangeset for help on using the changeset viewer.