Changeset 5478d3d


Ignore:
Timestamp:
09/15/15 17:16:51 (5 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
8decff7
Parents:
624c2da
Message:

Fix all outstanding warnings

Implemented trace_get_statistics for formats that were missing it, so
we no longer need to use the deprecated trace_get_dropped_packets anywhere
within libtrace.

Files:
14 edited

Legend:

Unmodified
Added
Removed
  • examples/parallel/trivial_skeleton.c

    rccb89e4 r5478d3d  
    2222 *   packet -- the packet itself
    2323 */
    24 static libtrace_packet_t *process_packet(libtrace_t *trace,
    25                 libtrace_thread_t *t,
    26                 void *global, void *tls, libtrace_packet_t *packet) {
     24static libtrace_packet_t *process_packet(libtrace_t *trace UNUSED,
     25                libtrace_thread_t *t UNUSED,
     26                void *global UNUSED, void *tls UNUSED,
     27                libtrace_packet_t *packet) {
    2728
    2829        /* Note that in this example, global and tls will both be NULL.
  • lib/format_bpf.c

    r5ab626a r5478d3d  
    314314
    315315        return FORMATIN(trace)->stats.bs_drop;
     316}
     317
     318static void bpf_get_statistics(libtrace_t *trace, libtrace_stat_t *stat) {
     319        uint64_t dropped = bpf_get_dropped_packets(trace);
     320        uint64_t received = bpf_get_received_packets(trace);
     321
     322        if (dropped != (uint64_t)-1) {
     323                stat->dropped_valid = 1;
     324                stat->dropped = dropped;
     325        }
     326
     327        if (received != (uint64_t) -1) {
     328                stat->received_valid = 1;
     329                stat->received = received;
     330        }
     331
    316332}
    317333
     
    607623        bpf_get_framing_length, /* get_framing_length */
    608624        NULL,                   /* set_capture_length */
    609         bpf_get_received_packets,/* get_received_packets */
     625        NULL,                   /* get_received_packets */
    610626        NULL,                   /* get_filtered_packets */
    611         bpf_get_dropped_packets,/* get_dropped_packets */
    612         NULL,                   /* get_statistics */
     627        NULL,                   /* get_dropped_packets */
     628        bpf_get_statistics,     /* get_statistics */
    613629        bpf_get_fd,             /* get_fd */
    614630        trace_event_device,     /* trace_event */
  • lib/format_dag25.c

    ra6b44a7 r5478d3d  
    14601460}
    14611461
    1462 static void dag_get_thread_statisitics(libtrace_t *libtrace, libtrace_thread_t *t,
     1462static void dag_get_thread_statistics(libtrace_t *libtrace, libtrace_thread_t *t,
    14631463                                       libtrace_stat_t *stat) {
    14641464        struct dag_per_stream_t *stream_data = t->format_data;
     
    15661566        dag_pregister_thread,
    15671567        NULL,
    1568         dag_get_thread_statisitics      /* get thread stats */
     1568        dag_get_thread_statistics       /* get thread stats */
    15691569};
    15701570
  • lib/format_erf.c

    r91c2acc r5478d3d  
    802802}
    803803
    804 static uint64_t erf_get_dropped_packets(libtrace_t *trace)
    805 {
    806         if (trace->format_data == NULL)
    807                 return (uint64_t)-1;
    808         return DATA(trace)->drops;
     804static void erf_get_statistics(libtrace_t *trace, libtrace_stat_t *stat) {
     805
     806        if (trace->format_data) {
     807                stat->dropped_valid = 1;
     808                stat->dropped = DATA(trace)->drops;
     809        }
    809810}
    810811
     
    865866        NULL,                           /* get_received_packets */
    866867        NULL,                           /* get_filtered_packets */
    867         erf_get_dropped_packets,        /* get_dropped_packets */
    868         NULL,                           /* get_statistics */
     868        NULL,                           /* get_dropped_packets */
     869        erf_get_statistics,             /* get_statistics */
    869870        NULL,                           /* get_fd */
    870871        erf_event,                      /* trace_event */
     
    909910        NULL,                           /* get_received_packets */
    910911        NULL,                           /* get_filtered_packets */
    911         erf_get_dropped_packets,        /* get_dropped_packets */
    912         NULL,                           /* get_statistics */
     912        NULL,                           /* get_dropped_packets */
     913        erf_get_statistics,             /* get_statistics */
    913914        NULL,                           /* get_fd */
    914915        erf_event,                      /* trace_event */
  • lib/format_linux_int.c

    rbabeb70 r5478d3d  
    191191        if ((int) hdr->wirelen == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
    192192                /* Do message queue check or select */
    193                 int message_fd;
     193                int message_fd = 0;
    194194                int largestfd = stream->fd;
    195195
  • lib/format_pcap.c

    r5ab626a r5478d3d  
    755755}
    756756
    757 static uint64_t pcap_get_dropped_packets(libtrace_t *trace)
    758 {
    759         struct pcap_stat stats;
    760         if (pcap_stats(DATA(trace)->input.pcap,&stats)==-1) {
     757static void pcap_get_statistics(libtrace_t *trace, libtrace_stat_t *stat) {
     758
     759        struct pcap_stat pcapstats;
     760        if (pcap_stats(DATA(trace)->input.pcap,&pcapstats)==-1) {
    761761                char *errmsg = pcap_geterr(DATA(trace)->input.pcap);
    762762                trace_set_err(trace,TRACE_ERR_UNSUPPORTED,
    763                                 "Failed to retreive stats: %s\n",
     763                                "Failed to retrieve stats: %s\n",
    764764                                errmsg ? errmsg : "Unknown pcap error");
    765                 return ~0;
    766         }
    767 
    768         return stats.ps_drop;
     765                return;
     766        }
     767
     768        stat->dropped_valid = 1;
     769        stat->dropped = pcapstats.ps_drop;
    769770}
    770771
     
    873874        NULL,                           /* get_received_packets */
    874875        NULL,                           /* get_filtered_packets */
    875         pcap_get_dropped_packets,       /* get_dropped_packets */
    876         NULL,                           /* get_statistics */
     876        NULL,                           /* get_dropped_packets */
     877        pcap_get_statistics,            /* get_statistics */
    877878        pcap_get_fd,                    /* get_fd */
    878879        trace_event_device,             /* trace_event */
  • lib/format_rt.c

    r6264e8e r5478d3d  
    628628        rt_header_t hdr;
    629629        rt_header_t *pkt_hdr = NULL;
    630         void *void_hdr;
    631630        libtrace_rt_types_t switch_type;
    632631       
  • lib/libtrace.h.in

    rf625817 r5478d3d  
    14831483DLLEXPORT void trace_destroy_output(libtrace_out_t *trace);
    14841484
    1485 /** Create a callback set that can be used to define callbacks for parallel
    1486   * libtrace threads.
    1487   *
    1488   * @return A pointer to a freshly allocated callback set.
    1489   */
    1490 DLLEXPORT libtrace_callback_set_t *trace_create_callback_set();
    1491 
    1492 /** Destroys a callback set, freeing up an resources it was using.
    1493  *
    1494  * @param cbset         The callback set to be destroyed.
    1495  */
    1496 DLLEXPORT void trace_destroy_callback_set(libtrace_callback_set_t *cbset);
    1497 
    1498 
    14991485/** Check (and clear) the current error state of an input trace
    15001486 * @param trace         The input trace to check the error state on
  • lib/libtrace_parallel.h

    ra31e166 r5478d3d  
    608608DLLEXPORT int trace_set_user_message_cb(libtrace_callback_set_t *cbset,
    609609                fn_cb_usermessage handler);
     610
     611/** Create a callback set that can be used to define callbacks for parallel
     612  * libtrace threads.
     613  *
     614  * @return A pointer to a freshly allocated callback set.
     615  */
     616DLLEXPORT libtrace_callback_set_t *trace_create_callback_set(void);
     617
     618/** Destroys a callback set, freeing up an resources it was using.
     619 *
     620 * @param cbset         The callback set to be destroyed.
     621 */
     622DLLEXPORT void trace_destroy_callback_set(libtrace_callback_set_t *cbset);
     623
    610624
    611625/** Pauses a trace previously started with trace_pstart()
  • lib/trace.c

    rf625817 r5478d3d  
    21022102libtrace_stat_t *trace_get_statistics(libtrace_t *trace, libtrace_stat_t *stat)
    21032103{
    2104         uint64_t ret;
     2104        uint64_t ret = 0;
    21052105        int i;
    21062106        assert(trace);
     
    21292129#undef X
    21302130        /* Both accepted and filtered are stored against in the library */
    2131         ret = trace_get_accepted_packets(trace);
    2132         if (ret != UINT64_MAX) {
    2133                 stat->accepted_valid = 1;
    2134                 stat->accepted = ret;
    2135         }
     2131
     2132        /* We always add to a thread's accepted count before dispatching the
     2133         * packet to the user. However if the underlying trace is single
     2134         * threaded it will also be increasing the global count. So if we
     2135         * find perpkt ignore the global count.
     2136         */
     2137        for (i = 0; i < trace->perpkt_thread_count; i++) {
     2138                ret += trace->perpkt_threads[i].accepted_packets;
     2139        }
     2140
     2141        stat->accepted_valid = 1;
     2142        stat->accepted = ret ? ret : trace->accepted_packets;
    21362143
    21372144        stat->filtered_valid = 1;
     
    21432150        if (trace->format->get_statistics) {
    21442151                trace->format->get_statistics(trace, stat);
    2145         } else {
    2146                 /* Fallback to the old way */
    2147                 ret = trace_get_received_packets(trace);
    2148                 if (ret != UINT64_MAX) {
    2149                         stat->received_valid = 1;
    2150                         stat->received = ret;
    2151                 }
    2152                 ret = trace_get_dropped_packets(trace);
    2153                 if (ret != UINT64_MAX) {
    2154                         stat->dropped_valid = 1;
    2155                         stat->dropped = ret;
    2156                 }
    21572152        }
    21582153        return stat;
  • lib/trace_parallel.c

    ra31e166 r5478d3d  
    252252}
    253253
     254DLLEXPORT void trace_destroy_callback_set(libtrace_callback_set_t *cbset) {
     255        free(cbset);
     256}
     257
    254258DLLEXPORT libtrace_callback_set_t *trace_create_callback_set() {
    255259        libtrace_callback_set_t *cbset;
     
    258262        memset(cbset, 0, sizeof(libtrace_callback_set_t));
    259263        return cbset;
    260 }
    261 
    262 DLLEXPORT void trace_destroy_callback_set(libtrace_callback_set_t *cbset) {
    263         free(cbset);
    264264}
    265265
  • tools/tracereport/dir_report.c

    r39aa3c7 r5478d3d  
    1212void dir_per_packet(struct libtrace_packet_t *packet)
    1313{
    14         if (trace_get_direction(packet)==~0U)
     14        if (trace_get_direction(packet)==-1)
    1515                return;
    1616        dir_bytes[trace_get_direction(packet)]+=trace_get_wire_length(packet);
  • tools/tracereport/drops_report.c

    r4423dc7 r5478d3d  
    44#include <time.h>
    55#include <string.h>
     6#include <stdlib.h>
    67#include "libtrace.h"
    78#include "tracereport.h"
     
    2021void drops_per_trace(libtrace_t *trace)
    2122{
    22         uint64_t packets;
     23        libtrace_stat_t *stat;
    2324
    24         packets = trace_get_received_packets(trace);
    25         if (packets != UINT64_MAX) {
    26                 received_packets+=packets;
     25        stat = trace_create_statistics();
     26
     27        trace_get_statistics(trace, stat);
     28
     29        if (stat->received_valid) {
     30                received_packets+=stat->received;
    2731                has_received=true;
    2832        }
    2933
    30         packets = trace_get_filtered_packets(trace);
    31         if (packets != UINT64_MAX) {
    32                 filtered_packets+=packets;
     34        if (stat->filtered_valid) {
     35                filtered_packets+=stat->filtered;
    3336                has_filtered=true;
    3437        }
    3538
    36         packets = trace_get_dropped_packets(trace);
    37         if (packets != UINT64_MAX) {
    38                 dropped_packets+=packets;
     39        if (stat->dropped_valid) {
     40                dropped_packets+=stat->dropped;
    3941                has_dropped=true;
    4042        }
    4143
    42         packets = trace_get_accepted_packets(trace);
    43         if (packets != UINT64_MAX) {
    44                 accepted_packets+=packets;
     44        if (stat->accepted_valid) {
     45                accepted_packets+=stat->accepted;
    4546                has_accepted=true;
    4647        }
     48        free(stat);
    4749}
    4850
  • tools/tracesplit/tracesplit.c

    r17f954f r5478d3d  
    8282static int per_packet(libtrace_packet_t *packet) {
    8383
    84         if (trace_get_link_type(packet) == ~0U) {
     84        if (trace_get_link_type(packet) == -1) {
    8585                fprintf(stderr, "Halted due to being unable to determine linktype - input trace may be corrupt.\n");
    8686                return -1;
     
    387387
    388388        if (verbose) {
    389                 uint64_t f;
    390                 f=trace_get_received_packets(input);
    391                 if (f!=UINT64_MAX)
    392                         fprintf(stderr,"%" PRIu64 " packets on input\n",f);
    393                 f=trace_get_filtered_packets(input);
    394                 if (f!=UINT64_MAX)
    395                         fprintf(stderr,"%" PRIu64 " packets filtered\n",f);
    396                 f=trace_get_dropped_packets(input);
    397                 if (f!=UINT64_MAX)
    398                         fprintf(stderr,"%" PRIu64 " packets dropped\n",f);
    399                 f=trace_get_accepted_packets(input);
    400                 if (f!=UINT64_MAX)
    401                         fprintf(stderr,"%" PRIu64 " packets accepted\n",f);
    402         }
     389                libtrace_stat_t *stat;
     390               
     391                stat = trace_create_statistics();
     392                trace_get_statistics(input, stat);
     393
     394                if (stat->received_valid)
     395                        fprintf(stderr,"%" PRIu64 " packets on input\n",
     396                                        stat->received);
     397                if (stat->filtered_valid)
     398                        fprintf(stderr,"%" PRIu64 " packets filtered\n",
     399                                        stat->filtered);
     400                if (stat->dropped_valid)
     401                        fprintf(stderr,"%" PRIu64 " packets dropped\n",
     402                                        stat->dropped);
     403                if (stat->accepted_valid)
     404                        fprintf(stderr,"%" PRIu64 " packets accepted\n",
     405                                        stat->accepted);
     406                free(stat);
     407        }
    403408       
    404409        if (output)
Note: See TracChangeset for help on using the changeset viewer.