WPS: Use generic MAC Address attribute builder
authorJouni Malinen <j@w1.fi>
Sat, 27 Apr 2013 19:13:36 +0000 (22:13 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 27 Apr 2013 19:13:36 +0000 (22:13 +0300)
Signed-hostap: Jouni Malinen <j@w1.fi>

src/wps/wps_attr_build.c
src/wps/wps_enrollee.c
src/wps/wps_i.h
src/wps/wps_registrar.c

index edcc18c..ac9bb1e 100644 (file)
@@ -417,3 +417,14 @@ struct wpabuf * wps_ie_encapsulate(struct wpabuf *data)
 
        return ie;
 }
+
+
+int wps_build_mac_addr(struct wpabuf *msg, const u8 *addr)
+{
+       wpa_printf(MSG_DEBUG, "WPS:  * MAC Address (" MACSTR ")",
+                  MAC2STR(addr));
+       wpabuf_put_be16(msg, ATTR_MAC_ADDR);
+       wpabuf_put_be16(msg, ETH_ALEN);
+       wpabuf_put_data(msg, addr, ETH_ALEN);
+       return 0;
+}
index 9c0cebb..1af43c2 100644 (file)
 #include "wps_dev_attr.h"
 
 
-static int wps_build_mac_addr(struct wps_data *wps, struct wpabuf *msg)
-{
-       wpa_printf(MSG_DEBUG, "WPS:  * MAC Address");
-       wpabuf_put_be16(msg, ATTR_MAC_ADDR);
-       wpabuf_put_be16(msg, ETH_ALEN);
-       wpabuf_put_data(msg, wps->mac_addr_e, ETH_ALEN);
-       return 0;
-}
-
-
 static int wps_build_wps_state(struct wps_data *wps, struct wpabuf *msg)
 {
        u8 state;
@@ -149,7 +139,7 @@ static struct wpabuf * wps_build_m1(struct wps_data *wps)
        if (wps_build_version(msg) ||
            wps_build_msg_type(msg, WPS_M1) ||
            wps_build_uuid_e(msg, wps->uuid_e) ||
-           wps_build_mac_addr(wps, msg) ||
+           wps_build_mac_addr(msg, wps->mac_addr_e) ||
            wps_build_enrollee_nonce(wps, msg) ||
            wps_build_public_key(wps, msg) ||
            wps_build_auth_type_flags(wps, msg) ||
index 6efc3bf..354df28 100644 (file)
@@ -169,6 +169,7 @@ int wps_build_oob_dev_pw(struct wpabuf *msg, u16 dev_pw_id,
                         const struct wpabuf *pubkey, const u8 *dev_pw,
                         size_t dev_pw_len);
 struct wpabuf * wps_ie_encapsulate(struct wpabuf *data);
+int wps_build_mac_addr(struct wpabuf *msg, const u8 *addr);
 
 /* wps_attr_process.c */
 int wps_process_authenticator(struct wps_data *wps, const u8 *authenticator,
index a26b8ee..b4f9335 100644 (file)
@@ -1526,18 +1526,6 @@ static int wps_build_cred_network_key(struct wpabuf *msg,
 }
 
 
-static int wps_build_cred_mac_addr(struct wpabuf *msg,
-                                  const struct wps_credential *cred)
-{
-       wpa_printf(MSG_DEBUG, "WPS:  * MAC Address (" MACSTR ")",
-                  MAC2STR(cred->mac_addr));
-       wpabuf_put_be16(msg, ATTR_MAC_ADDR);
-       wpabuf_put_be16(msg, ETH_ALEN);
-       wpabuf_put_data(msg, cred->mac_addr, ETH_ALEN);
-       return 0;
-}
-
-
 static int wps_build_credential(struct wpabuf *msg,
                                const struct wps_credential *cred)
 {
@@ -1546,7 +1534,7 @@ static int wps_build_credential(struct wpabuf *msg,
            wps_build_cred_auth_type(msg, cred) ||
            wps_build_cred_encr_type(msg, cred) ||
            wps_build_cred_network_key(msg, cred) ||
-           wps_build_cred_mac_addr(msg, cred))
+           wps_build_mac_addr(msg, cred->mac_addr))
                return -1;
        return 0;
 }