From 532e8020e581a4c05cc871dff59e2287bdf594f4 Mon Sep 17 00:00:00 2001 From: Philip Paeps Date: Tue, 24 Jun 2014 11:57:05 +0200 Subject: mbpi: add support for provisioning the auth method Use the authentication method from the mobile-broadband-provider-info database if it is specified and supported (we support CHAP and PAP). Default to CHAP if the database does not specify a method (i.e.: the previous behaviour). --- plugins/mbpi.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'plugins') diff --git a/plugins/mbpi.c b/plugins/mbpi.c index dff8752c..ae92c762 100644 --- a/plugins/mbpi.c +++ b/plugins/mbpi.c @@ -128,6 +128,37 @@ static const GMarkupParser text_parser = { NULL, }; +static void authentication_start(GMarkupParseContext *context, + const gchar **attribute_names, + const gchar **attribute_values, + enum ofono_gprs_auth_method *auth_method, + GError **error) +{ + const char *text = NULL; + int i; + + for (i = 0; attribute_names[i]; i++) + if (g_str_equal(attribute_names[i], "method") == TRUE) + text = attribute_values[i]; + + if (text == NULL) { + mbpi_g_set_error(context, error, G_MARKUP_ERROR, + G_MARKUP_ERROR_MISSING_ATTRIBUTE, + "Missing attribute: method"); + return; + } + + if (strcmp(text, "chap") == 0) + *auth_method = OFONO_GPRS_AUTH_METHOD_CHAP; + else if (strcmp(text, "pap") == 0) + *auth_method = OFONO_GPRS_AUTH_METHOD_PAP; + else + mbpi_g_set_error(context, error, G_MARKUP_ERROR, + G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, + "Unknown authentication method: %s", + text); +} + static void usage_start(GMarkupParseContext *context, const gchar **attribute_names, const gchar **attribute_values, @@ -174,6 +205,9 @@ static void apn_start(GMarkupParseContext *context, const gchar *element_name, else if (g_str_equal(element_name, "password")) g_markup_parse_context_push(context, &text_parser, &apn->password); + else if (g_str_equal(element_name, "authentication")) + authentication_start(context, attribute_names, + attribute_values, &apn->auth_method, error); else if (g_str_equal(element_name, "mmsc")) g_markup_parse_context_push(context, &text_parser, &apn->message_center); @@ -291,6 +325,7 @@ static void apn_handler(GMarkupParseContext *context, struct gsm_data *gsm, ap->apn = g_strdup(apn); ap->type = OFONO_GPRS_CONTEXT_TYPE_INTERNET; ap->proto = OFONO_GPRS_PROTO_IP; + ap->auth_method = OFONO_GPRS_AUTH_METHOD_CHAP; g_markup_parse_context_push(context, &apn_parser, ap); } -- cgit v1.2.3