Changeset 3d4fb8f for tools


Ignore:
Timestamp:
03/13/06 11:01:18 (15 years ago)
Author:
Perry Lorier <perry@…>
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:
32f365f
Parents:
8f80e87
Message:

Cleanup the tools

Location:
tools
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • tools/traceanon/traceanon.1

    reb6f2ea r3d4fb8f  
    88[ \-p prefix | \-\^\-prefix=prefix ]
    99[ \-c key | \-\^\-cryptopan=key ]
     10sourceuri
     11desturi
    1012.SH DESCRPTION
    1113traceanon anonymises a trace by replacing IP addresses found in the IP header,
  • tools/traceanon/traceanon.c

    rd56089a r3d4fb8f  
    2222        "-p --prefix=C.I.D.R/bits Substitute the prefix of the address\n"
    2323        ,argv0);
     24        trace_help();
    2425        exit(1);
    2526}
    2627
    27 // Incrementally update a checksum
     28/* Incrementally update a checksum */
    2829void update_in_cksum(uint16_t *csum, uint16_t old, uint16_t new)
    2930{
     
    154155        enc_init(enc_type,key);
    155156
    156         // open input uri
     157        /* open input uri */
    157158        trace = trace_create(argv[optind]);
    158         if (!trace) {
    159                 fprintf(stderr,"Cannot open %s\n",argv[optind]);
    160                 trace_perror(argv[optind]);
     159        if (trace_is_err(trace)) {
     160                trace_perror(trace,argv[optind]);
     161                trace_destroy(trace);
    161162                return 1;
    162163        }
    163164       
    164165        if (optind == argc) {
    165                 // no output specified, output in same format to stdout
     166                /* no output specified, output in same format to stdout */
    166167                asprintf(&output,"%s:-","erf");
    167168                writer = trace_create_output(output);
     
    169170                writer = trace_create_output(argv[optind +1]);
    170171        }
    171         if (!writer) {
    172                 trace_perror("trace_create_output");
     172        if (trace_is_err_output(writer)) {
     173                trace_perror_output(writer,"trace_create_output");
     174                trace_destroy_output(writer);
     175                trace_destroy(trace);
    173176                return 1;
    174177        }
    175178       
    176        
     179        if (trace_start(trace)==-1) {
     180                trace_perror(trace,"trace_start");
     181        }
     182        if (trace_start_output(writer)==-1) {
     183                trace_perror_output(writer,"trace_start_output");
     184        }
    177185        for(;;) {
    178186                struct libtrace_ip *ipptr;
    179187                int psize;
    180                 if ((psize = trace_read_packet(trace, packet)) <= 0) {
     188                psize = trace_read_packet(trace, packet);
     189                if (psize == 0) {
     190                        break;
     191                }
     192                if (psize < 0) {
     193                        trace_perror(trace,"read_packet");
    181194                        break;
    182195                }
     
    189202                /* TODO: Encrypt IP's in ARP packets */
    190203
    191                 trace_write_packet(writer,packet);
    192         }
     204                if (trace_write_packet(writer,packet)==-1) {
     205                        trace_perror_output(writer,"writer");
     206                        break;
     207                }
     208        }
     209        trace_destroy_packet(&packet);
     210        trace_destroy(trace);
     211        trace_destroy_output(writer);
    193212        return 0;
    194213}
  • tools/tracedump/tracedump.cc

    rd56089a r3d4fb8f  
    1313        "-f --filter=expr       BPF filter specification, quoted\n"
    1414        "-c --count=num         terminate after num packets\n"
    15         ,argv0);
     15                ,argv0);
    1616        exit(0);
    1717}
     
    6161                trace = trace_create(argv[optind]);
    6262                numpackets = 0;
    63                 if (!trace) {
    64                         errx(1,"Failed to open trace");
     63                if (trace_is_err(trace)) {
     64                        trace_perror(trace,"trace_create");
     65                        trace_destroy(trace);
     66                        continue;
    6567                }
    6668
     69                trace_start(trace);
    6770                while(trace_read_packet(trace,packet)> 0 ){
    6871                        if (filter && !trace_bpf_filter(filter,packet))
     
    7073
    7174                        trace_dump_packet(packet);
     75
    7276                        if(count) {
    7377                                numpackets++;
  • tools/tracertstats/output_csv.c

    re3b0188 r3d4fb8f  
    4646
    4747struct output_type_t output_csv = {
    48 name: "csv",
    49 init: output_csv_init,
    50 flush: output_csv_flush,
    51 destroy: output_csv_destroy,
     48.name= "csv",
     49.init= output_csv_init,
     50.flush= output_csv_flush,
     51.destroy= output_csv_destroy,
    5252};
  • tools/tracertstats/output_html.c

    re3b0188 r3d4fb8f  
    6565
    6666struct output_type_t output_html = {
    67 name: "html",
    68 init: output_html_init,
    69 flush: output_html_flush,
    70 destroy: output_html_destroy,
     67.name= "html",
     68.init= output_html_init,
     69.flush= output_html_flush,
     70.destroy= output_html_destroy,
    7171};
  • tools/tracertstats/output_png.c

    re3b0188 r3d4fb8f  
    7676
    7777struct output_type_t output_png = {
    78         name: "png",
    79         init: output_png_init,
    80         flush: output_png_flush,
    81         destroy: output_png_destroy,
     78        .name= "png",
     79        .init= output_png_init,
     80        .flush= output_png_flush,
     81        .destroy= output_png_destroy,
    8282};
  • tools/tracertstats/output_txt.c

    re3b0188 r3d4fb8f  
    44#include <inttypes.h>
    55#include <lt_inttypes.h>
     6#include <string.h>
    67
    78#define COLWIDTH 11
     
    5354
    5455struct output_type_t output_txt = {
    55 name: "txt",
    56 init: output_txt_init,
    57 flush: output_txt_flush,
    58 destroy: output_txt_destroy,
     56.name= "txt",
     57.init= output_txt_init,
     58.flush= output_txt_flush,
     59.destroy= output_txt_destroy,
    5960};
  • tools/tracertstats/tracertstats.c

    rd56089a r3d4fb8f  
    2929 */
    3030
    31 //
    32 // This program takes a series of traces and bpf filters and outputs how many
    33 // bytes/packets every time interval
     31/* This program takes a series of traces and bpf filters and outputs how many
     32 * bytes/packets every time interval
     33 */
    3434
    3535#include <stdio.h>
     
    9898        double ts = 0;
    9999
    100         output=output_init(uri,output_format?:"txt");
    101         output_add_column(output,"unix_time");
     100        output=output_init(uri,output_format?output_format:"txt");
     101        output_add_column(output,"ts");
    102102        output_add_column(output,"packets");
    103103        output_add_column(output,"bytes");
     
    113113
    114114        trace = trace_create(uri);
     115        if (trace_is_err(trace)) {
     116                trace_perror(trace,"trace_create");
     117                trace_destroy(trace);
     118                output_destroy(output);
     119                return;
     120        }
     121        if (trace_start(trace)==-1) {
     122                trace_perror(trace,"trace_start");
     123                trace_destroy(trace);
     124                output_destroy(output);
     125                return;
     126        }
    115127
    116128        for (;;) {
     
    141153                }
    142154
    143                 if (count > packet_count) {
     155                if (count >= packet_count) {
    144156                        report_results(ts,count,bytes);
    145157                        count=0;
Note: See TracChangeset for help on using the changeset viewer.