Changeset d3b2234 for lib/format_pcap.c


Ignore:
Timestamp:
02/23/06 15:22:40 (16 years ago)
Author:
Perry Lorier <perry@…>
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:
9836f12
Parents:
b7d2de5
Message:

depacket->sizeification

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcap.c

    rb7d2de5 rd3b2234  
    250250static void trace_pcap_handler(u_char *user, const struct pcap_pkthdr *pcaphdr, const u_char *pcappkt) {
    251251        struct libtrace_packet_t *packet = (struct libtrace_packet_t *)user;   
    252         int numbytes = 0;
    253 
    254252        /*
    255253        // pcap provides us with the right bits, in it's own buffers.
    256254        // We hijack them.
    257255        */
    258         numbytes = pcaphdr->len;
    259256
    260257        if (!packet->buffer || packet->buf_control==TRACE_CTRL_EXTERNAL) {
     
    271268        packet->payload = (void *)pcappkt;
    272269
    273         packet->size = numbytes + sizeof(struct pcap_pkthdr);
    274 
    275         printf("%i %i %i\n",pcaphdr->caplen,pcaphdr->len,packet->size);
    276 
    277270        assert(pcaphdr->caplen>=0 && pcaphdr->caplen<=65536);
    278271}
     
    289282                return pcapbytes;
    290283        }
    291         return (packet->size - sizeof(struct pcap_pkthdr));
     284        return ((struct pcap_pkthdr*)packet->header)->len+sizeof(struct pcap_pkthdr);
    292285}
    293286
     
    402395
    403396
    404 static int pcap_get_capture_length(const struct libtrace_packet_t *packet) {
     397static int pcap_get_capture_length(const libtrace_packet_t *packet) {
    405398        struct pcap_pkthdr *pcapptr = 0;
    406399        pcapptr = (struct pcap_pkthdr *)packet->header;
     
    409402}
    410403
    411 static int pcap_get_wire_length(const struct libtrace_packet_t *packet) {
     404static int pcap_get_wire_length(const libtrace_packet_t *packet) {
    412405        struct pcap_pkthdr *pcapptr = 0;
    413406        pcapptr = (struct pcap_pkthdr *)packet->header;
     
    415408}
    416409
    417 static int pcap_get_framing_length(const struct libtrace_packet_t *packet UNUSED) {
     410static int pcap_get_framing_length(const libtrace_packet_t *packet UNUSED) {
    418411        return sizeof(struct pcap_pkthdr);
    419412}
    420413
    421 static size_t pcap_set_capture_length(struct libtrace_packet_t *packet,size_t size) {
     414static size_t pcap_set_capture_length(libtrace_packet_t *packet,size_t size) {
    422415        struct pcap_pkthdr *pcapptr = 0;
    423416        assert(packet);
    424         if ((size + sizeof(struct pcap_pkthdr)) > packet->size) {
     417        if (size > trace_get_capture_length(packet)) {
    425418                /* can't make a packet larger */
    426                 return (packet->size - sizeof(struct pcap_pkthdr));
     419                return trace_get_capture_length(packet);
    427420        }
    428421        pcapptr = (struct pcap_pkthdr *)packet->header;
    429422        pcapptr->caplen = size;
    430         packet->size = size + sizeof(struct pcap_pkthdr);
    431         return packet->size;
     423        return trace_get_capture_length(packet);
    432424}
    433425
Note: See TracChangeset for help on using the changeset viewer.