P2P: Extend P2P manager functionality to work with driver MLME
Add P2P IE into Beacon, Probe Response, and (Re)Association Request frames for drivers that generate this frames internally.
This commit is contained in:
parent
b74c19faf5
commit
dce044cce5
7 changed files with 96 additions and 29 deletions
|
@ -719,6 +719,11 @@ ifdef CONFIG_IEEE80211N
|
||||||
OBJS += ../src/ap/ieee802_11_ht.o
|
OBJS += ../src/ap/ieee802_11_ht.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef CONFIG_P2P_MANAGER
|
||||||
|
CFLAGS += -DCONFIG_P2P_MANAGER
|
||||||
|
OBJS += ../src/ap/p2p_hostapd.o
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef CONFIG_NO_STDOUT_DEBUG
|
ifdef CONFIG_NO_STDOUT_DEBUG
|
||||||
CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
|
CFLAGS += -DCONFIG_NO_STDOUT_DEBUG
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "ieee802_11.h"
|
#include "ieee802_11.h"
|
||||||
#include "sta_info.h"
|
#include "sta_info.h"
|
||||||
#include "ap_config.h"
|
#include "ap_config.h"
|
||||||
|
#include "p2p_hostapd.h"
|
||||||
#include "ap_drv_ops.h"
|
#include "ap_drv_ops.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,18 +87,70 @@ static int hostapd_set_ap_wps_ie(struct hostapd_data *hapd)
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_P2P */
|
#endif /* CONFIG_P2P */
|
||||||
|
|
||||||
|
#ifdef CONFIG_P2P_MANAGER
|
||||||
|
if (hapd->conf->p2p & P2P_MANAGE) {
|
||||||
|
struct wpabuf *a;
|
||||||
|
|
||||||
|
a = wpabuf_alloc(100 + (beacon ? wpabuf_len(beacon) : 0));
|
||||||
|
if (a) {
|
||||||
|
u8 *start, *p;
|
||||||
|
if (beacon)
|
||||||
|
wpabuf_put_buf(a, beacon);
|
||||||
|
if (beacon != hapd->wps_beacon_ie)
|
||||||
|
wpabuf_free(beacon);
|
||||||
|
start = wpabuf_put(a, 0);
|
||||||
|
p = hostapd_eid_p2p_manage(hapd, start);
|
||||||
|
wpabuf_put(a, p - start);
|
||||||
|
beacon = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
a = wpabuf_alloc(100 + (proberesp ? wpabuf_len(proberesp) :
|
||||||
|
0));
|
||||||
|
if (a) {
|
||||||
|
u8 *start, *p;
|
||||||
|
if (proberesp)
|
||||||
|
wpabuf_put_buf(a, proberesp);
|
||||||
|
if (proberesp != hapd->wps_probe_resp_ie)
|
||||||
|
wpabuf_free(proberesp);
|
||||||
|
start = wpabuf_put(a, 0);
|
||||||
|
p = hostapd_eid_p2p_manage(hapd, start);
|
||||||
|
wpabuf_put(a, p - start);
|
||||||
|
proberesp = a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_P2P_MANAGER */
|
||||||
|
|
||||||
#ifdef CONFIG_WPS2
|
#ifdef CONFIG_WPS2
|
||||||
if (hapd->conf->wps_state)
|
if (hapd->conf->wps_state)
|
||||||
assocresp = wps_build_assoc_resp_ie();
|
assocresp = wps_build_assoc_resp_ie();
|
||||||
#endif /* CONFIG_WPS2 */
|
#endif /* CONFIG_WPS2 */
|
||||||
|
|
||||||
|
#ifdef CONFIG_P2P_MANAGER
|
||||||
|
if (hapd->conf->p2p & P2P_MANAGE) {
|
||||||
|
struct wpabuf *a;
|
||||||
|
a = wpabuf_alloc(100 + (assocresp ? wpabuf_len(assocresp) :
|
||||||
|
0));
|
||||||
|
if (a) {
|
||||||
|
u8 *start, *p;
|
||||||
|
start = wpabuf_put(a, 0);
|
||||||
|
p = hostapd_eid_p2p_manage(hapd, start);
|
||||||
|
wpabuf_put(a, p - start);
|
||||||
|
if (assocresp) {
|
||||||
|
wpabuf_put_buf(a, assocresp);
|
||||||
|
wpabuf_free(assocresp);
|
||||||
|
}
|
||||||
|
assocresp = a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_P2P_MANAGER */
|
||||||
|
|
||||||
ret = hapd->driver->set_ap_wps_ie(hapd->drv_priv, beacon, proberesp,
|
ret = hapd->driver->set_ap_wps_ie(hapd->drv_priv, beacon, proberesp,
|
||||||
assocresp);
|
assocresp);
|
||||||
|
|
||||||
#ifdef CONFIG_P2P
|
if (beacon != hapd->wps_beacon_ie)
|
||||||
wpabuf_free(beacon);
|
wpabuf_free(beacon);
|
||||||
wpabuf_free(proberesp);
|
if (proberesp != hapd->wps_probe_resp_ie)
|
||||||
#endif /* CONFIG_P2P */
|
wpabuf_free(proberesp);
|
||||||
wpabuf_free(assocresp);
|
wpabuf_free(assocresp);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "wmm.h"
|
#include "wmm.h"
|
||||||
#include "ap_config.h"
|
#include "ap_config.h"
|
||||||
#include "sta_info.h"
|
#include "sta_info.h"
|
||||||
|
#include "p2p_hostapd.h"
|
||||||
#include "beacon.h"
|
#include "beacon.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,30 +196,6 @@ static u8 * hostapd_eid_wpa(struct hostapd_data *hapd, u8 *eid, size_t len,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_P2P_MANAGER
|
|
||||||
u8 * hostapd_eid_p2p_manage(struct hostapd_data *hapd, u8 *eid)
|
|
||||||
{
|
|
||||||
u8 bitmap;
|
|
||||||
*eid++ = WLAN_EID_VENDOR_SPECIFIC;
|
|
||||||
*eid++ = 4 + 3 + 1;
|
|
||||||
WPA_PUT_BE24(eid, OUI_WFA);
|
|
||||||
eid += 3;
|
|
||||||
*eid++ = P2P_OUI_TYPE;
|
|
||||||
|
|
||||||
*eid++ = P2P_ATTR_MANAGEABILITY;
|
|
||||||
WPA_PUT_LE16(eid, 1);
|
|
||||||
eid += 2;
|
|
||||||
bitmap = P2P_MAN_DEVICE_MANAGEMENT;
|
|
||||||
if (hapd->conf->p2p & P2P_ALLOW_CROSS_CONNECTION)
|
|
||||||
bitmap |= P2P_MAN_CROSS_CONNECTION_PERMITTED;
|
|
||||||
bitmap |= P2P_MAN_COEXISTENCE_OPTIONAL;
|
|
||||||
*eid++ = bitmap;
|
|
||||||
|
|
||||||
return eid;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_P2P_MANAGER */
|
|
||||||
|
|
||||||
|
|
||||||
void handle_probe_req(struct hostapd_data *hapd,
|
void handle_probe_req(struct hostapd_data *hapd,
|
||||||
const struct ieee80211_mgmt *mgmt, size_t len)
|
const struct ieee80211_mgmt *mgmt, size_t len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,6 @@ struct ieee80211_mgmt;
|
||||||
|
|
||||||
void handle_probe_req(struct hostapd_data *hapd,
|
void handle_probe_req(struct hostapd_data *hapd,
|
||||||
const struct ieee80211_mgmt *mgmt, size_t len);
|
const struct ieee80211_mgmt *mgmt, size_t len);
|
||||||
u8 * hostapd_eid_p2p_manage(struct hostapd_data *hapd, u8 *eid);
|
|
||||||
#ifdef NEED_AP_MLME
|
#ifdef NEED_AP_MLME
|
||||||
void ieee802_11_set_beacon(struct hostapd_data *hapd);
|
void ieee802_11_set_beacon(struct hostapd_data *hapd);
|
||||||
void ieee802_11_set_beacons(struct hostapd_iface *iface);
|
void ieee802_11_set_beacons(struct hostapd_iface *iface);
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#include "accounting.h"
|
#include "accounting.h"
|
||||||
#include "ap_config.h"
|
#include "ap_config.h"
|
||||||
#include "ap_mlme.h"
|
#include "ap_mlme.h"
|
||||||
|
#include "p2p_hostapd.h"
|
||||||
#include "ieee802_11.h"
|
#include "ieee802_11.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,17 @@
|
||||||
#include "utils/includes.h"
|
#include "utils/includes.h"
|
||||||
|
|
||||||
#include "utils/common.h"
|
#include "utils/common.h"
|
||||||
|
#include "common/ieee802_11_defs.h"
|
||||||
#include "p2p/p2p.h"
|
#include "p2p/p2p.h"
|
||||||
#include "hostapd.h"
|
#include "hostapd.h"
|
||||||
|
#include "ap_config.h"
|
||||||
#include "ap_drv_ops.h"
|
#include "ap_drv_ops.h"
|
||||||
#include "sta_info.h"
|
#include "sta_info.h"
|
||||||
#include "p2p_hostapd.h"
|
#include "p2p_hostapd.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_P2P
|
||||||
|
|
||||||
int hostapd_p2p_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
int hostapd_p2p_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
||||||
char *buf, size_t buflen)
|
char *buf, size_t buflen)
|
||||||
{
|
{
|
||||||
|
@ -88,3 +92,29 @@ void hostapd_p2p_non_p2p_sta_disconnected(struct hostapd_data *hapd)
|
||||||
hapd->noa_duration);
|
hapd->noa_duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_P2P */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CONFIG_P2P_MANAGER
|
||||||
|
u8 * hostapd_eid_p2p_manage(struct hostapd_data *hapd, u8 *eid)
|
||||||
|
{
|
||||||
|
u8 bitmap;
|
||||||
|
*eid++ = WLAN_EID_VENDOR_SPECIFIC;
|
||||||
|
*eid++ = 4 + 3 + 1;
|
||||||
|
WPA_PUT_BE24(eid, OUI_WFA);
|
||||||
|
eid += 3;
|
||||||
|
*eid++ = P2P_OUI_TYPE;
|
||||||
|
|
||||||
|
*eid++ = P2P_ATTR_MANAGEABILITY;
|
||||||
|
WPA_PUT_LE16(eid, 1);
|
||||||
|
eid += 2;
|
||||||
|
bitmap = P2P_MAN_DEVICE_MANAGEMENT;
|
||||||
|
if (hapd->conf->p2p & P2P_ALLOW_CROSS_CONNECTION)
|
||||||
|
bitmap |= P2P_MAN_CROSS_CONNECTION_PERMITTED;
|
||||||
|
bitmap |= P2P_MAN_COEXISTENCE_OPTIONAL;
|
||||||
|
*eid++ = bitmap;
|
||||||
|
|
||||||
|
return eid;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_P2P_MANAGER */
|
||||||
|
|
|
@ -36,4 +36,6 @@ static inline int hostapd_p2p_get_mib_sta(struct hostapd_data *hapd,
|
||||||
|
|
||||||
#endif /* CONFIG_P2P */
|
#endif /* CONFIG_P2P */
|
||||||
|
|
||||||
|
u8 * hostapd_eid_p2p_manage(struct hostapd_data *hapd, u8 *eid);
|
||||||
|
|
||||||
#endif /* P2P_HOSTAPD_H */
|
#endif /* P2P_HOSTAPD_H */
|
||||||
|
|
Loading…
Reference in a new issue