From 78c88d814d9f429949f933aff0d5c84e52775ab0 Mon Sep 17 00:00:00 2001 From: Julien Massot Date: Fri, 13 Apr 2012 15:16:34 +0000 Subject: service: Add function to check the WPS PIN validity --- src/service.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/service.c b/src/service.c index 96dd0f9e..88d79120 100644 --- a/src/service.c +++ b/src/service.c @@ -4277,6 +4277,26 @@ int __connman_service_add_passphrase(struct connman_service *service, return err; } +static int check_wpspin(const char *wpspin) +{ + guint i; + + if (wpspin == NULL) + return 0; + + /* A WPS PIN is always 8 chars length, + * its content is in digit representation. + */ + if (strlen(wpspin) != 8) + return -ENOKEY; + + for (i = 0; i < 8; i++) + if (!isdigit((unsigned char) wpspin[i])) + return -ENOKEY; + + return 0; +} + static void request_input_cb (struct connman_service *service, connman_bool_t values_received, const char *name, int name_len, -- cgit v1.2.3