Ignore:
Timestamp:
11/03/05 02:49:40 (16 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:
2a34193
Parents:
5a67294
Message:

Added:

  • error reports
  • flow reports
  • per port reports
  • direction report
  • moved everything to use the container library
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/tracereport/flow_report.c

    rd3ff1fb r49ce177  
    55#include "libtrace.h"
    66#include "tracereport.h"
    7 #include "tree.h"
     7#include "contain.h"
    88
    9 static tree_t *flows=NULL;
    109static uint64_t flow_count=0;
    1110
     
    1817};
    1918
    20 static int fivetuplecmp(const void *a, const void *b)
     19static int fivetuplecmp(struct fivetuple_t a, struct fivetuple_t b)
    2120{
    22         const struct fivetuple_t *as=a;
    23         const struct fivetuple_t *bs=b;
    24         if (as->ipa != bs->ipa) return as->ipa-bs->ipa;
    25         if (as->ipb != bs->ipb) return as->ipb-bs->ipb;
    26         if (as->porta != bs->porta) return as->porta-bs->porta;
    27         if (as->portb != bs->portb) return as->portb-bs->portb;
    28         return as->porta - as->portb;
     21        if (a.porta != b.porta) return a.porta-b.porta;
     22        if (a.portb != b.portb) return a.portb-b.portb;
     23        if (a.ipa != b.ipa) return a.ipa-b.ipa;
     24        if (a.ipb != b.ipb) return a.ipb-b.ipb;
     25        return a.prot - b.prot;
    2926}
     27
     28SET_CREATE(flowset,struct fivetuple_t,fivetuplecmp)
    3029
    3130void flow_per_packet(struct libtrace_packet_t *packet)
    3231{
    3332        struct libtrace_ip *ip = trace_get_ip(packet);
    34         struct fivetuple_t *ftp;
     33        struct fivetuple_t ft;
    3534        if (!ip)
    3635                return;
    37         ftp=malloc(sizeof(struct fivetuple_t));
    38         ftp->ipa=ip->ip_src.s_addr;
    39         ftp->ipb=ip->ip_dst.s_addr;
    40         ftp->porta=trace_get_source_port(packet);
    41         ftp->portb=trace_get_destination_port(packet);
     36        ft.ipa=ip->ip_src.s_addr;
     37        ft.ipb=ip->ip_dst.s_addr;
     38        ft.porta=trace_get_source_port(packet);
     39        ft.portb=trace_get_destination_port(packet);
    4240
    43         stat_t *stat=tree_find(&flows,ftp,fivetuplecmp);
    44         if (!stat) {
    45                 stat=calloc(1,sizeof(stat_t));
    46                 ++flow_count;
    47         }
    48 
    49         ++stat->count;
    50         stat->bytes+=trace_get_wire_length(packet);
    51 
    52         if (tree_replace(&flows,ftp,fivetuplecmp,stat)) {
    53                 free(ftp);
     41        if (!SET_CONTAINS(flowset,ft)) {
     42                SET_INSERT(flowset,ft);
     43                flow_count++;
    5444        }
    5545}
Note: See TracChangeset for help on using the changeset viewer.