- Timestamp:
- 06/02/15 14:49:11 (6 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, 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:
- 8b12caf
- Parents:
- 94725ea
- Location:
- tools/traceanon
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/traceanon/traceanon.1
r17f954f r4a5678c 8 8 [ \-p prefix | \-\^\-prefix=prefix ] 9 9 [ \-c key | \-\^\-cryptopan=key ] 10 [ \-f key-file | \-\^\-keyfile=file ] 10 [ \-F key-file | \-\^\-keyfile=file ] 11 [ \-f expr | \-\^\-filter=expr ] 11 12 [ \-z level | \-\^\-compress-level=level ] 12 13 [ \-Z method | \-\^\-compress-type=method ] … … 59 60 .TP 60 61 .PD 0 61 .BI \- f62 .BI \-F 62 63 .TP 63 64 .PD … … 67 68 long. A suitable method of generating a key is by using the command dd to read 68 69 from /dev/urandom. 70 71 .TP 72 .PD 0 73 .BI \-f 74 .TP 75 .PD 76 .BI \-\^\-filter=expr 77 Discard all packets that do not match the BPF expression specified in 'expr'. 69 78 70 79 -
tools/traceanon/traceanon.c
r17f954f r4a5678c 9 9 #include <string.h> 10 10 #include <time.h> 11 #include <signal.h> 11 12 #include "ipenc.h" 12 13 13 14 14 static void usage(char *argv0) … … 20 20 "-c --cryptopan=key Encrypt the addresses with the cryptopan\n" 21 21 " prefix preserving\n" 22 "-f --keyfile=file A file containing the cryptopan key\n" 22 "-F --keyfile=file A file containing the cryptopan key\n" 23 "-f --filter=expr Discard all packets that do not match the\n" 24 " provided BPF expression\n" 23 25 "-p --prefix=C.I.D.R/bits Substitute the prefix of the address\n" 24 26 "-H --libtrace-help Print libtrace runtime documentation\n" 25 27 "-z --compress-level Compress the output trace at the specified level\n" 26 "-Z --compress-type Compress the output trace using the specified "28 "-Z --compress-type Compress the output trace using the specified\n" 27 29 " compression algorithm\n" 28 30 ,argv0); 29 31 exit(1); 32 } 33 34 volatile int done=0; 35 36 static void cleanup_signal(int sig) 37 { 38 (void)sig; 39 done=1; 40 trace_interrupt(); 30 41 } 31 42 … … 116 127 struct libtrace_packet_t *packet = trace_create_packet(); 117 128 struct libtrace_out_t *writer = 0; 129 struct libtrace_filter_t *filter = NULL; 118 130 bool enc_source = false; 119 131 bool enc_dest = false; 120 132 char *output = 0; 121 133 int level = -1; 134 char *filterstring = NULL; 122 135 char *compress_type_str=NULL; 123 136 trace_option_compresstype_t compress_type = TRACE_OPTION_COMPRESSTYPE_NONE; 124 137 struct sigaction sigact; 125 138 126 139 if (argc<2) 127 140 usage(argv[0]); 141 142 sigact.sa_handler = cleanup_signal; 143 sigemptyset(&sigact.sa_mask); 144 sigact.sa_flags = SA_RESTART; 145 146 signal(SIGINT,&cleanup_signal); 147 signal(SIGTERM,&cleanup_signal); 128 148 129 149 while (1) { … … 133 153 { "encrypt-dest", 0, 0, 'd' }, 134 154 { "cryptopan", 1, 0, 'c' }, 135 { "cryptopan-file", 1, 0, 'f' }, 155 { "cryptopan-file", 1, 0, 'F' }, 156 { "filter", 1, 0, 'f' }, 136 157 { "prefix", 1, 0, 'p' }, 137 158 { "compress-level", 1, 0, 'z' }, … … 152 173 case 's': enc_source=true; break; 153 174 case 'd': enc_dest =true; break; 175 case 'f': filterstring = optarg; break; 154 176 case 'c': 155 177 if (key!=NULL) { … … 160 182 enc_type = ENC_CRYPTOPAN; 161 183 break; 162 case ' f':184 case 'F': 163 185 if(key != NULL) { 164 186 fprintf(stderr,"You can only have one encryption type and one key\n"); … … 230 252 231 253 254 if (filterstring) { 255 filter = trace_create_filter(filterstring); 256 } 257 232 258 enc_init(enc_type,key); 233 259 … … 279 305 } 280 306 307 if (filter && trace_config(trace, TRACE_OPTION_FILTER, filter) == -1) { 308 trace_perror(trace, "Configuring input filter"); 309 trace_destroy_output(writer); 310 trace_destroy(trace); 311 return 1; 312 } 313 281 314 if (trace_start(trace)==-1) { 282 315 trace_perror(trace,"trace_start"); … … 298 331 int psize; 299 332 psize = trace_read_packet(trace, packet); 300 if (psize == 0) { 301 break; 302 } 303 if (psize < 0) { 304 trace_perror(trace,"read_packet"); 333 if (psize <= 0) { 305 334 break; 306 335 } … … 334 363 break; 335 364 } 336 } 365 366 if (done) 367 break; 368 } 369 if (trace_is_err(trace)) { 370 trace_perror(trace,"read_packet"); 371 } 372 373 if (filter) 374 trace_destroy_filter(filter); 375 337 376 trace_destroy_packet(packet); 338 377 trace_destroy(trace);
Note: See TracChangeset
for help on using the changeset viewer.