summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorPhilip Paeps <philip@paeps.cx>2014-06-24 11:57:05 +0200
committerDenis Kenzior <denkenz@gmail.com>2014-06-24 12:46:18 -0500
commit532e8020e581a4c05cc871dff59e2287bdf594f4 (patch)
tree162e641f6aad880836f100b854091b6ab5bd39f6 /plugins
parent310915429bb3175fda43ae29a65f7ad77cbde4e2 (diff)
downloadofono-532e8020e581a4c05cc871dff59e2287bdf594f4.tar.bz2
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).
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mbpi.c35
1 files changed, 35 insertions, 0 deletions
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);
}