Changeset f0c639b


Ignore:
Timestamp:
03/26/07 11:47:31 (14 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:
38f9537
Parents:
be22b51
Message:
  • Remove trace_get_wireless_fcs as it is no longer part of the Radiotap standard.
  • Update trace_get_wire_length to account for the presence (or absence) of FCS bytes at the end of wireless frames. (only pcap and pcapfile for now)
  • Update radiotap libpacketdump decoder to no longer output non-standard FCS field.
  • Update test-wireless to ensure new length functions work correctly.
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • lib/format_pcap.c

    rd5a27e8 rf0c639b  
    513513        if (packet->type==pcap_dlt_to_rt(TRACE_DLT_EN10MB))
    514514                return pcapptr->len+4; /* Include the missing FCS */
    515         else
    516                 return pcapptr->len;
     515        else if (packet->type==pcap_dlt_to_rt(TRACE_DLT_IEEE802_11_RADIO)) {
     516                /* If the packet is Radiotap and the flags field indicates
     517                 * that the FCS is not included in the 802.11 frame, then
     518                 * we need to add 4 to the wire-length to account for it.
     519                 */
     520                uint16_t flags;
     521                trace_get_wireless_flags(trace_get_link(packet), trace_get_link_type(packet), &flags);
     522                if ((flags & TRACE_RADIOTAP_F_FCS) == 0)
     523                        return pcapptr->len + 4;
     524        }
     525        return pcapptr->len;
    517526}
    518527
  • lib/format_pcapfile.c

    rc85b715 rf0c639b  
    432432                /* Include the missing FCS */
    433433                return swapl(packet->trace,pcapptr->wirelen)+4;
    434         else
    435                 return swapl(packet->trace,pcapptr->wirelen);
     434        else if (packet->type==pcap_dlt_to_rt(TRACE_DLT_IEEE802_11_RADIO)) {
     435                /* If the packet is Radiotap and the flags field indicates
     436                 * that the FCS is not included in the 802.11 frame, then
     437                 * we need to add 4 to the wire-length to account for it.
     438                 */
     439                uint16_t flags;
     440                trace_get_wireless_flags(trace_get_link(packet), trace_get_link_type(packet), &flags);
     441                if ((flags & TRACE_RADIOTAP_F_FCS) == 0)
     442                        return swapl(packet->trace,pcapptr->wirelen)+4;
     443        }
     444        return swapl(packet->trace,pcapptr->wirelen);
    436445}
    437446
  • lib/libtrace.h.in

    rbe22b51 rf0c639b  
    347347    TRACE_RADIOTAP_DB_ANTSIGNAL = 12, /**< Signal power in dB from a fixed reference (uint8) */
    348348    TRACE_RADIOTAP_DB_ANTNOISE = 13, /**< Noise power in dB from a fixed reference (uint8) */
    349     TRACE_RADIOTAP_FCS = 14, /**< Received frame check sequence (uint32) */
    350349    TRACE_RADIOTAP_EXT = 31
    351350} libtrace_radiotap_field_t;
     
    16251624        libtrace_linktype_t linktype, uint8_t *antenna);
    16261625
    1627 /** Get the wireless Frame Check Sequence field
    1628  * @param link the wireless header
    1629  * @param linktype the linktype of the wireless header passed in
    1630  * @param[out] fcs the Frame Check Sequence of the frame.
    1631  * @return true if the field was available, false if not.
    1632  */
    1633 DLLEXPORT bool trace_get_wireless_fcs(void *linkptr,
    1634         libtrace_linktype_t linktype, uint32_t *fcs);
    1635 
    16361626/*@}*/
    16371627
  • lib/libtrace_int.h

    rd5a27e8 rf0c639b  
    457457void duck_constructor(void);
    458458
    459 
     459/* Used internally by get_wire_length() methods */
     460bool trace_get_wireless_flags(void *link, libtrace_linktype_t linktype, uint8_t *flags);
     461#define TRACE_RADIOTAP_F_FCS 0x10
    460462       
    461463#ifdef __cplusplus
  • lib/link_wireless.c

    rd5a27e8 rf0c639b  
    156156        if (field == TRACE_RADIOTAP_DB_ANTNOISE)
    157157                return (void *) p;
     158        /*
    158159        if (bswap_le_to_host32(rtap->it_present) & (1 << TRACE_RADIOTAP_DB_ANTNOISE))
    159160                p+= sizeof (uint8_t);
    160 
    161         if (field == TRACE_RADIOTAP_FCS)
    162                 ALIGN_NATURAL_32(p,s);
    163         return (void *)p;
     161        */
    164162
    165163        /* Unknown field */
     
    198196 * for now. Maybe it will be included in the API later if it becomes useful
    199197 * and we come up with a suitable abstraction.
    200  */
    201 static
     198 * This function isn't marked static as the various format modules need to
     199 * access it for get_wire_length(). It's not meant to be exported though.
     200 */
    202201bool trace_get_wireless_flags(void *link,
    203202                libtrace_linktype_t linktype, uint8_t *flags)
     
    591590}
    592591
    593 DLLEXPORT bool trace_get_wireless_fcs(void *link,
    594                 libtrace_linktype_t linktype, uint32_t *fcs)
    595 {
    596         uint32_t *p;
    597         void *l;
    598         uint16_t type;
    599 
    600         if (link == NULL || fcs == NULL) return false;
    601         switch (linktype) {
    602                 case TRACE_TYPE_80211_RADIO:
    603                         if ((p = (uint32_t *) trace_get_radiotap_field(link,
    604                                                         TRACE_RADIOTAP_FCS))) {
    605                                 *fcs = bswap_le_to_host32(*p);
    606                                 return true;
    607                         } else break;
    608                 case TRACE_TYPE_LINUX_SLL:
    609                         l = trace_get_payload_from_linux_sll(link, &type, NULL);
    610                         return trace_get_wireless_fcs(l, arphrd_type_to_libtrace(type), fcs);
    611                 default:
    612                         return false;
    613         }
    614         return false;
    615 }
    616 
  • libpacketdump/link_15.c

    r1515e07 rf0c639b  
    149149        }
    150150
    151         if (rtap->it_present & (1 << TRACE_RADIOTAP_FCS)) {
    152                 ALIGN_NATURAL_32(p,s,rtap_real_len);
    153                 printf(" Radiotap: Frame Check Sequence = %#10x\n", bswap_le_to_host32(*((uint32_t *)p)));
    154                 p += sizeof (uint32_t);
    155                 rtap_real_len += sizeof(uint32_t);
    156         }
    157 
    158151        if (rtap_real_len != rtap_len)
    159                 printf(" Radiotap: WARNING: Header length does not match fields present (%u)\n", rtap_real_len);
     152                printf(" Radiotap: WARNING: Header contains un-decoded fields.\n");
    160153
    161154        if (len > rtap_len)
  • test/test-wireless.c

    rd5a27e8 rf0c639b  
    6565        uint64_t tsft;
    6666        uint16_t freq, tmp16;
    67         uint32_t fcs;
    6867        uint8_t flags, rate, sdbm, ndbm, sdb, antenna, tmp8;
    6968       
    70         uint32_t total_fcs, expected_fcs = 3012874435;
    7169        uint16_t total_freq, expected_freq = 24170;
    7270       
     
    9896        assert(trace_get_wireless_signal_strength_db(l,lt,&sdb));
    9997        assert(trace_get_wireless_antenna(l,lt,&antenna));
    100         assert(trace_get_wireless_fcs(l,lt,&fcs));
    10198
    10299        /* Check that the fields that do not exist in this trace are
     
    111108         * TODO: Check all fields :)
    112109         */
    113         total_fcs = fcs;
    114110        total_freq = freq;
    115111       
    116112        while((result = trace_read_packet(trace, packet)) > 0) {
    117                 if(trace_get_wireless_fcs(l,lt,&fcs))
    118                         total_fcs += fcs;
     113                /* This trace has no FCS at the end of packets, so ensure
     114                 * that wire-length is 4 bytes greater than capture length */
     115                int caplen = trace_get_capture_length(packet);
     116                int wirelen = trace_get_wire_length(packet);
     117                assert(wirelen == caplen + 4);
    119118                if(trace_get_wireless_freq(l,lt,&freq))
    120119                        total_freq += freq;
    121120        }
    122121
    123         assert(total_fcs == expected_fcs);
    124122        assert(total_freq == expected_freq);
    125123
     
    146144        assert(!trace_get_wireless_signal_strength_db(l,lt,&sdb));
    147145        assert(!trace_get_wireless_antenna(l,lt,&antenna));
    148         assert(!trace_get_wireless_fcs(l,lt,&fcs));
    149146        assert(!trace_get_wireless_noise_strength_db(l,lt,&tmp8));
    150147        assert(!trace_get_wireless_tx_attenuation(l,lt,&tmp16));
Note: See TracChangeset for help on using the changeset viewer.