diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-10-07 20:19:13 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-10-07 21:12:00 +0200 |
commit | ebd792d2aaa0917a6628eb1f9c1fbeedafbf2617 (patch) | |
tree | d8b5c542ffaa6951ab7d921427fbd1cfd42ca52e /libmm-glib/mm-common-helpers.c | |
parent | 7ae18eecdd3c0aae851441d970b3a54319dd3404 (diff) |
api,libmm-glib: new `allowed-auth' configuration for bearers
For bearers using STATIC or DHCP IP method, the modem itself is the one
negotiating authentication with the network. The new `allowed-auth' property
allows users to specify which authentication method(s) are allowed to be used.
See the following NetworkManager commit for more reference:
commit 34aef8aaaa09b7473b9496aa49e550bd2def03f8
Author: Andrew Bird <ajb@spheresystems.co.uk>
Date: Thu Mar 15 16:19:43 2012 -0500
Diffstat (limited to 'libmm-glib/mm-common-helpers.c')
-rw-r--r-- | libmm-glib/mm-common-helpers.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/libmm-glib/mm-common-helpers.c b/libmm-glib/mm-common-helpers.c index 552881e5..f32a83a0 100644 --- a/libmm-glib/mm-common-helpers.c +++ b/libmm-glib/mm-common-helpers.c @@ -417,6 +417,66 @@ mm_common_get_ip_type_from_string (const gchar *str, return MM_BEARER_IP_FAMILY_UNKNOWN; } +MMBearerAllowedAuth +mm_common_get_allowed_auth_from_string (const gchar *str, + GError **error) +{ + GError *inner_error = NULL; + MMBearerAllowedAuth allowed_auth; + gchar **strings; + GFlagsClass *flags_class; + + allowed_auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN; + + flags_class = G_FLAGS_CLASS (g_type_class_ref (MM_TYPE_BEARER_ALLOWED_AUTH)); + strings = g_strsplit (str, "|", -1); + + if (strings) { + guint i; + + for (i = 0; strings[i]; i++) { + guint j; + gboolean found = FALSE; + + for (j = 0; flags_class->values[j].value_nick; j++) { + if (!g_ascii_strcasecmp (strings[i], flags_class->values[j].value_nick)) { + allowed_auth |= flags_class->values[j].value; + found = TRUE; + break; + } + } + + if (!found) { + inner_error = g_error_new ( + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Couldn't match '%s' with a valid MMBearerAllowedAuth value", + strings[i]); + break; + } + } + } + + if (inner_error) { + g_propagate_error (error, inner_error); + allowed_auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN; + } + + /* 'none' is a special value which, if given, must be given alone */ + if (allowed_auth & MM_BEARER_ALLOWED_AUTH_NONE && + allowed_auth != MM_BEARER_ALLOWED_AUTH_NONE) { + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_INVALID_ARGS, + "Allowed auth 'none' cannot be given along with other values"); + allowed_auth = MM_BEARER_ALLOWED_AUTH_UNKNOWN; + } + + g_type_class_unref (flags_class); + g_strfreev (strings); + return allowed_auth; +} + MMSmsStorage mm_common_get_sms_storage_from_string (const gchar *str, GError **error) |