Ignore:
Timestamp:
12/10/18 15:59:45 (2 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
develop
Children:
10fd24b
Parents:
418c78d
Message:

Move packet cached fields into a distinct structure.

This will help tidy up the packet structure a little, as well as
simplify the cache clearing process (and maybe even speed it up
a little).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/protocols_transport.c

    r2193905 rd439067  
    6464
    6565        /* Just use the cached length if we can */
    66         if (packet->payload_length != -1)
    67                 return packet->payload_length; 
     66        if (packet->cached.payload_length != -1)
     67                return packet->cached.payload_length;   
    6868
    6969        /* Set to zero so that we can return early without having to
    7070         * worry about forgetting to update the cached value */
    71         ((libtrace_packet_t *)packet)->payload_length = 0;
     71        ((libtrace_packet_t *)packet)->cached.payload_length = 0;
    7272        layer = trace_get_layer3(packet, &ethertype, &rem);
    7373        if (!layer)
     
    162162        }
    163163
    164         ((libtrace_packet_t *)packet)->payload_length = len;
     164        ((libtrace_packet_t *)packet)->cached.payload_length = len;
    165165        return len;
    166166
     
    181181        if (!remaining) remaining=&dummy_remaining;
    182182
    183         if (packet->l4_header) {
     183        if (packet->cached.l4_header) {
    184184                /*
    185185                void *link;
     
    189189                        return NULL;
    190190                */
    191                 *proto = packet->transport_proto;
    192                 /* *remaining -= (packet->l4_header - link); */
    193                 *remaining = packet->l4_remaining;
    194                 return packet->l4_header;
     191                *proto = packet->cached.transport_proto;
     192                *remaining = packet->cached.l4_remaining;
     193                return packet->cached.l4_header;
    195194        }
    196195
     
    221220        }
    222221
    223         ((libtrace_packet_t *)packet)->transport_proto = *proto;
    224         ((libtrace_packet_t *)packet)->l4_header = transport;
    225         ((libtrace_packet_t *)packet)->l4_remaining = *remaining;
     222        ((libtrace_packet_t *)packet)->cached.transport_proto = *proto;
     223        ((libtrace_packet_t *)packet)->cached.l4_header = transport;
     224        ((libtrace_packet_t *)packet)->cached.l4_remaining = *remaining;
    226225
    227226
Note: See TracChangeset for help on using the changeset viewer.