Changeset d439067 for lib/protocols_l3.c


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_l3.c

    r2193905 rd439067  
    226226
    227227        /* use l3 cache */
    228         if (packet->l3_header)
     228        if (packet->cached.l3_header)
    229229        {
    230230                /*
     
    235235                */
    236236
    237                 *ethertype = packet->l3_ethertype;
    238                 /* *remaining -= (packet->l3_header - link); */
    239                 *remaining = packet->l3_remaining;
    240 
    241                 return packet->l3_header;
    242         }
    243 
    244         if (packet->l2_header) {
    245                 link = packet->l2_header;
    246                 linktype = packet->link_type;
    247                 *remaining = packet->l2_remaining;
     237                *ethertype = packet->cached.l3_ethertype;
     238                /* *remaining -= (packet->cached.l3_header - link); */
     239                *remaining = packet->cached.l3_remaining;
     240
     241                return packet->cached.l3_header;
     242        }
     243
     244        if (packet->cached.l2_header) {
     245                link = packet->cached.l2_header;
     246                linktype = packet->cached.link_type;
     247                *remaining = packet->cached.l2_remaining;
    248248        } else {
    249249                link = trace_get_layer2(packet,&linktype,remaining);
     
    288288        /* Store values in the cache for later */
    289289        /* Cast away constness, nasty, but this is just a cache */
    290         ((libtrace_packet_t*)packet)->l3_ethertype = *ethertype;
    291         ((libtrace_packet_t*)packet)->l3_header = iphdr;
    292         ((libtrace_packet_t*)packet)->l3_remaining = *remaining;
     290        ((libtrace_packet_t*)packet)->cached.l3_ethertype = *ethertype;
     291        ((libtrace_packet_t*)packet)->cached.l3_header = iphdr;
     292        ((libtrace_packet_t*)packet)->cached.l3_remaining = *remaining;
    293293
    294294        return iphdr;
Note: See TracChangeset for help on using the changeset viewer.