Changeset 6df012d for lib/protocols.c


Ignore:
Timestamp:
09/17/06 18:36:13 (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:
1dc7df3
Parents:
3af7b80
Message:

Fix get_payload_from_link for prism and radiotap.
Make sure to use bswap when looking at radiotap length.
Tidy up exported API, don't export get_payload_from_prism or _from_radiotap.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/protocols.c

    rc4cf162 r6df012d  
    190190/* Returns the 'payload' of the prism header, which is the 802.11 frame */
    191191static void *trace_get_payload_from_prism (void *link,
    192         uint16_t *type, uint32_t *remaining)
    193 {
    194     if (remaining) {
    195         if (*remaining<144)
    196             return NULL;
    197         *remaining-=144;
    198     }
    199 
    200     if (type) *type = 0;
    201 
    202     return (void *) ((char*)link+144);
     192                uint16_t *type, uint32_t *remaining)
     193{
     194        if (remaining) {
     195                if (*remaining<144)
     196                        return NULL;
     197                *remaining-=144;
     198        }
     199
     200        if (type) *type = 0;
     201
     202        return (void *) ((char*)link+144);
    203203}
    204204
    205205/* Returns the 'payload' of the radiotap header, which is the 802.11 frame */
    206206static void *trace_get_payload_from_radiotap (void *link,
    207         uint16_t *type, uint32_t *remaining)
    208 {
    209     struct libtrace_radiotap_t *rtap = (struct libtrace_radiotap_t*)link;
    210     if (remaining) {
    211                 if (*remaining<rtap->it_len)
    212                         return NULL;
    213                 *remaining-=rtap->it_len;
     207                uint16_t *type, uint32_t *remaining)
     208{
     209        struct libtrace_radiotap_t *rtap = (struct libtrace_radiotap_t*)link;
     210        uint16_t rtaplen = bswap_le_to_host16(rtap->it_len);
     211        if (remaining) {
     212                if (*remaining < rtaplen)
     213                        return NULL;
     214                *remaining -= rtaplen;
    214215        }
    215216
    216217        if (type) *type = 0;
    217    
    218         return (void*) ((char*)link + rtap->it_len);
    219 }
    220        
     218
     219        return (void*) ((char*)link + rtaplen);
     220}
     221
    221222void *trace_get_payload_from_link(void *link, libtrace_linktype_t linktype,
    222223                uint16_t *type, uint32_t *remaining)
    223224{
    224     void *l;
    225    
     225        void *l = NULL;
     226
    226227        switch(linktype) {
    227228                case TRACE_TYPE_80211_PRISM:
    228             l = trace_get_payload_from_prism(link,type,remaining);
    229             l ? trace_get_payload_from_80211(l,type,remaining) : NULL;
    230         case TRACE_TYPE_80211_RADIO:
    231             l = trace_get_payload_from_radiotap(link,type,remaining);
    232             l ? trace_get_payload_from_80211(l,type,remaining) : NULL ;
     229                        l = trace_get_payload_from_prism(link,type,remaining);
     230                        return(l ? trace_get_payload_from_80211(l,type,remaining) : NULL);
     231                case TRACE_TYPE_80211_RADIO:
     232                        l = trace_get_payload_from_radiotap(link,type,remaining);
     233                        return(l ? trace_get_payload_from_80211(l,type,remaining) : NULL);
    233234                case TRACE_TYPE_80211:
    234235                        return trace_get_payload_from_80211(link,type,remaining);
Note: See TracChangeset for help on using the changeset viewer.