diff options
author | Dan Williams <dcbw@redhat.com> | 2008-09-28 03:17:09 +0000 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2008-09-28 03:17:09 +0000 |
commit | 33110acba83860b3c5def9ea303f96e507c59382 (patch) | |
tree | b2913d045bda93573405cf128db29794673d34bf /libnm-util | |
parent | a15af58cdd8fbcb0b7e47f6631ced96c816aafea (diff) | |
download | NetworkManager-33110acba83860b3c5def9ea303f96e507c59382.tar.gz |
2008-09-27 Dan Williams <dcbw@redhat.com>
* libnm-util/nm-setting-gsm.c
- (verify): verify GSM network ID
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4118 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
Diffstat (limited to 'libnm-util')
-rw-r--r-- | libnm-util/nm-setting-gsm.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/libnm-util/nm-setting-gsm.c b/libnm-util/nm-setting-gsm.c index 68c836b206..bec4f408d2 100644 --- a/libnm-util/nm-setting-gsm.c +++ b/libnm-util/nm-setting-gsm.c @@ -24,6 +24,7 @@ */ #include <string.h> +#include <ctype.h> #include "nm-setting-gsm.h" #include "nm-setting-serial.h" #include "nm-utils.h" @@ -149,6 +150,30 @@ verify (NMSetting *setting, GSList *all_settings, GError **error) return FALSE; } + if (self->network_id) { + guint32 nid_len = strlen (self->network_id); + guint32 i; + + /* Accept both 5 and 6 digit MCC/MNC codes */ + if ((nid_len < 5) || (nid_len > 6)) { + g_set_error (error, + NM_SETTING_GSM_ERROR, + NM_SETTING_GSM_ERROR_INVALID_PROPERTY, + NM_SETTING_GSM_NETWORK_ID); + return FALSE; + } + + for (i = 0; i < nid_len; i++) { + if (!isdigit (self->network_id[i])) { + g_set_error (error, + NM_SETTING_GSM_ERROR, + NM_SETTING_GSM_ERROR_INVALID_PROPERTY, + NM_SETTING_GSM_NETWORK_ID); + return FALSE; + } + } + } + return TRUE; } @@ -328,7 +353,7 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class) (object_class, PROP_NETWORK_ID, g_param_spec_string (NM_SETTING_GSM_NETWORK_ID, "Network ID", - "Network ID", + "Network ID (GSM LAI format)", NULL, G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE)); |