Changeset b297e50
- Timestamp:
- 10/13/05 16:26:37 (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:
- c9caf07
- Parents:
- eb6f2ea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/tracemerge/tracemerge.c
r801a5cc rb297e50 4 4 #include <inttypes.h> 5 5 #include <stdbool.h> 6 #include <getopt.h> 7 8 void usage(char *argv0) 9 { 10 fprintf(stderr,"Usage: %s [ -i | --set-interface ] outputuri traceuri...\n",argv0); 11 fprintf(stderr,"\n"); 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"); 13 exit(1); 14 } 6 15 7 16 int main(int argc, char *argv[]) … … 12 21 struct libtrace_packet_t *packet; 13 22 bool *live; 23 bool set_interface=false; 14 24 int i=0; 15 25 16 if (argc<2) { 17 printf("Usage: %s outputuri traceuri...\n",argv[0]); 18 printf("\n"); 19 printf("Merges traces together, each trace gets it's own direction\n"); 26 while (1) { 27 int option_index; 28 struct option long_options[] = { 29 { "set-interface", 0, 0, 'i' }, 30 { NULL, 0, 0, 0 }, 31 }; 32 33 int c=getopt_long(argc, argv, "i:", 34 long_options, &option_index); 35 36 if (c==-1) 37 break; 38 39 switch (c) { 40 case 'i': set_interface=true; break; 41 default: 42 fprintf(stderr,"unknown option: %c\n",c); 43 usage(argv[0]); 44 45 } 46 47 } 48 49 if (optind+2<argc) 50 usage(argv[0]); 51 52 output=trace_output_create(argv[optind]); 53 if (!output) { 54 fprintf(stderr,"Unable to open output file %s\n",argv[optind]); 20 55 return 1; 21 56 } 22 57 23 output=trace_output_create(argv[1]); 24 if (!output) { 25 fprintf(stderr,"Unable to open output file %s\n",argv[1]); 26 return 1; 27 } 28 29 input=calloc((argc-2),sizeof(struct libtrace_t *)); 30 packet=calloc((argc-2),sizeof(struct libtrace_packet_t)); 31 live=calloc((argc-2),sizeof(bool)); 32 for(i=0;i<argc-2;++i) { 58 input=calloc((argc-optind),sizeof(struct libtrace_t *)); 59 packet=calloc((argc-optind),sizeof(struct libtrace_packet_t)); 60 live=calloc((argc-optind),sizeof(bool)); 61 for(i=0;i<argc-optind;++i) { 33 62 struct libtrace_t *f; 34 63 struct libtrace_packet_t p; 35 f=trace_create(argv[i+ 2]);64 f=trace_create(argv[i+optind]); 36 65 input[i]=f; 37 66 if (!input[i]) { 38 fprintf(stderr,"Could not read %s\n",argv[i+ 2]);67 fprintf(stderr,"Could not read %s\n",argv[i+optind]); 39 68 return 1; 40 }41 else {42 fprintf(stderr,"Created %s @ %p\n",argv[i+2],input[i]);43 69 } 44 70 trace_read_packet(f,&p); … … 77 103 } 78 104 79 trace_set_direction(&packet[oldest],oldest); 105 if (set_interface) 106 trace_set_direction(&packet[oldest],oldest); 80 107 trace_write_packet(output,&packet[oldest]); 81 108 live[oldest]=false;
Note: See TracChangeset
for help on using the changeset viewer.