Changeset 1037


Ignore:
Timestamp:
10/11/06 16:09:48 (7 years ago)
Author:
perry
Message:

Correctly generate/parse LINUX_SLL headers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/linktypes.c

    r1029 r1037  
    128128                libtrace_sll_header_t *hdr; 
    129129 
     130                if (pcap_dlt_to_libtrace(rt_to_pcap_dlt(packet->type)) 
     131                        == TRACE_TYPE_LINUX_SLL) { 
     132                        /* This is already been promoted, so ignore it */ 
     133                        return; 
     134                } 
     135 
     136                /* This should be easy, just prepend the header */ 
     137                tmpbuffer= (char*)malloc( 
     138                                sizeof(libtrace_sll_header_t) 
     139                                +trace_get_capture_length(packet) 
     140                                +trace_get_framing_length(packet) 
     141                                ); 
     142 
     143                hdr=(libtrace_sll_header_t*)((char*)tmpbuffer 
     144                        +trace_get_framing_length(packet)); 
     145 
     146                hdr->halen=htons(6); 
     147                hdr->pkttype=TRACE_SLL_OUTGOING; 
     148 
    130149                switch(pcap_dlt_to_libtrace(rt_to_pcap_dlt(packet->type))) { 
    131                         case TRACE_TYPE_LINUX_SLL: 
    132                                 return; /* Unnecessary */ 
    133  
    134150                        case TRACE_TYPE_NONE: 
    135                         case TRACE_TYPE_ETH: 
    136                                 /* This should be easy, just prepend the header */ 
    137                                 tmpbuffer= (char*)malloc( 
    138                                                 sizeof(libtrace_sll_header_t) 
    139                                                 +trace_get_capture_length(packet) 
    140                                                 +trace_get_framing_length(packet) 
    141                                                 ); 
    142  
    143                                 hdr=(libtrace_sll_header_t*)((char*)tmpbuffer 
    144                                         +trace_get_framing_length(packet)); 
    145  
    146                                 hdr->pkttype=TRACE_SLL_OUTGOING; 
    147                                 if (pcap_dlt_to_libtrace(rt_to_pcap_dlt(packet->type))==TRACE_TYPE_ETH) 
    148                                         hdr->hatype = htons(ARPHRD_ETHER); 
    149                                 else 
    150                                         hdr->hatype = htons(ARPHRD_PPP); 
    151151                                trace_get_payload_from_link( 
    152152                                        trace_get_link(packet), 
     
    154154                                        &hdr->protocol, 
    155155                                        NULL); 
    156                                 /* Linux SLL appears to have the protocol 
    157                                  * field in /host/ byte order. 
    158                                  */ 
    159                                 hdr->protocol=ntohs(hdr->protocol); 
     156                                hdr->hatype = htons(ARPHRD_PPP); 
     157                                hdr->protocol=htons(hdr->protocol); 
     158                                break; 
     159                        case TRACE_TYPE_ETH: 
     160                                hdr->hatype = htons(ARPHRD_ETHER); 
     161                                hdr->protocol=htons(0x0060); /* ETH_P_LOOP */ 
    160162                                break; 
    161163                        default: 
Note: See TracChangeset for help on using the changeset viewer.