Changeset 341c38f


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

Files:
18 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • INSTALL

    r0ae5feb rc24de65  
    33 * >=libpcap-0.8
    44 * flex and bison
    5 
    6 Strongly recommended:
    7  * zlib-dev (for reading and writing compressed traces)
     5 * libwandio (get it from http://research.wand.net.nz/software/libwandio.php)
    86
    97Optional:
  • Makefile.am

    ra2ce0a6 r3a333e2  
    11LIBPACKETDUMP_DIR = libpacketdump
    22TOOLS_DIR = tools
    3 WANDIO_DIR=libwandio
    4 SUBDIRS = $(WANDIO_DIR) lib $(LIBPACKETDUMP_DIR) $(TOOLS_DIR) docs examples
     3SUBDIRS = lib $(LIBPACKETDUMP_DIR) $(TOOLS_DIR) docs examples
    54
    65ACLOCAL_AMFLAGS = -I m4
  • configure.in

    r4007dbb r341c38f  
    4141        examples/stats/Makefile examples/tutorial/Makefile examples/parallel/Makefile
    4242        docs/libtrace.doxygen
    43         lib/libtrace.h libwandio/Makefile libwandio/tools/wandiocat/Makefile
     43        lib/libtrace.h
    4444        ])
    4545
     
    100100
    101101LIBPKTDUMP_LIBS="-ltrace "
    102 ADD_LDFLAGS="$ADD_LDFLAGS -L\$(abs_top_srcdir)/libwandio -L\$(abs_top_srcdir)/lib"
    103 LIBTRACE_LIBS="-lwandio"
     102ADD_LDFLAGS="$ADD_LDFLAGS -L\$(abs_top_srcdir)/lib"
     103LIBTRACE_LIBS=""
    104104TOOLS_LIBS=""
    105 LIBWANDIO_LIBS=""
    106105
    107106CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wextra -DLT_BUILDING_DLL=1"
     
    201200# Checking for libgdc
    202201AC_CHECK_HEADER(gdc.h,AC_DEFINE(HAVE_LIBGDC,1,[has gdc.h]))
     202
     203# Check for libwandio (no longer bundled with libtrace)
     204AC_CHECK_LIB(wandio,wandio_create,wandiofound=1,wandiofound=0)
     205if test "$wandiofound" = 0; then
     206        AC_MSG_ERROR(libwandio is required to compile libtrace. If you have installed it in a non-standard location please use LDFLAGS to specify the location of the library. WANDIO can be obtained from http://research.wand.net.nz/software/libwandio.php)
     207else
     208        LIBTRACE_LIBS="$LIBTRACE_LIBS -lwandio"
     209        TOOLS_LIBS="$TOOLS_LIBS -lwandio"
     210        AC_DEFINE([HAVE_LIBWANDIO],1,[compile with libwandio support])
     211fi
    203212
    204213# Check for libpcap
     
    449458
    450459if test "$have_pthread" = 1; then
    451         LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lpthread"
    452460        AC_DEFINE(HAVE_LIBPTHREAD, 1, [Set to 1 if pthreads are supported])
    453461fi
     
    551559        with_ncurses=no]
    552560)
    553                        
    554 AC_ARG_WITH([bzip2],
    555         AC_HELP_STRING([--with-bzip2], [build with support for bzip2 compressed files]))
    556 
    557 AS_IF([test "x$with_bzip2" != "xno"],
    558         [
    559         AC_CHECK_LIB(bz2, BZ2_bzDecompressInit, have_bzip=yes, have_bzip=no)
    560         ], [have_bzip=no])
    561 
    562 AS_IF([test "x$have_bzip" = "xyes"], [
    563         if test "$ac_cv_lib_bz2_BZ2_bzDecompressInit" != "none required"; then
    564                 LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lbz2"
    565         fi
    566         with_bzip2=yes
    567         AC_DEFINE(HAVE_LIBBZ2, 1, "Compiled with bzip2 support")],
    568        
    569         [AS_IF([test "x$with_bzip2" = "xyes"],
    570                 [AC_MSG_ERROR([bzip2 requested but not found])])
    571         AC_DEFINE(HAVE_LIBBZ2, 0, "Compiled with bzip2 support")
    572         with_bzip2=no]
    573 )
    574 
    575 AC_ARG_WITH([zlib],
    576         AC_HELP_STRING([--with-zlib], [build with support for zlib compressed files]))
    577 
    578 AS_IF([test "x$with_zlib" != "xno"],
    579         [
    580         AC_CHECK_LIB(z, deflate, have_zlib=yes, have_zlib=no)
    581         ], [have_zlib=no])
    582 
    583 AS_IF([test "x$have_zlib" = "xyes"], [
    584         if test "$ac_cv_lib_z_deflate" != "none required"; then
    585                 LIBWANDIO_LIBS="$LIBWANDIO_LIBS -lz"
    586         fi
    587         AC_DEFINE(HAVE_LIBZ, 1, "Compiled with zlib support")
    588         with_zlib=yes],
    589 
    590        
    591         [AS_IF([test "x$with_zlib" = "xyes"],
    592                 [AC_MSG_ERROR([zlib requested but not found])])
    593         AC_DEFINE(HAVE_LIBZ, 0, "Compiled with zlib support")
    594         with_zlib=no]
    595 )
    596 
    597 AC_ARG_WITH([lzo],
    598         AC_HELP_STRING([--with-lzo], [build with support for writing lzo compressed files]))
    599 
    600 AS_IF([test "x$with_lzo" != "xno"],
    601         [
    602         AC_CHECK_LIB(lzo2, lzo1x_1_compress, have_lzo=yes, have_lzo=no)
    603         ], [have_lzo=no])
    604 
    605 AS_IF([test "x$have_lzo" = "xyes"], [
    606         if test "$ac_cv_lib_lzo2_lzo1x_1_compress" != "none required"; then
    607                 LIBWANDIO_LIBS="$LIBWANDIO_LIBS -llzo2"
    608         fi
    609         AC_DEFINE(HAVE_LIBLZO2, 1, "Compiled with lzo2 support")
    610         with_lzo=yes],
    611 
    612        
    613         [AS_IF([test "x$with_lzo" = "xyes"],
    614                 [AC_MSG_ERROR([lzo requested but not found])])
    615         AC_DEFINE(HAVE_LIBLZO2, 0, "Compiled with lzo2 support")
    616         with_lzo=no]
    617 )
    618 
    619 AC_ARG_WITH([lzma],
    620         AC_HELP_STRING([--with-lzma], [build with support for lzma compressed files]))
    621 
    622 AS_IF([test "x$with_lzma" != "xno"],
    623         [
    624         AC_CHECK_HEADER(lzma.h, have_lzma=yes, have_lzma=no)
    625         ], [have_lzma=no])
    626 
    627 AS_IF([test "x$have_lzma" = "xyes"], [
    628         if test "$ac_cv_lib_lzma_code" != "none required"; then
    629                 LIBWANDIO_LIBS="$LIBWANDIO_LIBS -llzma"
    630         fi
    631         AC_DEFINE(HAVE_LIBLZMA, 1, "Compiled with lzma support")
    632         with_lzma=yes],
    633 
    634        
    635         [AS_IF([test "x$with_lzma" = "xyes"],
    636                 [AC_MSG_ERROR([lzma requested but not found])])
    637         AC_DEFINE(HAVE_LIBLZMA, 0, "Compiled with lzma support")
    638         with_lzma=no]
    639 )
    640561
    641562# Define automake conditionals for use in our Makefile.am files
     
    649570AM_CONDITIONAL([HAVE_LLVM], [test "x$JIT" != "xno" ])
    650571AM_CONDITIONAL([HAVE_NCURSES], [test "x$with_ncurses" != "xno"])
    651 AM_CONDITIONAL([HAVE_BZLIB], [test "x$with_bzip2" != "xno"])
    652 AM_CONDITIONAL([HAVE_ZLIB], [test "x$with_zlib" != "xno"])
    653 AM_CONDITIONAL([HAVE_LZO], [ test "x$with_lzo" != "xno"])
    654 AM_CONDITIONAL([HAVE_LZMA], [ test "x$with_lzma" != "xno"])
    655572
    656573# Check for miscellaneous programs
     
    662579AC_SUBST([LIBTRACE_LIBS])
    663580AC_SUBST([LIBPKTDUMP_LIBS])
    664 AC_SUBST([LIBWANDIO_LIBS])
    665581AC_SUBST([TOOLS_LIBS])
    666582#AC_SUBST([ADD_LIBS])
     
    704620fi
    705621
    706 reportopt "Compiled with compressed trace (zlib) support" $with_zlib
    707 reportopt "Compiled with compressed trace (bz2) support" $with_bzip2
    708 reportopt "Compiled with compressed trace (lzo write only) support" $with_lzo
    709 reportopt "Compiled with compressed trace (lzma) support" $with_lzma
    710622if test x"$libtrace_dag" = xtrue; then
    711623        if test "$libtrace_dag_version" = 24; then
  • examples/Makefile.examples

    rfdb5e98 r3a333e2  
    1 AM_CFLAGS=-I"$(top_srcdir)/lib" -I"$(top_srcdir)/libpacketdump" \
    2         -I"$(top_srcdir)/libwandio"
    3 AM_CXXFLAGS=-I"$(top_srcdir)/lib" -I"$(top_srcdir)/libpacketdump" \
    4         -I"$(top_srcdir)/libwandio"
    5 
     1AM_CFLAGS=-I"$(top_srcdir)/lib" -I"$(top_srcdir)/libpacketdump"
     2AM_CXXFLAGS=-I"$(top_srcdir)/lib" -I"$(top_srcdir)/libpacketdump"
    63AM_LDFLAGS=-L"$(top_srcdir)/lib" -L"$(top_srcdir)/libpacketdump" \
    7         -L"$(top_srcdir)/libwandio" -ltrace -lwandio
     4        -ltrace -lwandio
  • lib/Makefile.am

    r7c95027 r341c38f  
    6969endif
    7070
    71 AM_CPPFLAGS= @ADD_INCLS@ -I../libwandio
     71AM_CPPFLAGS= @ADD_INCLS@
    7272libtrace_la_LIBADD = @LIBTRACE_LIBS@ @LTLIBOBJS@ $(DPDKLIBS)
    7373libtrace_la_LDFLAGS=-version-info @LIBTRACE_MAJOR@:@LIBTRACE_MINOR@:@LIBTRACE_MID@ @ADD_LDFLAGS@
  • lib/format_dag25.c

    r6b98325 r341c38f  
    299299
    300300        dag_close(dev->fd);
    301         if (dev->dev_name)
    302                 free(dev->dev_name);
    303301        free(dev);
    304302}
  • lib/format_erf.c

    r5ab626a r341c38f  
    4949#include <string.h>
    5050#include <stdlib.h>
     51
    5152
    5253#ifdef WIN32
     
    135136        if (packet->trace->format->type==TRACE_FORMAT_ERF) {
    136137                dag_record_t *erfptr = (dag_record_t *)packet->header;
    137                 switch(erfptr->type) {
     138                switch((erfptr->type & 0x7f)) {
    138139                        case TYPE_ETH:         
    139140                        case TYPE_DSM_COLOR_ETH:
     
    152153int erf_get_framing_length(const libtrace_packet_t *packet)
    153154{
    154         return dag_record_size + erf_get_padding(packet);
     155        uint16_t extsize = 0;
     156        dag_record_t *erfptr = NULL;
     157        uint64_t *exthdr = NULL;
     158       
     159        erfptr = (dag_record_t *)packet->header;
     160        if ((erfptr->type & 0x80) == 0x80) {
     161                /* Extension headers are present */
     162                exthdr = (uint64_t *)((char *)packet->header + dag_record_size);
     163                extsize += 8;
     164
     165                while (*exthdr < (1UL << 31)) {
     166                        extsize += 8;
     167                        exthdr ++;
     168                        assert(extsize <= ntohs(erfptr->rlen));
     169                }
     170        }
     171       
     172
     173        return dag_record_size + extsize + erf_get_padding(packet);
    155174}
    156175
     
    186205        }
    187206        /* Is this a proper typed packet */
    188         if (erf->type > TYPE_AAL2) {
     207        if ((erf->type & 0x7f) > TYPE_AAL2) {
    189208                return 0;
    190209        }
     
    448467
    449468        /* Check for loss */
    450         if (erfptr->type == TYPE_DSM_COLOR_ETH) {
     469        if ((erfptr->type & 0x7f) == TYPE_DSM_COLOR_ETH) {
    451470                /* No idea how we get this yet */
    452471
     
    505524
    506525        /* Unknown/corrupt */
    507         if (((dag_record_t *)packet->buffer)->type >= TYPE_RAW_LINK) {
     526        if ((((dag_record_t *)packet->buffer)->type & 0x7f) >= TYPE_RAW_LINK) {
    508527                trace_set_err(libtrace, TRACE_ERR_BAD_PACKET,
    509528                                "Corrupt or Unknown ERF type");
     
    684703        dag_record_t *erfptr = 0;
    685704        erfptr = (dag_record_t *)packet->header;
    686         if (erfptr->type != TYPE_LEGACY)
    687                 return erf_type_to_libtrace(erfptr->type);
     705        uint8_t type = (erfptr->type & 0x7f);
     706        if (type != TYPE_LEGACY) {
     707                /* The top-most bit is now used to indicate the presence of
     708                 * extension headers :/ */
     709                return erf_type_to_libtrace(type);
     710        }
    688711        else {
    689712                /* Sigh, lets start wildly guessing */
  • lib/libtrace.h.in

    r652d720 r341c38f  
    18731873void *trace_get_link(const libtrace_packet_t *packet);
    18741874
     1875/** Strips layer 2.5 headers from a given packet.
     1876 * @param packet        The packet to strip headers from.
     1877 *
     1878 * @return The packet with the requested headers removed (if they were
     1879 * present).
     1880 *
     1881 * This function is intended for removing those pesky layer 2.5 headers
     1882 * that are not supported by other packet analysis applications, e.g. VLAN
     1883 * and MPLS headers. If successful, the resulting packet will be a simple
     1884 * Ethernet-IP-Transport packet that just about anything should be able to
     1885 * parse without difficulty.
     1886 *
     1887 * If this function encounters a layer 2 or 2.5 header that it does not
     1888 * support, stripping will cease and the packet returning will be stripped
     1889 * up to but not including the unsupported header.
     1890 *
     1891 * New in libtrace 4.0.0
     1892 *
     1893 * @note This function only supports stripping headers from Ethernet packets
     1894 * for now. Passing in packets of other link types will simply result in
     1895 * the original packet being returned unmodified.
     1896 *
     1897 */
     1898DLLEXPORT libtrace_packet_t *trace_strip_packet(libtrace_packet_t *packet);
     1899
    18751900/** Get a pointer to the IPv4 header (if any) for a given packet
    18761901 * @param packet        The packet to get the IPv4 header for
  • lib/protocols_l2.c

    rf7bcbfb r84cdb05  
    3737#include <assert.h>
    3838#include <stdlib.h>
     39#include <string.h>
    3940
    4041
     
    9798
    9899        return (void*)((char *)ethernet + sizeof(*vlanhdr));
     100
     101}
     102
     103libtrace_packet_t *trace_strip_packet(libtrace_packet_t *packet) {
     104
     105        libtrace_ether_t *ethernet;
     106        libtrace_linktype_t linktype;
     107        uint16_t ethertype;
     108        uint32_t remaining;
     109        char *nextpayload;
     110        uint16_t finalethertype = 0;
     111        uint16_t caplen, removed = 0;
     112        char *dest;
     113        uint8_t done = 0;
     114        uint32_t oldrem;
     115
     116        /* For now, this will just work for Ethernet packets. */
     117        ethernet = (libtrace_ether_t *)trace_get_layer2(packet,
     118                        &linktype, &remaining);
     119
     120        if (linktype != TRACE_TYPE_ETH) {
     121                return packet;
     122        }
     123
     124        /* No headers to strip, return the original packet */
     125        if (ethernet->ether_type == TRACE_ETHERTYPE_IP ||
     126                        ethernet->ether_type == TRACE_ETHERTYPE_IPV6) {
     127                return packet;
     128        }
     129
     130        if (remaining <= sizeof(libtrace_ether_t))
     131                return packet;
     132
     133        caplen = trace_get_capture_length(packet);
     134        ethertype = ntohs(ethernet->ether_type);
     135        dest = ((char *)ethernet) + sizeof(libtrace_ether_t);
     136        nextpayload = dest;
     137        remaining -= sizeof(libtrace_ether_t);
     138
     139        /* I'd normally use trace_get_layer3 here, but it works out faster
     140         * to do it this way (mostly less function call overhead).
     141         *
     142         * XXX This approach is going to just strip everything between the
     143         * Ethernet and IP headers -- is there a use case where someone
     144         * might want to selectively strip headers?
     145         */
     146        while (!done) {
     147
     148                if (nextpayload == NULL || remaining == 0)
     149                        break;
     150
     151                oldrem = remaining;
     152                switch (ethertype) {
     153
     154                case TRACE_ETHERTYPE_8021Q:
     155                        nextpayload = (char *)trace_get_payload_from_vlan(
     156                                        nextpayload,
     157                                        &ethertype, &remaining);
     158                        removed += (oldrem - remaining);
     159                        break;
     160
     161                case TRACE_ETHERTYPE_MPLS:
     162                        nextpayload = (char *)trace_get_payload_from_mpls(
     163                                        nextpayload,
     164                                        &ethertype, &remaining);
     165                        removed += (oldrem - remaining);
     166                        break;
     167                case TRACE_ETHERTYPE_PPP_SES:
     168                        nextpayload = (char *)trace_get_payload_from_pppoe(
     169                                        nextpayload,
     170                                        &ethertype, &remaining);
     171                        removed += (oldrem - remaining);
     172                        break;
     173
     174                case TRACE_ETHERTYPE_IP:
     175                case TRACE_ETHERTYPE_IPV6:
     176                default:
     177                        if (finalethertype == 0)
     178                                finalethertype = ethertype;
     179                        done = true;
     180                        break;
     181                }
     182        }
     183
     184        if (nextpayload != NULL) {
     185
     186                ethernet->ether_type = ntohs(finalethertype);
     187                trace_set_capture_length(packet, caplen - removed);
     188                memmove(nextpayload - (dest - (char *)packet->payload),
     189                        packet->payload,
     190                        (dest - (char *)packet->payload));
     191                packet->payload = nextpayload - (dest - (char *)packet->payload);
     192                packet->l2_header = NULL;
     193        }
     194       
     195        return packet;
    99196
    100197}
  • lib/protocols_l3.c

    r7baa948 r0277ab8  
    245245        }
    246246
    247         link = trace_get_layer2(packet,&linktype,remaining);
     247        if (packet->l2_header) {
     248                link = packet->l2_header;
     249                linktype = packet->link_type;
     250                *remaining = packet->l2_remaining;
     251        } else {
     252                link = trace_get_layer2(packet,&linktype,remaining);
     253        }
    248254        iphdr = trace_get_payload_from_layer2(
    249255                        link,
  • libpacketdump/Makefile.am

    rbd119b3 r3a333e2  
    172172dist_plugin_DATA = $(TXT_PROTOCOLS)
    173173
    174 AM_CPPFLAGS= @ADD_INCLS@ -I../lib -I../libwandio
     174AM_CPPFLAGS= @ADD_INCLS@ -I../lib
    175175
    176176# NOTE: You CANNOT add @LEXLIBS@ here, as they are statically compiled
  • 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.