Changeset c4cf162 for lib/protocols.c


Ignore:
Timestamp:
09/12/06 13:46:45 (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:
935c3d0
Parents:
07a1cec
Message:

Adds initial wireless support to libtrace. Applications can now use the trace_get_wireless_* functions to get wireless information such as signal strength, noise levels, frame check sequences, etc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/protocols.c

    re0f9c80 rc4cf162  
    171171{
    172172        libtrace_pflog_header_t *pflog = (libtrace_pflog_header_t*)link;
    173         if (remaining) {
     173    if (remaining) {
    174174                if (*remaining<sizeof(*pflog))
    175175                        return NULL;
     
    188188}
    189189
     190/* Returns the 'payload' of the prism header, which is the 802.11 frame */
     191static 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);
     203}
     204
     205/* Returns the 'payload' of the radiotap header, which is the 802.11 frame */
     206static 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;
     214        }
     215
     216        if (type) *type = 0;
     217   
     218        return (void*) ((char*)link + rtap->it_len);
     219}
     220       
    190221void *trace_get_payload_from_link(void *link, libtrace_linktype_t linktype,
    191222                uint16_t *type, uint32_t *remaining)
    192223{
     224    void *l;
     225   
    193226        switch(linktype) {
    194227                case TRACE_TYPE_80211_PRISM:
    195                         return trace_get_payload_from_80211((char*)link+144,
    196                                         type,remaining);
     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 ;
    197233                case TRACE_TYPE_80211:
    198234                        return trace_get_payload_from_80211(link,type,remaining);
Note: See TracChangeset for help on using the changeset viewer.