]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P NFC: Add NDEF helpers for P2P connection handover messages
authorJouni Malinen <jouni@qca.qualcomm.com>
Sat, 27 Apr 2013 14:55:20 +0000 (17:55 +0300)
committerJouni Malinen <j@w1.fi>
Mon, 27 Jan 2014 19:10:55 +0000 (21:10 +0200)
Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

src/wps/ndef.c
src/wps/wps.h

index ceeb482395984443754e3383f07a3ace9d599b67..2b3506476e1312c5cd0bf65aebb61694c1eb67ce 100644 (file)
@@ -30,6 +30,7 @@ struct ndef_record {
 };
 
 static char wifi_handover_type[] = "application/vnd.wfa.wsc";
+static char p2p_handover_type[] = "application/vnd.wfa.p2p";
 
 static int ndef_parse_record(const u8 *data, u32 size,
                             struct ndef_record *record)
@@ -168,3 +169,28 @@ struct wpabuf * ndef_build_wifi(const struct wpabuf *buf)
                                 FLAG_TNF_RFC2046, wifi_handover_type,
                                 os_strlen(wifi_handover_type), NULL, 0, buf);
 }
+
+
+static int p2p_filter(struct ndef_record *record)
+{
+       if (record->type_length != os_strlen(p2p_handover_type))
+               return 0;
+       if (os_memcmp(record->type, p2p_handover_type,
+                     os_strlen(p2p_handover_type)) != 0)
+               return 0;
+       return 1;
+}
+
+
+struct wpabuf * ndef_parse_p2p(const struct wpabuf *buf)
+{
+       return ndef_parse_records(buf, p2p_filter);
+}
+
+
+struct wpabuf * ndef_build_p2p(const struct wpabuf *buf)
+{
+       return ndef_build_record(FLAG_MESSAGE_BEGIN | FLAG_MESSAGE_END |
+                                FLAG_TNF_RFC2046, p2p_handover_type,
+                                os_strlen(p2p_handover_type), NULL, 0, buf);
+}
index 5ad7725e499301fbcb6210912a7ed073d40783f0..f185d0587a978e6388ad62acefba1a78acd68672 100644 (file)
@@ -872,6 +872,8 @@ struct wpabuf * wps_build_nfc_handover_sel(struct wps_context *ctx,
 /* ndef.c */
 struct wpabuf * ndef_parse_wifi(const struct wpabuf *buf);
 struct wpabuf * ndef_build_wifi(const struct wpabuf *buf);
+struct wpabuf * ndef_parse_p2p(const struct wpabuf *buf);
+struct wpabuf * ndef_build_p2p(const struct wpabuf *buf);
 
 #ifdef CONFIG_WPS_STRICT
 int wps_validate_beacon(const struct wpabuf *wps_ie);