Changeset 979a84f4


Ignore:
Timestamp:
09/20/11 15:50:53 (9 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:
50c5053
Parents:
c0ccccd
Message:
  • We now cache the wire length as well
  • If we're going to cache the link type, we should probably use it whenever we call trace_get_link_type()!
Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/libtrace.h.in

    rc0506ea r979a84f4  
    420420        buf_control_t buf_control;      /**< Describes memory ownership */
    421421        int capture_length;             /**< Cached capture length */
     422        int wire_length;                /**< Cached wire length */
    422423        int payload_length;             /**< Cached payload length */
    423424        void *l2_header;                /**< Cached link header */
  • lib/protocols_l2.c

    ree58d0d r979a84f4  
    381381                case TRACE_TYPE_METADATA:
    382382                case TRACE_TYPE_NONDATA:
    383                         ((libtrace_packet_t*)packet)->link_type = *linktype;
    384383                        ((libtrace_packet_t*)packet)->l2_header = meta;
    385384                        ((libtrace_packet_t*)packet)->l2_remaining = *remaining;
     
    414413                                case TRACE_TYPE_METADATA:
    415414                                case TRACE_TYPE_NONDATA:
    416                                         ((libtrace_packet_t*)packet)->link_type = *linktype;
    417415                                        ((libtrace_packet_t*)packet)->l2_header = meta;
    418416                                        ((libtrace_packet_t*)packet)->l2_remaining = *remaining;
  • lib/trace.c

    rc0506ea r979a84f4  
    10411041 */
    10421042DLLEXPORT size_t trace_get_wire_length(const libtrace_packet_t *packet){
    1043         if (packet->trace->format->get_wire_length) {
    1044                 return packet->trace->format->get_wire_length(packet);
    1045         }
    1046         return ~0U;
     1043       
     1044        if (packet->wire_length == -1) {
     1045                if (!packet->trace->format->get_wire_length)
     1046                        return ~0U;
     1047                ((libtrace_packet_t *)packet)->wire_length =
     1048                        packet->trace->format->get_wire_length(packet);
     1049        }
     1050
     1051        assert(packet->wire_length < LIBTRACE_PACKET_BUFSIZE);
     1052        return packet->wire_length;
    10471053
    10481054}
     
    10681074 */
    10691075DLLEXPORT libtrace_linktype_t trace_get_link_type(const libtrace_packet_t *packet ) {
    1070         if (packet->trace->format->get_link_type) {
    1071                 return packet->trace->format->get_link_type(packet);
    1072         }
    1073         return (libtrace_linktype_t)-1;
     1076
     1077        if (packet->link_type == 0) {
     1078                if (!packet->trace->format->get_link_type)
     1079                        return (libtrace_linktype_t)-1;
     1080                ((libtrace_packet_t *)packet)->link_type =
     1081                        packet->trace->format->get_link_type(packet);
     1082        }
     1083
     1084        return packet->link_type;
    10741085}
    10751086
     
    18341845        packet->transport_proto = 0;
    18351846        packet->capture_length = -1;
     1847        packet->wire_length = -1;
    18361848        packet->payload_length = -1;
    18371849        packet->l2_remaining = 0;
Note: See TracChangeset for help on using the changeset viewer.