2 * hostapd / P2P integration
3 * Copyright (c) 2009-2010, Atheros Communications
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
15 #include "utils/includes.h"
17 #include "utils/common.h"
18 #include "common/ieee802_11_defs.h"
21 #include "ap_config.h"
22 #include "ap_drv_ops.h"
24 #include "p2p_hostapd.h"
29 int hostapd_p2p_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta,
30 char *buf, size_t buflen)
32 if (sta->p2p_ie == NULL)
35 return p2p_ie_text(sta->p2p_ie, buf, buf + buflen);
39 int hostapd_p2p_set_noa(struct hostapd_data *hapd, u8 count, int start,
42 wpa_printf(MSG_DEBUG, "P2P: Set NoA parameters: count=%u start=%d "
43 "duration=%d", count, start, duration);
46 hapd->noa_enabled = 0;
48 hapd->noa_duration = 0;
52 wpa_printf(MSG_DEBUG, "P2P: Non-periodic NoA - set "
54 return hostapd_driver_set_noa(hapd, count, start, duration);
57 hapd->noa_enabled = 1;
58 hapd->noa_start = start;
59 hapd->noa_duration = duration;
61 if (hapd->num_sta_no_p2p == 0) {
62 wpa_printf(MSG_DEBUG, "P2P: No legacy STAs connected - update "
63 "periodic NoA parameters");
64 return hostapd_driver_set_noa(hapd, count, start, duration);
67 wpa_printf(MSG_DEBUG, "P2P: Legacy STA(s) connected - do not enable "
74 void hostapd_p2p_non_p2p_sta_connected(struct hostapd_data *hapd)
76 wpa_printf(MSG_DEBUG, "P2P: First non-P2P device connected");
78 if (hapd->noa_enabled) {
79 wpa_printf(MSG_DEBUG, "P2P: Disable periodic NoA");
80 hostapd_driver_set_noa(hapd, 0, 0, 0);
85 void hostapd_p2p_non_p2p_sta_disconnected(struct hostapd_data *hapd)
87 wpa_printf(MSG_DEBUG, "P2P: Last non-P2P device disconnected");
89 if (hapd->noa_enabled) {
90 wpa_printf(MSG_DEBUG, "P2P: Enable periodic NoA");
91 hostapd_driver_set_noa(hapd, 255, hapd->noa_start,
96 #endif /* CONFIG_P2P */
99 #ifdef CONFIG_P2P_MANAGER
100 u8 * hostapd_eid_p2p_manage(struct hostapd_data *hapd, u8 *eid)
103 *eid++ = WLAN_EID_VENDOR_SPECIFIC;
105 WPA_PUT_BE24(eid, OUI_WFA);
107 *eid++ = P2P_OUI_TYPE;
109 *eid++ = P2P_ATTR_MANAGEABILITY;
110 WPA_PUT_LE16(eid, 1);
112 bitmap = P2P_MAN_DEVICE_MANAGEMENT;
113 if (hapd->conf->p2p & P2P_ALLOW_CROSS_CONNECTION)
114 bitmap |= P2P_MAN_CROSS_CONNECTION_PERMITTED;
115 bitmap |= P2P_MAN_COEXISTENCE_OPTIONAL;
120 #endif /* CONFIG_P2P_MANAGER */