]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
DPP2: Move connStatus object building into a helper function
authorJouni Malinen <jouni@codeaurora.org>
Sat, 9 May 2020 13:40:44 +0000 (16:40 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 11 May 2020 13:41:33 +0000 (16:41 +0300)
Allow the same helper function to be used for reconfiguration.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/common/dpp.c
src/common/dpp_i.h

index d2bf5cf920c10dd83136271bb9b2ec4e96ae273c..4b34b4f0582ef641203f1a6f514842a91baad214 100644 (file)
@@ -6165,16 +6165,11 @@ fail:
 }
 
 
-struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth,
-                                            enum dpp_status_error result,
-                                            const u8 *ssid, size_t ssid_len,
-                                            const char *channel_list)
+struct wpabuf * dpp_build_conn_status(enum dpp_status_error result,
+                                     const u8 *ssid, size_t ssid_len,
+                                     const char *channel_list)
 {
-       struct wpabuf *msg = NULL, *clear = NULL, *json;
-       size_t nonce_len, clear_len, attr_len;
-       const u8 *addr[2];
-       size_t len[2];
-       u8 *wrapped;
+       struct wpabuf *json;
 
        json = wpabuf_alloc(1000);
        if (!json)
@@ -6183,8 +6178,10 @@ struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth,
        json_add_int(json, "result", result);
        if (ssid) {
                json_value_sep(json);
-               if (json_add_base64url(json, "ssid64", ssid, ssid_len) < 0)
-                       goto fail;
+               if (json_add_base64url(json, "ssid64", ssid, ssid_len) < 0) {
+                       wpabuf_free(json);
+                       return NULL;
+               }
        }
        if (channel_list) {
                json_value_sep(json);
@@ -6194,6 +6191,25 @@ struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth,
        wpa_hexdump_ascii(MSG_DEBUG, "DPP: connStatus JSON",
                          wpabuf_head(json), wpabuf_len(json));
 
+       return json;
+}
+
+
+struct wpabuf * dpp_build_conn_status_result(struct dpp_authentication *auth,
+                                            enum dpp_status_error result,
+                                            const u8 *ssid, size_t ssid_len,
+                                            const char *channel_list)
+{
+       struct wpabuf *msg = NULL, *clear = NULL, *json;
+       size_t nonce_len, clear_len, attr_len;
+       const u8 *addr[2];
+       size_t len[2];
+       u8 *wrapped;
+
+       json = dpp_build_conn_status(result, ssid, ssid_len, channel_list);
+       if (!json)
+               return NULL;
+
        nonce_len = auth->curve->nonce_len;
        clear_len = 5 + 4 + nonce_len + 4 + wpabuf_len(json);
        attr_len = 4 + clear_len + AES_BLOCK_SIZE;
index 5a8fa9454deeb407bbf0c5d177fbfcd95a13aa68..402b7cbfeacb9ed5a7dacbaa3f1f73306054ae99 100644 (file)
@@ -30,6 +30,9 @@ struct dpp_global {
 
 void dpp_build_attr_status(struct wpabuf *msg, enum dpp_status_error status);
 unsigned int dpp_next_id(struct dpp_global *dpp);
+struct wpabuf * dpp_build_conn_status(enum dpp_status_error result,
+                                     const u8 *ssid, size_t ssid_len,
+                                     const char *channel_list);
 struct json_token * dpp_parse_own_connector(const char *own_connector);
 
 /* dpp_crypto.c */