Changeset 0ff6ddf for lib/linktypes.c


Ignore:
Timestamp:
06/06/06 17:32:24 (15 years ago)
Author:
Perry Lorier <perry@…>
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:
b0acff7
Parents:
41f22e4
Message:

Add demotion of packets from LINUX_SLL to ethernet when writing ERF packets.
We don't need the extra header to store the direction information, and erf
doesn't have a type for linux-sll /anyway/.

This also adds a test which takes a packet, promotes it and demotes it again
which should catch direction related bugs

Closes: #21

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/linktypes.c

    r77285d9 r0ff6ddf  
    154154        }
    155155}
     156
     157/* Try and simplify the packet one step, kinda the opposite to promote_packet
     158 *
     159 * returns true if demotion was possible, false if not.
     160 */
     161bool demote_packet(libtrace_packet_t *packet)
     162{
     163        switch(trace_get_link_type(packet)) {
     164                case TRACE_TYPE_LINUX_SLL:
     165                        switch(((libtrace_sll_header_t*)packet->payload)
     166                                        ->hatype) {
     167                                case ARPHRD_PPP:
     168                                        packet->type=pcap_dlt_to_rt(DLT_NULL);
     169                                        break;
     170                                case ARPHRD_ETHER:
     171                                        packet->type=pcap_dlt_to_rt(DLT_EN10MB);
     172                                        break;
     173                                default:
     174                                        /* Dunno how to demote this packet */
     175                                        return false;
     176                        }
     177                        packet->payload=(void*)((char*)packet->payload
     178                                        +sizeof(libtrace_sll_header_t));
     179                        trace_set_capture_length(packet,
     180                                trace_get_capture_length(packet)
     181                                        -sizeof(libtrace_sll_header_t));
     182                        break;
     183                default:
     184                        return false;
     185        }
     186}
Note: See TracChangeset for help on using the changeset viewer.