P2PS: Helper functions to build new P2P attributes

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Krishna Vamsi 2014-12-10 12:26:33 +05:30 committed by Jouni Malinen
parent 60d11488ff
commit 5f18501f46
2 changed files with 93 additions and 0 deletions

View file

@ -342,6 +342,91 @@ void p2p_buf_add_oob_go_neg_channel(struct wpabuf *buf, const char *country,
}
void p2p_buf_add_session_info(struct wpabuf *buf, const char *info)
{
size_t info_len = 0;
if (info && info[0])
info_len = os_strlen(info);
/* Session Information Data Info */
wpabuf_put_u8(buf, P2P_ATTR_SESSION_INFORMATION_DATA);
wpabuf_put_le16(buf, (u16) info_len);
if (info) {
wpabuf_put_data(buf, info, info_len);
wpa_printf(MSG_DEBUG, "P2P: * Session Info Data (%s)", info);
}
}
void p2p_buf_add_connection_capability(struct wpabuf *buf, u8 connection_cap)
{
/* Connection Capability Info */
wpabuf_put_u8(buf, P2P_ATTR_CONNECTION_CAPABILITY);
wpabuf_put_le16(buf, 1);
wpabuf_put_u8(buf, connection_cap);
wpa_printf(MSG_DEBUG, "P2P: * Connection Capability: 0x%x",
connection_cap);
}
void p2p_buf_add_advertisement_id(struct wpabuf *buf, u32 id, const u8 *mac)
{
if (!buf || !mac)
return;
/* Advertisement ID Info */
wpabuf_put_u8(buf, P2P_ATTR_ADVERTISEMENT_ID);
wpabuf_put_le16(buf, (u16) (sizeof(u32) + ETH_ALEN));
wpabuf_put_le32(buf, id);
wpabuf_put_data(buf, mac, ETH_ALEN);
wpa_printf(MSG_DEBUG, "P2P: * Advertisement ID (%x) " MACSTR,
id, MAC2STR(mac));
}
void p2p_buf_add_session_id(struct wpabuf *buf, u32 id, const u8 *mac)
{
if (!buf || !mac)
return;
/* Session ID Info */
wpabuf_put_u8(buf, P2P_ATTR_SESSION_ID);
wpabuf_put_le16(buf, (u16) (sizeof(u32) + ETH_ALEN));
wpabuf_put_le32(buf, id);
wpabuf_put_data(buf, mac, ETH_ALEN);
wpa_printf(MSG_DEBUG, "P2P: * Session ID Info (%x) " MACSTR,
id, MAC2STR(mac));
}
void p2p_buf_add_feature_capability(struct wpabuf *buf, u16 len, const u8 *mask)
{
if (!buf || !len || !mask)
return;
/* Feature Capability */
wpabuf_put_u8(buf, P2P_ATTR_FEATURE_CAPABILITY);
wpabuf_put_le16(buf, len);
wpabuf_put_data(buf, mask, len);
wpa_printf(MSG_DEBUG, "P2P: * Feature Capability (%d)", len);
}
void p2p_buf_add_persistent_group_info(struct wpabuf *buf, const u8 *dev_addr,
const u8 *ssid, size_t ssid_len)
{
/* P2P Group ID */
wpabuf_put_u8(buf, P2P_ATTR_PERSISTENT_GROUP);
wpabuf_put_le16(buf, ETH_ALEN + ssid_len);
wpabuf_put_data(buf, dev_addr, ETH_ALEN);
wpabuf_put_data(buf, ssid, ssid_len);
wpa_printf(MSG_DEBUG, "P2P: * P2P Group ID " MACSTR,
MAC2STR(dev_addr));
}
static int p2p_add_wps_string(struct wpabuf *buf, enum wps_attribute attr,
const char *val)
{

View file

@ -723,6 +723,14 @@ void p2p_buf_add_p2p_interface(struct wpabuf *buf, struct p2p_data *p2p);
void p2p_buf_add_oob_go_neg_channel(struct wpabuf *buf, const char *country,
u8 oper_class, u8 channel,
enum p2p_role_indication role);
void p2p_buf_add_session_info(struct wpabuf *buf, const char *info);
void p2p_buf_add_connection_capability(struct wpabuf *buf, u8 connection_cap);
void p2p_buf_add_advertisement_id(struct wpabuf *buf, u32 id, const u8 *mac);
void p2p_buf_add_session_id(struct wpabuf *buf, u32 id, const u8 *mac);
void p2p_buf_add_feature_capability(struct wpabuf *buf, u16 len,
const u8 *mask);
void p2p_buf_add_persistent_group_info(struct wpabuf *buf, const u8 *dev_addr,
const u8 *ssid, size_t ssid_len);
int p2p_build_wps_ie(struct p2p_data *p2p, struct wpabuf *buf, int pw_id,
int all_attr);