Changeset 2193905 for lib/format_pcap.c


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_pcap.c

    rf6f3ae5 r2193905  
    3131
    3232#include <sys/stat.h>
    33 #include <assert.h>
    3433#include <stdio.h>
    3534#include <stdlib.h>
     
    103102
    104103        if (!libtrace->format_data) {
    105                 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcap_init_input()");
     104                trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for "
     105                        "format data inside pcap_init_input()");
    106106                return -1;
    107107        }
     
    178178                        return -1;
    179179        }
    180         /*assert(0);*/
    181180        return -1;
    182181}
     
    185184        libtrace->format_data = malloc(sizeof(struct pcap_format_data_out_t));
    186185        if (!libtrace->format_data) {
    187                 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcap_init_output()");
     186                trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for "
     187                        "format data inside pcap_init_output()");
    188188                return -1;
    189189        }
     
    198198        libtrace->format_data = malloc(sizeof(struct pcap_format_data_out_t));
    199199        if (!libtrace->format_data) {
    200                 trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcapint_init_output()");
     200                trace_set_err_out(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for "
     201                        "format data inside pcapint_init_output()");
    201202                return -1;
    202203        }
     
    222223        libtrace->format_data = malloc(sizeof(struct pcap_format_data_t));
    223224        if (!libtrace->format_data) {
    224                 trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory pcapint_init_input()");
     225                trace_set_err(libtrace, TRACE_ERR_INIT_FAILED, "Unable to allocate memory for "
     226                        "format data inside pcapint_init_input()");
    225227                return -1;
    226228        }
     
    261263                        return -1;
    262264        }
    263         /*assert(0);*/
    264265        return -1;
    265266}
     
    446447        uint32_t flags = 0;
    447448
    448         /*assert(libtrace->format_data);*/
    449449        if (!libtrace->format_data) {
    450                 trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Trace format data missing, call init_input() before calling pcap_read_packet()");
     450                trace_set_err(libtrace, TRACE_ERR_BAD_FORMAT, "Trace format data missing, "
     451                        "call trace_create() before calling pcap_read_packet()");
    451452                return -1;
    452453        }
     
    611612                        pcap_pkt_hdr.len = trace_get_wire_length(packet);
    612613
    613                 /*assert(pcap_pkt_hdr.caplen<65536);*/
    614614                if (pcap_pkt_hdr.caplen >= 65536) {
    615615                        trace_set_err_out(libtrace, TRACE_ERR_BAD_HEADER, "Header capture length is larger than it should be in pcap_write_packet()");
    616616                        return -1;
    617617                }
    618                 /*assert(pcap_pkt_hdr.len<65536);*/
    619618                if (pcap_pkt_hdr.len >= 65536) {
    620619                        trace_set_err_out(libtrace, TRACE_ERR_BAD_HEADER, "Header wire length is larger than it should be pcap_write_packet()");
     
    720719        struct pcap_pkthdr *pcapptr = 0;
    721720        pcapptr = (struct pcap_pkthdr *)packet->header;
    722         /*assert(pcapptr->caplen<=65536);*/
    723721        if (pcapptr->caplen > 65536) {
    724722                trace_set_err(packet->trace, TRACE_ERR_BAD_PACKET, "Capture length is to large, Packet may be corrupt in pcap_get_capture_length()");
     
    756754static size_t pcap_set_capture_length(libtrace_packet_t *packet,size_t size) {
    757755        struct pcap_pkthdr *pcapptr = 0;
    758         /*assert(packet);*/
    759756        if (!packet) {
    760757                fprintf(stderr, "NULL packet passed to pcap_set_capture_length()\n");
     
    777774                return TRACE_ERR_NULL_TRACE;
    778775        }
    779         /*assert(trace->format_data);*/
    780776        if (!trace->format_data) {
    781777                /* cant do this because trace is a const? */
Note: See TracChangeset for help on using the changeset viewer.