Changeset 64d4398 for lib


Ignore:
Timestamp:
10/24/12 13:37:54 (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:
afaf6e8
Parents:
d11be03
Message:

Fixed bugs when converting packets from Linux SLL (pcap) to ERF - thanks to Simon Wadsworth for reporting this problem

  • Raw IP packets (e.g. captured using pcapint:any) are now treated as TRACE_TYPE_NONE internally.
  • TRACE_TYPE_NONE maps to the ERF type TYPE_IPV4 - distinguishing between IPv4 and IPv6 within the current API is a bit tricky so that's on the TODO list
  • Wire length calculation for Ethernet encapsulated inside Linux SLL now includes the FCS, just like every other libtrace packet format.
Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcapfile.c

    rd8eb866 r64d4398  
    629629                if ((flags & TRACE_RADIOTAP_F_FCS) == 0)
    630630                        return swapl(packet->trace,pcapptr->wirelen)+4;
    631         }
     631        } else if (packet->type == pcap_linktype_to_rt(TRACE_DLT_LINUX_SLL)) {
     632                libtrace_sll_header_t *sll;
     633                sll = (libtrace_sll_header_t *)packet->payload;
     634
     635                /* Account for FCS when dealing with Ethernet packets that are
     636                 * encapsulated in Linux SLL. This should fix the problem
     637                 * where the wire lengths differ if we convert the packet to
     638                 * ERF */
     639                if (ntohs(sll->protocol) == TRACE_ETHERTYPE_LOOPBACK)
     640                        return swapl(packet->trace,pcapptr->wirelen)+4;
     641        }
     642
    632643        return swapl(packet->trace,pcapptr->wirelen);
    633644}
  • lib/libtrace.h.in

    r16c598d r64d4398  
    405405typedef enum {
    406406        /* Numbers <=1500 are of course, LLC/SNAP */
     407        TRACE_ETHERTYPE_LOOPBACK= 0x0060,       /**< Ethernet Loopback */
    407408        TRACE_ETHERTYPE_IP      = 0x0800,       /**< IPv4 */
    408409        TRACE_ETHERTYPE_ARP     = 0x0806,       /**< Address resolution protocol */
  • lib/linktypes.c

    rd726c7b r64d4398  
    151151                case TYPE_AAL5:         return TRACE_TYPE_AAL5;
    152152                case TYPE_DSM_COLOR_ETH:return TRACE_TYPE_ETH;
     153                case TYPE_IPV4:         return TRACE_TYPE_NONE;
     154                case TYPE_IPV6:         return TRACE_TYPE_NONE;
    153155        }
    154156        return ~0U;
     
    162164                case TRACE_TYPE_ATM:    return TYPE_ATM;
    163165                case TRACE_TYPE_AAL5:   return TYPE_AAL5;
     166                case TRACE_TYPE_NONE:   return TYPE_IPV4;
    164167                /* Unsupported conversions */
    165168                case TRACE_TYPE_LLCSNAP:
     
    169172                case TRACE_TYPE_80211:
    170173                case TRACE_TYPE_PFLOG:
    171                 case TRACE_TYPE_NONE:
    172174                case TRACE_TYPE_LINUX_SLL:
    173175                case TRACE_TYPE_PPP:
     
    286288{
    287289        uint8_t type;
     290        uint16_t ha_type, next_proto;
     291        libtrace_sll_header_t *sll = NULL;
    288292        uint32_t remaining = 0;
    289293        char *tmp;
     
    335339
    336340                case TRACE_TYPE_LINUX_SLL:
     341                        sll = (libtrace_sll_header_t *)(packet->payload);
     342
     343                        ha_type = ntohs(sll->hatype);
     344                        next_proto = ntohs(sll->protocol);
     345               
     346                        /* Preserved from older libtrace behaviour */
     347                        if (ha_type == ARPHRD_PPP)
     348                                packet->type = pcap_linktype_to_rt(TRACE_DLT_RAW);
     349                        /* Don't decide trace type based on ha_type,
     350                         * decide based on the protocol header that is
     351                         * coming up!
     352                         */
     353                        else if (next_proto == TRACE_ETHERTYPE_LOOPBACK)
     354                                packet->type = pcap_linktype_to_rt(TRACE_DLT_EN10MB);
     355                        else if (next_proto == TRACE_ETHERTYPE_IP)
     356                                packet->type = pcap_linktype_to_rt(TRACE_DLT_RAW);
     357                        else if (next_proto == TRACE_ETHERTYPE_IPV6)
     358                                packet->type = pcap_linktype_to_rt(TRACE_DLT_RAW);
     359                        else
     360                                return false;
     361
     362#if 0
    337363                        switch(ntohs(((libtrace_sll_header_t*)packet->payload)
    338364                                        ->hatype)) {
     
    347373                                        return false;
    348374                        }
     375#endif
    349376                        /* Skip the Linux SLL header */
    350377                        packet->payload=(void*)((char*)packet->payload
Note: See TracChangeset for help on using the changeset viewer.