2 * hostapd / P2P integration
3 * Copyright (c) 2009-2010, Atheros Communications
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
11 #include "utils/common.h"
12 #include "common/ieee802_11_defs.h"
15 #include "ap_config.h"
16 #include "ap_drv_ops.h"
18 #include "p2p_hostapd.h"
23 int hostapd_p2p_get_mib_sta(struct hostapd_data
*hapd
, struct sta_info
*sta
,
24 char *buf
, size_t buflen
)
26 if (sta
->p2p_ie
== NULL
)
29 return p2p_ie_text(sta
->p2p_ie
, buf
, buf
+ buflen
);
33 int hostapd_p2p_set_noa(struct hostapd_data
*hapd
, u8 count
, int start
,
36 wpa_printf(MSG_DEBUG
, "P2P: Set NoA parameters: count=%u start=%d "
37 "duration=%d", count
, start
, duration
);
40 hapd
->noa_enabled
= 0;
42 hapd
->noa_duration
= 0;
46 wpa_printf(MSG_DEBUG
, "P2P: Non-periodic NoA - set "
48 return hostapd_driver_set_noa(hapd
, count
, start
, duration
);
51 hapd
->noa_enabled
= 1;
52 hapd
->noa_start
= start
;
53 hapd
->noa_duration
= duration
;
55 if (hapd
->num_sta_no_p2p
== 0) {
56 wpa_printf(MSG_DEBUG
, "P2P: No legacy STAs connected - update "
57 "periodic NoA parameters");
58 return hostapd_driver_set_noa(hapd
, count
, start
, duration
);
61 wpa_printf(MSG_DEBUG
, "P2P: Legacy STA(s) connected - do not enable "
68 void hostapd_p2p_non_p2p_sta_connected(struct hostapd_data
*hapd
)
70 wpa_printf(MSG_DEBUG
, "P2P: First non-P2P device connected");
72 if (hapd
->noa_enabled
) {
73 wpa_printf(MSG_DEBUG
, "P2P: Disable periodic NoA");
74 hostapd_driver_set_noa(hapd
, 0, 0, 0);
79 void hostapd_p2p_non_p2p_sta_disconnected(struct hostapd_data
*hapd
)
81 wpa_printf(MSG_DEBUG
, "P2P: Last non-P2P device disconnected");
83 if (hapd
->noa_enabled
) {
84 wpa_printf(MSG_DEBUG
, "P2P: Enable periodic NoA");
85 hostapd_driver_set_noa(hapd
, 255, hapd
->noa_start
,
90 #endif /* CONFIG_P2P */
93 #ifdef CONFIG_P2P_MANAGER
94 u8
* hostapd_eid_p2p_manage(struct hostapd_data
*hapd
, u8
*eid
)
97 *eid
++ = WLAN_EID_VENDOR_SPECIFIC
;
99 WPA_PUT_BE24(eid
, OUI_WFA
);
101 *eid
++ = P2P_OUI_TYPE
;
103 *eid
++ = P2P_ATTR_MANAGEABILITY
;
104 WPA_PUT_LE16(eid
, 1);
106 bitmap
= P2P_MAN_DEVICE_MANAGEMENT
;
107 if (hapd
->conf
->p2p
& P2P_ALLOW_CROSS_CONNECTION
)
108 bitmap
|= P2P_MAN_CROSS_CONNECTION_PERMITTED
;
109 bitmap
|= P2P_MAN_COEXISTENCE_OPTIONAL
;
114 #endif /* CONFIG_P2P_MANAGER */