device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-core / nm-setting-gsm.c
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
3 /*
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301 USA.
18  *
19  * Copyright 2007 - 2013 Red Hat, Inc.
20  * Copyright 2007 - 2008 Novell, Inc.
21  */
22
23 #include "nm-default.h"
24
25 #include <string.h>
26
27 #include "nm-setting-gsm.h"
28 #include "nm-utils.h"
29 #include "nm-setting-private.h"
30 #include "nm-core-enum-types.h"
31
32 /**
33  * SECTION:nm-setting-gsm
34  * @short_description: Describes GSM/3GPP-based mobile broadband properties
35  *
36  * The #NMSettingGsm object is a #NMSetting subclass that describes
37  * properties that allow connections to 3GPP-based mobile broadband
38  * networks, including those using GPRS/EDGE and UMTS/HSPA technology.
39  */
40
41 G_DEFINE_TYPE_WITH_CODE (NMSettingGsm, nm_setting_gsm, NM_TYPE_SETTING,
42                          _nm_register_setting (GSM, 1))
43 NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_GSM)
44
45 #define NM_SETTING_GSM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_GSM, NMSettingGsmPrivate))
46
47 typedef struct {
48         char *number; /* For dialing, duh */
49         char *username;
50         char *password;
51         NMSettingSecretFlags password_flags;
52
53         /* Restrict connection to certain devices or SIMs */
54         char *device_id;
55         char *sim_id;
56         char *sim_operator_id;
57
58         char *apn; /* NULL for dynamic */
59         char *network_id; /* for manual registration or NULL for automatic */
60
61         char *pin;
62         NMSettingSecretFlags pin_flags;
63
64         gboolean home_only;
65 } NMSettingGsmPrivate;
66
67 enum {
68         PROP_0,
69         PROP_NUMBER,
70         PROP_USERNAME,
71         PROP_PASSWORD,
72         PROP_PASSWORD_FLAGS,
73         PROP_APN,
74         PROP_NETWORK_ID,
75         PROP_PIN,
76         PROP_PIN_FLAGS,
77         PROP_HOME_ONLY,
78         PROP_DEVICE_ID,
79         PROP_SIM_ID,
80         PROP_SIM_OPERATOR_ID,
81
82         LAST_PROP
83 };
84
85 /**
86  * nm_setting_gsm_new:
87  *
88  * Creates a new #NMSettingGsm object with default values.
89  *
90  * Returns: the new empty #NMSettingGsm object
91  **/
92 NMSetting *
93 nm_setting_gsm_new (void)
94 {
95         return (NMSetting *) g_object_new (NM_TYPE_SETTING_GSM, NULL);
96 }
97
98 /**
99  * nm_setting_gsm_get_number:
100  * @setting: the #NMSettingGsm
101  *
102  * Returns: the #NMSettingGsm:number property of the setting
103  **/
104 const char *
105 nm_setting_gsm_get_number (NMSettingGsm *setting)
106 {
107         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
108
109         return NM_SETTING_GSM_GET_PRIVATE (setting)->number;
110 }
111
112 /**
113  * nm_setting_gsm_get_username:
114  * @setting: the #NMSettingGsm
115  *
116  * Returns: the #NMSettingGsm:username property of the setting
117  **/
118 const char *
119 nm_setting_gsm_get_username (NMSettingGsm *setting)
120 {
121         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
122
123         return NM_SETTING_GSM_GET_PRIVATE (setting)->username;
124 }
125
126 /**
127  * nm_setting_gsm_get_password:
128  * @setting: the #NMSettingGsm
129  *
130  * Returns: the #NMSettingGsm:password property of the setting
131  **/
132 const char *
133 nm_setting_gsm_get_password (NMSettingGsm *setting)
134 {
135         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
136
137         return NM_SETTING_GSM_GET_PRIVATE (setting)->password;
138 }
139
140 /**
141  * nm_setting_gsm_get_password_flags:
142  * @setting: the #NMSettingGsm
143  *
144  * Returns: the #NMSettingSecretFlags pertaining to the #NMSettingGsm:password
145  **/
146 NMSettingSecretFlags
147 nm_setting_gsm_get_password_flags (NMSettingGsm *setting)
148 {
149         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NM_SETTING_SECRET_FLAG_NONE);
150
151         return NM_SETTING_GSM_GET_PRIVATE (setting)->password_flags;
152 }
153
154 /**
155  * nm_setting_gsm_get_apn:
156  * @setting: the #NMSettingGsm
157  *
158  * Returns: the #NMSettingGsm:apn property of the setting
159  **/
160 const char *
161 nm_setting_gsm_get_apn (NMSettingGsm *setting)
162 {
163         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
164
165         return NM_SETTING_GSM_GET_PRIVATE (setting)->apn;
166 }
167
168 /**
169  * nm_setting_gsm_get_network_id:
170  * @setting: the #NMSettingGsm
171  *
172  * Returns: the #NMSettingGsm:network-id property of the setting
173  **/
174 const char *
175 nm_setting_gsm_get_network_id (NMSettingGsm *setting)
176 {
177         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
178
179         return NM_SETTING_GSM_GET_PRIVATE (setting)->network_id;
180 }
181
182 /**
183  * nm_setting_gsm_get_pin:
184  * @setting: the #NMSettingGsm
185  *
186  * Returns: the #NMSettingGsm:pin property of the setting
187  **/
188 const char *
189 nm_setting_gsm_get_pin (NMSettingGsm *setting)
190 {
191         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
192
193         return NM_SETTING_GSM_GET_PRIVATE (setting)->pin;
194 }
195
196 /**
197  * nm_setting_gsm_get_pin_flags:
198  * @setting: the #NMSettingGsm
199  *
200  * Returns: the #NMSettingSecretFlags pertaining to the #NMSettingGsm:pin
201  **/
202 NMSettingSecretFlags
203 nm_setting_gsm_get_pin_flags (NMSettingGsm *setting)
204 {
205         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NM_SETTING_SECRET_FLAG_NONE);
206
207         return NM_SETTING_GSM_GET_PRIVATE (setting)->pin_flags;
208 }
209
210 /**
211  * nm_setting_gsm_get_home_only:
212  * @setting: the #NMSettingGsm
213  *
214  * Returns: the #NMSettingGsm:home-only property of the setting
215  **/
216 gboolean
217 nm_setting_gsm_get_home_only (NMSettingGsm *setting)
218 {
219         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), FALSE);
220
221         return NM_SETTING_GSM_GET_PRIVATE (setting)->home_only;
222 }
223
224 /**
225  * nm_setting_gsm_get_device_id:
226  * @setting: the #NMSettingGsm
227  *
228  * Returns: the #NMSettingGsm:device-id property of the setting
229  *
230  * Since: 1.2
231  **/
232 const char *
233 nm_setting_gsm_get_device_id (NMSettingGsm *setting)
234 {
235         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
236
237         return NM_SETTING_GSM_GET_PRIVATE (setting)->device_id;
238 }
239
240 /**
241  * nm_setting_gsm_get_sim_id:
242  * @setting: the #NMSettingGsm
243  *
244  * Returns: the #NMSettingGsm:sim-id property of the setting
245  *
246  * Since: 1.2
247  **/
248 const char *
249 nm_setting_gsm_get_sim_id (NMSettingGsm *setting)
250 {
251         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
252
253         return NM_SETTING_GSM_GET_PRIVATE (setting)->sim_id;
254 }
255
256 /**
257  * nm_setting_gsm_get_sim_operator_id:
258  * @setting: the #NMSettingGsm
259  *
260  * Returns: the #NMSettingGsm:sim-operator-id property of the setting
261  *
262  * Since: 1.2
263  **/
264 const char *
265 nm_setting_gsm_get_sim_operator_id (NMSettingGsm *setting)
266 {
267         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
268
269         return NM_SETTING_GSM_GET_PRIVATE (setting)->sim_operator_id;
270 }
271
272 static gboolean
273 verify (NMSetting *setting, NMConnection *connection, GError **error)
274 {
275         NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting);
276
277         if (priv->number && !priv->number[0]) {
278                 g_set_error_literal (error,
279                                      NM_CONNECTION_ERROR,
280                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
281                                      _("property is empty"));
282                 g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_NUMBER);
283                 return FALSE;
284         }
285
286         if (priv->apn) {
287                 guint32 apn_len = strlen (priv->apn);
288                 guint32 i;
289
290                 if (apn_len < 1 || apn_len > 64) {
291                         g_set_error (error,
292                                      NM_CONNECTION_ERROR,
293                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
294                                      _("property value '%s' is empty or too long (>64)"),
295                                      priv->apn);
296                         g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_APN);
297                         return FALSE;
298                 }
299
300                 /* APNs roughly follow the same rules as DNS domain names.  Allowed
301                  * characters are a-z, 0-9, . and -.  GSM 03.03 Section 9.1 states:
302                  *
303                  *   The syntax of the APN shall follow the Name Syntax defined in
304                  *   RFC 2181 [14] and RFC 1035 [15]. The APN consists of one or
305                  *   more labels. Each label is coded as one octet length field
306                  *   followed by that number of octets coded as 8 bit ASCII characters.
307                  *   Following RFC 1035 [15] the labels should consist only of the
308                  *   alphabetic characters (A-Z and a-z), digits (0-9) and the
309                  *   dash (-). The case of alphabetic characters is not significant.
310                  *
311                  * A dot (.) is commonly used to separate parts of the APN, and
312                  * apparently the underscore (_) is used as well.  RFC 2181 indicates
313                  * that no restrictions of any kind are placed on DNS labels, and thus
314                  * it would appear that none are placed on APNs either, but many modems
315                  * and networks will fail to accept APNs that include odd characters
316                  * like space ( ) and such.
317                  */
318                 for (i = 0; i < apn_len; i++) {
319                         if (   !g_ascii_isalnum (priv->apn[i])
320                             && (priv->apn[i] != '.')
321                             && (priv->apn[i] != '_')
322                             && (priv->apn[i] != '-')) {
323                                 g_set_error (error,
324                                              NM_CONNECTION_ERROR,
325                                              NM_CONNECTION_ERROR_INVALID_PROPERTY,
326                                              _("'%s' contains invalid char(s) (use [A-Za-z._-])"),
327                                              priv->apn);
328                                 g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_APN);
329                                 return FALSE;
330                         }
331                 }
332         }
333
334         if (priv->username && !strlen (priv->username)) {
335                 g_set_error_literal (error,
336                                      NM_CONNECTION_ERROR,
337                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
338                                      _("property is empty"));
339                 g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_USERNAME);
340                 return FALSE;
341         }
342
343         if (priv->network_id) {
344                 guint32 nid_len = strlen (priv->network_id);
345                 guint32 i;
346
347                 /* Accept both 5 and 6 digit MCC/MNC codes */
348                 if ((nid_len < 5) || (nid_len > 6)) {
349                         g_set_error (error,
350                                      NM_CONNECTION_ERROR,
351                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
352                                      _("'%s' length is invalid (should be 5 or 6 digits)"),
353                                      priv->network_id);
354                         g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_NETWORK_ID);
355                         return FALSE;
356                 }
357
358                 for (i = 0; i < nid_len; i++) {
359                         if (!g_ascii_isdigit (priv->network_id[i])) {
360                                 g_set_error (error,
361                                              NM_CONNECTION_ERROR,
362                                              NM_CONNECTION_ERROR_INVALID_PROPERTY,
363                                              _("'%s' is not a number"),
364                                              priv->network_id);
365                                 g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_NETWORK_ID);
366                                 return FALSE;
367                         }
368                 }
369         }
370
371         if (priv->device_id && !priv->device_id[0]) {
372                 g_set_error_literal (error,
373                                      NM_CONNECTION_ERROR,
374                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
375                                      _("property is empty"));
376                 g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_DEVICE_ID);
377                 return FALSE;
378         }
379
380         if (priv->sim_id && !priv->sim_id[0]) {
381                 g_set_error_literal (error,
382                                      NM_CONNECTION_ERROR,
383                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
384                                      _("property is empty"));
385                 g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_SIM_ID);
386                 return FALSE;
387         }
388
389         if (priv->sim_operator_id) {
390                 size_t len = strlen (priv->sim_operator_id);
391                 const char *p = priv->sim_operator_id;
392
393                 if (len == 0 || (len != 5 && len != 6)) {
394                         g_set_error_literal (error,
395                                              NM_CONNECTION_ERROR,
396                                              NM_CONNECTION_ERROR_INVALID_PROPERTY,
397                                              _("property is empty or wrong size"));
398                         g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_SIM_OPERATOR_ID);
399                         return FALSE;
400                 }
401
402                 while (p && *p) {
403                         if (!g_ascii_isdigit (*p++)) {
404                                 g_set_error_literal (error,
405                                                      NM_CONNECTION_ERROR,
406                                                      NM_CONNECTION_ERROR_INVALID_PROPERTY,
407                                                      _("property must contain only digits"));
408                                 g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_SIM_OPERATOR_ID);
409                                 return FALSE;
410                         }
411                 }
412         }
413
414         return TRUE;
415 }
416
417 static gboolean
418 verify_secrets (NMSetting *setting, NMConnection *connection, GError **error)
419 {
420         return _nm_setting_verify_secret_string (NM_SETTING_GSM_GET_PRIVATE (setting)->password,
421                                                  NM_SETTING_GSM_SETTING_NAME,
422                                                  NM_SETTING_GSM_PASSWORD,
423                                                  error);
424 }
425
426 static GPtrArray *
427 need_secrets (NMSetting *setting)
428 {
429         NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting);
430         GPtrArray *secrets = NULL;
431
432         if (priv->password && *priv->password)
433                 return NULL;
434
435         if (priv->username) {
436                 if (!(priv->password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED)) {
437                         secrets = g_ptr_array_sized_new (1);
438                         g_ptr_array_add (secrets, NM_SETTING_GSM_PASSWORD);
439                 }
440         }
441
442         return secrets;
443 }
444
445 static void
446 nm_setting_gsm_init (NMSettingGsm *setting)
447 {
448 }
449
450 static void
451 finalize (GObject *object)
452 {
453         NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (object);
454
455         g_free (priv->number);
456         g_free (priv->username);
457         g_free (priv->password);
458         g_free (priv->apn);
459         g_free (priv->network_id);
460         g_free (priv->pin);
461         g_free (priv->device_id);
462         g_free (priv->sim_id);
463         g_free (priv->sim_operator_id);
464
465         G_OBJECT_CLASS (nm_setting_gsm_parent_class)->finalize (object);
466 }
467
468 static void
469 set_property (GObject *object, guint prop_id,
470               const GValue *value, GParamSpec *pspec)
471 {
472         NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (object);
473         char *tmp;
474
475         switch (prop_id) {
476         case PROP_NUMBER:
477                 g_free (priv->number);
478                 priv->number = g_value_dup_string (value);
479                 break;
480         case PROP_USERNAME:
481                 g_free (priv->username);
482                 priv->username = g_value_dup_string (value);
483                 break;
484         case PROP_PASSWORD:
485                 g_free (priv->password);
486                 priv->password = g_value_dup_string (value);
487                 break;
488         case PROP_PASSWORD_FLAGS:
489                 priv->password_flags = g_value_get_flags (value);
490                 break;
491         case PROP_APN:
492                 g_free (priv->apn);
493                 priv->apn = NULL;
494                 tmp = g_value_dup_string (value);
495                 if (tmp)
496                         priv->apn = g_strstrip (tmp);
497                 break;
498         case PROP_NETWORK_ID:
499                 g_free (priv->network_id);
500                 priv->network_id = NULL;
501                 tmp = g_value_dup_string (value);
502                 if (tmp)
503                         priv->network_id = g_strstrip (tmp);
504                 break;
505         case PROP_PIN:
506                 g_free (priv->pin);
507                 priv->pin = g_value_dup_string (value);
508                 break;
509         case PROP_PIN_FLAGS:
510                 priv->pin_flags = g_value_get_flags (value);
511                 break;
512         case PROP_HOME_ONLY:
513                 priv->home_only = g_value_get_boolean (value);
514                 break;
515         case PROP_DEVICE_ID:
516                 g_free (priv->device_id);
517                 priv->device_id = g_value_dup_string (value);
518                 break;
519         case PROP_SIM_ID:
520                 g_free (priv->sim_id);
521                 priv->sim_id = g_value_dup_string (value);
522                 break;
523         case PROP_SIM_OPERATOR_ID:
524                 g_free (priv->sim_operator_id);
525                 priv->sim_operator_id = g_value_dup_string (value);
526                 break;
527         default:
528                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
529                 break;
530         }
531 }
532
533 static void
534 get_property (GObject *object, guint prop_id,
535               GValue *value, GParamSpec *pspec)
536 {
537         NMSettingGsm *setting = NM_SETTING_GSM (object);
538
539         switch (prop_id) {
540         case PROP_NUMBER:
541                 g_value_set_string (value, nm_setting_gsm_get_number (setting));
542                 break;
543         case PROP_USERNAME:
544                 g_value_set_string (value, nm_setting_gsm_get_username (setting));
545                 break;
546         case PROP_PASSWORD:
547                 g_value_set_string (value, nm_setting_gsm_get_password (setting));
548                 break;
549         case PROP_PASSWORD_FLAGS:
550                 g_value_set_flags (value, nm_setting_gsm_get_password_flags (setting));
551                 break;
552         case PROP_APN:
553                 g_value_set_string (value, nm_setting_gsm_get_apn (setting));
554                 break;
555         case PROP_NETWORK_ID:
556                 g_value_set_string (value, nm_setting_gsm_get_network_id (setting));
557                 break;
558         case PROP_PIN:
559                 g_value_set_string (value, nm_setting_gsm_get_pin (setting));
560                 break;
561         case PROP_PIN_FLAGS:
562                 g_value_set_flags (value, nm_setting_gsm_get_pin_flags (setting));
563                 break;
564         case PROP_HOME_ONLY:
565                 g_value_set_boolean (value, nm_setting_gsm_get_home_only (setting));
566                 break;
567         case PROP_DEVICE_ID:
568                 g_value_set_string (value, nm_setting_gsm_get_device_id (setting));
569                 break;
570         case PROP_SIM_ID:
571                 g_value_set_string (value, nm_setting_gsm_get_sim_id (setting));
572                 break;
573         case PROP_SIM_OPERATOR_ID:
574                 g_value_set_string (value, nm_setting_gsm_get_sim_operator_id (setting));
575                 break;
576         default:
577                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
578                 break;
579         }
580 }
581
582 static void
583 nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
584 {
585         GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
586         NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
587
588         g_type_class_add_private (setting_class, sizeof (NMSettingGsmPrivate));
589
590         /* virtual methods */
591         object_class->set_property = set_property;
592         object_class->get_property = get_property;
593         object_class->finalize     = finalize;
594         parent_class->verify       = verify;
595         parent_class->verify_secrets = verify_secrets;
596         parent_class->need_secrets = need_secrets;
597
598         /* Properties */
599
600         /**
601          * NMSettingGsm:number:
602          *
603          * Number to dial when establishing a PPP data session with the GSM-based
604          * mobile broadband network.  Many modems do not require PPP for connections
605          * to the mobile network and thus this property should be left blank, which
606          * allows NetworkManager to select the appropriate settings automatically.
607          **/
608         g_object_class_install_property
609                 (object_class, PROP_NUMBER,
610                  g_param_spec_string (NM_SETTING_GSM_NUMBER, "", "",
611                                       NULL,
612                                       G_PARAM_READWRITE |
613                                       G_PARAM_STATIC_STRINGS));
614
615         /**
616          * NMSettingGsm:username:
617          *
618          * The username used to authenticate with the network, if required.  Many
619          * providers do not require a username, or accept any username.  But if a
620          * username is required, it is specified here.
621          **/
622         g_object_class_install_property
623                 (object_class, PROP_USERNAME,
624                  g_param_spec_string (NM_SETTING_GSM_USERNAME, "", "",
625                                       NULL,
626                                       G_PARAM_READWRITE |
627                                       G_PARAM_STATIC_STRINGS));
628
629         /**
630          * NMSettingGsm:password:
631          *
632          * The password used to authenticate with the network, if required.  Many
633          * providers do not require a password, or accept any password.  But if a
634          * password is required, it is specified here.
635          **/
636         g_object_class_install_property
637                 (object_class, PROP_PASSWORD,
638                  g_param_spec_string (NM_SETTING_GSM_PASSWORD, "", "",
639                                       NULL,
640                                       G_PARAM_READWRITE |
641                                       NM_SETTING_PARAM_SECRET |
642                                       G_PARAM_STATIC_STRINGS));
643
644         /**
645          * NMSettingGsm:password-flags:
646          *
647          * Flags indicating how to handle the #NMSettingGsm:password property.
648          **/
649         g_object_class_install_property
650                 (object_class, PROP_PASSWORD_FLAGS,
651                  g_param_spec_flags (NM_SETTING_GSM_PASSWORD_FLAGS, "", "",
652                                      NM_TYPE_SETTING_SECRET_FLAGS,
653                                      NM_SETTING_SECRET_FLAG_NONE,
654                                      G_PARAM_READWRITE |
655                                      G_PARAM_STATIC_STRINGS));
656
657         /**
658          * NMSettingGsm:apn:
659          *
660          * The GPRS Access Point Name specifying the APN used when establishing a
661          * data session with the GSM-based network.  The APN often determines how
662          * the user will be billed for their network usage and whether the user has
663          * access to the Internet or just a provider-specific walled-garden, so it
664          * is important to use the correct APN for the user's mobile broadband plan.
665          * The APN may only be composed of the characters a-z, 0-9, ., and - per GSM
666          * 03.60 Section 14.9.
667          **/
668         g_object_class_install_property
669                 (object_class, PROP_APN,
670                  g_param_spec_string (NM_SETTING_GSM_APN, "", "",
671                                       NULL,
672                                       G_PARAM_READWRITE |
673                                       G_PARAM_STATIC_STRINGS));
674
675         /**
676          * NMSettingGsm:network-id:
677          *
678          * The Network ID (GSM LAI format, ie MCC-MNC) to force specific network
679          * registration.  If the Network ID is specified, NetworkManager will
680          * attempt to force the device to register only on the specified network.
681          * This can be used to ensure that the device does not roam when direct
682          * roaming control of the device is not otherwise possible.
683          **/
684         g_object_class_install_property
685                 (object_class, PROP_NETWORK_ID,
686                  g_param_spec_string (NM_SETTING_GSM_NETWORK_ID, "", "",
687                                       NULL,
688                                       G_PARAM_READWRITE |
689                                       G_PARAM_STATIC_STRINGS));
690
691         /**
692          * NMSettingGsm:pin:
693          *
694          * If the SIM is locked with a PIN it must be unlocked before any other
695          * operations are requested.  Specify the PIN here to allow operation of the
696          * device.
697          **/
698         g_object_class_install_property
699                 (object_class, PROP_PIN,
700                  g_param_spec_string (NM_SETTING_GSM_PIN, "", "",
701                                       NULL,
702                                       G_PARAM_READWRITE |
703                                       NM_SETTING_PARAM_SECRET |
704                                       G_PARAM_STATIC_STRINGS));
705
706         /**
707          * NMSettingGsm:pin-flags:
708          *
709          * Flags indicating how to handle the #NMSettingGsm:pin property.
710          **/
711         g_object_class_install_property
712                 (object_class, PROP_PIN_FLAGS,
713                  g_param_spec_flags (NM_SETTING_GSM_PIN_FLAGS, "", "",
714                                      NM_TYPE_SETTING_SECRET_FLAGS,
715                                      NM_SETTING_SECRET_FLAG_NONE,
716                                      G_PARAM_READWRITE |
717                                      G_PARAM_STATIC_STRINGS));
718
719         /**
720          * NMSettingGsm:home-only:
721          *
722          * When %TRUE, only connections to the home network will be allowed.
723          * Connections to roaming networks will not be made.
724          **/
725         g_object_class_install_property
726                 (object_class, PROP_HOME_ONLY,
727                  g_param_spec_boolean (NM_SETTING_GSM_HOME_ONLY, "", "",
728                                        FALSE,
729                                        G_PARAM_READWRITE |
730                                        G_PARAM_STATIC_STRINGS));
731
732         /**
733          * NMSettingGsm:device-id:
734          *
735          * The device unique identifier (as given by the WWAN management service)
736          * which this connection applies to.  If given, the connection will only
737          * apply to the specified device.
738          *
739          * Since: 1.2
740          **/
741         g_object_class_install_property
742                 (object_class, PROP_DEVICE_ID,
743                  g_param_spec_string (NM_SETTING_GSM_DEVICE_ID, "", "",
744                                       NULL,
745                                       G_PARAM_READWRITE |
746                                       G_PARAM_STATIC_STRINGS));
747
748         /**
749          * NMSettingGsm:sim-id:
750          *
751          * The SIM card unique identifier (as given by the WWAN management service)
752          * which this connection applies to.  If given, the connection will apply
753          * to any device also allowed by #NMSettingGsm:device-id which contains a
754          * SIM card matching the given identifier.
755          *
756          * Since: 1.2
757          **/
758         g_object_class_install_property
759                 (object_class, PROP_SIM_ID,
760                  g_param_spec_string (NM_SETTING_GSM_SIM_ID, "", "",
761                                       NULL,
762                                       G_PARAM_READWRITE |
763                                       G_PARAM_STATIC_STRINGS));
764
765         /**
766          * NMSettingGsm:sim-operator-id:
767          *
768          * A MCC/MNC string like "310260" or "21601" identifying the specific
769          * mobile network operator which this connection applies to.  If given,
770          * the connection will apply to any device also allowed by
771          * #NMSettingGsm:device-id and #NMSettingGsm:sim-id which contains a SIM
772          * card provisioined by the given operator.
773          *
774          * Since: 1.2
775          **/
776         g_object_class_install_property
777                 (object_class, PROP_SIM_OPERATOR_ID,
778                  g_param_spec_string (NM_SETTING_GSM_SIM_OPERATOR_ID, "", "",
779                                       NULL,
780                                       G_PARAM_READWRITE |
781                                       G_PARAM_STATIC_STRINGS));
782
783         /* Ignore incoming deprecated properties */
784         _nm_setting_class_add_dbus_only_property (parent_class, "allowed-bands",
785                                                   G_VARIANT_TYPE_UINT32,
786                                                   NULL, NULL);
787         _nm_setting_class_add_dbus_only_property (parent_class, "network-type",
788                                                   G_VARIANT_TYPE_INT32,
789                                                   NULL, NULL);
790 }