Changeset 1134


Ignore:
Timestamp:
02/08/07 11:46:05 (6 years ago)
Author:
smr26
Message:

Ensure that libpacketdump correctly deals with both 3- and 4-address 802.11 frames.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libpacketdump/link_4.c

    r1099 r1134  
    5555} __attribute__ ((__packed__)) ieee80211_ctrl_frame_2addr; 
    5656 
     57typedef struct ieee80211_data_frame_3 { 
     58        ieee80211_frame_control ctl; 
     59        uint16_t        duration; 
     60        uint8_t         addr1[6]; 
     61        uint8_t         addr2[6]; 
     62        uint8_t         addr3[6]; 
     63        uint16_t        seq_ctrl; 
     64} __attribute__ ((__packed__)) ieee80211_data_frame_3; 
    5765 
    5866typedef struct ieee80211_data_frame { 
     
    650658        printf(" 802.11MAC: Data frame: "); 
    651659         
    652         if (len < sizeof(ieee80211_data_frame)) { 
     660        if (len < sizeof(ieee80211_data_frame_3)) { 
    653661                printf("[Truncated]\n"); 
    654662                return; 
     
    681689                        (data->seq_ctrl & 0xFFF0) >> 4); 
    682690 
     691        hdrlen = sizeof(ieee80211_data_frame_3); 
     692         
    683693        if (! data->ctl.from_ds && ! data->ctl.to_ds) { 
    684694                printf(" 802.11MAC: DA      = %s\n", macaddr(data->addr1)); 
     
    694704                printf(" 802.11MAC: BSSID   = %s\n", macaddr(data->addr2)); 
    695705        } else { 
     706                /* Check to make sure we have a four-address frame first */ 
     707                if (len < sizeof(ieee80211_data_frame)) { 
     708                        printf(" 802.11MAC: [Truncated]\n"); 
     709                        return; 
     710                } 
    696711                printf(" 802.11MAC: DA      = %s\n", macaddr(data->addr3)); 
    697712                printf(" 802.11MAC: SA      = %s\n", macaddr(data->addr4)); 
    698713                printf(" 802.11MAC: TA      = %s\n", macaddr(data->addr2)); 
    699714                printf(" 802.11MAC: RA      = %s\n", macaddr(data->addr1)); 
    700         } 
    701  
    702         hdrlen = 0; 
     715                hdrlen = sizeof(ieee80211_data_frame); /* 4 addr header */ 
     716        } 
     717 
    703718 
    704719        if (data->ctl.subtype >= 8) {  
     
    706721                if (len > sizeof(ieee80211_qos_data_frame))  
    707722                        hdrlen = sizeof(ieee80211_qos_data_frame); 
    708         } else { 
    709                 if (len > sizeof(ieee80211_data_frame))  
    710                         hdrlen = sizeof(ieee80211_data_frame); 
    711         } 
    712          
    713         /* hdrlen will be zero if there wasn't a payload */ 
    714         if (hdrlen > 0) { 
     723        } 
     724         
     725        if (len > hdrlen) { 
    715726                pld = (ieee80211_payload *) ((char *)pkt + hdrlen) ; 
    716727                printf(" 802.11MAC: Payload ethertype = 0x%04x\n", ntohs(pld->ethertype)); 
Note: See TracChangeset for help on using the changeset viewer.