Changeset 566e404


Ignore:
Timestamp:
04/14/06 17:36:52 (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:
671566a
Parents:
97e39a7
Message:

Fix bugs with forward porting of format_linux:

  • Fix the buffer management
  • Fill out uninitialised packet->type
Location:
lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lib/format_linux.c

    r97e39a7 r566e404  
    6868        if (FORMAT(libtrace->format_data)->fd==-1) {
    6969                free(libtrace->format_data);
    70                 return 0;
     70                return -1;
    7171        }
    7272        addr.sll_family = AF_PACKET;
     
    7777                        close(FORMAT(libtrace->format_data)->fd);
    7878                        free(libtrace->format_data);
    79                         return 0;
     79                        return -1;
    8080                }
    8181        }
     
    8787                                sizeof(addr))==-1) {
    8888                free(libtrace->format_data);
    89                 return 0;
     89                return -1;
    9090        }
    9191        /* enable promisc mode when listening on an interface */
     
    102102        }
    103103
    104         return 1;
     104        return 0;
    105105}
    106106
     
    112112
    113113static int linuxnative_read_packet(struct libtrace_t *libtrace, struct libtrace_packet_t *packet) {
    114         struct libtrace_linuxnative_header *hdr=(void*)packet->buffer;
     114        struct libtrace_linuxnative_header *hdr;
     115        if (!packet->buffer || packet->buf_control == TRACE_CTRL_EXTERNAL) {
     116                packet->buffer = malloc(LIBTRACE_PACKET_BUFSIZE);
     117                packet->buf_control = TRACE_CTRL_PACKET;
     118        }
     119
     120        packet->header = packet->buffer;
     121        packet->type = RT_DATA_LINUX_NATIVE;
     122        packet->payload = packet->buffer+sizeof(*hdr);
     123
     124        hdr=(void*)packet->buffer;
    115125        socklen_t socklen=sizeof(hdr->hdr);
    116126        hdr->wirelen = recvfrom(FORMAT(libtrace->format_data)->fd,
    117                         (void*)packet->buffer+sizeof(*hdr),
    118                         sizeof(packet->buffer)-sizeof(*hdr),
     127                        (void*)packet->payload,
     128                        LIBTRACE_PACKET_BUFSIZE-sizeof(*hdr),
    119129                        MSG_TRUNC,
    120130                        (void *)&hdr->hdr,
  • lib/rt_protocol.h

    r4617920 r566e404  
    6060 RT_DATA_LEGACY_POS     =RT_DATA_SIMPLE + TRACE_FORMAT_LEGACY_POS,
    6161 RT_DATA_LEGACY_ETH     =RT_DATA_SIMPLE + TRACE_FORMAT_LEGACY_ETH,
     62 RT_DATA_LINUX_NATIVE   =RT_DATA_SIMPLE + TRACE_FORMAT_LINUX_NATIVE,
    6263
    6364#ifdef HAVE_PCAP
Note: See TracChangeset for help on using the changeset viewer.