- Timestamp:
- 03/31/06 11:10:43 (16 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:
- 7e16db7
- Parents:
- 4af54d1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/tracemerge/tracemerge.c
r18544c8 rc2f71ad 8 8 void usage(char *argv0) 9 9 { 10 fprintf(stderr,"Usage: %s [ -i | --set-interface ] outputuri traceuri...\n",argv0);10 fprintf(stderr,"Usage: %s [ -i | --set-interface ] [ -u | --unique-packets ] outputuri traceuri...\n",argv0); 11 11 fprintf(stderr,"\n"); 12 12 fprintf(stderr,"Merges traces together, with -i each trace gets it's own direction/interface,\n without traces keep whatever direction/interface they have set\n"); … … 22 22 bool *live; 23 23 bool set_interface=false; 24 bool unique_packets=false; 24 25 int i=0; 26 uint64_t last_ts=0; 25 27 26 28 while (1) { … … 28 30 struct option long_options[] = { 29 31 { "set-interface", 0, 0, 'i' }, 32 { "unique-packets", 0, 0, 'u' }, 30 33 { NULL, 0, 0, 0 }, 31 34 }; 32 35 33 int c=getopt_long(argc, argv, "i :",36 int c=getopt_long(argc, argv, "iu", 34 37 long_options, &option_index); 35 38 … … 39 42 switch (c) { 40 43 case 'i': set_interface=true; break; 44 case 'u': unique_packets=true; break; 41 45 default: 42 46 fprintf(stderr,"unknown option: %c\n",c); … … 65 69 for(i=0;i<argc-optind;++i) { 66 70 struct libtrace_t *f; 67 struct libtrace_packet_t *p;68 71 f=trace_create(argv[i+optind]); 69 72 if (trace_is_err(f)) { … … 78 81 input[i]=f; 79 82 packet[i]=p; 80 trace_read_packet(f,p); 83 if (trace_read_packet(f,packet[i])>0) 84 live[i]=true; 81 85 } 82 86 … … 103 107 if (live[i] && 104 108 (oldest==-1 || 105 oldest_ts <trace_get_erf_timestamp(packet[i]))) {109 oldest_ts>trace_get_erf_timestamp(packet[i]))) { 106 110 oldest=i; 107 111 oldest_ts=trace_get_erf_timestamp(packet[i]); … … 113 117 } 114 118 119 live[oldest]=false; 120 115 121 if (set_interface) 116 122 trace_set_direction(packet[oldest],oldest); 123 124 if (unique_packets && oldest_ts == last_ts) 125 continue; 126 117 127 trace_write_packet(output,packet[oldest]); 118 live[oldest]=false; 128 129 last_ts=oldest_ts; 119 130 120 131 }
Note: See TracChangeset
for help on using the changeset viewer.