Changeset 8889370 for lib/linktypes.c


Ignore:
Timestamp:
09/21/06 16:29:24 (15 years ago)
Author:
Scott Raynel <smr26@…>
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:
52c7cda
Parents:
7e758fc
Message:

trace_get_payload_from_linux_sll now returns a pointer to the start of the next header intead of trying to jump through the next one. It also returns the hardware address type instead of the protocol type now. trace_get_payload_from_link has been updated to recurse to step through the protocols. This makes _from_linux_sll more like the rest of the functions in protocols.c.
We also now have arphrd_type_to_libtrace() and libtrace_to_arphrd_type() functions to help with this.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/linktypes.c

    rc4cf162 r8889370  
    8585                case TRACE_TYPE_ATM:    return TYPE_ATM;
    8686                case TRACE_TYPE_AAL5:   return TYPE_AAL5;
     87        }
     88        return -1;
     89}
     90
     91libtrace_linktype_t arphrd_type_to_libtrace(unsigned int arphrd) {
     92        switch(arphrd) {
     93                case ARPHRD_ETHER: return TRACE_TYPE_ETH;       
     94                case ARPHRD_IEEE80211: return TRACE_TYPE_80211;
     95                case ARPHRD_80211_RADIOTAP: return TRACE_TYPE_80211_RADIO;
     96        }
     97        return ~0;
     98}
     99
     100unsigned int libtrace_to_arphrd_type(libtrace_linktype_t linktype) {
     101        switch(linktype) {
     102                case TRACE_TYPE_ETH: return ARPHRD_ETHER;
     103                case TRACE_TYPE_80211: return ARPHRD_IEEE80211;
     104                case TRACE_TYPE_80211_RADIO: return ARPHRD_80211_RADIOTAP;
    87105        }
    88106        return -1;
     
    121139                                hdr->pkttype=TRACE_SLL_OUTGOING;
    122140                                if (pcap_dlt_to_libtrace(rt_to_pcap_dlt(packet->type))==TRACE_TYPE_ETH)
    123                                         hdr->hatype = ARPHRD_ETHER;
     141                                        hdr->hatype = htons(ARPHRD_ETHER);
    124142                                else
    125                                         hdr->hatype = ARPHRD_PPP;
     143                                        hdr->hatype = htons(ARPHRD_PPP);
    126144                                trace_get_payload_from_link(
    127145                                        trace_get_link(packet),
     
    172190        switch(trace_get_link_type(packet)) {
    173191                case TRACE_TYPE_LINUX_SLL:
    174                         switch(((libtrace_sll_header_t*)packet->payload)
    175                                         ->hatype) {
     192                        switch(ntohs(((libtrace_sll_header_t*)packet->payload)
     193                                        ->hatype)) {
    176194                                case ARPHRD_PPP:
    177195                                        packet->type=pcap_dlt_to_rt(DLT_NULL);
Note: See TracChangeset for help on using the changeset viewer.