Changeset 95b1d6d


Ignore:
Timestamp:
11/27/07 14:30:48 (13 years ago)
Author:
Shane Alcock <salcock@…>
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:
f2fae49
Parents:
631c337
Message:
  • Remember to clear the packet cache when trace_event is used to read packets
  • Packets that had a corrupt or incorrect rt_type will no longer be erroneously treated as pcap packets (unless the rt_type ends up being between 2000 and 2999!)
Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/format_rt.c

    r631c337 r95b1d6d  
    307307                                RT_INFO->buf_filled);
    308308                RT_INFO->buf_current = RT_INFO->pkt_buffer;
    309                
    310309#ifndef MSG_NOSIGNAL
    311310#  define MSG_NOSIGNAL 0
     
    363362static int rt_set_format(libtrace_t *libtrace, libtrace_packet_t *packet)
    364363{
    365        
    366         if (packet->type >= TRACE_RT_DATA_DLT) {
     364
     365        /* Try to minimize the number of corrupt packets that slip through
     366         * while making it easy to identify new pcap DLTs */
     367        if (packet->type > TRACE_RT_DATA_DLT &&
     368                        packet->type < TRACE_RT_DATA_DLT_END) {
    367369                if (!RT_INFO->dummy_pcap) {
    368370                        RT_INFO->dummy_pcap = trace_create_dead("pcap:-");
     
    399401                        return -1;
    400402                default:
    401                         printf("Unrecognised format: %d\n", packet->type);
     403                        printf("Unrecognised format: %u\n", packet->type);
    402404                        trace_set_err(libtrace, TRACE_ERR_BAD_PACKET, "Unrecognised packet format");
    403405                        return -1;
     
    489491        if (RT_INFO->rt_hdr.type == TRACE_RT_LAST) {
    490492                void_hdr = (void *)pkt_hdr;
    491                
    492493                /* FIXME: Better error handling required */
    493494                if (rt_read(libtrace, &void_hdr,
     
    506507        packet->type = RT_INFO->rt_hdr.type;
    507508
     509       
    508510        if (packet->type >= TRACE_RT_DATA_SIMPLE) {
    509511                if (rt_read(libtrace,
     
    677679                event.type = TRACE_EVENT_PACKET;
    678680        }
     681
    679682       
    680683        return event;
  • lib/libtrace.h.in

    r8f18776 r95b1d6d  
    319319        TRACE_RT_DLT_PFLOG              =TRACE_RT_DATA_DLT+TRACE_DLT_PFLOG,
    320320        TRACE_RT_DLT_ATM_RFC1483        =TRACE_RT_DATA_DLT+TRACE_DLT_ATM_RFC1483,
     321        TRACE_RT_DATA_DLT_END           = 2999,
    321322        TRACE_RT_LAST                   = (2<<31)
    322323} libtrace_rt_types_t;
  • lib/trace.c

    rdc6dc11 r95b1d6d  
    977977        assert(packet);
    978978
     979        /* Clear the packet cache */
     980        packet->capture_length = -1;
     981        packet->l3_header = NULL;
     982        packet->l3_ethertype = 0;
     983       
    979984        /* Store the trace we are reading from into the packet opaque
    980985         * structure */
Note: See TracChangeset for help on using the changeset viewer.