Changeset 341c38f for tools


Ignore:
Timestamp:
08/25/15 14:48:04 (5 years ago)
Author:
Richard Sanger <rsangerarj@…>
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:
03aca91
Parents:
54cf135 (diff), 84cdb05 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'upstream/develop' into develop

Location:
tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tools/Makefile.tools

    rfdb5e98 r3a333e2  
    11
    22
    3 AM_CFLAGS=-I"$(top_srcdir)/lib" -I"$(top_srcdir)/libpacketdump" \
    4         -I"$(top_srcdir)/libwandio"
    5 AM_CXXFLAGS=-I"$(top_srcdir)/lib" -I"$(top_srcdir)/libpacketdump" \
    6         -I"$(top_srcdir)/libwandio"
    7        
     3AM_CFLAGS=-I"$(top_srcdir)/lib" -I"$(top_srcdir)/libpacketdump"
     4AM_CXXFLAGS=-I"$(top_srcdir)/lib" -I"$(top_srcdir)/libpacketdump"
    85AM_LDFLAGS=-L"$(top_srcdir)/lib" -L"$(top_srcdir)/libpacketdump" \
    9         -L"$(top_srcdir)/libwandio" -ltrace -lwandio @TOOLS_LIBS@
     6       -ltrace @TOOLS_LIBS@
  • tools/traceanon/traceanon.1

    r17f954f r8b12caf  
    88[ \-p prefix | \-\^\-prefix=prefix ]
    99[ \-c key | \-\^\-cryptopan=key ]
    10 [ \-f key-file | \-\^\-keyfile=file ]
     10[ \-F key-file | \-\^\-keyfile=file ]
     11[ \-f expr | \-\^\-filter=expr ]
    1112[ \-z level | \-\^\-compress-level=level ]
    1213[ \-Z method | \-\^\-compress-type=method ]
     
    5960.TP
    6061.PD 0
    61 .BI \-f
     62.BI \-F
    6263.TP
    6364.PD
     
    6768long. A suitable method of generating a key is by using the command dd to read
    6869from /dev/urandom.
     70
     71.TP
     72.PD 0
     73.BI \-f
     74.TP
     75.PD
     76.BI \-\^\-filter=expr
     77Discard all packets that do not match the BPF expression specified in 'expr'.
     78Filtering is applied *before* any anonymisation occurs, so IP address filters
     79will attempt to match against the original unencrypted addresses.
    6980
    7081
  • tools/traceanon/traceanon.c

    r17f954f r4a5678c  
    99#include <string.h>
    1010#include <time.h>
     11#include <signal.h>
    1112#include "ipenc.h"
    12 
    1313
    1414static void usage(char *argv0)
     
    2020        "-c --cryptopan=key     Encrypt the addresses with the cryptopan\n"
    2121        "                       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"
    2325        "-p --prefix=C.I.D.R/bits Substitute the prefix of the address\n"
    2426        "-H --libtrace-help     Print libtrace runtime documentation\n"
    2527        "-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"
    2729        "                       compression algorithm\n"
    2830        ,argv0);
    2931        exit(1);
     32}
     33
     34volatile int done=0;
     35
     36static void cleanup_signal(int sig)
     37{
     38        (void)sig;
     39        done=1;
     40        trace_interrupt();
    3041}
    3142
     
    116127        struct libtrace_packet_t *packet = trace_create_packet();
    117128        struct libtrace_out_t *writer = 0;
     129        struct libtrace_filter_t *filter = NULL;
    118130        bool enc_source = false;
    119131        bool enc_dest   = false;
    120132        char *output = 0;
    121133        int level = -1;
     134        char *filterstring = NULL;
    122135        char *compress_type_str=NULL;
    123136        trace_option_compresstype_t compress_type = TRACE_OPTION_COMPRESSTYPE_NONE;
    124 
     137        struct sigaction sigact;
    125138
    126139        if (argc<2)
    127140                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);
    128148
    129149        while (1) {
     
    133153                        { "encrypt-dest",       0, 0, 'd' },
    134154                        { "cryptopan",          1, 0, 'c' },
    135                         { "cryptopan-file",     1, 0, 'f' },
     155                        { "cryptopan-file",     1, 0, 'F' },
     156                        { "filter",             1, 0, 'f' },
    136157                        { "prefix",             1, 0, 'p' },
    137158                        { "compress-level",     1, 0, 'z' },
     
    152173                        case 's': enc_source=true; break;
    153174                        case 'd': enc_dest  =true; break;
     175                        case 'f': filterstring = optarg; break;
    154176                        case 'c':
    155177                                  if (key!=NULL) {
     
    160182                                  enc_type = ENC_CRYPTOPAN;
    161183                                  break;
    162                         case 'f':
     184                        case 'F':
    163185                                  if(key != NULL) {
    164186                                    fprintf(stderr,"You can only have one encryption type and one key\n");
     
    230252       
    231253
     254        if (filterstring) {
     255            filter = trace_create_filter(filterstring);
     256        }
     257
    232258        enc_init(enc_type,key);
    233259
     
    279305        }
    280306
     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
    281314        if (trace_start(trace)==-1) {
    282315                trace_perror(trace,"trace_start");
     
    298331                int psize;
    299332                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) {
    305334                        break;
    306335                }
     
    334363                        break;
    335364                }
    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       
    337376        trace_destroy_packet(packet);
    338377        trace_destroy(trace);
Note: See TracChangeset for help on using the changeset viewer.