]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
WPS: Share common function for building WSC ACK/NACK
authorJouni Malinen <jouni.malinen@atheros.com>
Thu, 4 Nov 2010 16:16:14 +0000 (18:16 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 4 Nov 2010 16:16:14 +0000 (18:16 +0200)
These are identical functions in Enrollee and Registrar and there
is no need to maintain two copies of the same functionality.

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

index 1897af32e9a1322015a69d9d5a75a2630e61a482..2790a3556bced44247c6945ae468747f0f6ea595 100644 (file)
@@ -653,3 +653,50 @@ u16 wps_config_methods_str2bin(const char *str)
 
        return methods;
 }
+
+
+struct wpabuf * wps_build_wsc_ack(struct wps_data *wps)
+{
+       struct wpabuf *msg;
+
+       wpa_printf(MSG_DEBUG, "WPS: Building Message WSC_ACK");
+
+       msg = wpabuf_alloc(1000);
+       if (msg == NULL)
+               return NULL;
+
+       if (wps_build_version(msg) ||
+           wps_build_msg_type(msg, WPS_WSC_ACK) ||
+           wps_build_enrollee_nonce(wps, msg) ||
+           wps_build_registrar_nonce(wps, msg) ||
+           wps_build_wfa_ext(msg, 0, NULL, 0)) {
+               wpabuf_free(msg);
+               return NULL;
+       }
+
+       return msg;
+}
+
+
+struct wpabuf * wps_build_wsc_nack(struct wps_data *wps)
+{
+       struct wpabuf *msg;
+
+       wpa_printf(MSG_DEBUG, "WPS: Building Message WSC_NACK");
+
+       msg = wpabuf_alloc(1000);
+       if (msg == NULL)
+               return NULL;
+
+       if (wps_build_version(msg) ||
+           wps_build_msg_type(msg, WPS_WSC_NACK) ||
+           wps_build_enrollee_nonce(wps, msg) ||
+           wps_build_registrar_nonce(wps, msg) ||
+           wps_build_config_error(msg, wps->config_error) ||
+           wps_build_wfa_ext(msg, 0, NULL, 0)) {
+               wpabuf_free(msg);
+               return NULL;
+       }
+
+       return msg;
+}
index 8d0d37c2122af773d43b06d2de70ce95a2087d02..b25b70067ce05d69c069d8dd4115208ef6f44174 100644 (file)
@@ -379,53 +379,6 @@ static struct wpabuf * wps_build_wsc_done(struct wps_data *wps)
 }
 
 
-static struct wpabuf * wps_build_wsc_ack(struct wps_data *wps)
-{
-       struct wpabuf *msg;
-
-       wpa_printf(MSG_DEBUG, "WPS: Building Message WSC_ACK");
-
-       msg = wpabuf_alloc(1000);
-       if (msg == NULL)
-               return NULL;
-
-       if (wps_build_version(msg) ||
-           wps_build_msg_type(msg, WPS_WSC_ACK) ||
-           wps_build_enrollee_nonce(wps, msg) ||
-           wps_build_registrar_nonce(wps, msg) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
-               wpabuf_free(msg);
-               return NULL;
-       }
-
-       return msg;
-}
-
-
-static struct wpabuf * wps_build_wsc_nack(struct wps_data *wps)
-{
-       struct wpabuf *msg;
-
-       wpa_printf(MSG_DEBUG, "WPS: Building Message WSC_NACK");
-
-       msg = wpabuf_alloc(1000);
-       if (msg == NULL)
-               return NULL;
-
-       if (wps_build_version(msg) ||
-           wps_build_msg_type(msg, WPS_WSC_NACK) ||
-           wps_build_enrollee_nonce(wps, msg) ||
-           wps_build_registrar_nonce(wps, msg) ||
-           wps_build_config_error(msg, wps->config_error) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
-               wpabuf_free(msg);
-               return NULL;
-       }
-
-       return msg;
-}
-
-
 struct wpabuf * wps_enrollee_get_msg(struct wps_data *wps,
                                     enum wsc_op_code *op_code)
 {
index e0f28bb19979c77b6032ef4e21fd7937562c0da3..9953efbca997dccbf1e6cde9b997e4feab124e62 100644 (file)
@@ -223,6 +223,9 @@ extern struct oob_device_data oob_ufd_device_data;
 extern struct oob_device_data oob_nfc_device_data;
 extern struct oob_nfc_device_data oob_nfc_pn531_device_data;
 
+struct wpabuf * wps_build_wsc_ack(struct wps_data *wps);
+struct wpabuf * wps_build_wsc_nack(struct wps_data *wps);
+
 /* wps_attr_parse.c */
 int wps_parse_msg(const struct wpabuf *msg, struct wps_parse_attr *attr);
 
index b2c76de98b58d8aa1e29fcdbb4dd00f767b7f735..b2c6f0063f42395811ab9ab0e42bf5d0cd5b0865 100644 (file)
@@ -1724,53 +1724,6 @@ static struct wpabuf * wps_build_m8(struct wps_data *wps)
 }
 
 
-static struct wpabuf * wps_build_wsc_ack(struct wps_data *wps)
-{
-       struct wpabuf *msg;
-
-       wpa_printf(MSG_DEBUG, "WPS: Building Message WSC_ACK");
-
-       msg = wpabuf_alloc(1000);
-       if (msg == NULL)
-               return NULL;
-
-       if (wps_build_version(msg) ||
-           wps_build_msg_type(msg, WPS_WSC_ACK) ||
-           wps_build_enrollee_nonce(wps, msg) ||
-           wps_build_registrar_nonce(wps, msg) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
-               wpabuf_free(msg);
-               return NULL;
-       }
-
-       return msg;
-}
-
-
-static struct wpabuf * wps_build_wsc_nack(struct wps_data *wps)
-{
-       struct wpabuf *msg;
-
-       wpa_printf(MSG_DEBUG, "WPS: Building Message WSC_NACK");
-
-       msg = wpabuf_alloc(1000);
-       if (msg == NULL)
-               return NULL;
-
-       if (wps_build_version(msg) ||
-           wps_build_msg_type(msg, WPS_WSC_NACK) ||
-           wps_build_enrollee_nonce(wps, msg) ||
-           wps_build_registrar_nonce(wps, msg) ||
-           wps_build_config_error(msg, wps->config_error) ||
-           wps_build_wfa_ext(msg, 0, NULL, 0)) {
-               wpabuf_free(msg);
-               return NULL;
-       }
-
-       return msg;
-}
-
-
 struct wpabuf * wps_registrar_get_msg(struct wps_data *wps,
                                      enum wsc_op_code *op_code)
 {