Changeset 1602


Ignore:
Timestamp:
07/15/10 16:53:37 (3 years ago)
Author:
salcock
Message:
  • Set the value of remaining to the minimum of the wire and capture lengths when calling trace_get_packet_buffer()
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/trace.c

    r1586 r1602  
    817817DLLEXPORT void *trace_get_packet_buffer(const libtrace_packet_t *packet, 
    818818                libtrace_linktype_t *linktype, uint32_t *remaining) { 
     819        int cap_len; 
     820        int wire_len; 
     821 
    819822        assert(packet != NULL); 
    820823        if (linktype) *linktype = trace_get_link_type(packet); 
    821         if (remaining) *remaining = trace_get_capture_length(packet); 
     824        if (remaining) { 
     825                /* I think we should choose the minimum of the capture and 
     826                 * wire lengths to be the "remaining" value. If the packet has 
     827                 * been padded to increase the capture length, we don't want 
     828                 * to allow subsequent protocol decoders to consider the  
     829                 * padding as part of the packet. 
     830                 * 
     831                 * For example, in Auck 4 there is a trace where the IP header 
     832                 * length is incorrect (24 bytes) followed by a 20 byte TCP 
     833                 * header. Total IP length is 40 bytes. As a result, the 
     834                 * legacyatm padding gets treated as the "missing" bytes of 
     835                 * the TCP header, which isn't the greatest. We're probably 
     836                 * better off returning an incomplete TCP header in that case. 
     837                 */ 
     838                 
     839                cap_len = trace_get_capture_length(packet); 
     840                wire_len = trace_get_wire_length(packet); 
     841 
     842                assert(cap_len >= 0 && wire_len >= 0); 
     843                if (wire_len < cap_len) 
     844                        *remaining = wire_len; 
     845                else 
     846                        *remaining = cap_len; 
     847                /* *remaining = trace_get_capture_length(packet); */ 
     848        } 
    822849        return (void *) packet->payload; 
    823850} 
Note: See TracChangeset for help on using the changeset viewer.