Ignore:
Timestamp:
11/29/18 10:12:59 (2 years ago)
Author:
Jacob Van Walraven <jcv9@…>
Branches:
develop
Children:
fdf23b8
Parents:
d74ca03
Message:

Apply changes required for pull request #81

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcapfile.c

    rf6f3ae5 r2193905  
    3131
    3232#include <sys/stat.h>
    33 #include <assert.h>
    3433#include <stdio.h>
    3534#include <stdlib.h>
     
    126125        libtrace->format_data = malloc(sizeof(struct pcapfile_format_data_t));
    127126        if (!libtrace->format_data) {
    128                 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcapfile_init_input()");
     127                trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for "
     128                        "format data inside pcapfile_init_input()");
    129129                return -1;
    130130        }
     
    139139                malloc(sizeof(struct pcapfile_format_data_out_t));
    140140        if (!libtrace->format_data) {
    141                 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcapfile_init_output()");
     141                trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for "
     142                        "format data inside pcapfile_init_output()");
    142143                return -1;
    143144        }
     
    204205
    205206                DATA(libtrace)->started = true;
    206                 /*assert(sizeof(DATA(libtrace)->header) > 0);*/
    207207                if (!(sizeof(DATA(libtrace)->header) > 0)) {
    208208                        trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Trace is missing header in pcapfile_start_input()");
     
    352352        size_t bytes_to_read = 0;
    353353
    354         /*assert(libtrace->format_data);*/
    355354        if (!libtrace->format_data) {
    356                 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT,
    357                         "Trace format data missing, call init_input() before calling pcapfile_read_packet()");
     355                trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Trace format data missing, "
     356                        "call trace_create() before calling trace_read_packet()");
    358357                return -1;
    359358        }
     
    456455                                TRACE_ERR_NO_CONVERSION,
    457456                                "pcap does not support this format");
    458                         /*assert(0);*/
    459457                        return -1;
    460458                }
     
    497495        hdr.ts_usec = (uint32_t)tv.tv_usec;
    498496        hdr.caplen = trace_get_capture_length(packet);
    499         /*assert(hdr.caplen < LIBTRACE_PACKET_BUFSIZE);*/
    500497        if (hdr.caplen >= LIBTRACE_PACKET_BUFSIZE) {
    501498                trace_set_err_out(out, TRACE_ERR_BAD_PACKET, "Capture length is greater than buffer size in pcap_write_packet()");
     
    579576                return ts;
    580577        }
    581         /*assert(packet->header);*/
     578
    582579        if (!packet->header) {
    583                 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "Trace with NULL header passed to pcapfile_get_timeval()");
     580                trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "pcap packet with NULL header passed to "
     581                        "pcapfile_get_timeval()");
    584582                /* Return default timeval on error? */
    585583                return ts;
     
    607605                return ts;
    608606        }
    609         /*assert(packet->header);*/
     607
    610608        if (!packet->header) {
    611                 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "Trace with NULL header passed to pcapfile_get_timespec()");
     609                trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "pcap packet with NULL header passed to "
     610                        "pcapfile_get_timespec()");
    612611                /* Return fefault timespec on error? */
    613612                return ts;
     
    632631                return TRACE_ERR_NULL_PACKET;
    633632        }
    634         /*assert(packet->header);*/
     633
    635634        if (!packet->header) {
    636                 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "Trace with NULL header passed to pcapfile_get_capture_length()");
     635                trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "pcap packet with NULL header passed to "
     636                        "pcapfile_get_capture_length()");
    637637                return -1;
    638638        }
     
    649649                return TRACE_ERR_NULL_PACKET;
    650650        }
    651         /*assert(packet->header); */
     651
    652652        if (!packet->header) {
    653                 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "Trace with NULL header passed to pcapfile_get_wire_length()");
     653                trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "pcap packet with NULL header passed to "
     654                        "pcapfile_get_wire_length()");
    654655                return -1;
    655656        }
     
    692693static size_t pcapfile_set_capture_length(libtrace_packet_t *packet,size_t size) {
    693694        libtrace_pcapfile_pkt_hdr_t *pcapptr = 0;
    694         /*assert(packet);*/
     695
    695696        if (!packet) {
    696697                fprintf(stderr, "NULL packet passed into pcapfile_set_capture_length\n");
     
    698699                return ~0U;
    699700        }
    700         /*assert(packet->header);*/
     701
    701702        if (!packet->header) {
    702                 trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "Trace with NULL header passed to pcapfile_set_capture_length()");
     703                trace_set_err(packet->trace, TRACE_ERR_BAD_HEADER, "pcap packet with NULL header passed to "
     704                        "pcapfile_set_capture_length()");
    703705                /* Return -1 on error? */
    704706                return ~0U;
Note: See TracChangeset for help on using the changeset viewer.