mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-10-15 12:34:55 +00:00
gsm: correct GSM band implementation and settings
NM didn't pass it to MM anyway, so it was mainly unused, but the band settings were still wrong. Fix that (and still preserve ABI) by adding a new property for allowed bands that can actually hold all the bands instead of limiting to 16-bits. Clean up some of the deprecation stuff at the same time to make it clearer what's deprecated and what to do about it.
This commit is contained in:
parent
59d89050f2
commit
00f945e54e
|
@ -76,8 +76,8 @@ typedef struct {
|
||||||
|
|
||||||
char *apn; /* NULL for dynamic */
|
char *apn; /* NULL for dynamic */
|
||||||
char *network_id; /* for manual registration or NULL for automatic */
|
char *network_id; /* for manual registration or NULL for automatic */
|
||||||
int network_type; /* One of the NM_GSM_NETWORK_* */
|
int network_type; /* One of the NM_SETTING_GSM_NETWORK_TYPE_* */
|
||||||
int band;
|
guint32 allowed_bands; /* A bitfield of NM_SETTING_GSM_BAND_* */
|
||||||
|
|
||||||
char *pin;
|
char *pin;
|
||||||
} NMSettingGsmPrivate;
|
} NMSettingGsmPrivate;
|
||||||
|
@ -93,6 +93,7 @@ enum {
|
||||||
PROP_BAND,
|
PROP_BAND,
|
||||||
PROP_PIN,
|
PROP_PIN,
|
||||||
PROP_PUK,
|
PROP_PUK,
|
||||||
|
PROP_ALLOWED_BANDS,
|
||||||
|
|
||||||
LAST_PROP
|
LAST_PROP
|
||||||
};
|
};
|
||||||
|
@ -163,9 +164,16 @@ nm_setting_gsm_get_network_type (NMSettingGsm *setting)
|
||||||
int
|
int
|
||||||
nm_setting_gsm_get_band (NMSettingGsm *setting)
|
nm_setting_gsm_get_band (NMSettingGsm *setting)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), -1);
|
g_warning ("Tried to get deprecated property " NM_SETTING_GSM_SETTING_NAME "/" NM_SETTING_GSM_BAND);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return NM_SETTING_GSM_GET_PRIVATE (setting)->band;
|
guint32
|
||||||
|
nm_setting_gsm_get_allowed_bands (NMSettingGsm *setting)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NM_SETTING_GSM_BAND_UNKNOWN);
|
||||||
|
|
||||||
|
return NM_SETTING_GSM_GET_PRIVATE (setting)->allowed_bands;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
@ -306,6 +314,7 @@ set_property (GObject *object, guint prop_id,
|
||||||
const GValue *value, GParamSpec *pspec)
|
const GValue *value, GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (object);
|
NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (object);
|
||||||
|
const char *str;
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_NUMBER:
|
case PROP_NUMBER:
|
||||||
|
@ -332,14 +341,20 @@ set_property (GObject *object, guint prop_id,
|
||||||
priv->network_type = g_value_get_int (value);
|
priv->network_type = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
case PROP_BAND:
|
case PROP_BAND:
|
||||||
priv->band = g_value_get_int (value);
|
if (g_value_get_int (value) != -1)
|
||||||
|
g_warning ("Tried to set deprecated property " NM_SETTING_GSM_SETTING_NAME "/" NM_SETTING_GSM_BAND);
|
||||||
|
break;
|
||||||
|
case PROP_ALLOWED_BANDS:
|
||||||
|
priv->allowed_bands = g_value_get_uint (value);
|
||||||
break;
|
break;
|
||||||
case PROP_PIN:
|
case PROP_PIN:
|
||||||
g_free (priv->pin);
|
g_free (priv->pin);
|
||||||
priv->pin = g_value_dup_string (value);
|
priv->pin = g_value_dup_string (value);
|
||||||
break;
|
break;
|
||||||
case PROP_PUK:
|
case PROP_PUK:
|
||||||
g_warning ("Tried to set deprecated property " NM_SETTING_GSM_SETTING_NAME "/" NM_SETTING_GSM_PUK);
|
str = g_value_get_string (value);
|
||||||
|
if (str && strlen (str))
|
||||||
|
g_warning ("Tried to set deprecated property " NM_SETTING_GSM_SETTING_NAME "/" NM_SETTING_GSM_PUK);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -372,13 +387,17 @@ get_property (GObject *object, guint prop_id,
|
||||||
case PROP_NETWORK_TYPE:
|
case PROP_NETWORK_TYPE:
|
||||||
g_value_set_int (value, nm_setting_gsm_get_network_type (setting));
|
g_value_set_int (value, nm_setting_gsm_get_network_type (setting));
|
||||||
break;
|
break;
|
||||||
case PROP_BAND:
|
case PROP_ALLOWED_BANDS:
|
||||||
g_value_set_int (value, nm_setting_gsm_get_band (setting));
|
g_value_set_uint (value, nm_setting_gsm_get_allowed_bands (setting));
|
||||||
break;
|
break;
|
||||||
case PROP_PIN:
|
case PROP_PIN:
|
||||||
g_value_set_string (value, nm_setting_gsm_get_pin (setting));
|
g_value_set_string (value, nm_setting_gsm_get_pin (setting));
|
||||||
break;
|
break;
|
||||||
case PROP_PUK:
|
case PROP_PUK:
|
||||||
|
/* deprecated */
|
||||||
|
break;
|
||||||
|
case PROP_BAND:
|
||||||
|
/* deprecated */
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
@ -447,18 +466,32 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
|
||||||
g_param_spec_int (NM_SETTING_GSM_NETWORK_TYPE,
|
g_param_spec_int (NM_SETTING_GSM_NETWORK_TYPE,
|
||||||
"Network type",
|
"Network type",
|
||||||
"Network type",
|
"Network type",
|
||||||
NM_GSM_NETWORK_ANY,
|
NM_SETTING_GSM_NETWORK_TYPE_ANY,
|
||||||
NM_GSM_NETWORK_PREFER_GPRS_EDGE,
|
NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE,
|
||||||
NM_GSM_NETWORK_ANY,
|
NM_SETTING_GSM_NETWORK_TYPE_ANY,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||||
|
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_BAND,
|
(object_class, PROP_ALLOWED_BANDS,
|
||||||
g_param_spec_int (NM_SETTING_GSM_BAND,
|
g_param_spec_uint (NM_SETTING_GSM_ALLOWED_BANDS,
|
||||||
"Band",
|
"Allowed Bands",
|
||||||
"Band",
|
"Bitfield of allowed frequency bands",
|
||||||
-1, 5, -1, /* FIXME: Use an enum for it */
|
NM_SETTING_GSM_BAND_UNKNOWN,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
NM_SETTING_GSM_BAND_UNKNOWN
|
||||||
|
|| NM_SETTING_GSM_BAND_ANY
|
||||||
|
|| NM_SETTING_GSM_BAND_EGSM
|
||||||
|
|| NM_SETTING_GSM_BAND_DCS
|
||||||
|
|| NM_SETTING_GSM_BAND_PCS
|
||||||
|
|| NM_SETTING_GSM_BAND_G850
|
||||||
|
|| NM_SETTING_GSM_BAND_U2100
|
||||||
|
|| NM_SETTING_GSM_BAND_U1800
|
||||||
|
|| NM_SETTING_GSM_BAND_U17IV
|
||||||
|
|| NM_SETTING_GSM_BAND_U800
|
||||||
|
|| NM_SETTING_GSM_BAND_U850
|
||||||
|
|| NM_SETTING_GSM_BAND_U900
|
||||||
|
|| NM_SETTING_GSM_BAND_U17IX,
|
||||||
|
NM_SETTING_GSM_BAND_ANY,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||||
|
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_PIN,
|
(object_class, PROP_PIN,
|
||||||
|
@ -468,6 +501,7 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
|
||||||
NULL,
|
NULL,
|
||||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
|
||||||
|
|
||||||
|
/* Deprecated properties */
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_PUK,
|
(object_class, PROP_PUK,
|
||||||
g_param_spec_string (NM_SETTING_GSM_PUK,
|
g_param_spec_string (NM_SETTING_GSM_PUK,
|
||||||
|
@ -475,4 +509,12 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
|
||||||
"PUK (DEPRECATED and UNUSED)",
|
"PUK (DEPRECATED and UNUSED)",
|
||||||
NULL,
|
NULL,
|
||||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
|
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_BAND,
|
||||||
|
g_param_spec_int (NM_SETTING_GSM_BAND,
|
||||||
|
"Band (DEPRECATED and UNUSED)",
|
||||||
|
"Band (DEPRECATED and UNUSED)",
|
||||||
|
-1, 5, -1,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | NM_SETTING_PARAM_SERIALIZE));
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,25 +53,49 @@ GType nm_setting_gsm_error_get_type (void);
|
||||||
#define NM_SETTING_GSM_ERROR nm_setting_gsm_error_quark ()
|
#define NM_SETTING_GSM_ERROR nm_setting_gsm_error_quark ()
|
||||||
GQuark nm_setting_gsm_error_quark (void);
|
GQuark nm_setting_gsm_error_quark (void);
|
||||||
|
|
||||||
#define NM_SETTING_GSM_NUMBER "number"
|
#define NM_SETTING_GSM_NUMBER "number"
|
||||||
#define NM_SETTING_GSM_USERNAME "username"
|
#define NM_SETTING_GSM_USERNAME "username"
|
||||||
#define NM_SETTING_GSM_PASSWORD "password"
|
#define NM_SETTING_GSM_PASSWORD "password"
|
||||||
#define NM_SETTING_GSM_APN "apn"
|
#define NM_SETTING_GSM_APN "apn"
|
||||||
#define NM_SETTING_GSM_NETWORK_ID "network-id"
|
#define NM_SETTING_GSM_NETWORK_ID "network-id"
|
||||||
#define NM_SETTING_GSM_NETWORK_TYPE "network-type"
|
#define NM_SETTING_GSM_NETWORK_TYPE "network-type"
|
||||||
#define NM_SETTING_GSM_BAND "band"
|
#define NM_SETTING_GSM_ALLOWED_BANDS "allowed-bands"
|
||||||
#define NM_SETTING_GSM_PIN "pin"
|
#define NM_SETTING_GSM_PIN "pin"
|
||||||
|
|
||||||
/* DEPRECATED & UNUSED */
|
/* DEPRECATED & UNUSED */
|
||||||
#define NM_SETTING_GSM_PUK "puk"
|
#define NM_SETTING_GSM_PUK "puk"
|
||||||
|
#define NM_SETTING_GSM_BAND "band"
|
||||||
|
|
||||||
enum {
|
/* DEPRECATED, use NM_SETTING_NETWORK_TYPE_* instead */
|
||||||
NM_GSM_NETWORK_ANY = -1,
|
#define NM_GSM_NETWORK_ANY NM_SETTING_GSM_NETWORK_TYPE_ANY
|
||||||
NM_GSM_NETWORK_UMTS_HSPA = 0,
|
#define NM_GSM_NETWORK_UMTS_HSPA NM_SETTING_GSM_NETWORK_TYPE_UMTS_HSPA
|
||||||
NM_GSM_NETWORK_GPRS_EDGE = 1,
|
#define NM_GSM_NETWORK_GPRS_EDGE NM_SETTING_GSM_NETWORK_TYPE_GPRS_EDGE
|
||||||
NM_GSM_NETWORK_PREFER_UMTS_HSPA = 2,
|
#define NM_GSM_NETWORK_PREFER_UMTS_HSPA NM_SETTING_GSM_NETWORK_TYPE_PREFER_UMTS_HSPA
|
||||||
NM_GSM_NETWORK_PREFER_GPRS_EDGE = 3
|
#define NM_GSM_NETWORK_PREFER_GPRS_EDGE NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE
|
||||||
};
|
|
||||||
|
typedef enum {
|
||||||
|
NM_SETTING_GSM_NETWORK_TYPE_ANY = -1,
|
||||||
|
NM_SETTING_GSM_NETWORK_TYPE_UMTS_HSPA = 0,
|
||||||
|
NM_SETTING_GSM_NETWORK_TYPE_GPRS_EDGE = 1,
|
||||||
|
NM_SETTING_GSM_NETWORK_TYPE_PREFER_UMTS_HSPA = 2,
|
||||||
|
NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE = 3
|
||||||
|
} NMSettingGsmNetworkType;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
NM_SETTING_GSM_BAND_UNKNOWN = 0x00000000,
|
||||||
|
NM_SETTING_GSM_BAND_ANY = 0x00000001,
|
||||||
|
NM_SETTING_GSM_BAND_EGSM = 0x00000002, /* 900 MHz */
|
||||||
|
NM_SETTING_GSM_BAND_DCS = 0x00000004, /* 1800 MHz */
|
||||||
|
NM_SETTING_GSM_BAND_PCS = 0x00000008, /* 1900 MHz */
|
||||||
|
NM_SETTING_GSM_BAND_G850 = 0x00000010, /* 850 MHz */
|
||||||
|
NM_SETTING_GSM_BAND_U2100 = 0x00000020, /* WCDMA 3GPP UMTS 2100 MHz (Class I) */
|
||||||
|
NM_SETTING_GSM_BAND_U1800 = 0x00000040, /* WCDMA 3GPP UMTS 1800 MHz (Class III) */
|
||||||
|
NM_SETTING_GSM_BAND_U17IV = 0x00000080, /* WCDMA 3GPP AWS 1700/2100 MHz (Class IV) */
|
||||||
|
NM_SETTING_GSM_BAND_U800 = 0x00000100, /* WCDMA 3GPP UMTS 800 MHz (Class VI) */
|
||||||
|
NM_SETTING_GSM_BAND_U850 = 0x00000200, /* WCDMA 3GPP UMTS 850 MHz (Class V) */
|
||||||
|
NM_SETTING_GSM_BAND_U900 = 0x00000400, /* WCDMA 3GPP UMTS 900 MHz (Class VIII) */
|
||||||
|
NM_SETTING_GSM_BAND_U17IX = 0x00000800, /* WCDMA 3GPP UMTS 1700 MHz (Class IX) */
|
||||||
|
} NMSettingGsmNetworkBand;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NMSetting parent;
|
NMSetting parent;
|
||||||
|
@ -89,16 +113,19 @@ typedef struct {
|
||||||
|
|
||||||
GType nm_setting_gsm_get_type (void);
|
GType nm_setting_gsm_get_type (void);
|
||||||
|
|
||||||
NMSetting *nm_setting_gsm_new (void);
|
NMSetting *nm_setting_gsm_new (void);
|
||||||
const char *nm_setting_gsm_get_number (NMSettingGsm *setting);
|
const char *nm_setting_gsm_get_number (NMSettingGsm *setting);
|
||||||
const char *nm_setting_gsm_get_username (NMSettingGsm *setting);
|
const char *nm_setting_gsm_get_username (NMSettingGsm *setting);
|
||||||
const char *nm_setting_gsm_get_password (NMSettingGsm *setting);
|
const char *nm_setting_gsm_get_password (NMSettingGsm *setting);
|
||||||
const char *nm_setting_gsm_get_apn (NMSettingGsm *setting);
|
const char *nm_setting_gsm_get_apn (NMSettingGsm *setting);
|
||||||
const char *nm_setting_gsm_get_network_id (NMSettingGsm *setting);
|
const char *nm_setting_gsm_get_network_id (NMSettingGsm *setting);
|
||||||
int nm_setting_gsm_get_network_type (NMSettingGsm *setting);
|
int nm_setting_gsm_get_network_type (NMSettingGsm *setting);
|
||||||
int nm_setting_gsm_get_band (NMSettingGsm *setting);
|
guint32 nm_setting_gsm_get_allowed_bands (NMSettingGsm *setting);
|
||||||
const char *nm_setting_gsm_get_pin (NMSettingGsm *setting);
|
const char *nm_setting_gsm_get_pin (NMSettingGsm *setting);
|
||||||
const char *nm_setting_gsm_get_puk (NMSettingGsm *setting);
|
|
||||||
|
/* DEPRECATED & UNUSED */
|
||||||
|
const char *nm_setting_gsm_get_puk (NMSettingGsm *setting);
|
||||||
|
int nm_setting_gsm_get_band (NMSettingGsm *setting);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -226,16 +226,16 @@ create_connect_properties (NMConnection *connection)
|
||||||
value_hash_add_str (properties, "password", str);
|
value_hash_add_str (properties, "password", str);
|
||||||
|
|
||||||
switch (nm_setting_gsm_get_network_type (setting)) {
|
switch (nm_setting_gsm_get_network_type (setting)) {
|
||||||
case NM_GSM_NETWORK_UMTS_HSPA:
|
case NM_SETTING_GSM_NETWORK_TYPE_UMTS_HSPA:
|
||||||
value_hash_add_uint (properties, "network_mode", MM_MODEM_GSM_MODE_3G_ONLY);
|
value_hash_add_uint (properties, "network_mode", MM_MODEM_GSM_MODE_3G_ONLY);
|
||||||
break;
|
break;
|
||||||
case NM_GSM_NETWORK_GPRS_EDGE:
|
case NM_SETTING_GSM_NETWORK_TYPE_GPRS_EDGE:
|
||||||
value_hash_add_uint (properties, "network_mode", MM_MODEM_GSM_MODE_2G_ONLY);
|
value_hash_add_uint (properties, "network_mode", MM_MODEM_GSM_MODE_2G_ONLY);
|
||||||
break;
|
break;
|
||||||
case NM_GSM_NETWORK_PREFER_UMTS_HSPA:
|
case NM_SETTING_GSM_NETWORK_TYPE_PREFER_UMTS_HSPA:
|
||||||
value_hash_add_uint (properties, "network_mode", MM_MODEM_GSM_MODE_3G_PREFERRED);
|
value_hash_add_uint (properties, "network_mode", MM_MODEM_GSM_MODE_3G_PREFERRED);
|
||||||
break;
|
break;
|
||||||
case NM_GSM_NETWORK_PREFER_GPRS_EDGE:
|
case NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE:
|
||||||
value_hash_add_uint (properties, "network_mode", MM_MODEM_GSM_MODE_2G_PREFERRED);
|
value_hash_add_uint (properties, "network_mode", MM_MODEM_GSM_MODE_2G_PREFERRED);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue