Use P2P_IE_VENDOR_TYPE more consistently

Previously, both this and combination of OUI_WFA and P2P_OUI_TYPE were
used. Using the full 32-bit value as a single operation saves a bit in
code size, so start moving towards using it more consistently when
writing or finding the P2P vendor specific element.

Signed-off-by: Rahul Jain <rahul.jain@samsung.com>
This commit is contained in:
Rahul Jain 2014-02-26 11:48:07 +05:30 committed by Jouni Malinen
parent 8714caa1c2
commit 8bc4372f37
5 changed files with 30 additions and 63 deletions

View File

@ -250,9 +250,8 @@ static int p2p_manager_disconnect(struct hostapd_data *hapd, u16 stype,
*pos++ = WLAN_EID_VENDOR_SPECIFIC; *pos++ = WLAN_EID_VENDOR_SPECIFIC;
*pos++ = 4 + 3 + 1; *pos++ = 4 + 3 + 1;
WPA_PUT_BE24(pos, OUI_WFA); WPA_PUT_BE32(pos, P2P_IE_VENDOR_TYPE);
pos += 3; pos += 4;
*pos++ = P2P_OUI_TYPE;
*pos++ = P2P_ATTR_MINOR_REASON_CODE; *pos++ = P2P_ATTR_MINOR_REASON_CODE;
WPA_PUT_LE16(pos, 1); WPA_PUT_LE16(pos, 1);

View File

@ -96,9 +96,8 @@ u8 * hostapd_eid_p2p_manage(struct hostapd_data *hapd, u8 *eid)
u8 bitmap; u8 bitmap;
*eid++ = WLAN_EID_VENDOR_SPECIFIC; *eid++ = WLAN_EID_VENDOR_SPECIFIC;
*eid++ = 4 + 3 + 1; *eid++ = 4 + 3 + 1;
WPA_PUT_BE24(eid, OUI_WFA); WPA_PUT_BE32(eid, P2P_IE_VENDOR_TYPE);
eid += 3; eid += 4;
*eid++ = P2P_OUI_TYPE;
*eid++ = P2P_ATTR_MANAGEABILITY; *eid++ = P2P_ATTR_MANAGEABILITY;
WPA_PUT_LE16(eid, 1); WPA_PUT_LE16(eid, 1);

View File

@ -1660,20 +1660,15 @@ static void p2p_rx_action_public(struct p2p_data *p2p, const u8 *da,
case WLAN_PA_VENDOR_SPECIFIC: case WLAN_PA_VENDOR_SPECIFIC:
data++; data++;
len--; len--;
if (len < 3) if (len < 4)
return; return;
if (WPA_GET_BE24(data) != OUI_WFA) if (WPA_GET_BE32(data) != P2P_IE_VENDOR_TYPE)
return; return;
data += 3; data += 4;
len -= 3; len -= 4;
if (len < 1)
return;
if (*data != P2P_OUI_TYPE) p2p_rx_p2p_action(p2p, sa, data, len, freq);
return;
p2p_rx_p2p_action(p2p, sa, data + 1, len - 1, freq);
break; break;
case WLAN_PA_GAS_INITIAL_REQ: case WLAN_PA_GAS_INITIAL_REQ:
p2p_rx_gas_initial_req(p2p, sa, data + 1, len - 1, freq); p2p_rx_gas_initial_req(p2p, sa, data + 1, len - 1, freq);
@ -1706,15 +1701,10 @@ void p2p_rx_action(struct p2p_data *p2p, const u8 *da, const u8 *sa,
if (len < 4) if (len < 4)
return; return;
if (WPA_GET_BE24(data) != OUI_WFA) if (WPA_GET_BE32(data) != P2P_IE_VENDOR_TYPE)
return; return;
data += 3; data += 4;
len -= 3; len -= 4;
if (*data != P2P_OUI_TYPE)
return;
data++;
len--;
/* P2P action frame */ /* P2P action frame */
p2p_dbg(p2p, "RX P2P Action from " MACSTR, MAC2STR(sa)); p2p_dbg(p2p, "RX P2P Action from " MACSTR, MAC2STR(sa));

View File

@ -17,8 +17,7 @@
void p2p_buf_add_action_hdr(struct wpabuf *buf, u8 subtype, u8 dialog_token) void p2p_buf_add_action_hdr(struct wpabuf *buf, u8 subtype, u8 dialog_token)
{ {
wpabuf_put_u8(buf, WLAN_ACTION_VENDOR_SPECIFIC); wpabuf_put_u8(buf, WLAN_ACTION_VENDOR_SPECIFIC);
wpabuf_put_be24(buf, OUI_WFA); wpabuf_put_be32(buf, P2P_IE_VENDOR_TYPE);
wpabuf_put_u8(buf, P2P_OUI_TYPE);
wpabuf_put_u8(buf, subtype); /* OUI Subtype */ wpabuf_put_u8(buf, subtype); /* OUI Subtype */
wpabuf_put_u8(buf, dialog_token); wpabuf_put_u8(buf, dialog_token);
@ -31,8 +30,7 @@ void p2p_buf_add_public_action_hdr(struct wpabuf *buf, u8 subtype,
{ {
wpabuf_put_u8(buf, WLAN_ACTION_PUBLIC); wpabuf_put_u8(buf, WLAN_ACTION_PUBLIC);
wpabuf_put_u8(buf, WLAN_PA_VENDOR_SPECIFIC); wpabuf_put_u8(buf, WLAN_PA_VENDOR_SPECIFIC);
wpabuf_put_be24(buf, OUI_WFA); wpabuf_put_be32(buf, P2P_IE_VENDOR_TYPE);
wpabuf_put_u8(buf, P2P_OUI_TYPE);
wpabuf_put_u8(buf, subtype); /* OUI Subtype */ wpabuf_put_u8(buf, subtype); /* OUI Subtype */
wpabuf_put_u8(buf, dialog_token); wpabuf_put_u8(buf, dialog_token);
@ -47,8 +45,7 @@ u8 * p2p_buf_add_ie_hdr(struct wpabuf *buf)
/* P2P IE header */ /* P2P IE header */
wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC); wpabuf_put_u8(buf, WLAN_EID_VENDOR_SPECIFIC);
len = wpabuf_put(buf, 1); /* IE length to be filled */ len = wpabuf_put(buf, 1); /* IE length to be filled */
wpabuf_put_be24(buf, OUI_WFA); wpabuf_put_be32(buf, P2P_IE_VENDOR_TYPE);
wpabuf_put_u8(buf, P2P_OUI_TYPE);
wpa_printf(MSG_DEBUG, "P2P: * P2P IE header"); wpa_printf(MSG_DEBUG, "P2P: * P2P IE header");
return len; return len;
} }

View File

@ -171,8 +171,7 @@ static struct wpabuf * p2p_build_sd_query(u16 update_indic,
/* ANQP Query Request Frame */ /* ANQP Query Request Frame */
len_pos = gas_anqp_add_element(buf, ANQP_VENDOR_SPECIFIC); len_pos = gas_anqp_add_element(buf, ANQP_VENDOR_SPECIFIC);
wpabuf_put_be24(buf, OUI_WFA); wpabuf_put_be32(buf, P2P_IE_VENDOR_TYPE);
wpabuf_put_u8(buf, P2P_OUI_TYPE);
wpabuf_put_le16(buf, update_indic); /* Service Update Indicator */ wpabuf_put_le16(buf, update_indic); /* Service Update Indicator */
wpabuf_put_buf(buf, tlvs); wpabuf_put_buf(buf, tlvs);
gas_anqp_set_element_len(buf, len_pos); gas_anqp_set_element_len(buf, len_pos);
@ -218,8 +217,7 @@ static struct wpabuf * p2p_build_sd_response(u8 dialog_token, u16 status_code,
if (tlvs) { if (tlvs) {
/* ANQP Query Response Frame */ /* ANQP Query Response Frame */
len_pos = gas_anqp_add_element(buf, ANQP_VENDOR_SPECIFIC); len_pos = gas_anqp_add_element(buf, ANQP_VENDOR_SPECIFIC);
wpabuf_put_be24(buf, OUI_WFA); wpabuf_put_be32(buf, P2P_IE_VENDOR_TYPE);
wpabuf_put_u8(buf, P2P_OUI_TYPE);
/* Service Update Indicator */ /* Service Update Indicator */
wpabuf_put_le16(buf, update_indic); wpabuf_put_le16(buf, update_indic);
wpabuf_put_buf(buf, tlvs); wpabuf_put_buf(buf, tlvs);
@ -250,8 +248,7 @@ static struct wpabuf * p2p_build_gas_comeback_resp(u8 dialog_token,
/* ANQP Query Response Frame */ /* ANQP Query Response Frame */
wpabuf_put_le16(buf, ANQP_VENDOR_SPECIFIC); /* Info ID */ wpabuf_put_le16(buf, ANQP_VENDOR_SPECIFIC); /* Info ID */
wpabuf_put_le16(buf, 3 + 1 + 2 + total_len); wpabuf_put_le16(buf, 3 + 1 + 2 + total_len);
wpabuf_put_be24(buf, OUI_WFA); wpabuf_put_be32(buf, P2P_IE_VENDOR_TYPE);
wpabuf_put_u8(buf, P2P_OUI_TYPE);
/* Service Update Indicator */ /* Service Update Indicator */
wpabuf_put_le16(buf, update_indic); wpabuf_put_le16(buf, update_indic);
} }
@ -393,17 +390,12 @@ void p2p_rx_gas_initial_req(struct p2p_data *p2p, const u8 *sa,
return; return;
} }
if (WPA_GET_BE24(pos) != OUI_WFA) { if (WPA_GET_BE32(pos) != P2P_IE_VENDOR_TYPE) {
p2p_dbg(p2p, "Unsupported ANQP OUI %06x", WPA_GET_BE24(pos)); p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
WPA_GET_BE32(pos));
return; return;
} }
pos += 3; pos += 4;
if (*pos != P2P_OUI_TYPE) {
p2p_dbg(p2p, "Unsupported ANQP vendor type %u", *pos);
return;
}
pos++;
if (pos + 2 > end) if (pos + 2 > end)
return; return;
@ -571,17 +563,12 @@ void p2p_rx_gas_initial_resp(struct p2p_data *p2p, const u8 *sa,
return; return;
} }
if (WPA_GET_BE24(pos) != OUI_WFA) { if (WPA_GET_BE32(pos) != P2P_IE_VENDOR_TYPE) {
p2p_dbg(p2p, "Unsupported ANQP OUI %06x", WPA_GET_BE24(pos)); p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
WPA_GET_BE32(pos));
return; return;
} }
pos += 3; pos += 4;
if (*pos != P2P_OUI_TYPE) {
p2p_dbg(p2p, "Unsupported ANQP vendor type %u", *pos);
return;
}
pos++;
if (pos + 2 > end) if (pos + 2 > end)
return; return;
@ -795,17 +782,12 @@ void p2p_rx_gas_comeback_resp(struct p2p_data *p2p, const u8 *sa,
if (pos + 4 > end) if (pos + 4 > end)
return; return;
if (WPA_GET_BE24(pos) != OUI_WFA) { if (WPA_GET_BE32(pos) != P2P_IE_VENDOR_TYPE) {
p2p_dbg(p2p, "Unsupported ANQP OUI %06x", WPA_GET_BE24(pos)); p2p_dbg(p2p, "Unsupported ANQP vendor OUI-type %08x",
WPA_GET_BE32(pos));
return; return;
} }
pos += 3; pos += 4;
if (*pos != P2P_OUI_TYPE) {
p2p_dbg(p2p, "Unsupported ANQP vendor type %u", *pos);
return;
}
pos++;
if (pos + 2 > end) if (pos + 2 > end)
return; return;