static void handle_ieee80211_packet(omphalos_packet *op,const void *frame,size_t len,unsigned freq){ const ieee80211hdr *ihdr = frame; // FIXME certain packets don't have the full 802.11 header (8 bytes, // control/duration/h_dest, seems to be the minimum). if(len < sizeof(ieee80211hdr)){ op->malformed = 1; diagnostic("%s Packet too small (%zu) on %s", __func__,len,op->i->name); return; } if(IEEE80211_VERSION(ihdr->control) != 0){ op->noproto = 1; diagnostic("%s Unknown version (%d) on %s",__func__, IEEE80211_VERSION(ihdr->control),op->i->name); return; } switch(IEEE80211_TYPE(ihdr->control)){ case MANAGEMENT_FRAME:{ unsigned stype = IEEE80211_SUBTYPE(ihdr->control); if(stype != IEEE80211_SUBTYPE_PROBE_REQUEST){ handle_ieee80211_mgmt(op,frame,len,freq); } }break; case CONTROL_FRAME:{ handle_ieee80211_ctrl(op,frame,len); }break; case DATA_FRAME:{ handle_ieee80211_data(op,frame,len); }break; default:{ op->noproto = 1; diagnostic("%s Unknown type %d on %s",__func__, IEEE80211_TYPE(ihdr->control),op->i->name); return; }break; } }
void ProbeRequestFilter::received(PacketP_t packet) { assert(packet->size() >= sizeof(struct ieee80211_radiotap_hdr)); const struct ieee80211_radiotap_hdr *rh = (const struct ieee80211_radiotap_hdr*)packet->getData().data(); assert(rh->version == 0); packet->pull(rh->len); // At this point we can no longer dereference the rh pointer! rh = NULL; assert(packet->size() >= sizeof(struct ieee80211_hdr)); const struct ieee80211_hdr *hdr = (const struct ieee80211_hdr*)packet->getData().data(); /* We're only interested in administrative frames, not data frames */ if (IEEE80211_TYPE(hdr->frame_control) != WLAN_FC_TYPE_MGMT) return; /* We're only interested in probe requests */ if (IEEE80211_STYPE(hdr->frame_control) != WLAN_FC_STYPE_PROBE_REQ) return; /* Copy out mac address */ ProbeRequestP_t req(new ProbeRequest(hdr->addr2)); packet->pull(sizeof(struct ieee80211_hdr)); hdr = NULL; TagParser tp(packet->getData()); assert(tp.hasTag(WLAN_EID_SSID)); req->SSID = tp.getTagData(WLAN_EID_SSID); if (req->SSID.size() == 0) req->SSID = "Broadcast"; emit probeRequest(req); }