Changeset faf16af


Ignore:
Timestamp:
07/07/14 14:25:36 (7 years ago)
Author:
Shane Alcock <salcock@…>
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:
262a093, ce7153d, ea602cd
Parents:
1ca603b (diff), 17f954f (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 branch 'develop'

Files:
10 added
35 edited

Legend:

Unmodified
Added
Removed
  • README

    rfbd4ba6 r9ad7a35  
    1 libtrace 3.0.19
     1libtrace 3.0.20
    22
    33---------------------------------------------------------------------------
  • configure.in

    rfbd4ba6 r457bf45  
    44# and in the README
    55
    6 AC_INIT([libtrace],[3.0.19],[contact@wand.net.nz],[libtrace])
     6AC_INIT([libtrace],[3.0.20],[contact@wand.net.nz],[libtrace])
    77
    88LIBTRACE_MAJOR=3
    99LIBTRACE_MID=0
    10 LIBTRACE_MINOR=19
     10LIBTRACE_MINOR=20
    1111
    1212# OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not
     
    1919AC_CONFIG_MACRO_DIR([m4])
    2020AC_CONFIG_SRCDIR(lib/trace.c)
    21 AM_INIT_AUTOMAKE
     21AM_INIT_AUTOMAKE([subdir-objects])
    2222
    2323# Make sure we use the relatively silent automake output
     
    105105LIBWANDIO_LIBS=""
    106106
    107 # Set our C compiler flags based on the gcc version
    108 if test "$GCC" = "yes"; then
     107CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wextra -DLT_BUILDING_DLL=1"
     108CXXFLAGS="$CXXFLAGS -Wall -DLT_BUILDING_DLL=1"
     109
     110# Check for -fvisibility
     111gl_VISIBILITY
     112
     113gcc_PACKED
     114gcc_DEPRECATED
     115gcc_UNUSED
     116gcc_PURE
     117gcc_FORMAT
    109118       
    110         gcc_version=`gcc -dumpversion`
    111 
    112         # This is probably not the most reliable way to test whether our
    113         # compiler supports visibility, but it's better than nothing
    114         #
    115         # According to the gcc wiki - http://gcc.gnu.org/wiki/Visibility -
    116         # visibility is supported in gcc 4.0 or later, so we just need to
    117         # check the major version number
    118 
    119         major=$(echo $gcc_version | cut -d'.' -f1)
    120 
    121         #major=${gcc_version%\.*\.*}
    122 
    123         if test "$major" -lt 4; then
    124                 vis=no
    125         else
    126                 vis=yes
    127         fi
    128        
    129         CFLAGS="$CFLAGS -Wall -Wmissing-prototypes"
    130         CXXFLAGS="$CXXFLAGS -Wall"
    131         LIBCFLAGS="$CFLAGS"
    132         LIBCFLAGS="$LIBCFLAGS -DLT_BUILDING_DLL=1"
    133         LIBCXXFLAGS="$CXXFLAGS"
    134         LIBCXXFLAGS="$CXXFLAGS -DLT_BUILDING_DLL=1"
    135        
    136         if test "$vis" = "yes"; then
    137                 LIBCFLAGS="$LIBCFLAGS -Wextra -fvisibility=hidden"
    138                 LIBCXXFLAGS="$CXXFLAGS -Wextra -fvisibility=hidden"
    139         fi
    140 fi
    141 
    142119# Check for libtool
    143120AC_PROG_LIBTOOL
     
    603580)
    604581
     582AC_ARG_WITH([lzma],
     583        AC_HELP_STRING([--with-lzma], [build with support for lzma compressed files]))
     584
     585AS_IF([test "x$with_lzma" != "xno"],
     586        [
     587        AC_CHECK_HEADER(lzma.h, have_lzma=yes, have_lzma=no)
     588        ], [have_lzma=no])
     589
     590AS_IF([test "x$have_lzma" = "xyes"], [
     591        if test "$ac_cv_lib_lzma_code" != "none required"; then
     592                LIBWANDIO_LIBS="$LIBWANDIO_LIBS -llzma"
     593        fi
     594        AC_DEFINE(HAVE_LIBLZMA, 1, "Compiled with lzma support")
     595        with_lzma=yes],
     596
     597       
     598        [AS_IF([test "x$with_lzma" = "xyes"],
     599                [AC_MSG_ERROR([lzma requested but not found])])
     600        AC_DEFINE(HAVE_LIBLZMA, 0, "Compiled with lzma support")
     601        with_lzma=no]
     602)
    605603
    606604# Define automake conditionals for use in our Makefile.am files
     
    617615AM_CONDITIONAL([HAVE_ZLIB], [test "x$with_zlib" != "xno"])
    618616AM_CONDITIONAL([HAVE_LZO], [ test "x$with_lzo" != "xno"])
     617AM_CONDITIONAL([HAVE_LZMA], [ test "x$with_lzma" != "xno"])
    619618
    620619# Check for miscellaneous programs
     
    671670reportopt "Compiled with compressed trace (bz2) support" $with_bzip2
    672671reportopt "Compiled with compressed trace (lzo write only) support" $with_lzo
     672reportopt "Compiled with compressed trace (lzma) support" $with_lzma
    673673if test x"$libtrace_dag" = xtrue; then
    674674        if test "$libtrace_dag_version" = 24; then
  • lib/Makefile.am

    r2138553 rbd119b3  
    22include_HEADERS = libtrace.h dagformat.h lt_inttypes.h daglegacy.h rt_protocol.h erftypes.h 
    33
    4 AM_CFLAGS=@LIBCFLAGS@
    5 AM_CXXFLAGS=@LIBCXXFLAGS@
     4AM_CFLAGS=@LIBCFLAGS@ @CFLAG_VISIBILITY@
     5AM_CXXFLAGS=@LIBCXXFLAGS@ @CFLAG_VISIBILITY@
    66
    77extra_DIST = format_template.c
     
    5858endif
    5959
    60 INCLUDES= @ADD_INCLS@ -I../libwandio
     60AM_CPPFLAGS= @ADD_INCLS@ -I../libwandio
    6161libtrace_la_LIBADD = @LIBTRACE_LIBS@ @LTLIBOBJS@ $(DPDKLIBS)
    6262libtrace_la_LDFLAGS=-version-info @LIBTRACE_MAJOR@:@LIBTRACE_MINOR@:@LIBTRACE_MID@ @ADD_LDFLAGS@
  • lib/format_helper.c

    r8b49230 r74ecbc7  
    263263{
    264264        iow_t *io = NULL;
    265         assert(level<10);
    266         assert(level>=0);
     265
     266        if (level < 0 || level > 9) {
     267                trace_set_err_out(trace, TRACE_ERR_UNSUPPORTED_COMPRESS,
     268                                "Compression level %d is invalid, must be between 0 and 9 inclusive",
     269                                level);
     270                return NULL;
     271        }
     272
     273        if (compress_type < 0 ||
     274                        compress_type >= TRACE_OPTION_COMPRESSTYPE_LAST) {
     275                trace_set_err_out(trace, TRACE_ERR_UNSUPPORTED_COMPRESS,
     276                                "Invalid compression type %d", compress_type);
     277                return NULL;
     278        }
    267279
    268280        io = wandio_wcreate(trace->uridata, compress_type, level, fileflag);
  • lib/format_linux.c

    r7a529a9 rd1af45d  
    10201020        struct pollfd pollset; 
    10211021        int ret;
     1022        unsigned int snaplen;
    10221023       
    10231024        ring_release_frame(libtrace, packet);
     
    10481049
    10491050        packet->buffer = header;
     1051
     1052        /* If a snaplen was configured, automatically truncate the packet to
     1053         * the desired length.
     1054         */
     1055        snaplen=LIBTRACE_MIN(
     1056                        (int)LIBTRACE_PACKET_BUFSIZE-(int)sizeof(*header),
     1057                        (int)FORMAT(libtrace->format_data)->snaplen);
     1058       
     1059        TO_TP_HDR(packet->buffer)->tp_snaplen = LIBTRACE_MIN((unsigned int)snaplen, TO_TP_HDR(packet->buffer)->tp_len);
    10501060
    10511061        /* Move to next buffer */
  • lib/libtrace.h.in

    rf7bcbfb r17f954f  
    8080#if defined(LITTLE_ENDIAN) && !defined(__LITTLE_ENDIAN)
    8181#define __LITTLE_ENDIAN LITTLE_ENDIAN
    82 #endif
    83 
    84 #ifdef _MSC_VER
    85     /* define the following from MSVC's internal types */
    86     typedef             __int8  int8_t;
    87     typedef             __int16 int16_t;
    88     typedef             __int32 int32_t;
    89     typedef             __int64 int64_t;
    90     typedef unsigned    __int8  uint8_t;
    91     typedef unsigned    __int16 uint16_t;
    92     typedef unsigned    __int32 uint32_t;
    93     typedef unsigned    __int64 uint64_t;
    94     #ifdef LT_BUILDING_DLL
    95         #define DLLEXPORT __declspec(dllexport)
    96     #else
    97         #define DLLEXPORT __declspec(dllimport)
    98     #endif
    99     #define DLLLOCAL
    100     /* Windows pads bitfields out to to the size of their parent type
    101      * however gcc warns that this doesn't meet with the iso C specification
    102      * so produces warnings for this behaviour.  sigh.
    103      */
    104     #define LT_BITFIELD8        uint8_t
    105     #define LT_BITFIELD16       uint16_t
    106     #define LT_BITFIELD32       uint32_t
    107     #define LT_BITFIELD64       uint64_t
    108 #else
    109     #ifdef HAVE_STDINT_H
    110         #   include <stdint.h>
    111     #endif
    112     #if __GNUC__ >= 4
    113         #ifdef LT_BUILDING_DLL
    114                 #define DLLEXPORT __attribute__ ((visibility("default")))
    115                 #define DLLLOCAL __attribute__ ((visibility("hidden")))
    116         #else
    117                 #define DLLEXPORT
    118                 #define DLLLOCAL
    119         #endif
    120     #else
    121         #define DLLEXPORT
    122         #define DLLLOCAL
    123     #endif
    124     /* GCC warns if the bitfield type is not "unsigned int", however windows
    125      * generates incorrect code for this (see above), so we define these
    126      * macros.  How Hideous.  So much for C's portability.
    127      */
    128     #define LT_BITFIELD8        unsigned int
    129     #define LT_BITFIELD16       unsigned int
    130     #define LT_BITFIELD32       unsigned int
    131     #define LT_BITFIELD64       unsigned int
    13282#endif
    13383
     
    170120#endif
    171121
    172 /* Function does not depend on anything but its
    173  * parameters, used to hint gcc's optimisations
    174  */
    175 #if __GNUC__ >= 3
     122#ifdef _MSC_VER
     123    /* define the following from MSVC's internal types */
     124    typedef             __int8  int8_t;
     125    typedef             __int16 int16_t;
     126    typedef             __int32 int32_t;
     127    typedef             __int64 int64_t;
     128    typedef unsigned    __int8  uint8_t;
     129    typedef unsigned    __int16 uint16_t;
     130    typedef unsigned    __int32 uint32_t;
     131    typedef unsigned    __int64 uint64_t;
     132   
     133    /* Windows pads bitfields out to to the size of their parent type
     134     * however gcc warns that this doesn't meet with the iso C specification
     135     * so produces warnings for this behaviour.  sigh.
     136     */
     137    #define LT_BITFIELD8        uint8_t
     138    #define LT_BITFIELD16       uint16_t
     139    #define LT_BITFIELD32       uint32_t
     140    #define LT_BITFIELD64       uint64_t
     141#else
     142    #ifdef HAVE_STDINT_H
     143        #   include <stdint.h>
     144    #endif
     145    /* GCC warns if the bitfield type is not "unsigned int", however windows
     146     * generates incorrect code for this (see above), so we define these
     147     * macros.  How Hideous.  So much for C's portability.
     148     */
     149    #define LT_BITFIELD8        unsigned int
     150    #define LT_BITFIELD16       unsigned int
     151    #define LT_BITFIELD32       unsigned int
     152    #define LT_BITFIELD64       unsigned int
     153#endif
     154
     155/* Ensure these gcc optimisation attributes are defined consistently,
     156 * without requiring users to need to have access to the config.h
     157 * generated by running configure.
     158 */
     159
     160#define LT_USE_PACKED @HAVE_ATTRIBUTE_PACKED@
     161#define LT_USE_UNUSED @HAVE_ATTRIBUTE_UNUSED@
     162#define LT_USE_DEPRECATED @HAVE_ATTRIBUTE_DEPRECATED@
     163#define LT_USE_PURE @HAVE_ATTRIBUTE_PURE@
     164#define LT_USE_PRINTF @HAVE_ATTRIBUTE_FORMAT@
     165#define LT_USE_VISIBILITY @HAVE_VISIBILITY@
     166
     167#if LT_USE_PACKED
     168#  define PACKED __attribute__((packed))
     169#else
     170#  define PACKED
     171#endif
     172
     173#if LT_USE_UNUSED
     174#  define UNUSED __attribute__((unused))
     175#else
     176#  define UNUSED
     177#endif
     178
     179#if LT_USE_DEPRECATED
    176180#  define DEPRECATED __attribute__((deprecated))
    177 #  define SIMPLE_FUNCTION __attribute__((pure))
    178 #  define UNUSED __attribute__((unused))
    179 #  define PACKED __attribute__((packed))
    180 #  define PRINTF(formatpos,argpos) __attribute__((format(printf,formatpos,argpos)))
    181181#else
    182182#  define DEPRECATED
     183#endif
     184
     185#if LT_USE_PURE
     186#  define SIMPLE_FUNCTION __attribute__((pure))
     187#else
    183188#  define SIMPLE_FUNCTION
    184 #  define UNUSED
    185 #  define PACKED
    186 #  define PRINTF(formatpos,argpos)
    187189#endif
     190
     191#if LT_USE_PRINTF
     192#  define PRINTF(formatpos, argpos) __attribute__((format(printf,formatpos, argpos)))
     193#else
     194#  define PRINTF(formatpos, argpos)
     195#endif
     196
     197#ifdef _MSC_VER
     198    #ifdef LT_BUILDING_DLL
     199        #define DLLEXPORT __declspec(dllexport)
     200    #else
     201        #define DLLEXPORT __declspec(dllimport)
     202    #endif
     203    #define DLLLOCAL
     204#else
     205    #ifndef DLLEXPORT
     206        #if LT_USE_VISIBILITY && LT_BUILDING_DLL
     207            #define DLLEXPORT __attribute__ ((visibility("default")))
     208            #define DLLLOCAL __attribute__ ((visibility("hidden")))
     209        #else
     210            #define DLLEXPORT
     211            #define DLLLOCAL
     212        #endif
     213    #endif
     214#endif
     215
    188216       
    189217/** Opaque structure holding information about an output trace */
     
    839867        uint8_t ospf_v;         /**< OSPF Version, should be 2 */
    840868        uint8_t type;           /**< OSPF Packet Type */
    841         uint16_t len;           /**< Packet length, including OSPF header */
     869        uint16_t ospf_len;      /**< Packet length, including OSPF header */
    842870        struct in_addr router;  /**< Router ID of the packet source */
    843871        struct in_addr area;    /**< Area the packet belongs to */
     
    12101238        TRACE_OPTION_COMPRESSTYPE_ZLIB = 1, /**< GZip Compression */
    12111239        TRACE_OPTION_COMPRESSTYPE_BZ2  = 2, /**< BZip2 Compression */
    1212         TRACE_OPTION_COMPRESSTYPE_LZO  = 3  /**< LZO Compression */
     1240        TRACE_OPTION_COMPRESSTYPE_LZO  = 3,  /**< LZO Compression */
     1241        TRACE_OPTION_COMPRESSTYPE_LZMA  = 4,  /**< LZO Compression */
     1242        TRACE_OPTION_COMPRESSTYPE_LAST
    12131243} trace_option_compresstype_t;
    12141244
     
    17501780DLLEXPORT uint16_t *trace_checksum_transport(libtrace_packet_t *packet,
    17511781                uint16_t *csum);
     1782
     1783/** Calculates the fragment offset in bytes for an IP packet
     1784 * @param packet        The libtrace packet to calculate the offset for
     1785 * @param[out] more     A boolean flag to indicate whether there are more
     1786 *                      fragments after the current packet.
     1787 * @return The fragment offset for the packet in bytes. If the packet is not
     1788 * an IP packet or the fragment offset is not present in packet, the return
     1789 * value will be 0.
     1790 *
     1791 * @note The value returned is in bytes, not 8-octet units as it is stored
     1792 * in the fragment offset field in the headers. In other words, libtrace
     1793 * automatically does the multiplication for you.
     1794 *
     1795 * The value passed in for 'more' does not matter; it will be overwritten
     1796 * with the value of the More Fragments flag from the IP header.
     1797 *
     1798 * New in libtrace 3.0.20
     1799 */
     1800DLLEXPORT uint16_t trace_get_fragment_offset(const libtrace_packet_t *packet,
     1801                uint8_t *more);
    17521802
    17531803/** Gets a pointer to the transport layer header (if any)
  • lib/libtrace_int.h

    r8b49230 r10f924c  
    147147#include "bpf-jit/bpf-jit.h"
    148148#endif
     149
    149150
    150151//#define RP_BUFSIZE 65536U
  • lib/protocols_l3.c

    r9ca1fce r7baa948  
    724724}
    725725
     726DLLEXPORT uint16_t trace_get_fragment_offset(const libtrace_packet_t *packet,
     727                uint8_t *more) {
     728
     729        void *l3;
     730        uint16_t ethertype;
     731        uint32_t remaining;
     732
     733        *more = 0;
     734
     735        l3 = trace_get_layer3(packet, &ethertype, &remaining);
     736        if (l3 == NULL)
     737                return 0;
     738
     739        if (ethertype == TRACE_ETHERTYPE_IP) {
     740                libtrace_ip_t *ip = (libtrace_ip_t *)l3;
     741                uint16_t offset = 0;
     742
     743                /* Fragment offset appears in 7th and 8th bytes */
     744                if (remaining < 8)
     745                        return 0;
     746                 
     747                offset = ntohs(ip->ip_off);
     748
     749                if ((offset & 0x2000) != 0)
     750                        *more = 1;
     751                return (offset & 0x1FFF) * 8;
     752        }
     753
     754        if (ethertype == TRACE_ETHERTYPE_IPV6) {
     755                libtrace_ip6_t *ip6 = (libtrace_ip6_t *)l3;
     756                void *payload = ip6++;
     757                uint8_t nxt = ip6->nxt;
     758                uint16_t len;
     759               
     760                /* First task, find a Fragment header if present */
     761                if (remaining < sizeof(libtrace_ip6_t))
     762                        return 0;
     763                remaining -= sizeof(libtrace_ip6_t);
     764
     765                /* Adapted from trace_get_payload_from_ip6 */
     766                while (1) {
     767                        switch (nxt) {
     768                        case 0:
     769                        case TRACE_IPPROTO_ROUTING:
     770                        case TRACE_IPPROTO_AH:
     771                        case TRACE_IPPROTO_DSTOPTS:
     772                        {
     773
     774                                /* Length does not include the first 8 bytes */
     775                                len=((libtrace_ip6_ext_t*)payload)->len * 8;
     776                                len += 8;
     777
     778                                if (remaining < len) {
     779                                        /* Snap too short */
     780                                        return 0;
     781                                }
     782                                remaining-=len;
     783
     784                                nxt=((libtrace_ip6_ext_t*)payload)->nxt;
     785                                continue;
     786                        }
     787                        case TRACE_IPPROTO_FRAGMENT:
     788                        {
     789                                libtrace_ip6_frag_t *frag = (libtrace_ip6_frag_t *)payload;
     790                                uint16_t offset;
     791                                len = sizeof(libtrace_ip6_frag_t);
     792                                if (remaining < len) {
     793                                        /* Snap too short */
     794                                        return 0;
     795                                }
     796                                remaining-=len;
     797
     798                                offset = ntohs(frag->frag_off);
     799                                if ((offset & 0x0001) != 0)
     800                                        *more = 1;
     801
     802                                return ((offset & 0xFFF8) >> 3) * 8;
     803                         }
     804                         default:
     805                                return 0;
     806                         }
     807                }
     808
     809        }
     810        return 0;
     811}
  • lib/protocols_ospf.c

    r8753bb8 r10f924c  
    3232 */
    3333
     34#include "libtrace_int.h"
    3435#include "libtrace.h"
    3536#include "protocols.h"
  • lib/protocols_transport.c

    rc909fad re0bea4e5  
    3333
    3434
     35#include "libtrace_int.h"
    3536#include "libtrace.h"
    3637#include "protocols.h"
     
    381382        uint32_t remaining;
    382383        uint8_t proto;
    383         const struct ports_t *port =
    384                 (const struct ports_t*)trace_get_transport((libtrace_packet_t*)packet,
     384        struct ports_t *port;
     385        uint16_t fragoff;
     386        uint8_t more;
     387
     388        fragoff = trace_get_fragment_offset(packet, &more);
     389
     390        /* If we're not the first fragment, we're unlikely to be able
     391         * to get any useful port numbers from this packet.
     392         */
     393        if (fragoff != 0)
     394                return 0;
     395       
     396       
     397        port = (struct ports_t*)trace_get_transport(
     398                        (libtrace_packet_t*)packet,
    385399                        &proto, &remaining);
    386400
     
    390404
    391405        /* ICMP *technically* doesn't have ports */
    392         if (proto == TRACE_IPPROTO_ICMP)
     406        if (proto == TRACE_IPPROTO_ICMP || proto == TRACE_IPPROTO_ICMPV6)
    393407                return 0;
    394408
     
    404418        uint32_t remaining;
    405419        uint8_t proto;
    406         struct ports_t *port =
    407                 (struct ports_t*)trace_get_transport((libtrace_packet_t*)packet,
     420        struct ports_t *port;
     421        uint16_t fragoff;
     422        uint8_t more;
     423
     424        fragoff = trace_get_fragment_offset(packet, &more);
     425
     426        /* If we're not the first fragment, we're unlikely to be able
     427         * to get any useful port numbers from this packet.
     428         */
     429        if (fragoff != 0)
     430                return 0;
     431       
     432       
     433        port = (struct ports_t*)trace_get_transport(
     434                        (libtrace_packet_t*)packet,
    408435                        &proto, &remaining);
    409436        /* Snapped too early */
     
    412439       
    413440        /* ICMP *technically* doesn't have ports */
    414         if (proto == TRACE_IPPROTO_ICMP)
     441        if (proto == TRACE_IPPROTO_ICMP || proto == TRACE_IPPROTO_ICMPV6)
    415442                return 0;
    416443
  • libpacketdump/Makefile.am

    r8b49230 rbd119b3  
    172172dist_plugin_DATA = $(TXT_PROTOCOLS)
    173173
    174 INCLUDES= @ADD_INCLS@ -I../lib -I../libwandio
     174AM_CPPFLAGS= @ADD_INCLS@ -I../lib -I../libwandio
    175175
    176176# NOTE: You CANNOT add @LEXLIBS@ here, as they are statically compiled
     
    182182        @ADD_LDFLAGS@
    183183
    184 AM_CXXFLAGS=-g -Wall -DDIRNAME=\"$(plugindir)\" $(INCLUDES)
     184AM_CXXFLAGS=-g -Wall -DDIRNAME=\"$(plugindir)\" $(AM_CPPFLAGS)
    185185BUILT_SOURCES=parser.h
    186186AM_YFLAGS=-d
  • libpacketdump/eth_2048.c

    r66ad025 r387d299  
    1010#include <netdb.h>
    1111
    12 #define DISPLAY_EXP(x,fmt,exp) \
    13         if ((unsigned int)len>=((char*)&ip->x-(char*)ip+sizeof(ip->x))) \
    14                 printf(fmt,exp); \
    15         else \
    16                 return;
    17 
    18 #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,ip->x)
    19 
    20 #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(ip->x))
    21 #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&ip->x))
    22 
    2312DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
    2413{
     
    2918        }
    3019        //DISPLAY(ip_tos," TOS %02x")
    31         DISPLAY_EXP(ip_tos," DSCP %02x",ip->ip_tos >> 2)
    32         DISPLAY_EXP(ip_tos," ECN %x",ip->ip_tos & 0x2)
    33         DISPLAYS(ip_len," Total Length %i")
     20        DISPLAY_EXP(ip, ip_tos," DSCP %02x",ip->ip_tos >> 2);
     21        DISPLAY_EXP(ip, ip_tos," ECN %x",ip->ip_tos & 0x2);
     22        DISPLAYS(ip, ip_len," Total Length %i");
    3423        printf("\n IP:");
    35         DISPLAYS(ip_id," Id %u");
     24        DISPLAYS(ip, ip_id," Id %u");
    3625       
    3726        if ((unsigned int)len >= ((char *)&ip->ip_ttl - (char *)ip - 2)) {
     
    4231        }
    4332        //printf("\n IP:");
    44         DISPLAY(ip_ttl,"\n IP: TTL %i");
     33        DISPLAY(ip, ip_ttl,"\n IP: TTL %i");
    4534        if ((unsigned int)len>=((char*)&ip->ip_p-(char*)ip+sizeof(ip->ip_p))) {
    4635                struct protoent *ent=getprotobynumber(ip->ip_p);
     
    5544                return;
    5645        }
    57         DISPLAYS(ip_sum," Checksum %i\n");
    58         DISPLAYIP(ip_src," IP: Source %s ");
    59         DISPLAYIP(ip_dst,"Destination %s\n");
     46        DISPLAYS(ip, ip_sum," Checksum %i\n");
     47        DISPLAYIP(ip, ip_src," IP: Source %s ");
     48        DISPLAYIP(ip, ip_dst,"Destination %s\n");
    6049        decode_next(packet+ip->ip_hl*4,len-ip->ip_hl*4,"ip",ip->ip_p);
    6150        return;
  • libpacketdump/ip_1.c

    rec0b927 r387d299  
    33#include <dlfcn.h>
    44#include "libpacketdump.h"
    5 
    6 #define STRUCT icmp
    7 
    8 #define SAFE(x) \
    9         ((unsigned int)len>=((char*)&STRUCT->x-(char*)STRUCT+sizeof(STRUCT->x)))
    10 #define DISPLAY_EXP(x,fmt,exp) \
    11         if (SAFE(x)) \
    12                 printf(fmt,exp); \
    13         else \
    14                 return;
    15 
    16 #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,STRUCT->x)
    17 
    18 #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(STRUCT->x))
    19 #define DISPLAYL(x,fmt) DISPLAY_EXP(x,fmt,htonl(STRUCT->x))
    20 #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&STRUCT->x))
    215
    226static char *unreach_types[]={
  • libpacketdump/ip_17.c

    rc7062df r387d299  
    88#include <netdb.h>
    99
    10 #define STRUCT udp
    11 
    12 #define SAFE(x) \
    13         ((unsigned int)len>=((char*)&STRUCT->x-(char*)STRUCT+sizeof(STRUCT->x)))
    14 #define DISPLAY_EXP(x,fmt,exp) \
    15         if (SAFE(x)) \
    16                 printf(fmt,exp); \
    17         else \
    18                 return;
    19 
    20 #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,STRUCT->x)
    21 
    22 #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(STRUCT->x))
    23 #define DISPLAYL(x,fmt) DISPLAY_EXP(x,fmt,htonl(STRUCT->x))
    24 #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&STRUCT->x))
    25 
    2610
    2711DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
     
    2913        struct libtrace_udp *udp = (struct libtrace_udp*)packet;
    3014        printf(" UDP:");
    31         if (SAFE(source)) {
     15        if (SAFE(udp, source)) {
    3216                struct servent *ent=getservbyport(udp->source,"udp");
    3317                if(ent) {
     
    4125                return;
    4226        }
    43         if (SAFE(dest)) {
     27        if (SAFE(udp, dest)) {
    4428                struct servent *ent=getservbyport(udp->dest,"udp");
    4529                if(ent) {
     
    5438        }
    5539        printf("\n UDP:");
    56         DISPLAYS(len," Len %u");
    57         DISPLAYS(check," Checksum %u");
     40        DISPLAYS(udp, len," Len %u");
     41        DISPLAYS(udp, check," Checksum %u");
    5842        printf("\n");
    5943        if (htons(udp->source) < htons(udp->dest))
  • libpacketdump/ip_33.c

    rc7062df r387d299  
    66#include <netinet/tcp.h>
    77#include <netinet/in.h>
    8 
    9 #define STRUCT dccp
    10 
    11 #define SAFE(x) \
    12         ((unsigned int)len>=((char*)&STRUCT->x-(char*)STRUCT+sizeof(STRUCT->x)))
    13 #define DISPLAY_EXP(x,fmt,exp) \
    14         if (SAFE(x)) \
    15                 printf(fmt,exp); \
    16         else \
    17                 return;
    18 
    19 #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,STRUCT->x)
    20 
    21 #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(STRUCT->x))
    22 #define DISPLAYL(x,fmt) DISPLAY_EXP(x,fmt,htonl(STRUCT->x))
    23 #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&STRUCT->x))
    248
    259struct dccphdr {
     
    5034{
    5135        struct dccphdr *dccp = (struct dccphdr*)packet;
    52         DISPLAYS(source," DCCP: Source %i");
    53         DISPLAYS(dest," Dest %i");
     36        DISPLAYS(dccp, source," DCCP: Source %i");
     37        DISPLAYS(dccp, dest," Dest %i");
    5438        if (len>4) {
    5539                printf("\n DCCP: Type %i",dccp->type);
     
    6953        else
    7054                return;
    71         DISPLAY(doff," DCCP: Dataoff: %i\n");
     55        DISPLAY(dccp, doff," DCCP: Dataoff: %i\n");
    7256        if (len>9)
    7357                printf(" DCCP: NDP %i CsLen: %i\n",dccp->ndp,dccp->cslen);
     
    7559                return;
    7660        }
    77         DISPLAY(check," DCCP: Checksum: %i\n");
     61        /* Should this be byteswapped??? */
     62        DISPLAY(dccp, check," DCCP: Checksum: %i\n");
    7863        if (htons(dccp->source) < htons(dccp->dest))
    7964                decode_next(packet+dccp->doff*4,len-dccp->doff*4,"dccp",htons(dccp->source));
  • libpacketdump/ip_6.c

    r9ca0b29 r387d299  
    55#include <assert.h>
    66#include <netdb.h>
    7 
    8 #define SAFE(x) \
    9         ((unsigned int)len>=((char*)&tcp->x-(char*)tcp+sizeof(tcp->x)))
    10 #define DISPLAY_EXP(x,fmt,exp) \
    11         if (SAFE(x)) \
    12                 printf(fmt,exp); \
    13         else \
    14                 return;
    15 
    16 #define DISPLAY(x,fmt) DISPLAY_EXP(x,fmt,tcp->x)
    17 
    18 #define DISPLAYS(x,fmt) DISPLAY_EXP(x,fmt,htons(tcp->x))
    19 #define DISPLAYL(x,fmt) DISPLAY_EXP(x,fmt,htonl(tcp->x))
    20 #define DISPLAYIP(x,fmt) DISPLAY_EXP(x,fmt,inet_ntoa(*(struct in_addr*)&tcp->x))
    217
    228DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
     
    2713        libtrace_tcp_t *tcp = (libtrace_tcp_t *)packet;
    2814        printf(" TCP:");
    29         if (SAFE(source)) {
     15        if (SAFE(tcp, source)) {
    3016                struct servent *ent=getservbyport(tcp->source,"tcp");
    3117                if(ent) {
     
    3925                return;
    4026        }
    41         if (SAFE(dest)) {
     27        if (SAFE(tcp, dest)) {
    4228                struct servent *ent=getservbyport(tcp->dest,"tcp");
    4329                if(ent) {
     
    5238        }
    5339        printf("\n TCP:");
    54         DISPLAYL(seq," Seq %u");
     40        DISPLAYL(tcp, seq," Seq %u");
    5541        printf("\n TCP:");
    56         DISPLAYL(ack_seq," Ack %u");
     42        DISPLAYL(tcp, ack_seq," Ack %u");
    5743        if ((char*)&tcp->window-(char *)tcp>len) {
    5844                printf("\n");
     
    7157        if (tcp->ack) printf(" ACK");
    7258        if (tcp->urg) printf(" URG");
    73         DISPLAYS(window," Window %i");
     59        DISPLAYS(tcp, window," Window %i");
    7460        printf("\n TCP:");
    75         DISPLAYS(check," Checksum %i");
    76         DISPLAYS(urg_ptr," Urgent %i");
     61        DISPLAYS(tcp, check," Checksum %i");
     62        DISPLAYS(tcp, urg_ptr," Urgent %i");
    7763        pkt = (unsigned char*)packet+sizeof(*tcp);
    7864        plen = (len-sizeof *tcp) < (tcp->doff*4-sizeof(*tcp))?(len-sizeof(*tcp)):(tcp->doff*4-sizeof *tcp);
  • libpacketdump/ip_89.c

    re224862 r387d299  
    1010static void dump_ospf_v2_header(libtrace_ospf_v2_t *hdr, unsigned len) {
    1111
    12         printf(" OSPF Header: Version %u Type %u ",
    13                         hdr->ospf_v, hdr->type);
     12        DISPLAY(hdr, ospf_v, " OSPF Header: Version %u");
     13        DISPLAY(hdr, type, " Type %u ");
    1414        switch(hdr->type) {
    1515                case TRACE_OSPF_HELLO:
     
    2929                        break;
    3030        }
     31        printf("\n");
    3132
    32         printf("\n OSPF Header: Length %u \n", ntohs(hdr->len));
    33         printf(" OSPF Header: Router Id %s ", inet_ntoa(hdr->router));
    34         printf("Area Id %s\n", inet_ntoa(hdr->area));
    35         printf(" OSPF Header: Checksum %u Auth Type %u\n", ntohs(hdr->sum),
    36                         ntohs(hdr->au_type));
    37 
    38         printf(" OSPF Header: Auth Key ID %u Auth Data Len %u\n",
    39                         hdr->au_key_id, hdr->au_data_len);
    40         printf(" OSPF Header: Auth Crypto Seq %u\n", ntohl(hdr->au_seq_num));
    41 
     33        DISPLAYS(hdr, ospf_len, "OSPF Header: Length %u \n");
     34        DISPLAYIP(hdr, router, " OSPF Header: Router Id %s ");
     35        DISPLAYIP(hdr, area, "Area Id %s\n");
     36        DISPLAYS(hdr, sum, " OSPF Header: Checksum %u ");
     37        DISPLAYS(hdr, au_type, "Auth Type %u\n");
     38        DISPLAY(hdr, au_key_id, " OSPF Header: Auth Key ID %u ");
     39        DISPLAY(hdr, au_data_len, "Auth Data Len %u\n");
     40        DISPLAYL(hdr, au_seq_num, " OSPF Header: Auth Crypto Seq %u\n");
    4241
    4342}
  • libpacketdump/libpacketdump.h

    r66ad025 r387d299  
    66extern "C" {
    77#endif
     8
     9#define SAFE(hdr,x) \
     10        ((unsigned int)len>=((char*)&hdr->x-(char*)hdr+sizeof(hdr->x)))
     11
     12#define DISPLAY_EXP(hdr,x,fmt,exp) \
     13        if (SAFE(hdr, x)) \
     14                printf(fmt,exp); \
     15        else {\
     16                printf("(Truncated)\n"); \
     17                return; \
     18        }
     19
     20#define DISPLAY(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,hdr->x)
     21
     22#define DISPLAYS(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,htons(hdr->x))
     23#define DISPLAYL(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,htonl(hdr->x))
     24#define DISPLAYIP(hdr,x,fmt) DISPLAY_EXP(hdr,x,fmt,inet_ntoa(*(struct in_addr*)&hdr->x))
     25
    826
    927void trace_hexdump_packet(libtrace_packet_t *packet);
  • libwandio/Makefile.am

    r60f3c4c r3b6e0cf  
    33include_HEADERS=wandio.h
    44
    5 AM_CFLAGS=@LIBCFLAGS@
    6 AM_CXXFLAGS=@LIBCXXFLAGS@
     5AM_CFLAGS=@LIBCFLAGS@ @CFLAG_VISIBILITY@
     6AM_CXXFLAGS=@LIBCXXFLAGS@ @CFLAG_VISIBILITY@
    77
    88if HAVE_ZLIB
     
    2424endif
    2525
     26if HAVE_LZMA
     27LIBTRACEIO_LZMA=ior-lzma.c iow-lzma.c
     28else
     29LIBTRACEIO_LZMA=
     30endif
     31
    2632libwandio_la_SOURCES=wandio.c ior-peek.c ior-stdio.c ior-thread.c \
    27                 iow-stdio.c iow-thread.c wandio.h \
    28                 $(LIBTRACEIO_ZLIB) $(LIBTRACEIO_BZLIB) $(LIBTRACEIO_LZO)
     33                iow-stdio.c iow-thread.c wandio.h wandio_internal.h \
     34                $(LIBTRACEIO_ZLIB) $(LIBTRACEIO_BZLIB) $(LIBTRACEIO_LZO) \
     35                $(LIBTRACEIO_LZMA)
    2936
    30 INCLUDES = @ADD_INCLS@
     37AM_CPPFLAGS = @ADD_INCLS@
    3138libwandio_la_LIBADD = @LIBWANDIO_LIBS@
    32 libwandio_la_LDFLAGS=-version-info 1:0:0 @ADD_LDFLAGS@
     39libwandio_la_LDFLAGS=-version-info 1:1:0 @ADD_LDFLAGS@
    3340
     41bin_PROGRAMS = wandiocat
     42wandiocat_SOURCES = wcat.c
     43wandiocat_CFLAGS = -I"$(top_srcdir)/libwandio"
     44wandiocat_CXXFLAGS = -I"$(top_srcdir)/libwandio"
     45wandiocat_LDFLAGS = -L"$(top_srcdir)/libwandio" -lwandio
  • libwandio/ior-stdio.c

    r60f3c4c r10f924c  
    3434
    3535#define _GNU_SOURCE 1
     36#include "wandio_internal.h"
    3637#include "wandio.h"
    3738#include <sys/types.h>
  • libwandio/ior-thread.c

    r954577b9 r10f924c  
    3434
    3535#include "config.h"
     36#include "wandio_internal.h"
    3637#include "wandio.h"
    3738#include <sys/types.h>
  • libwandio/iow-lzo.c

    r4a2529b rfa7faf3  
    4141
    4242#include <lzo/lzo1x.h>
     43#include "wandio_internal.h"
    4344#include "wandio.h"
    4445#include "config.h"
     
    273274}
    274275
    275 iow_t *lzo_wopen(iow_t *child, int compress_level UNUSED)
     276iow_t *lzo_wopen(iow_t *child, int compress_level)
    276277{
    277278        const int opt_filter = 0;
     
    289290                return NULL;
    290291        }
     292
     293        /* Compress level is useless for LZO, but getting UNUSED into here
     294         * is more trouble than it is worth so this check will at least
     295         * stop us from getting warnings about it.
     296         */
     297        if (compress_level < 0)
     298                return NULL;
    291299
    292300        iow = malloc(sizeof(iow_t));
  • libwandio/iow-stdio.c

    r60f3c4c r10f924c  
    3434
    3535#define _GNU_SOURCE 1
     36#include "wandio_internal.h"
    3637#include "wandio.h"
    3738#include <sys/types.h>
  • libwandio/iow-thread.c

    r954577b9 r10f924c  
    3434#include "config.h"
    3535#include "wandio.h"
     36#include "wandio_internal.h"
    3637#include <sys/types.h>
    3738#include <sys/stat.h>
  • libwandio/wandio.c

    r808eeef r4b0cd2f  
    3434
    3535#include "config.h"
     36#include "wandio_internal.h"
    3637#include "wandio.h"
    3738#include <stdlib.h>
     
    4546 */
    4647
    47 struct compression_type compression_type[]  = {
    48         { "GZ",         "gz",   WANDIO_COMPRESS_ZLIB    },
    49         { "BZ2",        "bz2",  WANDIO_COMPRESS_BZ2     },
    50         { "LZO",        "lzo",  WANDIO_COMPRESS_LZO     },
     48struct wandio_compression_type compression_type[]  = {
     49        { "gzip",       "gz",   WANDIO_COMPRESS_ZLIB    },
     50        { "bzip2",      "bz2",  WANDIO_COMPRESS_BZ2     },
     51        { "lzo",        "lzo",  WANDIO_COMPRESS_LZO     },
     52        { "lzma",       "xz",  WANDIO_COMPRESS_LZMA     },
    5153        { "NONE",       "",     WANDIO_COMPRESS_NONE    }
    5254};
     
    140142        DEBUG_PIPELINE("peek");
    141143        io_t *io = peek_open(stdio_open(filename));
    142         char buffer[1024];
     144        unsigned char buffer[1024];
    143145        int len;
    144146        if (!io)
     
    150152
    151153        if (autodetect) {
    152                 if (len>=3 && buffer[0] == '\037' && buffer[1] == '\213' &&
     154                if (len>=3 && buffer[0] == 0x1f && buffer[1] == 0x8b &&
    153155                                buffer[2] == 0x08) {
    154156#if HAVE_LIBZ
     
    161163                }
    162164                /* Auto detect compress(1) compressed data (gzip can read this) */
    163                 if (len>=2 && buffer[0] == '\037' && buffer[1] == '\235') {
     165                if (len>=2 && buffer[0] == 0x1f && buffer[1] == 0x9d) {
    164166#if HAVE_LIBZ
    165167                        DEBUG_PIPELINE("zlib");
     
    181183#endif
    182184                }
     185
     186                if (len >=5 && buffer[0] == 0xfd && buffer[1] == '7' &&
     187                                buffer[2] == 'z' && buffer[3] == 'X' &&
     188                                buffer[4] == 'Z') {
     189#if HAVE_LIBLZMA
     190                        DEBUG_PIPELINE("lzma");
     191                        io = lzma_open(io);
     192#else
     193                        fprintf(stderr, "File %s is lzma compressed but libtrace has not been built with lzma support!\n", filename);
     194                        return NULL;
     195#endif
     196                }
    183197        }       
    184198        /* Now open a threaded, peekable reader using the appropriate module
     
    192206        DEBUG_PIPELINE("peek");
    193207        return peek_open(io);
     208}
     209
     210DLLEXPORT struct wandio_compression_type *wandio_lookup_compression_type(
     211        const char *name) {
     212
     213        struct wandio_compression_type *wct = compression_type;
     214
     215        while (strcmp(wct->name, "NONE") != 0) {
     216                if (strcmp(wct->name, name) == 0)
     217                        return wct;
     218                wct++;
     219        }
     220
     221        return NULL;
    194222}
    195223
     
    290318        }
    291319#endif
     320#if HAVE_LIBLZMA
     321        else if (compression_level != 0 &&
     322            compress_type == WANDIO_COMPRESS_LZMA) {
     323                iow = lzma_wopen(iow,compression_level);
     324        }
     325#endif
    292326        /* Open a threaded writer */
    293327        if (use_threads)
  • libwandio/wandio.h

    r0acfd1e r4b0cd2f  
    3434#ifndef IO_H
    3535#define IO_H 1 /**< Guard Define */
    36 #include "config.h"
    3736#include <sys/types.h>
    3837#include <stdio.h>
     
    4039#include <stdbool.h>
    4140
    42 #if __GNUC__ >= 4
    43         #ifdef LT_BUILDING_DLL
    44                 #define DLLEXPORT __attribute__ ((visibility("default")))
    45                 #define DLLLOCAL __attribute__ ((visibility("hidden")))
    46         #else
    47                 #define DLLEXPORT
    48                 #define DLLLOCAL
    49         #endif
    50 #else
    51         #define DLLEXPORT
    52         #define DLLLOCAL
     41
     42#ifndef DLLEXPORT
     43        #if HAVE_VISIBILITY && LT_BUILDING_DLL
     44                #define DLLEXPORT __attribute__ ((visibility("default")))
     45                #define DLLLOCAL __attribute__ ((visibility("hidden")))
     46        #else
     47                #define DLLEXPORT
     48                #define DLLLOCAL
     49        #endif
    5350#endif
    5451
    55 #if __GNUC__ >= 3
    56 #  define DEPRECATED __attribute__((deprecated))
    57 #  define SIMPLE_FUNCTION __attribute__((pure))
    58 #  define UNUSED __attribute__((unused))
    59 #  define PACKED __attribute__((packed))
    60 #  define PRINTF(formatpos,argpos) __attribute__((format(printf,formatpos,argpos)))
    61 #else
    62 #  define DEPRECATED
    63 #  define SIMPLE_FUNCTION
    64 #  define UNUSED
    65 #  define PACKED
    66 #  define PRINTF(formatpos,argpos)
    67 #endif
    68 
     52// TODO: Use a proper check for these attribute rather than gcc version check
    6953
    7054/** @file
     
    8266
    8367/** Structure defining a supported compression method */
    84 struct compression_type {
     68struct wandio_compression_type {
    8569        /** Name of the compression method */
    8670        const char *name;
     
    9377
    9478/** The list of supported compression methods */
    95 extern struct compression_type compression_type[];
     79extern struct wandio_compression_type compression_type[];
    9680
    9781/** Structure defining a libtrace IO reader module */
     
    194178        /** LZO compression */
    195179        WANDIO_COMPRESS_LZO     = 3,
     180        /** LZMA compression */
     181        WANDIO_COMPRESS_LZMA    = 4,
    196182        /** All supported methods - used as a bitmask */
    197183        WANDIO_COMPRESS_MASK    = 7
     
    209195io_t *zlib_open(io_t *parent);
    210196io_t *thread_open(io_t *parent);
     197io_t *lzma_open(io_t *parent);
    211198io_t *peek_open(io_t *parent);
    212199io_t *stdio_open(const char *filename);
     
    215202iow_t *bz_wopen(iow_t *child, int compress_level);
    216203iow_t *lzo_wopen(iow_t *child, int compress_level);
     204iow_t *lzma_wopen(iow_t *child, int compress_level);
    217205iow_t *thread_wopen(iow_t *child);
    218206iow_t *stdio_wopen(const char *filename, int fileflags);
     
    227215 *
    228216 * @{ */
     217
     218/** Given a string describing the compression method, finds the internal
     219  * data structure representing that method. This is mostly useful for
     220  * nicely mapping a method name to the internal libwandio compression
     221  * method enum when configuring an output file.
     222  *
     223  * @param name          The compression method name as a string, e.g. "gzip",
     224  *                      "bzip2", "lzo" or "lzma".
     225  * @return A pointer to the compression_type structure representing the
     226  * compression method or NULL if no match can be found.
     227  *
     228  */
     229struct wandio_compression_type *wandio_lookup_compression_type(const char *name);
    229230
    230231/** Creates a new libtrace IO reader and opens the provided file for reading.
     
    330331/** @} */
    331332
    332 /** @name libtraceio options
    333  * @{ */
    334 extern int force_directio_read;
    335 extern int force_directio_write;
    336 extern uint64_t write_waits;
    337 extern uint64_t read_waits;
    338 extern unsigned int use_threads;
    339 extern unsigned int max_buffers;
    340 /* @} */
    341 
    342333#endif
  • test/Makefile

    r8782b67 rfb20640  
    1212
    1313BINS = test-pcap-bpf test-event test-time test-dir test-wireless test-errors \
    14         test-plen test-autodetect
     14        test-plen test-autodetect test-ports test-fragment
    1515
    1616.PHONY: all clean distclean install depend test
  • test/do-tests.sh

    r47e927a r95b6218  
    7373do_test ./test-plen
    7474
     75echo \* Testing port numbers
     76do_test ./test-ports
     77
     78echo \* Testing fragment parsing
     79do_test ./test-fragment
     80
    7581echo \* Testing event framework
    7682do_test ./test-event
    7783
    7884echo \* Testing time conversions
    79 do_test ./test-time
     85echo \* ERF
     86do_test ./test-time erf
     87echo \* pcapfile
     88do_test ./test-time pcapfile
     89echo \* pcapfilens
     90do_test ./test-time pcapfilens
     91echo \* legacyatm
     92do_test ./test-time legacyatm
     93echo \* legacypos
     94do_test ./test-time legacypos
     95echo \* legacyeth
     96do_test ./test-time legacyeth
     97echo \* pcap
     98do_test ./test-time pcap
     99echo \* rawerf
     100do_test ./test-time rawerf
     101echo \* tsh
     102do_test ./test-time tsh
    80103
    81104echo \* Testing directions
     
    204227echo " * format autodetection - bzip2"
    205228do_test ./test-autodetect traces/5_packets.erf.bz2
     229echo " * format autodetection - lzma"
     230do_test ./test-autodetect traces/5_packets.erf.xz
    206231
    207232echo
  • test/test-time.c

    rd5a27e8 r6a38a7e  
    5151struct libtrace_t *trace;
    5252
     53const char *lookup_uri(const char *type) {
     54        if (strchr(type,':'))
     55                return type;
     56        if (!strcmp(type,"erf"))
     57                return "erf:traces/100_packets.erf";
     58        if (!strcmp(type,"rawerf"))
     59                return "rawerf:traces/100_packets.erf";
     60        if (!strcmp(type,"pcap"))
     61                return "pcap:traces/100_packets.pcap";
     62        if (!strcmp(type,"wtf"))
     63                return "wtf:traces/wed.wtf";
     64        if (!strcmp(type,"rtclient"))
     65                return "rtclient:chasm";
     66        if (!strcmp(type,"pcapfile"))
     67                return "pcapfile:traces/100_packets.pcap";
     68        if (!strcmp(type,"pcapfilens"))
     69                return "pcapfile:traces/100_packetsns.pcap";
     70        if (!strcmp(type, "duck"))
     71                return "duck:traces/100_packets.duck";
     72        if (!strcmp(type, "legacyatm"))
     73                return "legacyatm:traces/legacyatm.gz";
     74        if (!strcmp(type, "legacypos"))
     75                return "legacypos:traces/legacypos.gz";
     76        if (!strcmp(type, "legacyeth"))
     77                return "legacyeth:traces/legacyeth.gz";
     78        if (!strcmp(type, "tsh"))
     79                return "tsh:traces/10_packets.tsh.gz";
     80        return type;
     81}
     82
    5383void iferr(libtrace_t *trace)
    5484{
     
    6191
    6292int main(int argc, char *argv[]) {
    63         char *uri = "erf:traces/100_packets.erf";
     93        char *uri = lookup_uri(argv[1]);
    6494        int psize = 0;
    6595        int error = 0;
     
    76106        for (;;) {
    77107                double ts;
     108                double tsdiff;
    78109                struct timeval tv;
    79110                if ((psize = trace_read_packet(trace, packet)) <0) {
     
    88119                tv=trace_get_timeval(packet);
    89120                ts=trace_get_seconds(packet);
    90                 assert((tv.tv_sec+tv.tv_usec/1000000.0)-ts<.000001);
     121                tsdiff = (tv.tv_sec+tv.tv_usec/1000000.0)-ts;
     122                assert(tsdiff > -0.001 && tsdiff < 0.001);
     123
    91124        }
    92125        trace_destroy_packet(packet);
  • tools/traceanon/traceanon.1

    rd6dc0f6 r17f954f  
    8686.BI \-\^\-compress-type=method
    8787compress the output trace using the compression algorithm "method". Possible
    88 algorithms are "gzip", "bzip2", "lzo" and "none". Default is "none".
     88algorithms are "gzip", "bzip2", "lzo", "xz" and "none". Default is "none".
    8989
    9090.SH EXAMPLES
  • tools/traceanon/traceanon.c

    rf5b5cca r17f954f  
    219219        } else if (strncmp(compress_type_str, "lzo", 3) == 0) {
    220220                compress_type = TRACE_OPTION_COMPRESSTYPE_LZO;
     221        } else if (strncmp(compress_type_str, "xz", 2) == 0) {
     222                compress_type = TRACE_OPTION_COMPRESSTYPE_LZMA;
    221223        } else if (strncmp(compress_type_str, "no", 2) == 0) {
    222224                compress_type = TRACE_OPTION_COMPRESSTYPE_NONE;
  • tools/tracemerge/tracemerge.1

    rd6dc0f6 r17f954f  
    5353.BI \-\^\-compress-type method
    5454Describes the compression algorithm to be used when writing the output trace.
    55 Possible methods are "gzip", "bzip2", "lzo" and "none". Defaults to "none".
     55Possible methods are "gzip", "bzip2", "lzo", "xz" and "none". Defaults to
     56"none".
    5657
    5758
  • tools/tracemerge/tracemerge.c

    rc0ccccd r17f954f  
    120120        } else if (strncmp(compress_type_str, "lzo", 3) == 0) {
    121121                compress_type = TRACE_OPTION_COMPRESSTYPE_LZO;
     122        } else if (strncmp(compress_type_str, "xz", 2) == 0) {
     123                compress_type = TRACE_OPTION_COMPRESSTYPE_LZMA;
    122124        } else if (strncmp(compress_type_str, "no", 2) == 0) {
    123125                compress_type = TRACE_OPTION_COMPRESSTYPE_NONE;
  • tools/tracesplit/tracesplit.1

    rd6dc0f6 r17f954f  
    6161\fB-Z\fR compression-method
    6262Compress the data using the specified compression algorithm. Accepted methods
    63 are "gzip", "bzip2", "lzo" or "none". Default value is none unless a
     63are "gzip", "bzip2", "lzo", "xz" or "none". Default value is none unless a
    6464compression level is specified, in which case gzip will be used.
    6565
  • tools/tracesplit/tracesplit.c

    r755855a r17f954f  
    316316        } else if (strncmp(compress_type_str, "lzo", 3) == 0) {
    317317                compress_type = TRACE_OPTION_COMPRESSTYPE_LZO;
     318        } else if (strncmp(compress_type_str, "xz", 2) == 0) {
     319                compress_type = TRACE_OPTION_COMPRESSTYPE_LZMA;
    318320        } else if (strncmp(compress_type_str, "no", 2) == 0) {
    319321                compress_type = TRACE_OPTION_COMPRESSTYPE_NONE;
Note: See TracChangeset for help on using the changeset viewer.