static void handle_tx_callback(hostapd *hapd, char *buf, size_t len, int ok) { struct ieee80211_hdr *hdr; u16 fc, type, stype; hdr = (struct ieee80211_hdr *) buf; fc = le_to_host16(hdr->frame_control); type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); switch (type) { case WLAN_FC_TYPE_MGMT: HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "MGMT (TX callback) %s\n", ok ? "ACK" : "fail"); ieee802_11_mgmt_cb(hapd, buf, len, stype, ok); break; case WLAN_FC_TYPE_CTRL: HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "CTRL (TX callback) %s\n", ok ? "ACK" : "fail"); break; case WLAN_FC_TYPE_DATA: HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "DATA (TX callback) %s\n", ok ? "ACK" : "fail"); /* TODO: could replace TXExc counter hack with kernel driver * in data polling for inactivity check with the new TX * callback.. */ /* handle_data_cb(hapd, buf, len, stype, ok); */ break; default: printf("unknown TX callback frame type %d\n", type); break; } }
void ap_mgmt_tx_cb(void *ctx, const u8 *buf, size_t len, u16 stype, int ok) { #ifdef NEED_AP_MLME struct wpa_supplicant *wpa_s = ctx; ieee802_11_mgmt_cb(wpa_s->ap_iface->bss[0], buf, len, stype, ok); #endif /* NEED_AP_MLME */ }
static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf, size_t len, u16 stype, int ok) { struct ieee80211_hdr *hdr; hdr = (struct ieee80211_hdr *) buf; hapd = get_hapd_bssid(hapd->iface, get_hdr_bssid(hdr, len)); if (hapd == NULL || hapd == HAPD_BROADCAST) return; ieee802_11_mgmt_cb(hapd, buf, len, stype, ok); }
static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf, size_t len, u16 type, int ok, const u8 *dst) { struct ieee80211_hdr *hdr; hdr = (struct ieee80211_hdr *) buf; //收到 auth 帧事件后调用 hapd = get_hapd_ssid(hapd, get_hdr_bssid(hdr, len), dst, type); if (hapd == NULL || hapd == HAPD_BROADCAST) return; ieee802_11_mgmt_cb(hapd, buf, len, WLAN_FC_GET_STYPE(type), ok); }
static void rtl871x_handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len, int ok) { #if 0 struct ieee80211_hdr *hdr; u16 fc, type, stype; struct sta_info *sta; //printf("%s\n", __func__); hdr = (struct ieee80211_hdr *) buf; fc = le_to_host16(hdr->frame_control); type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); switch (type) { case WLAN_FC_TYPE_MGMT: //printf("MGMT (TX callback) %s\n", // ok ? "ACK" : "fail"); ieee802_11_mgmt_cb(hapd, buf, len, stype, ok); break; case WLAN_FC_TYPE_CTRL: printf("CTRL (TX callback) %s\n", ok ? "ACK" : "fail"); break; case WLAN_FC_TYPE_DATA: printf("DATA (TX callback) %s\n", ok ? "ACK" : "fail"); sta = ap_get_sta(hapd, hdr->addr1); if (sta && sta->flags & WLAN_STA_PENDING_POLL) { wpa_printf(MSG_DEBUG, "STA " MACSTR " %s pending activity poll", MAC2STR(sta->addr), ok ? "ACKed" : "did not ACK"); if (ok) sta->flags &= ~WLAN_STA_PENDING_POLL; } if (sta) ieee802_1x_tx_status(hapd, sta, buf, len, ok); break; default: printf("unknown TX callback frame type %d\n", type); break; } #endif }
static void handle_tx_callback(hostapd *hapd, char *buf, size_t len, int ok) { struct ieee80211_hdr *hdr; u16 fc, type, stype; struct sta_info *sta; hdr = (struct ieee80211_hdr *) buf; fc = le_to_host16(hdr->frame_control); type = WLAN_FC_GET_TYPE(fc); stype = WLAN_FC_GET_STYPE(fc); switch (type) { case WLAN_FC_TYPE_MGMT: HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "MGMT (TX callback) %s\n", ok ? "ACK" : "fail"); ieee802_11_mgmt_cb(hapd, buf, len, stype, ok); break; case WLAN_FC_TYPE_CTRL: HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "CTRL (TX callback) %s\n", ok ? "ACK" : "fail"); break; case WLAN_FC_TYPE_DATA: HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "DATA (TX callback) %s\n", ok ? "ACK" : "fail"); sta = ap_get_sta(hapd, hdr->addr1); if (sta && sta->flags & WLAN_STA_PENDING_POLL) { HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "STA " MACSTR " %s pending activity poll\n", MAC2STR(sta->addr), ok ? "ACKed" : "did not ACK"); if (ok) sta->flags &= ~WLAN_STA_PENDING_POLL; } if (sta) ieee802_1x_tx_status(hapd, sta, buf, len, ok); break; default: printf("unknown TX callback frame type %d\n", type); break; } }
static void hostapd_mgmt_tx_cb(struct hostapd_data *hapd, const u8 *buf, size_t len, u16 stype, int ok) { struct ieee80211_hdr *hdr; struct hostapd_data *orig_hapd = hapd; hdr = (struct ieee80211_hdr *) buf; hapd = get_hapd_bssid(hapd->iface, get_hdr_bssid(hdr, len)); if (!hapd) return; if (hapd == HAPD_BROADCAST) { if (stype != WLAN_FC_STYPE_ACTION || len <= 25 || buf[24] != WLAN_ACTION_PUBLIC) return; hapd = get_hapd_bssid(orig_hapd->iface, hdr->addr2); if (!hapd || hapd == HAPD_BROADCAST) return; /* * Allow processing of TX status for a Public Action frame that * used wildcard BBSID. */ } ieee802_11_mgmt_cb(hapd, buf, len, stype, ok); }
static int test_driver_send_mgmt_frame(void *priv, const void *buf, size_t len, int flags) { struct test_driver_data *drv = priv; struct msghdr msg; struct iovec io[2]; const u8 *dest; int ret = 0, broadcast = 0; char desttxt[30]; struct sockaddr_un addr; struct dirent *dent; DIR *dir; struct ieee80211_hdr *hdr; u16 fc; if (drv->test_socket < 0 || len < 10 || drv->socket_dir == NULL) { wpa_printf(MSG_DEBUG, "%s: invalid parameters (sock=%d len=%lu" " socket_dir=%p)", __func__, drv->test_socket, (unsigned long) len, drv->socket_dir); return -1; } dest = buf; dest += 4; broadcast = memcmp(dest, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0; snprintf(desttxt, sizeof(desttxt), MACSTR, MAC2STR(dest)); io[0].iov_base = "MLME "; io[0].iov_len = 5; io[1].iov_base = (void *) buf; io[1].iov_len = len; memset(&msg, 0, sizeof(msg)); msg.msg_iov = io; msg.msg_iovlen = 2; dir = opendir(drv->socket_dir); if (dir == NULL) { perror("test_driver: opendir"); return -1; } while ((dent = readdir(dir))) { #ifdef _DIRENT_HAVE_D_TYPE /* Skip the file if it is not a socket. Also accept * DT_UNKNOWN (0) in case the C library or underlying file * system does not support d_type. */ if (dent->d_type != DT_SOCK && dent->d_type != DT_UNKNOWN) continue; #endif /* _DIRENT_HAVE_D_TYPE */ if (strcmp(dent->d_name, ".") == 0 || strcmp(dent->d_name, "..") == 0) continue; memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s", drv->socket_dir, dent->d_name); if (strcmp(addr.sun_path, drv->own_socket_path) == 0) continue; if (!broadcast && strstr(dent->d_name, desttxt) == NULL) continue; wpa_printf(MSG_DEBUG, "%s: Send management frame to %s", __func__, dent->d_name); msg.msg_name = &addr; msg.msg_namelen = sizeof(addr); ret = sendmsg(drv->test_socket, &msg, 0); if (ret < 0) perror("driver_test: sendmsg"); } closedir(dir); hdr = (struct ieee80211_hdr *) buf; fc = le_to_host16(hdr->frame_control); ieee802_11_mgmt_cb(drv->hapd, (u8 *) buf, len, WLAN_FC_GET_STYPE(fc), ret >= 0); return ret; }