Changeset 9a6bdbc for lib/format_pcap.c


Ignore:
Timestamp:
01/07/19 10:35:07 (22 months ago)
Author:
Jacob Van Walraven <jcv9@…>
Branches:
develop
Children:
51276bd
Parents:
979ab1a0
git-author:
Jacob Van Walraven <jcv9@…> (12/14/18 09:31:48)
git-committer:
Jacob Van Walraven <jcv9@…> (01/07/19 10:35:07)
Message:

Added can_write functions to each output format, Fixed pcapng_get_header_type incorrectly flipping type bytes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcap.c

    rd439067 r9a6bdbc  
    9797        } output;
    9898};
     99
     100static bool pcap_can_write(libtrace_packet_t *packet) {
     101        /* Get the linktype */
     102        libtrace_linktype_t ltype = trace_get_link_type(packet);
     103
     104        if (ltype == TRACE_TYPE_PCAPNG_META
     105                || ltype == TRACE_TYPE_CONTENT_INVALID
     106                || ltype == TRACE_TYPE_UNKNOWN
     107                || ltype == TRACE_TYPE_ERF_META
     108                || ltype == TRACE_TYPE_NONDATA) {
     109
     110                return false;
     111        }
     112
     113        return true;
     114}
    99115
    100116static int pcap_init_input(libtrace_t *libtrace) {
     
    521537{
    522538
     539        /* Check pcap can write this type of packet */
     540        if (!pcap_can_write(packet)) {
     541                return 0;
     542        }
     543
    523544        if (!libtrace) {
    524545                fprintf(stderr, "NULL trace passed into pcap_write_packet()\n");
     
    536557
    537558        link = trace_get_packet_buffer(packet,&linktype,&remaining);
    538 
    539         /* Silently discard RT metadata packets and packets with an
    540          * unknown linktype. */
    541         if (linktype == TRACE_TYPE_NONDATA || linktype == TRACE_TYPE_UNKNOWN || linktype == TRACE_TYPE_ERF_META || linktype == TRACE_TYPE_CONTENT_INVALID) {
    542                 return 0;
    543         }
    544559
    545560        /* We may have to convert this packet into a suitable PCAP packet */
Note: See TracChangeset for help on using the changeset viewer.