aboutsummaryrefslogtreecommitdiffstats
path: root/src/wps
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2012-06-27 19:51:11 +0300
committerJouni Malinen <j@w1.fi>2012-06-27 21:22:12 +0300
commit8a13732f832d4300cdb2a2a16d0139248dfbeac4 (patch)
tree7d1393e2650ed4fb4c32d1fbe8f43dece2ae1fe6 /src/wps
parent2f425090fb100c8d0469727e64b3106f721b6096 (diff)
downloadexternal_wpa_supplicant_8_ti-8a13732f832d4300cdb2a2a16d0139248dfbeac4.zip
external_wpa_supplicant_8_ti-8a13732f832d4300cdb2a2a16d0139248dfbeac4.tar.gz
external_wpa_supplicant_8_ti-8a13732f832d4300cdb2a2a16d0139248dfbeac4.tar.bz2
NDEF: Mark input data const when it is not modified
Signed-hostap: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'src/wps')
-rw-r--r--src/wps/ndef.c19
-rw-r--r--src/wps/wps.h4
2 files changed, 12 insertions, 11 deletions
diff --git a/src/wps/ndef.c b/src/wps/ndef.c
index 43412f7..7630ecb 100644
--- a/src/wps/ndef.c
+++ b/src/wps/ndef.c
@@ -20,9 +20,9 @@
#define FLAG_TNF_RFC2046 (0x02)
struct ndef_record {
- u8 *type;
- u8 *id;
- u8 *payload;
+ const u8 *type;
+ const u8 *id;
+ const u8 *payload;
u8 type_length;
u8 id_length;
u32 payload_length;
@@ -31,9 +31,10 @@ struct ndef_record {
static char wifi_handover_type[] = "application/vnd.wfa.wsc";
-static int ndef_parse_record(u8 *data, u32 size, struct ndef_record *record)
+static int ndef_parse_record(const u8 *data, u32 size,
+ struct ndef_record *record)
{
- u8 *pos = data + 1;
+ const u8 *pos = data + 1;
if (size < 2)
return -1;
@@ -72,12 +73,12 @@ static int ndef_parse_record(u8 *data, u32 size, struct ndef_record *record)
}
-static struct wpabuf * ndef_parse_records(struct wpabuf *buf,
+static struct wpabuf * ndef_parse_records(const struct wpabuf *buf,
int (*filter)(struct ndef_record *))
{
struct ndef_record record;
int len = wpabuf_len(buf);
- u8 *data = wpabuf_mhead(buf);
+ const u8 *data = wpabuf_head(buf);
while (len > 0) {
if (ndef_parse_record(data, len, &record) < 0) {
@@ -155,13 +156,13 @@ static int wifi_filter(struct ndef_record *record)
}
-struct wpabuf * ndef_parse_wifi(struct wpabuf *buf)
+struct wpabuf * ndef_parse_wifi(const struct wpabuf *buf)
{
return ndef_parse_records(buf, wifi_filter);
}
-struct wpabuf * ndef_build_wifi(struct wpabuf *buf)
+struct wpabuf * ndef_build_wifi(const struct wpabuf *buf)
{
return ndef_build_record(FLAG_MESSAGE_BEGIN | FLAG_MESSAGE_END |
FLAG_TNF_RFC2046, wifi_handover_type,
diff --git a/src/wps/wps.h b/src/wps/wps.h
index 7944f75..b49bb91 100644
--- a/src/wps/wps.h
+++ b/src/wps/wps.h
@@ -834,8 +834,8 @@ void uuid_gen_mac_addr(const u8 *mac_addr, u8 *uuid);
u16 wps_config_methods_str2bin(const char *str);
/* ndef.c */
-struct wpabuf * ndef_parse_wifi(struct wpabuf *buf);
-struct wpabuf * ndef_build_wifi(struct wpabuf *buf);
+struct wpabuf * ndef_parse_wifi(const struct wpabuf *buf);
+struct wpabuf * ndef_build_wifi(const struct wpabuf *buf);
#ifdef CONFIG_WPS_STRICT
int wps_validate_beacon(const struct wpabuf *wps_ie);