Changeset ffc8c8d for lib/format_pcap.c


Ignore:
Timestamp:
08/11/05 11:30:41 (16 years ago)
Author:
Daniel Lawson <dlawson@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, 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:
4d5a9a7
Parents:
a8ba977
Message:

better return codes in format_*.c, trace_perror stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcap.c

    r72bfe20 rffc8c8d  
    3434#include "libtrace_int.h"
    3535#include "format_helper.h"
    36 #include <inttypes.h>
     36
     37#ifdef HAVE_INTTYPES_H
     38#  include <inttypes.h>
     39#else
     40#  error "Can't find inttypes.h - this needs to be fixed"
     41#endif
     42
    3743#include <sys/types.h>
    3844#include <sys/stat.h>
     
    114120                }       
    115121        }
    116         fprintf(stderr,
    117                         "Unsupported scheme (%s) for format pcap\n",
    118                         CONNINFO.path);
    119         return 0;
     122        //fprintf(stderr,       "Unsupported scheme (%s) for format pcap\n",
     123        //              CONNINFO.path);
     124        return 1;
    120125       
    121126}
     
    136141                return 0;
    137142        }
    138 
     143        return 1;
    139144}
    140145
     
    153158
    154159        packet->size = numbytes + sizeof(struct pcap_pkthdr);
    155 
    156 }
     160}
     161
    157162static int pcap_read_packet(struct libtrace_t *libtrace, struct libtrace_packet_t *packet) {
    158163        const u_char *pcappkt;
    159164        int pcapbytes = 0;
    160165
    161         while ((pcapbytes = pcap_dispatch(INPUT.pcap,
     166        pcapbytes = pcap_dispatch(INPUT.pcap,
    162167                                        1, /* number of packets */
    163168                                        &trace_pcap_handler,
    164                                         (u_char *)packet)) == 0);
    165 
    166         if (pcapbytes < 0) {
    167                 return -1;
     169                                        (u_char *)packet);
     170
     171        if (pcapbytes <= 0) {
     172                return pcapbytes;
    168173        }
    169174        return (packet->size - sizeof(struct pcap_pkthdr));
Note: See TracChangeset for help on using the changeset viewer.