]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
NDEF: Skip unnecessary wpabuf to ptr/len conversion
authorJouni Malinen <j@w1.fi>
Wed, 27 Jun 2012 15:11:46 +0000 (18:11 +0300)
committerJouni Malinen <j@w1.fi>
Wed, 27 Jun 2012 18:22:12 +0000 (21:22 +0300)
Signed-hostap: Jouni Malinen <j@w1.fi>

src/wps/ndef.c

index 6128917a6e2dafc1595059e09b3dcd65f91d3465..43412f7192f48366ef576daa96e2ba79ce1c0580 100644 (file)
@@ -97,13 +97,14 @@ static struct wpabuf * ndef_parse_records(struct wpabuf *buf,
 
 static struct wpabuf * ndef_build_record(u8 flags, void *type,
                                         u8 type_length, void *id,
-                                        u8 id_length, void *payload,
-                                        u32 payload_length)
+                                        u8 id_length,
+                                        const struct wpabuf *payload)
 {
        struct wpabuf *record;
        size_t total_len;
        int short_record;
        u8 local_flag;
+       size_t payload_length = wpabuf_len(payload);
 
        short_record = payload_length < 256 ? 1 : 0;
 
@@ -138,7 +139,7 @@ static struct wpabuf * ndef_build_record(u8 flags, void *type,
                wpabuf_put_u8(record, id_length);
        wpabuf_put_data(record, type, type_length);
        wpabuf_put_data(record, id, id_length);
-       wpabuf_put_data(record, payload, payload_length);
+       wpabuf_put_buf(record, payload);
        return record;
 }
 
@@ -164,6 +165,5 @@ struct wpabuf * ndef_build_wifi(struct wpabuf *buf)
 {
        return ndef_build_record(FLAG_MESSAGE_BEGIN | FLAG_MESSAGE_END |
                                 FLAG_TNF_RFC2046, wifi_handover_type,
-                                os_strlen(wifi_handover_type), NULL, 0,
-                                wpabuf_mhead(buf), wpabuf_len(buf));
+                                os_strlen(wifi_handover_type), NULL, 0, buf);
 }