Changes in / [19f1efd:3b6ca9a]


Ignore:
Files:
4 added
24 edited

Legend:

Unmodified
Added
Removed
  • configure.in

    r0e8f8cb re8e9052  
    212212
    213213AC_CHECK_LIB(crypto, EVP_EncryptInit_ex, cryptofound=1, cryptofound=0)
     214if test "$cryptofound" = 1; then
     215        AC_CHECK_HEADER(openssl/evp.h, cryptofound=1, cryptofound=0)
     216fi
     217AC_CHECK_LIB(tasn1, asn1_array2tree, asn1found=1, asn1found=0)
    214218
    215219# Check for libpcap
     
    455459AC_CHECK_LIB(numa, numa_node_to_cpus, have_numa=1, have_numa=0)
    456460
     461# Need libwandder for ETSI live decoding
     462AC_CHECK_LIB(wandder, init_wandder_decoder, have_wandder=1, have_wandder=0)
     463
    457464# Checks for various "optional" libraries
    458465AC_CHECK_LIB(pthread, pthread_create, have_pthread=1, have_pthread=0)
     
    486493fi
    487494
     495if test "$have_wandder" = 1; then
     496        LIBTRACE_LIBS="$LIBTRACE_LIBS -lwandder"
     497        AC_DEFINE(HAVE_WANDDER, 1, [Set to 1 if libwandder is available])
     498        wandder_avail=yes
     499else
     500        AC_DEFINE(HAVE_WANDDER, 0, [Set to 1 if libwandder is available])
     501        wandder_avail=no
     502fi
     503
    488504if test "$dlfound" = 0; then
    489505        AC_MSG_ERROR("Unable to find dlopen. Please use LDFLAGS to specify the location of libdl and re-run configure")
     
    537553fi
    538554
     555
     556have_memfd_create=no
     557AC_RUN_IFELSE([AC_LANG_PROGRAM([
     558#include <sys/syscall.h>
     559],[
     560#ifndef __NR_memfd_create
     561exit(1)
     562#endif
     563])], [have_memfd_create=yes])
     564
     565if test "$have_memfd_create" = "yes"; then
     566        AC_DEFINE(HAVE_MEMFD_CREATE, 1, [Set to 1 if kernel supports memfd_create syscall])
     567fi
    539568
    540569# Stupid AC_SEARCH_LIB appends stuff to LIBS even when I don't want it to, so
     
    611640AM_CONDITIONAL([HAVE_DAG], [test "$libtrace_dag" = true])
    612641AM_CONDITIONAL([HAVE_DPDK], [test "$libtrace_dpdk" = true])
     642AM_CONDITIONAL([HAVE_WANDDER], [test "x$wandder_avail" = "xyes"])
    613643AM_CONDITIONAL([DAG2_4], [test "$libtrace_dag_version" = 24])
    614644AM_CONDITIONAL([DAG2_5], [test "$libtrace_dag_version" = 25])
     
    692722fi
    693723reportopt "Compiled with LLVM BPF JIT support" $JIT
     724reportopt "Compiled with live ETSI LI support (requires libwandder)" $wandder_avail
    694725reportopt "Building man pages/documentation" $libtrace_doxygen
    695726reportopt "Building tracetop (requires libncurses)" $with_ncurses
    696 reportopt "Building traceanon with CryptoPan (requires libcrypto)" $have_crypto
     727reportopt "Building traceanon with CryptoPan (requires libcrypto and openssl/evp.h)" $have_crypto
    697728
    698729# Report any errors relating to missing bison, flex, etc.
  • lib/Makefile.am

    r49969f2 rb663d33  
    77        data-struct/deque.h data-struct/linked_list.h \
    88        data-struct/buckets.h data-struct/sliding_window.h \
    9         data-struct/message_queue.h hash_toeplitz.h
     9        data-struct/message_queue.h hash_toeplitz.h \
     10        data-struct/simple_circular_buffer.h
    1011
    1112AM_CFLAGS=@LIBCFLAGS@ @CFLAG_VISIBILITY@ -pthread
     
    5152endif
    5253
     54if HAVE_WANDDER
     55ETSISOURCES=format_etsilive.c
     56else
     57ETSISOURCES=
     58endif
     59
    5360libtrace_la_SOURCES = trace.c trace_parallel.c common.h \
    5461                format_erf.c format_pcap.c format_legacy.c \
     
    6370                protocols_application.c \
    6471                $(DAGSOURCE) format_erf.h format_ndag.c format_ndag.h \
    65                 $(BPFJITSOURCE) \
     72                $(BPFJITSOURCE) $(ETSISOURCES) \
    6673                libtrace_arphrd.h \
    6774                data-struct/ring_buffer.c data-struct/vector.c \
     
    6976                data-struct/sliding_window.c data-struct/object_cache.c \
    7077                data-struct/linked_list.c hash_toeplitz.c combiner_ordered.c \
    71                 data-struct/buckets.c \
     78                data-struct/buckets.c data-struct/simple_circular_buffer.c \
    7279                combiner_sorted.c combiner_unordered.c \
    7380                pthread_spinlock.c pthread_spinlock.h
  • lib/format_dag25.c

    ra857389 rcc9c9de  
    608608                return -1;
    609609        case TRACE_OPTION_EVENT_REALTIME:
     610        case TRACE_OPTION_REPLAY_SPEEDUP:
    610611                /* Live capture is always going to be realtime */
    611612                return -1;
  • lib/format_dpdk.c

    r8ed07df r6d17620  
    9090struct dpdk_format_data_t {
    9191        int8_t promisc; /* promiscuous mode - RX only */
    92         uint8_t port; /* Always 0 we only whitelist a single port - Shared TX & RX */
    93         uint8_t nb_ports; /* Total number of usable ports on system should be 1 */
    9492        uint8_t paused; /* See paused_state */
     93        portid_t port; /* Always 0 we only whitelist a single port - Shared TX & RX */
     94        portid_t nb_ports; /* Total number of usable ports on system should be 1 */
    9595        uint16_t link_speed; /* Link speed 10,100,1000,10000 etc. */
    9696        int snaplen; /* The snap length for the capture - RX only */
     
    214214        int matches;
    215215        assert(str);
     216#if RTE_VERSION >= RTE_VERSION_NUM(17, 8, 0, 1)
    216217        matches = sscanf(str, "%8"SCNx32":%2"SCNx8":%2"SCNx8".%2"SCNx8"-%ld",
    217218                         &addr->domain, &addr->bus, &addr->devid,
    218219                         &addr->function, core);
     220#else
     221        matches = sscanf(str, "%4"SCNx16":%2"SCNx8":%2"SCNx8".%2"SCNx8"-%ld",
     222                         &addr->domain, &addr->bus, &addr->devid,
     223                         &addr->function, core);
     224#endif
    219225        if (matches >= 4) {
    220226                return 0;
     
    816822 * @param cb_arg The dpdk_format_data_t structure associated with the format
    817823 */
    818 static int dpdk_lsc_callback(uint16_t port, enum rte_eth_event_type event,
     824#if RTE_VERSION >= RTE_VERSION_NUM(17, 8, 0, 1)
     825static int dpdk_lsc_callback(portid_t port, enum rte_eth_event_type event,
    819826                              void *cb_arg, void *retparam UNUSED) {
     827#else
     828static void dpdk_lsc_callback(portid_t port, enum rte_eth_event_type event,
     829                              void *cb_arg) {
     830#endif
    820831        struct dpdk_format_data_t * format_data = cb_arg;
    821832        struct rte_eth_link link_info;
     
    852863        }
    853864#endif
     865#if RTE_VERSION >= RTE_VERSION_NUM(17, 8, 0, 1)
    854866        return 0;
     867#endif
    855868}
    856869
     
    11711184        if (ret < 0) {
    11721185                snprintf(err, errlen, "Intel DPDK - Cannot configure TX queue"
    1173                          " on port %"PRIu8" : %s", format_data->port,
     1186                         " on port %d : %s", (int)format_data->port,
    11741187                         strerror(-ret));
    11751188                return -1;
     
    12201233                if (ret < 0) {
    12211234                        snprintf(err, errlen, "Intel DPDK - Cannot configure"
    1222                                  " RX queue on port %"PRIu8" : %s",
    1223                                  format_data->port,
     1235                                 " RX queue on port %d : %s",
     1236                                 (int)format_data->port,
    12241237                                 strerror(-ret));
    12251238                        return -1;
     
    12901303}
    12911304
    1292 static inline size_t dpdk_get_max_rx_queues (uint8_t port_id) {
     1305static inline size_t dpdk_get_max_rx_queues (portid_t port_id) {
    12931306        struct rte_eth_dev_info dev_info;
    12941307        rte_eth_dev_info_get(port_id, &dev_info);
     
    15111524                memcpy(rte_pktmbuf_append(m_buff[0], caplen), packet->payload, caplen);
    15121525                do {
    1513                         ret = rte_eth_tx_burst(0 /*queue TODO*/, FORMAT(trace)->port, m_buff, 1);
     1526                        ret = rte_eth_tx_burst(FORMAT(trace)->port, 0 /*queue TODO*/, m_buff, 1);
    15141527                } while (ret != 1);
    15151528        }
  • lib/format_dpdk.h

    r8efa986 r6d17620  
    113113#define rte_mempool_in_use_count rte_mempool_free_count
    114114#endif
     115
     116/* 17.05-rc1 deprecated, 17.08 removed
     117 * rte_set_log_level -> rte_log_set_global_level
     118 */
     119#if RTE_VERSION < RTE_VERSION_NUM(17, 5, 0, 1)
     120#define rte_log_set_global_level rte_set_log_level
     121#endif
     122
     123/* 17.11-rc1 increases port size from 8 to 16bits
     124 */
     125#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 1)
     126typedef uint16_t portid_t;
     127#else
     128typedef uint8_t portid_t;
     129#endif
     130
    115131
    116132#include <rte_per_lcore.h>
  • lib/format_helper.c

    r633339d rde060a8  
    127127        double ts;
    128128        double now;
     129        double sincebeginnow = 0;
     130        double sincebegintrace = 0;
     131
    129132#ifdef WIN32
    130133        struct __timeb64 tstruct;
     
    182185
    183186       
    184         if (fabs(trace->event.tdelta)>1e-9) {
    185                 /* Subtract the tdelta from the walltime to get a suitable
     187        if (fabs(trace->event.first_ts)>1e-9) {
     188                /* Subtract the tdelta from the starting times to get a suitable
    186189                 * "relative" time */
    187                 now -= trace->event.tdelta;
     190                sincebeginnow = (now - trace->event.first_now);
     191                sincebegintrace = (ts - trace->event.first_ts);
    188192
    189193                /* If the trace timestamp is still in the future, return a
    190194                 * SLEEP event, otherwise return the packet */
    191                 if (ts > now) {
    192                         event.seconds = ts -
    193                                 trace->event.trace_last_ts;
    194                         trace->event.trace_last_ts = ts;
     195                if (sincebeginnow <= sincebegintrace / (double)trace->replayspeedup) {
     196                        event.seconds = ((sincebegintrace / (double)trace->replayspeedup) - sincebeginnow);
    195197                        event.type = TRACE_EVENT_SLEEP;
    196198                        trace->event.waiting = true;
     
    204206                 * trace file.
    205207                 */
    206                 trace->event.tdelta = now - ts;
     208                trace->event.first_now = (double)now;
     209                trace->event.first_ts = (double)ts;
    207210        }
    208211
     
    219222        event.type = TRACE_EVENT_PACKET;
    220223
    221         trace->event.trace_last_ts = ts;
    222224        trace->event.waiting = false;
    223225
  • lib/format_linux_common.c

    rd47ca18 rcc9c9de  
    164164                        /* Live captures are always going to be in trace time */
    165165                        break;
     166                case TRACE_OPTION_REPLAY_SPEEDUP:
     167                        break;
    166168                /* Avoid default: so that future options will cause a warning
    167169                 * here to remind us to implement it, or flag it as
  • lib/format_linux_ring.c

    rdb84bb2 r1060b6d  
    461461        struct pollfd pollset[2];
    462462
    463         ring_release_frame(libtrace, packet);
    464        
    465463        packet->buf_control = TRACE_CTRL_EXTERNAL;
    466464        packet->type = TRACE_RT_DATA_LINUX_RING;
  • lib/format_ndag.c

    r3004d6c r7c33187  
    114114        uint64_t received_packets;
    115115
    116         fd_set allsocks;
    117116        int maxfd;
    118117} recvstream_t;
     
    488487                FORMAT_DATA->receivers[i].received_packets = 0;
    489488                FORMAT_DATA->receivers[i].missing_records = 0;
    490                 FD_ZERO(&(FORMAT_DATA->receivers[i].allsocks));
    491489                FORMAT_DATA->receivers[i].maxfd = -1;
    492490
     
    771769        ssock->recordcount = 0;
    772770        rt->sourcecount += 1;
    773         FD_SET(ssock->sock, &(rt->allsocks));
    774771        if (ssock->sock > rt->maxfd) {
    775772                rt->maxfd = ssock->sock;
     
    881878                fprintf(stderr, "Received invalid record on the channel for %s:%u.\n",
    882879                                ssock->groupaddr, ssock->port);
    883                 FD_CLR(ssock->sock, &(rt->allsocks));
    884880                close(ssock->sock);
    885881                ssock->sock = -1;
     
    943939#if HAVE_RECVMMSG
    944940        int i;
    945 #endif
    946 
    947         if (ssock->sock == -1) {
    948                 return 0;
    949         }
    950 
    951 #if HAVE_RECVMMSG
    952         /* Plenty of full buffers, just use the packets in those */
    953         if (ssock->bufavail < RECV_BATCH_SIZE / 2) {
    954                 return 1;
    955         }
    956 #else
    957         if (ssock->bufavail == 0) {
    958                 return 1;
    959         }
    960941#endif
    961942
     
    987968                                        ssock->port);
    988969
    989                                 FD_CLR(ssock->sock, &(rt->allsocks));
    990970                                close(ssock->sock);
    991971                                ssock->sock = -1;
     
    997977                                ssock->groupaddr, ssock->port,
    998978                                strerror(errno));
    999                         FD_CLR(ssock->sock, &(rt->allsocks));
    1000979                        close(ssock->sock);
    1001980                        ssock->sock = -1;
     
    10351014        struct timeval tv;
    10361015        fd_set fds;
     1016        int maxfd = 0;
    10371017        struct timeval zerotv;
    10381018
     
    10401020        gottime = 0;
    10411021
    1042         fds = rt->allsocks;
     1022        FD_ZERO(&fds);
    10431023
    10441024        if (rt->maxfd == -1) {
     
    10491029        zerotv.tv_usec = 0;
    10501030
    1051         if (select(rt->maxfd + 1, &fds, NULL, NULL, &zerotv) == -1) {
     1031        for (i = 0; i < rt->sourcecount; i++) {
     1032                if (rt->sources[i].sock == -1) {
     1033                        continue;
     1034                }
     1035
     1036#if HAVE_RECVMMSG
     1037                /* Plenty of full buffers, just use the packets in those */
     1038                if (rt->sources[i].bufavail < RECV_BATCH_SIZE / 2) {
     1039                        readybufs ++;
     1040                        continue;
     1041                }
     1042#else
     1043                if (rt->sources[i].bufavail == 0) {
     1044                        readybufs ++;
     1045                        continue;
     1046                }
     1047#endif
     1048                FD_SET(rt->sources[i].sock, &fds);
     1049                if (maxfd < rt->sources[i].sock) {
     1050                        maxfd = rt->sources[i].sock;
     1051                }
     1052        }
     1053
     1054
     1055        if (maxfd <= 0) {
     1056                return readybufs;
     1057        }
     1058
     1059        if (select(maxfd + 1, &fds, NULL, NULL, &zerotv) == -1) {
    10521060                /* log the error? XXX */
    10531061                return -1;
     
    10561064        for (i = 0; i < rt->sourcecount; i++) {
    10571065                if (!FD_ISSET(rt->sources[i].sock, &fds)) {
     1066                        if (rt->sources[i].bufavail < ENCAP_BUFFERS) {
     1067                                readybufs ++;
     1068                        }
    10581069                        continue;
    10591070                }
  • lib/format_pcapfile.c

    r5a70a80 rcc9c9de  
    257257                case TRACE_OPTION_FILTER:
    258258                case TRACE_OPTION_HASHER:
     259                case TRACE_OPTION_REPLAY_SPEEDUP:
    259260                        /* All these are either unsupported or handled
    260261                         * by trace_config */
  • lib/format_pcapng.c

    r2c457ec r9845e97  
    260260                case TRACE_OPTION_FILTER:
    261261                case TRACE_OPTION_HASHER:
     262                case TRACE_OPTION_REPLAY_SPEEDUP:
    262263                        break;
    263264        }
     
    11941195
    11951196        ts.tv_sec = (timestamp / interface->tsresol);
    1196         ts.tv_nsec = (uint64_t)(timestamp - (ts.tv_sec * interface->tsresol)) / interface->tsresol * 1000000000;
     1197        ts.tv_nsec = (uint64_t)(timestamp - (ts.tv_sec * interface->tsresol))
     1198                        / ((double)interface->tsresol) * 1000000000;
    11971199
    11981200        return ts;
  • lib/libtrace.h.in

    r29cafc0 rcc9c9de  
    370370       TRACE_TYPE_NONDATA = 19,         /**< Not a data packet */
    371371       TRACE_TYPE_OPENBSD_LOOP = 20,    /**< OpenBSD loopback */
    372        TRACE_TYPE_ERF_META = 21 /**< ERF Provenance metadata record */
     372       TRACE_TYPE_ERF_META = 21, /**< ERF Provenance metadata record */
     373       TRACE_TYPE_ETSILI = 22   /**< ETSI Lawful Intercept */
    373374} libtrace_linktype_t;
    374375
     
    398399        TRACE_FORMAT_NDAG       =19,    /**< DAG multicast over a network */
    399400        TRACE_FORMAT_DPDK_NDAG       =20,    /**< DAG multicast over a network, received via DPDK */
     401        TRACE_FORMAT_ETSILIVE     =21,  /**< ETSI LI over a network */
    400402};
    401403
     
    453455        TRACE_RT_DATA_DPDK=TRACE_RT_DATA_SIMPLE+TRACE_FORMAT_DPDK,
    454456
     457        TRACE_RT_DATA_ETSILI = TRACE_RT_DATA_SIMPLE + TRACE_FORMAT_ETSILIVE,
     458
    455459        /** As PCAP does not store the linktype with the packet, we need to
    456460         * create a separate RT type for each supported DLT, starting from
     
    560564        uint64_t internalid;            /** Internal identifier for the pkt */
    561565        void *srcbucket;
     566
     567        pthread_mutex_t ref_lock;       /**< Lock for reference counter */
     568        int refcount;                 /**< Reference counter */
     569
    562570} libtrace_packet_t;
    563571
     
    13121320        /** The hasher function for a parallel libtrace. It is recommended to
    13131321         * access this option via trace_set_hasher(). */
    1314         TRACE_OPTION_HASHER
     1322        TRACE_OPTION_HASHER,
     1323
     1324        /** Speed up trace file replays (via trace_event()) by this factor */
     1325        TRACE_OPTION_REPLAY_SPEEDUP,
    13151326} trace_option_t;
    13161327
     
    17741785 */
    17751786DLLEXPORT void trace_destroy_packet(libtrace_packet_t *packet);
    1776 
    17771787
    17781788/** Read the next packet from an input trace
  • lib/libtrace_int.h

    re375e0f rcc9c9de  
    152152//#define RP_BUFSIZE 65536U
    153153
     154#define LIBTRACE_MAX_REPLAY_SPEEDUP 1000
     155
    154156/** Data about the most recent event from a trace file */
    155157struct libtrace_event_status_t {
    156158        /** A libtrace packet to store the packet when a PACKET event occurs */
    157159        libtrace_packet_t *packet;
    158         /** Time between the timestamp for the current packet and the current
    159          * walltime */
    160         double tdelta;
    161         /** The timestamp of the previous PACKET event */
    162         double trace_last_ts;
     160
     161        /* The walltime when we processed the first packet from the trace */
     162        double first_now;
     163
     164        /* The tracetime of the first packet in the trace */
     165        double first_ts;
     166
    163167        /** The size of the current PACKET event */
    164168        int psize;
     
    313317         * used only if the capture format does not support snapping natively */
    314318        size_t snaplen;                 
     319        /** Speed up the packet rate when using trace_event() to process trace
     320         * files by this factor. */
     321        int replayspeedup;
    315322        /** Count of the number of packets returned to the libtrace user */
    316323        uint64_t accepted_packets;
     
    12421249/** Constructor for the network DAG format module */
    12431250void ndag_constructor(void);
     1251/** Constructor for the live ETSI over TCP format module */
     1252void etsilive_constructor(void);
    12441253#ifdef HAVE_BPF
    12451254/** Constructor for the BPF format module */
  • lib/libtrace_parallel.h

    r5c07bfe rc22a4bb  
    731731/** Set the maximum number of perpkt threads to use in a trace.
    732732 *
     733 * Only valid on a new trace, that has not be started. Once started
     734 * the number of threads cannot be changed without destroying the trace.
     735 *
    733736 * @param[in] trace The parallel input trace
    734737 * @param[in] nb The number of threads to use. If set to 0, libtrace will
     
    12711274 */
    12721275DLLEXPORT void trace_free_packet(libtrace_t * libtrace, libtrace_packet_t * packet);
     1276
     1277/** Increments the internal reference counter for a packet.
     1278 * @param packet        The packet opaque pointer
     1279 *
     1280 * You may wish to use this function (and its decrementing counterpart)
     1281 * in situations where you are retaining multiple references to a packet
     1282 * outside of the core packet processing function. This will ensure that
     1283 * the packet is not released until there are no more outstanding references
     1284 * to the packet anywhere in your program.
     1285 */
     1286DLLEXPORT void trace_increment_packet_refcount(libtrace_packet_t *packet);
     1287
     1288/** Decrements the internal reference counter for a packet.
     1289 * @param packet        The packet opaque pointer
     1290 *
     1291 * If the reference counter goes below one, trace_fin_packet() will be
     1292 * called on the packet.
     1293 *
     1294 * You may wish to use this function (and its incrementing counterpart)
     1295 * in situations where you are retaining multiple references to a packet
     1296 * outside of the core packet processing function. This will ensure that
     1297 * the packet is not released until there are no more outstanding references
     1298 * to the packet anywhere in your program.
     1299 */
     1300DLLEXPORT void trace_decrement_packet_refcount(libtrace_packet_t *packet);
     1301
    12731302
    12741303/** Provides some basic information about a trace based on its input format.
  • lib/linktypes.c

    ra857389 rb663d33  
    109109                case TRACE_TYPE_METADATA:
    110110                case TRACE_TYPE_NONDATA:
     111                case TRACE_TYPE_ETSILI:
    111112                        break;
    112113                case TRACE_TYPE_UNKNOWN:
     
    211212                case TRACE_TYPE_NONDATA:
    212213                case TRACE_TYPE_OPENBSD_LOOP:
     214                case TRACE_TYPE_ETSILI:
    213215                case TRACE_TYPE_UNKNOWN:
    214216                        break;
  • lib/protocols_l2.c

    ra857389 rfa555ec  
    483483                case TRACE_TYPE_PFLOG:
    484484                case TRACE_TYPE_ERF_META:
     485                case TRACE_TYPE_ETSILI:
    485486                        break;
    486487                case TRACE_TYPE_UNKNOWN:
     
    519520                                case TRACE_TYPE_PFLOG:
    520521                                case TRACE_TYPE_ERF_META:
     522                                case TRACE_TYPE_ETSILI:
    521523                                        break;
    522524                                case TRACE_TYPE_UNKNOWN:
     
    574576                case TRACE_TYPE_PFLOG:
    575577                case TRACE_TYPE_LINUX_SLL:
     578                case TRACE_TYPE_ETSILI:
    576579                        return NULL;
    577580
     
    696699                case TRACE_TYPE_80211_PRISM:
    697700                case TRACE_TYPE_80211_RADIO:
     701                case TRACE_TYPE_ETSILI:
    698702                        assert(!"Metadata headers should already be skipped");
    699703                        break;
     
    746750                case TRACE_TYPE_80211_PRISM:
    747751                case TRACE_TYPE_80211_RADIO:
     752                case TRACE_TYPE_ETSILI:
    748753                        assert(!"Metadata headers should already be skipped");
    749754                        break;
  • lib/protocols_pktmeta.c

    ra857389 r691b182  
    2828#include "protocols.h"
    2929#include <assert.h>
     30
     31#ifdef HAVE_WANDDER
     32#include <libwandder_etsili.h>
     33#endif
    3034
    3135/* This file contains all the protocol decoding functions for the meta-data
     
    121125}
    122126
     127static void *trace_get_payload_from_etsili(const void *link,
     128                libtrace_linktype_t *type, uint32_t *remaining) {
     129
     130#ifdef HAVE_WANDDER
     131        wandder_etsispec_t *dec;
     132        uint8_t *ccptr;
     133
     134        /* XXX Bit annoying to be creating and freeing this every time */
     135        dec = wandder_create_etsili_decoder();
     136        wandder_attach_etsili_buffer(dec, (uint8_t *)link, *remaining, false);
     137        ccptr = wandder_etsili_get_cc_contents(dec, remaining, NULL, 0);
     138        /* Assuming all CCs are IP for now */
     139        *type = TRACE_TYPE_NONE;
     140        wandder_free_etsili_decoder(dec);
     141        return ccptr;
     142
     143#else
     144        *remaining = NULL;
     145        return NULL;
     146#endif
     147
     148}
     149
    123150DLLEXPORT void *trace_get_packet_meta(const libtrace_packet_t *packet,
    124151                libtrace_linktype_t *linktype,
     
    139166                case TRACE_TYPE_80211_PRISM:
    140167                case TRACE_TYPE_ERF_META:
     168                case TRACE_TYPE_ETSILI:
    141169                        return pktbuf;
    142170                /* Non metadata packets */
     
    199227                                        linktype, remaining);
    200228                        return nexthdr;
     229                case TRACE_TYPE_ETSILI:
     230                        nexthdr = trace_get_payload_from_etsili(meta,
     231                                        linktype, remaining);
     232                        return nexthdr;
     233
    201234                case TRACE_TYPE_HDLC_POS:
    202235                case TRACE_TYPE_ETH:
  • lib/trace.c

    re375e0f rcc9c9de  
    148148                rt_constructor();
    149149                ndag_constructor();
     150#ifdef HAVE_WANDDER
     151                etsilive_constructor();
     152#endif
    150153#ifdef HAVE_DAG
    151154                dag_constructor();
     
    248251        libtrace->format=NULL;
    249252
    250         libtrace->event.tdelta = 0.0;
    251253        libtrace->event.packet = NULL;
    252254        libtrace->event.psize = 0;
    253         libtrace->event.trace_last_ts = 0.0;
     255        libtrace->event.first_ts = 0.0;
     256        libtrace->event.first_now = 0.0;
    254257        libtrace->event.waiting = false;
    255258        libtrace->filter = NULL;
    256259        libtrace->snaplen = 0;
     260        libtrace->replayspeedup = 1;
    257261        libtrace->started=false;
    258262        libtrace->uridata = NULL;
     
    375379        libtrace->format=NULL;
    376380
    377         libtrace->event.tdelta = 0.0;
    378381        libtrace->event.packet = NULL;
    379382        libtrace->event.psize = 0;
    380         libtrace->event.trace_last_ts = 0.0;
     383        libtrace->event.first_ts = 0;
     384        libtrace->event.first_now = 0;
    381385        libtrace->filter = NULL;
    382386        libtrace->snaplen = 0;
     
    592596         * deal with some options itself, so give that a go */
    593597        switch(option) {
     598                case TRACE_OPTION_REPLAY_SPEEDUP:
     599                        /* Clear the error if there was one */
     600                        if (trace_is_err(libtrace)) {
     601                                trace_get_err(libtrace);
     602                        }
     603                        if (*(int*)value<1
     604                                || *(int*)value>LIBTRACE_MAX_REPLAY_SPEEDUP) {
     605                                trace_set_err(libtrace,TRACE_ERR_BAD_STATE,
     606                                        "Invalid replay speed");
     607                        }
     608                        libtrace->replayspeedup=*(int*)value;
     609                        return 0;
     610
    594611                case TRACE_OPTION_SNAPLEN:
    595612                        /* Clear the error if there was one */
     
    724741                libtrace_ocache_destroy(&libtrace->packet_freelist);
    725742                for (i = 0; i < libtrace->perpkt_thread_count; ++i) {
    726                         libtrace_message_queue_destroy(&libtrace->perpkt_threads[i].messages);
    727                 }
    728                 libtrace_message_queue_destroy(&libtrace->hasher_thread.messages);
    729                 libtrace_message_queue_destroy(&libtrace->keepalive_thread.messages);
    730                 libtrace_message_queue_destroy(&libtrace->reporter_thread.messages);
     743                        libtrace_message_queue_destroy(&libtrace->perpkt_threads[i].messages);
     744                }
     745                if (libtrace->hasher_thread.type == THREAD_HASHER)
     746                        libtrace_message_queue_destroy(&libtrace->hasher_thread.messages);
     747                if (libtrace->keepalive_thread.type == THREAD_KEEPALIVE)
     748                        libtrace_message_queue_destroy(&libtrace->keepalive_thread.messages);
     749                if (libtrace->reporter_thread.type == THREAD_REPORTER)
     750                        libtrace_message_queue_destroy(&libtrace->reporter_thread.messages);
    731751
    732752
     
    805825
    806826        packet->buf_control=TRACE_CTRL_PACKET;
     827        pthread_mutex_init(&(packet->ref_lock), NULL);
    807828        trace_clear_cache(packet);
    808829        return packet;
     
    856877                free(packet->buffer);
    857878        }
     879        pthread_mutex_destroy(&(packet->ref_lock));
    858880        packet->buf_control=(buf_control_t)'\0';
    859881                                /* A "bad" value to force an assert
     
    15381560                                trace_set_err(packet->trace,
    15391561                                                TRACE_ERR_NO_CONVERSION,
    1540                                                 "pcap does not support this format");
     1562                                                "pcap does not support this linktype so cannot apply BPF filters");
    15411563                                if (free_packet_needed) {
    15421564                                        trace_destroy_packet(packet_copy);
     
    23162338        packet->l3_remaining = 0;
    23172339        packet->l4_remaining = 0;
     2340        packet->refcount = 0;
    23182341
    23192342}
  • lib/trace_parallel.c

    re375e0f r8a237c7  
    10481048        ASSERT_RET(pthread_spin_unlock(&libtrace->first_packets.lock), == 0);
    10491049
     1050        memset(&mesg, 0, sizeof(libtrace_message_t));
    10501051        mesg.code = MESSAGE_FIRST_PACKET;
    10511052        trace_message_reporter(libtrace, &mesg);
     
    11951196
    11961197        gettimeofday(&prev, NULL);
     1198        memset(&message, 0, sizeof(libtrace_message_t));
    11971199        message.code = MESSAGE_TICK_INTERVAL;
    11981200
     
    15461548                       const char *name) {
    15471549#ifdef __linux__
    1548         pthread_attr_t attrib;
    15491550        cpu_set_t cpus;
    15501551        int i;
     
    15641565        for (i = 0; i < get_nb_cores(); i++)
    15651566                CPU_SET(i, &cpus);
    1566         pthread_attr_init(&attrib);
    1567         pthread_attr_setaffinity_np(&attrib, sizeof(cpus), &cpus);
    1568         ret = pthread_create(&t->tid, &attrib, start_routine, (void *) trace);
    1569         pthread_attr_destroy(&attrib);
     1567
     1568        ret = pthread_create(&t->tid, NULL, start_routine, (void *) trace);
     1569        if( ret == 0 ) {
     1570                ret = pthread_setaffinity_np(t->tid, sizeof(cpus), &cpus);
     1571        }
     1572
    15701573#else
    15711574        ret = pthread_create(&t->tid, NULL, start_routine, (void *) trace);
     
    24022405
    24032406DLLEXPORT int trace_set_perpkt_threads(libtrace_t *trace, int nb) {
    2404         if (!trace_is_configurable(trace)) return -1;
     2407        // Only supported on new traces not paused traces
     2408        if (trace->state != STATE_NEW) return -1;
    24052409
    24062410        /* TODO consider allowing an offset from the total number of cores i.e.
     
    26012605}
    26022606
     2607DLLEXPORT void trace_increment_packet_refcount(libtrace_packet_t *packet) {
     2608        pthread_mutex_lock(&(packet->ref_lock));
     2609        if (packet->refcount < 0) {
     2610                packet->refcount = 1;
     2611        } else {
     2612                packet->refcount ++;
     2613        }
     2614        pthread_mutex_unlock(&(packet->ref_lock));
     2615}
     2616
     2617DLLEXPORT void trace_decrement_packet_refcount(libtrace_packet_t *packet) {
     2618        pthread_mutex_lock(&(packet->ref_lock));
     2619        packet->refcount --;
     2620
     2621        if (packet->refcount <= 0) {
     2622                trace_free_packet(packet->trace, packet);
     2623        }
     2624        pthread_mutex_unlock(&(packet->ref_lock));
     2625}
     2626
     2627
    26032628DLLEXPORT libtrace_info_t *trace_get_information(libtrace_t * libtrace) {
    26042629        if (libtrace->format)
  • libpacketdump/Makefile.am

    r3a333e2 ra82a9e8  
    6060# 17: PPP
    6161TXT_PROTOCOLS+=link_17.protocol
     62
     63# 22: ETSI LI
     64BIN_PROTOCOLS+=link_22.la
    6265
    6366# Decoders for various ethertypes (in decimal)
     
    135138link_11_la_LDFLAGS=$(modflags)
    136139link_15_la_LDFLAGS=$(modflags)
     140link_22_la_LDFLAGS=$(modflags)
    137141eth_0_la_LDFLAGS=$(modflags)
    138142eth_2048_la_LDFLAGS=$(modflags)
  • test/do-test-build-dpdk.sh

    rcaf7841 r6d17620  
    2323}
    2424
    25 # Versions to check
     25# Old kernel version jessie 3.16
    2626declare -a dpdk_versions=(
    2727        "dpdk-1.7.1.tar.gz"
     
    3131        "dpdk-2.2.0.tar.gz"
    3232        "dpdk-16.04.tar.gz"
    33         "dpdk-16.07.tar.gz"
    34         "dpdk-16.11.tar.gz"
     33        "dpdk-16.07.2.tar.gz"
     34        "dpdk-16.11.6.tar.gz"
    3535        )
     36# Versions to check stretch linux 4.9
     37declare -a dpdk_versions=(
     38        "dpdk-2.2.0.tar.gz"
     39        "dpdk-16.04.tar.gz"
     40        "dpdk-16.07.2.tar.gz"
     41        "dpdk-16.11.6.tar.gz"
     42        "dpdk-17.02.1.tar.gz"
     43        "dpdk-17.05.2.tar.gz"
     44        "dpdk-17.08.2.tar.gz"
     45        "dpdk-17.11.2.tar.gz"
     46        "dpdk-18.02.1.tar.gz"
     47        )
     48
    3649
    3750mkdir "$DOWNLOAD_DIR" > /dev/null 2>&1
     
    6073# Build the DPDK libraries
    6174# We try to not overwrite these, so that a rebuild is faster
     75# We build DPDK without KNI, as most kernel dependent code is there
     76#   - also excluding makes the build faster
     77# We also disable error on warning, to improve forwards compiler compatibility
    6278cd "$DOWNLOAD_DIR"
    6379for dpdk_build in $(ls -d */)
     
    6783        do_test make install T=x86_64-native-linuxapp-gcc \
    6884                             CONFIG_RTE_BUILD_COMBINE_LIBS=y \
    69                              EXTRA_CFLAGS="-fPIC" -j $BUILD_THREADS \
     85                             CONFIG_RTE_LIBRTE_KNI=n \
     86                             CONFIG_RTE_KNI_KMOD=n \
     87                             EXTRA_CFLAGS="-fPIC -w" -j $BUILD_THREADS \
    7088                             > build_stdout.txt 2> build_stderr.txt
    7189        cd ..
  • tools/tracepktdump/tracepktdump.cc

    ree6e802 rf35a853  
    113113                                /* Ignore RT messages */
    114114                                continue;
     115                        if (trace_is_err(trace)) {
     116                                break;
     117                        }
    115118                        trace_dump_packet(packet);
    116119
  • tools/tracereplay/tracereplay.1

    rd6dc0f6 r1e0a804  
    44.SH SYNOPSIS
    55.B tracereplay
    6 [\-b | \-\^\-broadcast] [-s \-\^\-snaplength [ snaplength] ] 
    7 [\-f | \-\^\-filter [ filter string ] ]
     6[\-b | \-\^\-broadcast] [-s \-\^\-snaplength [ snaplength] ]
     7[\-f | \-\^\-filter [ filter string ] ] [\-X | \-\^\-speedup [ factor] ]
    88inputuri outputuri
    99.SH DESCRPTION
     
    2323.TP
    2424.PD 0
    25 .BI \-s [snaplength]
     25.BI \-s " snaplength"
    2626.TP
    2727.PD
    28 .BI \-\^\-snaplength [snaplength]
     28.BI \-\^\-snaplength " snaplength"
    2929Truncate the packets to the length specified. This only makes a difference
    3030if the inputuri is a capture device. The value should be > 0. Inappropriate
     
    3333.TP
    3434.PD 0
    35 .BI \-f [ filter string ]
     35.BI \-f " filterstring"
    3636.TP
    3737.PD
    38 .BI \-\^\-filter [ filter ]
     38.BI \-\^\-filter " filterstring"
    3939Apply a filter to the inputuri.
     40
     41.TP
     42.PD 0
     43.BI \-X " factor"
     44.TP
     45.PD
     46.BI \-\^\-speedup " factor"
     47Decrease the gaps between packets by the specified factor. This will accelerate
     48the rate at which the replay is performed. By default, the factor is 1 (i.e.
     49no acceleration).
    4050
    4151.SH LINKS
  • tools/tracereplay/tracereplay.c

    r8e11beb r1e0a804  
    9898        if (IS_LIBTRACE_META_PACKET(packet))
    9999                return NULL;
     100        if (trace_get_wire_length(packet) == 0)
     101                return NULL;
    100102
    101103        pkt_buffer = trace_get_packet_buffer(packet,&linktype,&remaining);
     
    194196        fprintf(stderr, " --broadcast\n");
    195197        fprintf(stderr, "\t\tSend ethernet frames to broadcast address\n");
     198        fprintf(stderr, " -X\n");
     199        fprintf(stderr, " --speedup\n");
     200        fprintf(stderr, "\t\tSpeed up replay by a factor of <speedup>\n");
    196201
    197202}
     
    207212        libtrace_packet_t * new;
    208213        int snaplen = 0;
     214        int speedup = 1;
    209215
    210216
     
    216222                        { "snaplen",    1, 0, 's'},
    217223                        { "broadcast",  0, 0, 'b'},
     224                        { "speedup",    1, 0, 'X'},
    218225                        { NULL,         0, 0, 0}
    219226                };
    220227
    221                 int c = getopt_long(argc, argv, "bhs:f:",
     228                int c = getopt_long(argc, argv, "bhs:f:X:",
    222229                                long_options, &option_index);
    223230
     
    232239                                snaplen = atoi(optarg);
    233240                                break;
    234 
     241                        case 'X':
     242                                speedup = atoi(optarg);
     243                                break;
    235244                        case 'b':
    236245                                broadcast = 1;
     
    257266        }
    258267
     268        if (speedup < 1) {
     269                speedup = 1;
     270        }
     271
    259272        uri = strdup(argv[optind]);
    260273
     
    279292                }
    280293        }
     294
     295        if (trace_config(trace, TRACE_OPTION_REPLAY_SPEEDUP, &speedup)) {
     296                trace_perror(trace, "error setting replay speedup factor");
     297                return 1;
     298        }
    281299
    282300        /* Starting the trace */
Note: See TracChangeset for help on using the changeset viewer.