Changes in / [41148f2:c99b1e5]


Ignore:
Files:
11 deleted
32 edited

Legend:

Unmodified
Added
Removed
  • README

    r9ad7a35 rf1015ad  
    44Libtrace functions might not function correctly breaking the supplied tools.
    55
    6 libtrace 3.0.20
     6libtrace 3.0.19
    77
    88---------------------------------------------------------------------------
  • configure.in

    r457bf45 rabf01b6  
    44# and in the README
    55
    6 AC_INIT([libtrace],[3.0.20],[contact@wand.net.nz],[libtrace])
     6AC_INIT([libtrace],[3.0.19],[contact@wand.net.nz],[libtrace])
    77
    88LIBTRACE_MAJOR=3
    99LIBTRACE_MID=0
    10 LIBTRACE_MINOR=20
     10LIBTRACE_MINOR=19
    1111
    1212# OpenSolaris hides libraries like libncurses in /usr/gnu/lib, which is not
     
    580580)
    581581
    582 AC_ARG_WITH([lzma],
    583         AC_HELP_STRING([--with-lzma], [build with support for lzma compressed files]))
    584 
    585 AS_IF([test "x$with_lzma" != "xno"],
    586         [
    587         AC_CHECK_HEADER(lzma.h, have_lzma=yes, have_lzma=no)
    588         ], [have_lzma=no])
    589 
    590 AS_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 )
    603582
    604583# Define automake conditionals for use in our Makefile.am files
     
    615594AM_CONDITIONAL([HAVE_ZLIB], [test "x$with_zlib" != "xno"])
    616595AM_CONDITIONAL([HAVE_LZO], [ test "x$with_lzo" != "xno"])
    617 AM_CONDITIONAL([HAVE_LZMA], [ test "x$with_lzma" != "xno"])
    618596
    619597# Check for miscellaneous programs
     
    670648reportopt "Compiled with compressed trace (bz2) support" $with_bzip2
    671649reportopt "Compiled with compressed trace (lzo write only) support" $with_lzo
    672 reportopt "Compiled with compressed trace (lzma) support" $with_lzma
    673650if test x"$libtrace_dag" = xtrue; then
    674651        if test "$libtrace_dag_version" = 24; then
  • lib/Makefile.am

    rdafe86a rbd119b3  
    3333export RTE_SDK=@RTE_SDK@
    3434export RTE_TARGET=@RTE_TARGET@
    35 export SAVED_CFLAGS:=$(CFLAGS)
    36 export SAVED_CXXFLAGS:=$(CXXFLAGS)
    3735include $(RTE_SDK)/mk/rte.vars.mk
    3836# We need to add -Wl before the linker otherwise this breaks our build
     
    4038export DPDK_LIBTRACE_MK=dpdk_libtrace.mk
    4139include $(DPDK_LIBTRACE_MK)
    42 export CFLAGS += $(SAVED_CFLAGS)
    43 export CXXFLAGS += $(SAVED_CXXFLAGS)
    4440endif
    4541
  • lib/format_dpdk.c

    r50ce607 rb13b939  
    4141 */
    4242
    43 #define _GNU_SOURCE
    44 
    4543#include "config.h"
    4644#include "libtrace.h"
     
    7876#include <rte_lcore.h>
    7977#include <rte_per_lcore.h>
    80 #include <pthread.h>
    8178
    8279/* The default size of memory buffers to use - This is the max size of standard
     
    114111#define MBUF_PKTDATA(x) ((char *) x + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
    115112#define FORMAT(x) ((struct dpdk_format_data_t*)(x->format_data))
    116 #define PERPKT_FORMAT(x) ((struct dpdk_per_lcore_t*)(x->format_data))
    117 
    118113#define TV_TO_NS(tv) ((uint64_t) tv.tv_sec*1000000000ull + \
    119114                        (uint64_t) tv.tv_usec*1000ull)
     
    187182};
    188183
    189 struct dpdk_per_lcore_t
     184struct per_lcore_t
    190185{
    191186        // TODO move time stamp stuff here
    192187        uint16_t queue_id;
    193188        uint8_t port;
     189        uint8_t enabled;
    194190};
    195191
     
    217213    uint32_t wrap_count; /* Number of times the NIC clock has wrapped around completely */
    218214#endif
    219         // DPDK normally seems to have a limit of 8 queues for a given card
    220         struct dpdk_per_lcore_t per_lcore[RTE_MAX_LCORE];
     215        // DPDK normally seems to have a limit of
     216        struct per_lcore_t per_lcore[RTE_MAX_LCORE];
    221217};
    222218
     
    355351    if (global_config != NULL) {
    356352        int i;
    357         fprintf(stderr, "Intel DPDK setup\n"
     353        printf("Intel DPDK setup\n"
    358354               "---Version      : %"PRIu32"\n"
    359355               "---Magic        : %"PRIu32"\n"
     
    364360       
    365361        for (i = 0 ; i < nb_cpu; i++) {
    366             fprintf(stderr, "   ---Core %d : %s\n", i,
     362            printf("   ---Core %d : %s\n", i,
    367363                   global_config->lcore_role[i] == ROLE_RTE ? "on" : "off");
    368364        }
     
    385381                proc_type = "something worse than invalid!!";
    386382        }
    387         fprintf(stderr, "---Process Type : %s\n", proc_type);
    388     }
    389    
    390 }
    391 #endif
    392 
    393 /**
    394  * Expects to be called from the master lcore and moves it to the given dpdk id
    395  * @param core (zero indexed) If core is on the physical system affinity is bound otherwise
    396  *               affinity is set to all cores. Must be less than RTE_MAX_LCORE
    397  *               and not already in use.
    398  * @return 0 is successful otherwise -1 on error.
    399  */
    400 static inline int dpdk_move_master_lcore(size_t core) {
    401     struct rte_config *cfg = rte_eal_get_configuration();
    402     cpu_set_t cpuset;
    403     int i;
    404 
    405     assert (core < RTE_MAX_LCORE);
    406     assert (rte_get_master_lcore() == rte_lcore_id());
    407 
    408     if (core == rte_lcore_id())
    409         return 0;
    410 
    411     // Make sure we are not overwriting someone else
    412     assert(!rte_lcore_is_enabled(core));
    413 
    414     // Move the core
    415     cfg->lcore_role[rte_lcore_id()] = ROLE_OFF;
    416     cfg->lcore_role[core] = ROLE_RTE;
    417     lcore_config[core].thread_id = lcore_config[rte_lcore_id()].thread_id;
    418     rte_eal_get_configuration()->master_lcore = core;
    419     RTE_PER_LCORE(_lcore_id) = core;
    420 
    421     // Now change the affinity
    422     CPU_ZERO(&cpuset);
    423 
    424     if (lcore_config[core].detected) {
    425         CPU_SET(core, &cpuset);
    426     } else {
    427         for (i = 0; i < RTE_MAX_LCORE; ++i) {
    428             if (lcore_config[i].detected)
    429                 CPU_SET(i, &cpuset);
    430         }
    431     }
    432 
    433     i = pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
    434     if (i != 0) {
    435         // TODO proper libtrace style error here!!
    436         fprintf(stderr, "pthread_setaffinity_np failed\n");
    437         return -1;
    438     }
    439     return 0;
    440 }
    441 
     383        printf("---Process Type : %s\n", proc_type);
     384    }
     385   
     386}
     387#endif
    442388
    443389static inline int dpdk_init_enviroment(char * uridata, struct dpdk_format_data_t * format_data,
     
    446392    struct rte_pci_addr use_addr; /* The only address that we don't blacklist */   
    447393    char cpu_number[10] = {0}; /* The CPU mask we want to bind to */
    448     char mem_map[20] = {0}; /* The memory name */
    449394    long nb_cpu; /* The number of CPUs in the system */
    450395    long my_cpu; /* The CPU number we want to bind to */
    451     int i;
    452     struct rte_config *cfg = rte_eal_get_configuration();
    453396   
    454397#if DEBUG
     
    458401#endif
    459402    /* Using proc-type auto allows this to be either primary or secondary
    460      * Secondary allows two instances of libtrace to be used on different
     403     * Secondary allows two intances of libtrace to be used on different
    461404     * ports. However current version of DPDK doesn't support this on the
    462      * same card (My understanding is this should work with two separate
     405     * same card (My understanding is this should work with two seperate
    463406     * cards).
    464      *
    465      * Using unique file prefixes mean separate memory is used, unlinking
    466      * the two processes. However be careful we still cannot access a
    467      * port that already in use.
    468407     */
    469     char* argv[] = {"libtrace", "-c", cpu_number, "-n", "1", "--proc-type", "auto",
    470                 "--file-prefix", mem_map, "-m", "256", NULL};
     408    char* argv[] = {"libtrace", "-c", NULL, "-n", "1", "--proc-type", "auto", NULL};
    471409    int argc = sizeof(argv) / sizeof(argv[0]) - 1;
    472410   
    473     /* This initialises the Environment Abstraction Layer (EAL)
     411    /* This initilises the Enviroment Abstraction Layer (EAL)
    474412     * If we had slave workers these are put into WAITING state
    475413     *
     
    513451    }
    514452
    515     /* Make our mask with all cores turned on this is so that DPDK to gets CPU
    516        info older versions */
    517     snprintf(cpu_number, sizeof(cpu_number), "%x", ~(UINT32_MAX<<MIN(31, nb_cpu)));
    518     //snprintf(cpu_number, sizeof(cpu_number), "%x", 0x1 << (my_cpu - 1));
    519 
    520         /* Give this a name */
    521         snprintf(mem_map, sizeof(mem_map), "libtrace-%d", (int) getpid());
     453    /* Make our mask */ //  0x1 << (my_cpu - 1)
     454    snprintf(cpu_number, sizeof(cpu_number), "%x", 0x3);
     455    argv[2] = cpu_number;
     456
    522457    /* rte_eal_init it makes a call to getopt so we need to reset the
    523458     * global optind variable of getopt otherwise this fails */
     
    528463        return -1;
    529464    }
    530 
    531     // These are still running but will never do anything with DPDK v1.7 we
    532     // should remove this XXX in the future
    533     for(i = 0; i < RTE_MAX_LCORE; ++i) {
    534         if (rte_lcore_is_enabled(i) && i != rte_get_master_lcore()) {
    535             cfg->lcore_role[i] = ROLE_OFF;
    536             cfg->lcore_count--;
    537         }
    538     }
    539     // Only the master should be running
    540     assert(cfg->lcore_count == 1);
    541 
    542     dpdk_move_master_lcore(my_cpu-1);
    543 
    544465#if DEBUG
    545466    dump_configuration();
     
    584505    char err[500];
    585506    err[0] = 0;
     507    int i;
    586508   
    587509    libtrace->format_data = (struct dpdk_format_data_t *)
     
    603525    FORMAT(libtrace)->wrap_count = 0;
    604526#endif
     527        for (i = 0;i < RTE_MAX_LCORE; i++) {
     528                // Disabled by default
     529                FORMAT(libtrace)->per_lcore[i].enabled = 0;
     530        }
    605531       
    606532    if (dpdk_init_enviroment(libtrace->uridata, FORMAT(libtrace), err, sizeof(err)) != 0) {
     
    665591                                        return -1;
    666592                        }
    667         break;
    668593        }
    669594        return -1;
     
    763688static const struct rte_eth_txconf tx_conf = {
    764689        .tx_thresh = {
    765         /**
    766          * TX_PTHRESH prefetch
    767          * Set on the NIC, if the number of unprocessed descriptors to queued on
    768          * the card fall below this try grab at least hthresh more unprocessed
    769          * descriptors.
    770          */
    771                 .pthresh = 36,
    772 
    773         /* TX_HTHRESH host
    774          * Set on the NIC, the batch size to prefetch unprocessed tx descriptors.
    775          */
    776                 .hthresh = 0,
    777        
    778         /* TX_WTHRESH writeback
    779          * Set on the NIC, the number of sent descriptors before writing back
    780          * status to confirm the transmission. This is done more efficiently as
    781          * a bulk DMA-transfer rather than writing one at a time.
    782          * Similar to tx_free_thresh however this is applied to the NIC, where
    783          * as tx_free_thresh is when DPDK will check these. This is extended
    784          * upon by tx_rs_thresh (10Gbit cards) which doesn't write all
    785          * descriptors rather only every n'th item, reducing DMA memory bandwidth.
    786          */
    787                 .wthresh = 4,
     690                .pthresh = 36,/* TX_PTHRESH prefetch */
     691                .hthresh = 0,/* TX_HTHRESH host */
     692                .wthresh = 4,/* TX_WTHRESH writeback */
    788693        },
    789 
    790     /* Used internally by DPDK rather than passed to the NIC. The number of
    791      * packet descriptors to send before checking for any responses written
    792      * back (to confirm the transmission). Default = 32 if set to 0)
    793      */
    794         .tx_free_thresh = 0,
    795 
    796     /* This is the Report Status threshold, used by 10Gbit cards,
    797      * This signals the card to only write back status (such as
    798      * transmission successful) after this minimum number of transmit
    799      * descriptors are seen. The default is 32 (if set to 0) however if set
    800      * to greater than 1 TX wthresh must be set to zero, because this is kindof
    801      * a replacement. See the dpdk programmers guide for more restrictions.
    802      */
    803         .tx_rs_thresh = 1,
     694        .tx_free_thresh = 0, /* Use PMD default values */
     695        .tx_rs_thresh = 0, /* Use PMD default values */
    804696};
    805697
     
    845737         */
    846738#if DEBUG
    847     fprintf(stderr, "Creating mempool named %s\n", format_data->mempool_name);
     739    printf("Creating mempool named %s\n", format_data->mempool_name);
    848740#endif
    849741        format_data->pktmbuf_pool =
     
    884776        return -1;
    885777    }
    886     /* Initialise the TX queue a minimum value if using this port for
     778    /* Initilise the TX queue a minimum value if using this port for
    887779     * receiving. Otherwise a larger size if writing packets.
    888780     */
     
    895787        return -1;
    896788    }
    897     /* Initialise the RX queue with some packets from memory */
     789    /* Initilise the RX queue with some packets from memory */
    898790    ret = rte_eth_rx_queue_setup(format_data->port, format_data->queue_id,
    899791                            format_data->nb_rx_buf, SOCKET_ID_ANY,
     
    926818    rte_eth_link_get(format_data->port, &link_info);
    927819#if DEBUG
    928     fprintf(stderr, "Link status is %d %d %d\n", (int) link_info.link_status,
     820    printf("Link status is %d %d %d\n", (int) link_info.link_status,
    929821            (int) link_info.link_duplex, (int) link_info.link_speed);
    930822#endif
    931823
    932     /* We have now successfully started/unpaused */
     824    /* We have now successfully started/unpased */
    933825    format_data->paused = DPDK_RUNNING;
    934826   
     
    936828}
    937829
    938 /* Attach memory to the port and start (or restart) the port/s.
    939  */
    940 static int dpdk_start_port_queues (libtrace_t *libtrace, struct dpdk_format_data_t *format_data, char *err, int errlen, uint16_t rx_queues){
     830/* Attach memory to the port and start the port or restart the ports.
     831 */
     832static int dpdk_start_port_queues (libtrace_t *libtrace, struct dpdk_format_data_t * format_data, char *err, int errlen, uint16_t rx_queues){
    941833    int ret, i; /* Check return values for errors */
    942834    struct rte_eth_link link_info; /* Wait for link */
     
    947839
    948840    /* First time started we need to alloc our memory, doing this here
    949      * rather than in environment setup because we don't have snaplen then */
     841     * rather than in enviroment setup because we don't have snaplen then */
    950842    if (format_data->paused == DPDK_NEVER_STARTED) {
    951843        if (format_data->snaplen == 0) {
     
    968860
    969861        /* Create the mbuf pool, which is the place our packets are allocated
    970          * from - TODO figure out if there is is a free function (I cannot see one)
     862         * from - TODO figure out if there is is a free function (I cannot see one) 
    971863         * NOTE: RX queue requires nb_packets + 1 otherwise it fails to
    972864         * allocate however that extra 1 packet is not used.
     
    1016908    printf("Doing dev configure\n");
    1017909#endif
    1018     /* Initialise the TX queue a minimum value if using this port for
     910    /* Initilise the TX queue a minimum value if using this port for
    1019911     * receiving. Otherwise a larger size if writing packets.
    1020912     */
     
    1032924    printf("Doing queue configure\n");
    1033925#endif 
    1034                 /* Initialise the RX queue with some packets from memory */
     926                /* Initilise the RX queue with some packets from memory */
    1035927                ret = rte_eth_rx_queue_setup(format_data->port, i,
    1036928                                                                format_data->nb_rx_buf, SOCKET_ID_ANY,
    1037929                                                                &rx_conf, format_data->pktmbuf_pool);
    1038         /* Init per_thread data structures */
    1039         format_data->per_lcore[i].port = format_data->port;
    1040         format_data->per_lcore[i].queue_id = i;
    1041 
    1042930                if (ret < 0) {
    1043931                        snprintf(err, errlen, "Intel DPDK - Cannot configure RX queue on port"
     
    1049937   
    1050938#if DEBUG
    1051     fprintf(stderr, "Doing start device\n");
     939    printf("Doing start device\n");
    1052940#endif 
    1053941    /* Start device */
    1054942    ret = rte_eth_dev_start(format_data->port);
    1055943#if DEBUG
    1056     fprintf(stderr, "Done start device\n");
     944    printf("Done start device\n");
    1057945#endif 
    1058946    if (ret < 0) {
     
    1084972    rte_eth_link_get(format_data->port, &link_info);
    1085973#if DEBUG
    1086     fprintf(stderr, "Link status is %d %d %d\n", (int) link_info.link_status,
     974    printf("Link status is %d %d %d\n", (int) link_info.link_status,
    1087975            (int) link_info.link_duplex, (int) link_info.link_speed);
    1088976#endif
     
    1104992}
    1105993
    1106 static inline size_t dpdk_get_max_rx_queues (uint8_t port_id) {
    1107     struct rte_eth_dev_info dev_info;
    1108     rte_eth_dev_info_get(port_id, &dev_info);
    1109     return dev_info.max_rx_queues;
    1110 }
    1111 
    1112 static inline size_t dpdk_processor_count () {
    1113     long nb_cpu = sysconf(_SC_NPROCESSORS_ONLN);
    1114     if (nb_cpu <= 0)
    1115         return 1;
    1116     else
    1117         return (size_t) nb_cpu;
    1118 }
    1119 
    1120994static int dpdk_pstart_input (libtrace_t *libtrace) {
    1121995    char err[500];
    1122     int i=0, phys_cores=0;
     996    int enabled_lcore_count = 0, i=0;
    1123997    int tot = libtrace->perpkt_thread_count;
    1124998    err[0] = 0;
    1125 
    1126     if (rte_lcore_id() != rte_get_master_lcore())
    1127         fprintf(stderr, "Warning dpdk_pstart_input should be called from the master DPDK thread!\n");
    1128 
    1129     // If the master is not on the last thread we move it there
    1130     if (rte_get_master_lcore() != RTE_MAX_LCORE - 1) {
    1131         // Consider error handling here
    1132         dpdk_move_master_lcore(RTE_MAX_LCORE - 1) == -1;
    1133     }
    1134 
    1135     // Don't exceed the number of cores in the system/detected by dpdk
    1136     // We don't have to force this but performance wont be good if we don't
    1137     for (i = 0; i < RTE_MAX_LCORE; ++i) {
    1138         if (lcore_config[i].detected) {
    1139             if (rte_lcore_is_enabled(i))
    1140                 fprintf(stderr, "Found core %d already in use!\n", i);
    1141             else
    1142                 phys_cores++;
    1143         }
    1144     }
    1145 
    1146         tot = MIN(libtrace->perpkt_thread_count, dpdk_get_max_rx_queues(FORMAT(libtrace)->port));
    1147     tot = MIN(tot, phys_cores);
    1148 
    1149         fprintf(stderr, "Running pstart DPDK tot=%d req=%d phys=%d\n", tot, libtrace->perpkt_thread_count, phys_cores);
     999       
     1000        libtrace->perpkt_thread_count;
     1001       
     1002        for (i = 0; i < RTE_MAX_LCORE; i++)
     1003        {
     1004                if (rte_lcore_is_enabled(i))
     1005                        enabled_lcore_count++;
     1006        }
     1007       
     1008        tot = MIN(libtrace->perpkt_thread_count, enabled_lcore_count);
     1009        tot = MIN(tot, 8);
     1010        printf("Running pstart DPDK %d %d %d %d\n", tot, libtrace->perpkt_thread_count, enabled_lcore_count, rte_lcore_count());
    11501011       
    11511012    if (dpdk_start_port_queues(libtrace, FORMAT(libtrace), err, sizeof(err), tot) != 0) {
     
    11551016        return -1;
    11561017    }
    1157 
    1158     // Make sure we only start the number that we should
    1159     libtrace->perpkt_thread_count = tot;
     1018   
    11601019    return 0;
    1161 }
    1162 
    1163 
    1164 /**
    1165  * Register a thread with the DPDK system,
    1166  * When we start DPDK in parallel libtrace we move the 'main thread' to the
    1167  * MAXIMUM CPU core slot (32) and remove any affinity restrictions DPDK
    1168  * gives it.
    1169  *
    1170  * We then allow a mapper thread to be started on every real core as DPDK would
    1171  * we also bind these to the corresponding CPU cores.
    1172  *
    1173  * @param libtrace A pointer to the trace
    1174  * @param reading True if the thread will be used to read packets, i.e. will
    1175  *                call pread_packet(), false if thread used to process packet
    1176  *                in any other manner including statistics functions.
    1177  */
    1178 static int dpdk_pregister_thread(libtrace_t *libtrace, libtrace_thread_t *t, bool reading)
    1179 {
    1180     struct rte_config *cfg = rte_eal_get_configuration();
    1181     int i;
    1182     int new_id = -1;
    1183 
    1184     // If 'reading packets' fill in cores from 0 up and bind affinity
    1185     // otherwise start from the MAX core (which is also the master) and work backwards
    1186     // in this case physical cores on the system will not exist so we don't bind
    1187     // these to any particular physical core
    1188     if (reading) {
    1189         for (i = 0; i < RTE_MAX_LCORE; ++i) {
    1190             if (!rte_lcore_is_enabled(i)) {
    1191                 new_id = i;
    1192                 if (!lcore_config[i].detected)
    1193                     fprintf(stderr, "Warning the number of 'reading' threads exceed cores on machine!!\n");
    1194                 break;
    1195             }
    1196         }
    1197     } else {
    1198         for (i = RTE_MAX_LCORE-1; i >= 0; --i) {
    1199             if (!rte_lcore_is_enabled(i)) {
    1200                 new_id = i;
    1201                 break;
    1202             }
    1203         }
    1204     }
    1205 
    1206     if (new_id == -1) {
    1207         assert(cfg->lcore_count == RTE_MAX_LCORE);
    1208         // TODO proper libtrace style error here!!
    1209         fprintf(stderr, "Too many threads for DPDK!!\n");
    1210         return -1;
    1211     }
    1212 
    1213     // Enable the core in global DPDK structs
    1214     cfg->lcore_role[new_id] = ROLE_RTE;
    1215     cfg->lcore_count++;
    1216     // Set TLS to reflect our new number
    1217     assert(rte_lcore_id() == 0); // I think new threads are going get a default thread number of 0
    1218     fprintf(stderr, "original id%d", rte_lcore_id());
    1219     RTE_PER_LCORE(_lcore_id) = new_id;
    1220     fprintf(stderr, " new id%d\n", rte_lcore_id());
    1221 
    1222     if (reading) {
    1223         // Set affinity bind to corresponding core
    1224         cpu_set_t cpuset;
    1225         CPU_ZERO(&cpuset);
    1226         CPU_SET(rte_lcore_id(), &cpuset);
    1227         i = pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset);
    1228         if (i != 0) {
    1229             fprintf(stderr, "Warning pthread_setaffinity_np failed\n");
    1230             return -1;
    1231         }
    1232     }
    1233 
    1234     // Map our TLS to the thread data
    1235     if (reading) {
    1236         if(t->type == THREAD_PERPKT) {
    1237             t->format_data = &FORMAT(libtrace)->per_lcore[t->perpkt_num];
    1238         } else {
    1239             t->format_data = &FORMAT(libtrace)->per_lcore[0];
    1240         }
    1241     }
    1242 }
    1243 
    1244 
    1245 /**
    1246  * Unregister a thread with the DPDK system.
    1247  *
    1248  * Only previously registered threads should be calling this just before
    1249  * they are destroyed.
    1250  */
    1251 static int dpdk_punregister_thread(libtrace_t libtrace, libtrace_thread_t *t UNUSED)
    1252 {
    1253     struct rte_config *cfg = rte_eal_get_configuration();
    1254 
    1255     assert(rte_lcore_id() >= 0 && rte_lcore_id() < RTE_MAX_LCORE);
    1256 
    1257     // Skip if master!!
    1258     if (rte_lcore_id() == rte_get_master_lcore()) {
    1259         fprintf(stderr, "INFO: we are skipping unregistering the master lcore\n");
    1260         return 0;
    1261     }
    1262 
    1263     // Disable this core in global DPDK structs
    1264     cfg->lcore_role[rte_lcore_id()] = ROLE_OFF;
    1265     cfg->lcore_count--;
    1266     RTE_PER_LCORE(_lcore_id) = -1; // Might make the world burn if used again
    1267     assert(cfg->lcore_count >= 1); // We cannot unregister the master LCORE!!
    1268     return 0;
     1020    return tot;
    12691021}
    12701022
     
    12871039    if (FORMAT(libtrace)->paused == DPDK_RUNNING) {
    12881040#if DEBUG     
    1289         fprintf(stderr, "Pausing port\n");
     1041        printf("Pausing port\n");
    12901042#endif
    12911043        rte_eth_dev_stop(FORMAT(libtrace)->port);
     
    16441396    return -1;
    16451397}
    1646 
    1647 static int dpdk_pread_packet (libtrace_t *libtrace, libtrace_thread_t *t, libtrace_packet_t *packet) {
     1398libtrace_thread_t * get_thread_table(libtrace_t *libtrace);
     1399static int dpdk_pread_packet (libtrace_t *libtrace, libtrace_packet_t *packet) {
    16481400    int nb_rx; /* Number of rx packets we've recevied */
    16491401    struct rte_mbuf* pkts_burst[1]; /* Array of 1 pointer(s) */
     
    16521404    if (packet->buffer != NULL) {
    16531405        /* Buffer is owned by DPDK */
    1654         if ( packet->buf_control == TRACE_CTRL_EXTERNAL) {
     1406        if ( packet->buf_control == TRACE_CTRL_EXTERNAL ) {
    16551407            rte_pktmbuf_free(packet->buffer);
    16561408            packet->buffer = NULL;
     
    16691421    while (1) {
    16701422        /* Poll for a single packet */
    1671         nb_rx = rte_eth_rx_burst(PERPKT_FORMAT(t)->port,
    1672                             PERPKT_FORMAT(t)->queue_id, pkts_burst, 1);
     1423        nb_rx = rte_eth_rx_burst(FORMAT(libtrace)->port,
     1424                            get_thread_table_num(libtrace), pkts_burst, 1);
    16731425        if (nb_rx > 0) { /* Got a packet - otherwise we keep spining */
    1674                         //fprintf(stderr, "Doing P READ PACKET port=%d q=%d\n", (int) FORMAT(libtrace)->port, (int) get_thread_table_num(libtrace));
     1426                        printf("Doing P READ PACKET port=%d q=%d\n", (int) FORMAT(libtrace)->port, (int) get_thread_table_num(libtrace));
    16751427            return dpdk_ready_pkt(libtrace, packet, pkts_burst[0]);
    16761428        }
    16771429        // Check the message queue this could be (Well it shouldn't but anyway) be less than 0
    1678         if (libtrace_message_queue_count(&t->messages) > 0) {
     1430        if (libtrace_message_queue_count(&(get_thread_table(libtrace)->messages)) > 0) {
    16791431                        printf("Extra message yay");
    16801432                        return -2;
     
    18891641        dpdk_pause_input, /* ppause */
    18901642        dpdk_fin_input, /* p_fin */
    1891         dpdk_pconfig_input, /* pconfig_input */
    1892     dpdk_pregister_thread, /* pregister_thread */
    1893     dpdk_punregister_thread /* unpregister_thread */
     1643        dpdk_pconfig_input /* pconfig_input */
    18941644};
    18951645
  • lib/format_linux.c

    r53eb1aa rb13b939  
    214214        // The flag layout should be the same for all (I Hope)
    215215        // max_order
    216 } ALIGN_STRUCT(CACHE_LINE_SIZE);
     216};
    217217
    218218struct linux_format_data_t {
     
    305305
    306306#define FORMAT(x) ((struct linux_format_data_t*)(x))
    307 #define PERPKT_FORMAT(x) ((struct linux_per_thread_t*)(x->format_data))
    308307#define DATAOUT(x) ((struct linux_output_format_data_t*)((x)->format_data))
    309308
     
    697696       
    698697        if (!FORMAT(libtrace->format_data)->per_thread) {
    699                 //per_thread = calloc(tot, sizeof(struct linux_per_thread_t));
    700                 posix_memalign((void **)&per_thread, CACHE_LINE_SIZE, tot*sizeof(struct linux_per_thread_t));
     698                per_thread = calloc(tot, sizeof(struct linux_per_thread_t));
    701699                FORMAT(libtrace->format_data)->per_thread = per_thread;
    702700        } else {
     
    752750}
    753751
    754 static int linux_pregister_thread(libtrace_t *libtrace, libtrace_thread_t *t, bool reading) {
    755         fprintf(stderr, "registering thread %d!!\n", t->perpkt_num);
    756     if (reading) {
    757         if(t->type == THREAD_PERPKT) {
    758             t->format_data = &FORMAT(libtrace->format_data)->per_thread[t->perpkt_num];
    759         } else {
    760             t->format_data = &FORMAT(libtrace->format_data)->per_thread[0];
    761         }
    762     }
    763     return 0;
    764 }
    765 
    766752static int linuxnative_start_output(libtrace_out_t *libtrace)
    767753{
     
    11091095        if (check_queue) {
    11101096                // Check for a packet - TODO only Linux has MSG_DONTWAIT should use fctl O_NONBLOCK
    1111                 hdr->wirelen = recvmsg(fd, &msghdr, MSG_DONTWAIT | MSG_TRUNC);
    1112                 if ((int) hdr->wirelen == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
     1097                hdr->wirelen = recvmsg(fd, &msghdr, MSG_DONTWAIT);
     1098                if ((unsigned) hdr->wirelen == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
    11131099                        // Do message queue check or select
    11141100                        int ret;
     
    11361122                }
    11371123        } else {
    1138                 hdr->wirelen = recvmsg(fd, &msghdr, MSG_TRUNC);
     1124                hdr->wirelen = recvmsg(fd, &msghdr, 0);
    11391125        }
    11401126       
     
    12131199}
    12141200
    1215 static int linuxnative_pread_packet(libtrace_t *libtrace, libtrace_thread_t *t, libtrace_packet_t *packet)
    1216 {
    1217         int fd = PERPKT_FORMAT(t)->fd;
    1218         //fprintf(stderr, "Thread number is #%d fd=%d\n", t->perpkt_num, PERPKT_FORMAT(t)->fd);
     1201static int linuxnative_pread_packet(libtrace_t *libtrace, libtrace_packet_t *packet)
     1202{
     1203        int fd = FORMAT(libtrace->format_data)->per_thread[get_thread_table_num(libtrace)].fd;
     1204        //printf("Thread number is #%d point %p\n", get_thread_table_num(libtrace), FORMAT(libtrace->format_data)->per_thread);
    12191205        return linuxnative_read_packet_fd(libtrace, packet, fd, 1);
    12201206}
     
    12561242static void linuxring_fin_packet(libtrace_packet_t *packet)
    12571243{
    1258 
    1259         if (packet->buffer == NULL)
    1260                 return;
    12611244        assert(packet->trace);
    12621245       
     
    13591342}
    13601343
    1361 static int linuxring_pread_packet(libtrace_t *libtrace, libtrace_thread_t *t, libtrace_packet_t *packet) {
    1362         fprintf(stderr, "Thread number is #%d\n", t->perpkt_num);
    1363         int fd = PERPKT_FORMAT(t)->fd;
    1364         int *rxring_offset = &PERPKT_FORMAT(t)->rxring_offset;
    1365         char *rx_ring = PERPKT_FORMAT(t)->rx_ring;
     1344static int linuxring_pread_packet(libtrace_t *libtrace, libtrace_packet_t *packet) {
     1345        int tnum = get_thread_table_num(libtrace);
     1346        int fd = FORMAT(libtrace->format_data)->per_thread[tnum].fd;
     1347        int *rxring_offset = &FORMAT(libtrace->format_data)->per_thread[tnum].rxring_offset;
     1348        char *rx_ring = FORMAT(libtrace->format_data)->per_thread[tnum].rx_ring;
     1349        printf("Thread number is #%d point %p\n", get_thread_table_num(libtrace), FORMAT(libtrace->format_data)->per_thread);
    13661350        return linuxring_read_packet_fd(libtrace, packet, fd, rxring_offset, rx_ring, 1);
    13671351}
     
    14221406
    14231407        return ret;
    1424 }
    1425 
     1408
     1409}
    14261410static int linuxring_write_packet(libtrace_out_t *trace,
    14271411                libtrace_packet_t *packet)
     
    18601844        linuxnative_ppause_input,                       /* ppause */
    18611845        linuxnative_fin_input,                          /* p_fin */
    1862         linuxnative_pconfig_input,                      /* pconfig input */
    1863         linux_pregister_thread,
    1864         NULL
     1846        linuxnative_pconfig_input                       /* pconfig input */
    18651847};
    18661848
     
    19111893        linuxnative_ppause_input,                       /* ppause */
    19121894        linuxnative_fin_input,                          /* p_fin */
    1913         linuxnative_pconfig_input,
    1914         linux_pregister_thread,
    1915         NULL
     1895        linuxnative_pconfig_input
     1896       
    19161897};
    19171898#else
  • lib/format_pcap.c

    ra6c77b0 rb13b939  
    578578static libtrace_direction_t pcap_set_direction(libtrace_packet_t *packet,
    579579                libtrace_direction_t dir) {
    580 
    581         /* We only support tagging with IN or OUT return error for any others */
    582         if(!(dir == TRACE_DIR_OUTGOING || dir == TRACE_DIR_INCOMING))
    583                 return -1;
    584 
     580       
    585581        /* PCAP doesn't have a direction field in the header, so we need to
    586582         * promote to Linux SLL to tag it properly */
  • lib/libtrace.h.in

    r50ce607 r9594cf9  
    194194#  define PRINTF(formatpos, argpos)
    195195#endif
    196 
    197 // Used to fight against false sharing
    198 #define CACHE_LINE_SIZE 64
    199 #define ALIGN_STRUCT(x) __attribute__((aligned(x)))
    200196
    201197#ifdef _MSC_VER
     
    883879        uint8_t ospf_v;         /**< OSPF Version, should be 2 */
    884880        uint8_t type;           /**< OSPF Packet Type */
    885         uint16_t ospf_len;      /**< Packet length, including OSPF header */
     881        uint16_t len;           /**< Packet length, including OSPF header */
    886882        struct in_addr router;  /**< Router ID of the packet source */
    887883        struct in_addr area;    /**< Area the packet belongs to */
     
    12551251        TRACE_OPTION_COMPRESSTYPE_BZ2  = 2, /**< BZip2 Compression */
    12561252        TRACE_OPTION_COMPRESSTYPE_LZO  = 3,  /**< LZO Compression */
    1257         TRACE_OPTION_COMPRESSTYPE_LZMA  = 4,  /**< LZO Compression */
    12581253        TRACE_OPTION_COMPRESSTYPE_LAST
    12591254} trace_option_compresstype_t;
     
    17961791DLLEXPORT uint16_t *trace_checksum_transport(libtrace_packet_t *packet,
    17971792                uint16_t *csum);
    1798 
    1799 /** Calculates the fragment offset in bytes for an IP packet
    1800  * @param packet        The libtrace packet to calculate the offset for
    1801  * @param[out] more     A boolean flag to indicate whether there are more
    1802  *                      fragments after the current packet.
    1803  * @return The fragment offset for the packet in bytes. If the packet is not
    1804  * an IP packet or the fragment offset is not present in packet, the return
    1805  * value will be 0.
    1806  *
    1807  * @note The value returned is in bytes, not 8-octet units as it is stored
    1808  * in the fragment offset field in the headers. In other words, libtrace
    1809  * automatically does the multiplication for you.
    1810  *
    1811  * The value passed in for 'more' does not matter; it will be overwritten
    1812  * with the value of the More Fragments flag from the IP header.
    1813  *
    1814  * New in libtrace 3.0.20
    1815  */
    1816 DLLEXPORT uint16_t trace_get_fragment_offset(const libtrace_packet_t *packet,
    1817                 uint8_t *more);
    18181793
    18191794/** Gets a pointer to the transport layer header (if any)
     
    31883163
    31893164DLLEXPORT int trace_pstart(libtrace_t *libtrace, void* global_blob, fn_per_pkt per_pkt, fn_reducer reducer);
    3190 DLLEXPORT int trace_pread_packet(libtrace_t *libtrace, libtrace_thread_t *t, libtrace_packet_t **packet);
     3165DLLEXPORT int trace_pread_packet(libtrace_t *libtrace, libtrace_packet_t **packet);
    31913166DLLEXPORT int trace_ppause(libtrace_t *libtrace);
    31923167DLLEXPORT int trace_pstop(libtrace_t *libtrace);
  • lib/libtrace_int.h

    r50ce607 r3296252  
    208208        enum thread_states state;
    209209        void* user_data; // TLS for the user to use
    210         void* format_data; // TLS for the format to use
    211210        pthread_t tid;
    212211        int perpkt_num; // A number from 0-X that represents this perpkt threads number
     
    913912         * @return same as read_packet, with the addition of return -2 to represent
    914913         * interrupted due to message waiting. */
    915         int (*pread_packet)(libtrace_t *trace, libtrace_thread_t *t, libtrace_packet_t *packet);
     914        int (*pread_packet)(libtrace_t *trace, libtrace_packet_t *packet);
    916915       
    917916        /** Pause a parallel trace
     
    937936         */
    938937        int (*pconfig_input)(libtrace_t *libtrace,trace_parallel_option_t option,void *value);
    939 
    940         /**
    941          * Register a thread for use with the format or using the packets produced
    942          * by it. This is NOT only used for threads reading packets infact all
    943          * threads use this.
    944          *
    945          * Some use cases include setting up any thread local storage required for
    946          * to read packets and free packets. For DPDK we require any thread that
    947          * may release or read a packet to have have an internal number associated
    948          * with it.
    949          *
    950          * The thread type can be used to see if this thread is going to be used
    951          * to read packets or otherwise.
    952          *
    953          * @return 0 if successful, -1 if the option is unsupported or an error
    954          * occurs (such as a maximum of threads being reached)
    955          */
    956         int (*pregister_thread)(libtrace_t *libtrace, libtrace_thread_t *t, bool reader);
    957 
    958         /**
    959          * If needed any memory allocated with pregister_thread can be released
    960          * in this function. The thread will be destroyed directly after this
    961          * function is called.
    962          */
    963         void (*punregister_thread)(libtrace_t *libtrace, libtrace_thread_t *t);
     938               
    964939};
    965940
     
    971946NULL,                   /* ppause_input */ \
    972947NULL,                   /* pfin_input */ \
    973 NULL,                   /* pconfig_input */ \
    974 NULL,                   /* pregister_thread */ \
    975 NULL                    /* punregister_thread */
     948NULL,                   /* pconfig_input */
    976949
    977950/** The list of registered capture formats */
  • lib/protocols_l3.c

    r7baa948 r9ca1fce  
    724724}
    725725
    726 DLLEXPORT 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_transport.c

    re0bea4e5 r10f924c  
    382382        uint32_t remaining;
    383383        uint8_t proto;
    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,
     384        const struct ports_t *port =
     385                (const struct ports_t*)trace_get_transport((libtrace_packet_t*)packet,
    399386                        &proto, &remaining);
    400387
     
    404391
    405392        /* ICMP *technically* doesn't have ports */
    406         if (proto == TRACE_IPPROTO_ICMP || proto == TRACE_IPPROTO_ICMPV6)
     393        if (proto == TRACE_IPPROTO_ICMP)
    407394                return 0;
    408395
     
    418405        uint32_t remaining;
    419406        uint8_t proto;
    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,
     407        struct ports_t *port =
     408                (struct ports_t*)trace_get_transport((libtrace_packet_t*)packet,
    435409                        &proto, &remaining);
    436410        /* Snapped too early */
     
    439413       
    440414        /* ICMP *technically* doesn't have ports */
    441         if (proto == TRACE_IPPROTO_ICMP || proto == TRACE_IPPROTO_ICMPV6)
     415        if (proto == TRACE_IPPROTO_ICMP)
    442416                return 0;
    443417
  • lib/trace_parallel.c

    r049a700 r3296252  
    317317        assert(t);
    318318        //printf("Yay Started perpkt thread #%d\n", (int) get_thread_table_num(trace));
    319         if (trace->format->pregister_thread) {
    320                 trace->format->pregister_thread(trace, t, !trace_has_dedicated_hasher(trace));
    321         }
    322319        assert(pthread_mutex_unlock(&trace->libtrace_lock) == 0);
    323320
     
    346343                                                // The hasher has stopped by this point, so the queue shouldn't be filling
    347344                                                while(!libtrace_ringbuffer_is_empty(&t->rbuffer)) {
    348                                                         psize = trace_pread_packet(trace, t, &packet);
     345                                                        psize = trace_pread_packet(trace, &packet);
    349346                                                        if (psize > 0) {
    350347                                                                packet = (*trace->per_pkt)(trace, packet, NULL, t);
     
    378375                        }
    379376                } else {
    380                         psize = trace_pread_packet(trace, t, &packet);
     377                        psize = trace_pread_packet(trace, &packet);
    381378                }
    382379
     
    416413        trace_send_message_to_reducer(trace, &message);
    417414
    418         assert(pthread_mutex_lock(&trace->libtrace_lock) == 0);
    419         if (trace->format->punregister_thread) {
    420                 trace->format->punregister_thread(trace, t);
    421         }
    422         assert(pthread_mutex_unlock(&trace->libtrace_lock) == 0);
    423 
    424415        pthread_exit(NULL);
    425416};
     
    443434        assert(t->type == THREAD_HASHER && pthread_equal(pthread_self(), t->tid));
    444435        printf("Hasher Thread started\n");
    445         if (trace->format->pregister_thread) {
    446                 trace->format->pregister_thread(trace, t, true);
    447         }
    448436        assert(pthread_mutex_unlock(&trace->libtrace_lock) == 0);
    449437        int pkt_skipped = 0;
     
    526514        message.additional.uint64 = 0;
    527515        trace_send_message_to_reducer(trace, &message);
    528         assert(pthread_mutex_lock(&trace->libtrace_lock) == 0);
    529         if (trace->format->punregister_thread) {
    530                 trace->format->punregister_thread(trace, t);
    531         }
    532         assert(pthread_mutex_unlock(&trace->libtrace_lock) == 0);
    533516
    534517        // TODO remove from TTABLE t sometime
     
    556539 * lock to read a packet from the underlying trace.
    557540 */
    558 inline static int trace_pread_packet_first_in_first_served(libtrace_t *libtrace, libtrace_thread_t *t, libtrace_packet_t **packet)
     541inline static int trace_pread_packet_first_in_first_served(libtrace_t *libtrace, libtrace_packet_t **packet)
    559542{
    560543        // We need this to fill the 'first' packet table
     544        libtrace_thread_t *t = get_thread_table(libtrace);
    561545        if (!*packet) {
    562546                if (!libtrace_ringbuffer_try_sread_bl(&libtrace->packet_freelist, (void **) packet))
     
    581565 * 2. Move that into the packet provided (packet)
    582566 */
    583 inline static int trace_pread_packet_hasher_thread(libtrace_t *libtrace, libtrace_thread_t *t, libtrace_packet_t **packet)
    584 {
     567inline static int trace_pread_packet_hasher_thread(libtrace_t *libtrace, libtrace_packet_t **packet)
     568{
     569        int this_thread = get_thread_table_num(libtrace); // Could be worth caching ... ?
     570        libtrace_thread_t* t = &libtrace->perpkt_threads[this_thread];
     571
    585572        if (*packet) // Recycle the old get the new
    586573                if (!libtrace_ringbuffer_try_swrite_bl(&libtrace->packet_freelist, (void *) *packet))
     
    688675 * 2. Move that into the packet provided (packet)
    689676 */
    690 inline static int trace_pread_packet_hash_locked(libtrace_t *libtrace, libtrace_thread_t *t, libtrace_packet_t **packet)
    691 {
     677inline static int trace_pread_packet_hash_locked(libtrace_t *libtrace, libtrace_packet_t **packet)
     678{
     679        int this_thread = get_thread_table_num(libtrace); // Could be worth caching ... ?
     680        libtrace_thread_t * t = &libtrace->perpkt_threads[this_thread];
    692681        int thread, ret/*, psize*/;
    693682
     
    707696                // Another thread cannot write a packet because a queue has filled up. Is it ours?
    708697                if (libtrace->perpkt_queue_full) {
    709                         contention_stats[t->perpkt_num].wait_for_fill_complete_hits++;
     698                        contention_stats[this_thread].wait_for_fill_complete_hits++;
    710699                        assert(pthread_mutex_unlock(&libtrace->libtrace_lock) == 0);
    711700                        continue;
     
    729718                trace_packet_set_hash(*packet, (*libtrace->hasher)(*packet, libtrace->hasher_data));
    730719                thread = trace_packet_get_hash(*packet) % libtrace->perpkt_thread_count;
    731                 if (thread == t->perpkt_num) {
     720                if (thread == this_thread) {
    732721                        // If it's this thread we must be in order because we checked the buffer once we got the lock
    733722                        assert(pthread_mutex_unlock(&libtrace->libtrace_lock) == 0);
     
    739728                                libtrace->perpkt_queue_full = true;
    740729                                assert(pthread_mutex_unlock(&libtrace->libtrace_lock) == 0);
    741                                 contention_stats[t->perpkt_num].full_queue_hits++;
     730                                contention_stats[this_thread].full_queue_hits++;
    742731                                assert(pthread_mutex_lock(&libtrace->libtrace_lock) == 0);
    743732                        }
     
    765754 * 2. Move that into the packet provided (packet)
    766755 */
    767 inline static int trace_pread_packet_sliding_window(libtrace_t *libtrace, libtrace_thread_t *t, libtrace_packet_t **packet)
    768 {
     756inline static int trace_pread_packet_sliding_window(libtrace_t *libtrace, libtrace_packet_t **packet)
     757{
     758        int this_thread = get_thread_table_num(libtrace); // Could be worth caching ... ?
     759        libtrace_thread_t * t = &libtrace->perpkt_threads[this_thread];
    769760        int ret, i, thread/*, psize*/;
    770761
     
    794785                        assert(pthread_mutex_unlock(&libtrace->libtrace_lock) == 0);
    795786                        assert(sem_post(&libtrace->sem) == 0);
    796                         contention_stats[t->perpkt_num].wait_for_fill_complete_hits++;
     787                        contention_stats[this_thread].wait_for_fill_complete_hits++;
    797788                        continue;
    798789                }
     
    842833                                if (libtrace->perpkt_threads[thread].state != THREAD_FINISHED) {
    843834                                        while (!libtrace_ringbuffer_try_swrite_bl(&libtrace->perpkt_threads[thread].rbuffer, *packet)) {
    844                                                 if (t->perpkt_num == thread)
     835                                                if (this_thread == thread)
    845836                                                {
    846837                                                        // TODO think about this case more because we have to stop early if this were to happen on the last read
     
    864855                                                        assert(sem_post(&libtrace->sem) == 0);
    865856
    866                                                 contention_stats[t->perpkt_num].full_queue_hits++;
     857                                                contention_stats[this_thread].full_queue_hits++;
    867858                                                assert(pthread_rwlock_wrlock(&libtrace->window_lock) == 0);
    868859                                                // Grab these back
     
    10571048 *
    10581049 */
    1059 static inline int trace_pread_packet_wrapper(libtrace_t *libtrace, libtrace_thread_t *t, libtrace_packet_t *packet) {
     1050static inline int trace_pread_packet_wrapper(libtrace_t *libtrace, libtrace_packet_t *packet) {
    10601051
    10611052        assert(libtrace && "You called trace_read_packet() with a NULL libtrace parameter!\n");
     
    10821073                         * structure */
    10831074                        packet->trace = libtrace;
    1084                         ret=libtrace->format->pread_packet(libtrace, t, packet);
     1075                        ret=libtrace->format->pread_packet(libtrace,packet);
    10851076                        if (ret==(size_t)-1 || ret==(size_t)-2 || ret==0) {
    10861077                                return ret;
     
    11121103 * Read a packet from the parallel trace
    11131104 */
    1114 DLLEXPORT int trace_pread_packet(libtrace_t *libtrace, libtrace_thread_t *t, libtrace_packet_t **packet)
     1105DLLEXPORT int trace_pread_packet(libtrace_t *libtrace, libtrace_packet_t **packet)
    11151106{
    11161107        int ret;
     1108        libtrace_thread_t *t = get_thread_table(libtrace);
    11171109
    11181110        // Cleanup the packet passed back
     
    11231115                if (!*packet)
    11241116                        *packet = trace_create_packet();
    1125                 ret = trace_pread_packet_wrapper(libtrace, t, *packet);
     1117                ret = trace_pread_packet_wrapper(libtrace, *packet);
    11261118        } else if (trace_has_dedicated_hasher(libtrace)) {
    1127                 ret = trace_pread_packet_hasher_thread(libtrace, t, packet);
     1119                ret = trace_pread_packet_hasher_thread(libtrace, packet);
    11281120        } else if (!trace_has_dedicated_hasher(libtrace)) {
    11291121                /* We don't care about which core a packet goes to */
    1130                 ret = trace_pread_packet_first_in_first_served(libtrace, t, packet);
     1122                ret = trace_pread_packet_first_in_first_served(libtrace, packet);
    11311123        } /* else {
    11321124                ret = trace_pread_packet_hash_locked(libtrace, packet);
     
    11731165                return -1;
    11741166        }
    1175        
    11761167        // NOTE: Until the trace is started we wont have a libtrace_lock initialised
    11771168        if (libtrace->state != STATE_NEW) {
  • libpacketdump/eth_2048.c

    r387d299 r66ad025  
    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
    1223DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
    1324{
     
    1829        }
    1930        //DISPLAY(ip_tos," TOS %02x")
    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");
     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")
    2334        printf("\n IP:");
    24         DISPLAYS(ip, ip_id," Id %u");
     35        DISPLAYS(ip_id," Id %u");
    2536       
    2637        if ((unsigned int)len >= ((char *)&ip->ip_ttl - (char *)ip - 2)) {
     
    3142        }
    3243        //printf("\n IP:");
    33         DISPLAY(ip, ip_ttl,"\n IP: TTL %i");
     44        DISPLAY(ip_ttl,"\n IP: TTL %i");
    3445        if ((unsigned int)len>=((char*)&ip->ip_p-(char*)ip+sizeof(ip->ip_p))) {
    3546                struct protoent *ent=getprotobynumber(ip->ip_p);
     
    4455                return;
    4556        }
    46         DISPLAYS(ip, ip_sum," Checksum %i\n");
    47         DISPLAYIP(ip, ip_src," IP: Source %s ");
    48         DISPLAYIP(ip, ip_dst,"Destination %s\n");
     57        DISPLAYS(ip_sum," Checksum %i\n");
     58        DISPLAYIP(ip_src," IP: Source %s ");
     59        DISPLAYIP(ip_dst,"Destination %s\n");
    4960        decode_next(packet+ip->ip_hl*4,len-ip->ip_hl*4,"ip",ip->ip_p);
    5061        return;
  • libpacketdump/ip_1.c

    r387d299 rec0b927  
    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))
    521
    622static char *unreach_types[]={
  • libpacketdump/ip_17.c

    r387d299 rc7062df  
    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
    1026
    1127DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
     
    1329        struct libtrace_udp *udp = (struct libtrace_udp*)packet;
    1430        printf(" UDP:");
    15         if (SAFE(udp, source)) {
     31        if (SAFE(source)) {
    1632                struct servent *ent=getservbyport(udp->source,"udp");
    1733                if(ent) {
     
    2541                return;
    2642        }
    27         if (SAFE(udp, dest)) {
     43        if (SAFE(dest)) {
    2844                struct servent *ent=getservbyport(udp->dest,"udp");
    2945                if(ent) {
     
    3854        }
    3955        printf("\n UDP:");
    40         DISPLAYS(udp, len," Len %u");
    41         DISPLAYS(udp, check," Checksum %u");
     56        DISPLAYS(len," Len %u");
     57        DISPLAYS(check," Checksum %u");
    4258        printf("\n");
    4359        if (htons(udp->source) < htons(udp->dest))
  • libpacketdump/ip_33.c

    r387d299 rc7062df  
    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))
    824
    925struct dccphdr {
     
    3450{
    3551        struct dccphdr *dccp = (struct dccphdr*)packet;
    36         DISPLAYS(dccp, source," DCCP: Source %i");
    37         DISPLAYS(dccp, dest," Dest %i");
     52        DISPLAYS(source," DCCP: Source %i");
     53        DISPLAYS(dest," Dest %i");
    3854        if (len>4) {
    3955                printf("\n DCCP: Type %i",dccp->type);
     
    5369        else
    5470                return;
    55         DISPLAY(dccp, doff," DCCP: Dataoff: %i\n");
     71        DISPLAY(doff," DCCP: Dataoff: %i\n");
    5672        if (len>9)
    5773                printf(" DCCP: NDP %i CsLen: %i\n",dccp->ndp,dccp->cslen);
     
    5975                return;
    6076        }
    61         /* Should this be byteswapped??? */
    62         DISPLAY(dccp, check," DCCP: Checksum: %i\n");
     77        DISPLAY(check," DCCP: Checksum: %i\n");
    6378        if (htons(dccp->source) < htons(dccp->dest))
    6479                decode_next(packet+dccp->doff*4,len-dccp->doff*4,"dccp",htons(dccp->source));
  • libpacketdump/ip_6.c

    r387d299 r9ca0b29  
    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))
    721
    822DLLEXPORT void decode(int link_type UNUSED,const char *packet,unsigned len)
     
    1327        libtrace_tcp_t *tcp = (libtrace_tcp_t *)packet;
    1428        printf(" TCP:");
    15         if (SAFE(tcp, source)) {
     29        if (SAFE(source)) {
    1630                struct servent *ent=getservbyport(tcp->source,"tcp");
    1731                if(ent) {
     
    2539                return;
    2640        }
    27         if (SAFE(tcp, dest)) {
     41        if (SAFE(dest)) {
    2842                struct servent *ent=getservbyport(tcp->dest,"tcp");
    2943                if(ent) {
     
    3852        }
    3953        printf("\n TCP:");
    40         DISPLAYL(tcp, seq," Seq %u");
     54        DISPLAYL(seq," Seq %u");
    4155        printf("\n TCP:");
    42         DISPLAYL(tcp, ack_seq," Ack %u");
     56        DISPLAYL(ack_seq," Ack %u");
    4357        if ((char*)&tcp->window-(char *)tcp>len) {
    4458                printf("\n");
     
    5771        if (tcp->ack) printf(" ACK");
    5872        if (tcp->urg) printf(" URG");
    59         DISPLAYS(tcp, window," Window %i");
     73        DISPLAYS(window," Window %i");
    6074        printf("\n TCP:");
    61         DISPLAYS(tcp, check," Checksum %i");
    62         DISPLAYS(tcp, urg_ptr," Urgent %i");
     75        DISPLAYS(check," Checksum %i");
     76        DISPLAYS(urg_ptr," Urgent %i");
    6377        pkt = (unsigned char*)packet+sizeof(*tcp);
    6478        plen = (len-sizeof *tcp) < (tcp->doff*4-sizeof(*tcp))?(len-sizeof(*tcp)):(tcp->doff*4-sizeof *tcp);
  • libpacketdump/ip_89.c

    r387d299 re224862  
    1010static void dump_ospf_v2_header(libtrace_ospf_v2_t *hdr, unsigned len) {
    1111
    12         DISPLAY(hdr, ospf_v, " OSPF Header: Version %u");
    13         DISPLAY(hdr, type, " Type %u ");
     12        printf(" OSPF Header: Version %u Type %u ",
     13                        hdr->ospf_v, hdr->type);
    1414        switch(hdr->type) {
    1515                case TRACE_OSPF_HELLO:
     
    2929                        break;
    3030        }
    31         printf("\n");
    3231
    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");
     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
    4142
    4243}
  • libpacketdump/libpacketdump.h

    r387d299 r66ad025  
    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 
    268
    279void trace_hexdump_packet(libtrace_packet_t *packet);
  • libwandio/Makefile.am

    r3b6e0cf rbd119b3  
    2424endif
    2525
    26 if HAVE_LZMA
    27 LIBTRACEIO_LZMA=ior-lzma.c iow-lzma.c
    28 else
    29 LIBTRACEIO_LZMA=
    30 endif
    31 
    3226libwandio_la_SOURCES=wandio.c ior-peek.c ior-stdio.c ior-thread.c \
    3327                iow-stdio.c iow-thread.c wandio.h wandio_internal.h \
    34                 $(LIBTRACEIO_ZLIB) $(LIBTRACEIO_BZLIB) $(LIBTRACEIO_LZO) \
    35                 $(LIBTRACEIO_LZMA)
     28                $(LIBTRACEIO_ZLIB) $(LIBTRACEIO_BZLIB) $(LIBTRACEIO_LZO)
    3629
    3730AM_CPPFLAGS = @ADD_INCLS@
    3831libwandio_la_LIBADD = @LIBWANDIO_LIBS@
    39 libwandio_la_LDFLAGS=-version-info 1:1:0 @ADD_LDFLAGS@
     32libwandio_la_LDFLAGS=-version-info 1:0:0 @ADD_LDFLAGS@
    4033
    41 bin_PROGRAMS = wandiocat
    42 wandiocat_SOURCES = wcat.c
    43 wandiocat_CFLAGS = -I"$(top_srcdir)/libwandio"
    44 wandiocat_CXXFLAGS = -I"$(top_srcdir)/libwandio"
    45 wandiocat_LDFLAGS = -L"$(top_srcdir)/libwandio" -lwandio
  • libwandio/iow-lzo.c

    rfa7faf3 r2a7047c  
    274274}
    275275
    276 iow_t *lzo_wopen(iow_t *child, int compress_level)
     276iow_t *lzo_wopen(iow_t *child, int compress_level UNUSED)
    277277{
    278278        const int opt_filter = 0;
     
    290290                return NULL;
    291291        }
    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;
    299292
    300293        iow = malloc(sizeof(iow_t));
  • libwandio/wandio.c

    r4b0cd2f r10f924c  
    4646 */
    4747
    48 struct 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     },
     48struct compression_type compression_type[]  = {
     49        { "GZ",         "gz",   WANDIO_COMPRESS_ZLIB    },
     50        { "BZ2",        "bz2",  WANDIO_COMPRESS_BZ2     },
     51        { "LZO",        "lzo",  WANDIO_COMPRESS_LZO     },
    5352        { "NONE",       "",     WANDIO_COMPRESS_NONE    }
    5453};
     
    142141        DEBUG_PIPELINE("peek");
    143142        io_t *io = peek_open(stdio_open(filename));
    144         unsigned char buffer[1024];
     143        char buffer[1024];
    145144        int len;
    146145        if (!io)
     
    152151
    153152        if (autodetect) {
    154                 if (len>=3 && buffer[0] == 0x1f && buffer[1] == 0x8b &&
     153                if (len>=3 && buffer[0] == '\037' && buffer[1] == '\213' &&
    155154                                buffer[2] == 0x08) {
    156155#if HAVE_LIBZ
     
    163162                }
    164163                /* Auto detect compress(1) compressed data (gzip can read this) */
    165                 if (len>=2 && buffer[0] == 0x1f && buffer[1] == 0x9d) {
     164                if (len>=2 && buffer[0] == '\037' && buffer[1] == '\235') {
    166165#if HAVE_LIBZ
    167166                        DEBUG_PIPELINE("zlib");
     
    183182#endif
    184183                }
    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                 }
    197184        }       
    198185        /* Now open a threaded, peekable reader using the appropriate module
     
    206193        DEBUG_PIPELINE("peek");
    207194        return peek_open(io);
    208 }
    209 
    210 DLLEXPORT 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;
    222195}
    223196
     
    318291        }
    319292#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
    326293        /* Open a threaded writer */
    327294        if (use_threads)
  • libwandio/wandio.h

    r4b0cd2f rc7021d9  
    6666
    6767/** Structure defining a supported compression method */
    68 struct wandio_compression_type {
     68struct compression_type {
    6969        /** Name of the compression method */
    7070        const char *name;
     
    7777
    7878/** The list of supported compression methods */
    79 extern struct wandio_compression_type compression_type[];
     79extern struct compression_type compression_type[];
    8080
    8181/** Structure defining a libtrace IO reader module */
     
    178178        /** LZO compression */
    179179        WANDIO_COMPRESS_LZO     = 3,
    180         /** LZMA compression */
    181         WANDIO_COMPRESS_LZMA    = 4,
    182180        /** All supported methods - used as a bitmask */
    183181        WANDIO_COMPRESS_MASK    = 7
     
    195193io_t *zlib_open(io_t *parent);
    196194io_t *thread_open(io_t *parent);
    197 io_t *lzma_open(io_t *parent);
    198195io_t *peek_open(io_t *parent);
    199196io_t *stdio_open(const char *filename);
     
    202199iow_t *bz_wopen(iow_t *child, int compress_level);
    203200iow_t *lzo_wopen(iow_t *child, int compress_level);
    204 iow_t *lzma_wopen(iow_t *child, int compress_level);
    205201iow_t *thread_wopen(iow_t *child);
    206202iow_t *stdio_wopen(const char *filename, int fileflags);
     
    215211 *
    216212 * @{ */
    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   */
    229 struct wandio_compression_type *wandio_lookup_compression_type(const char *name);
    230213
    231214/** Creates a new libtrace IO reader and opens the provided file for reading.
  • test/Makefile

    r262a093 r59ef093  
    1818
    1919BINS = test-pcap-bpf test-event test-time test-dir test-wireless test-errors \
    20         test-plen test-autodetect test-ports test-fragment test-live test-live-snaplen \
    21         $(BINS_DATASTRUCT) $(BINS_PARALLEL)
     20        test-plen test-autodetect $(BINS_DATASTRUCT) $(BINS_PARALLEL)
    2221
    2322.PHONY: all clean distclean install depend test
  • test/do-tests-datastruct.sh

    • Property mode changed from 100755 to 100644
  • test/do-tests-parallel.sh

    • Property mode changed from 100755 to 100644
  • test/do-tests.sh

    r95b6218 r5692bc4  
    7272echo \* Testing payload length
    7373do_test ./test-plen
    74 
    75 echo \* Testing port numbers
    76 do_test ./test-ports
    77 
    78 echo \* Testing fragment parsing
    79 do_test ./test-fragment
    8074
    8175echo \* Testing event framework
     
    227221echo " * format autodetection - bzip2"
    228222do_test ./test-autodetect traces/5_packets.erf.bz2
    229 echo " * format autodetection - lzma"
    230 do_test ./test-autodetect traces/5_packets.erf.xz
    231223
    232224echo
  • tools/traceanon/traceanon.1

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

    r17f954f rf5b5cca  
    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;
    223221        } else if (strncmp(compress_type_str, "no", 2) == 0) {
    224222                compress_type = TRACE_OPTION_COMPRESSTYPE_NONE;
  • tools/tracemerge/tracemerge.1

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

    r17f954f rc0ccccd  
    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;
    124122        } else if (strncmp(compress_type_str, "no", 2) == 0) {
    125123                compress_type = TRACE_OPTION_COMPRESSTYPE_NONE;
  • tools/tracesplit/tracesplit.1

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

    r17f954f r755855a  
    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;
    320318        } else if (strncmp(compress_type_str, "no", 2) == 0) {
    321319                compress_type = TRACE_OPTION_COMPRESSTYPE_NONE;
Note: See TracChangeset for help on using the changeset viewer.