libnm: Add initial EPS parameters to gsm settings

The configure flag and APN for the initial EPS bearer are used when
bringing up cellular modem connections. These settings are only relevant
for LTE modems.

Signed-off-by: Sven Schwermer <sven.schwermer@disruptive-technologies.com>
This commit is contained in:
Sven Schwermer
2022-08-09 09:48:20 +02:00
parent 49d6e1fe4b
commit db3b112846
8 changed files with 158 additions and 44 deletions

View File

@@ -1923,4 +1923,6 @@ global:
libnm_1_44_0 {
global:
nm_active_connection_get_controller;
nm_setting_gsm_get_initial_eps_apn;
nm_setting_gsm_get_initial_eps_config;
} libnm_1_42_0;

View File

@@ -1313,6 +1313,14 @@
dbus-type="b"
gprop-type="gboolean"
/>
<property name="initial-eps-bearer-apn"
dbus-type="s"
gprop-type="gchararray"
/>
<property name="initial-eps-bearer-configure"
dbus-type="b"
gprop-type="gboolean"
/>
<property name="mtu"
dbus-type="u"
gprop-type="guint"

View File

@@ -36,7 +36,9 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_AUTO_CONFIG,
PROP_DEVICE_ID,
PROP_SIM_ID,
PROP_SIM_OPERATOR_ID,
PROP_MTU, );
PROP_MTU,
PROP_INITIAL_EPS_CONFIG,
PROP_INITIAL_EPS_APN, );
typedef struct {
char *number;
@@ -48,11 +50,13 @@ typedef struct {
char *apn;
char *network_id;
char *pin;
char *initial_eps_apn;
guint password_flags;
guint pin_flags;
guint32 mtu;
bool auto_config;
bool home_only;
bool initial_eps_config;
} NMSettingGsmPrivate;
/**
@@ -286,6 +290,38 @@ nm_setting_gsm_get_mtu(NMSettingGsm *setting)
return NM_SETTING_GSM_GET_PRIVATE(setting)->mtu;
}
/**
* nm_setting_gsm_get_initial_eps_config:
* @setting: the #NMSettingGsm
*
* Returns: the #NMSettingGsm:initial-eps-bearer-configure property of the setting
*
* Since: 1.44
**/
gboolean
nm_setting_gsm_get_initial_eps_config(NMSettingGsm *setting)
{
g_return_val_if_fail(NM_IS_SETTING_GSM(setting), FALSE);
return NM_SETTING_GSM_GET_PRIVATE(setting)->initial_eps_config;
}
/**
* nm_setting_gsm_get_initial_eps_apn:
* @setting: the #NMSettingGsm
*
* Returns: the #NMSettingGsm:initial-eps-bearer-apn property of the setting
*
* Since: 1.44
**/
const char *
nm_setting_gsm_get_initial_eps_apn(NMSettingGsm *setting)
{
g_return_val_if_fail(NM_IS_SETTING_GSM(setting), NULL);
return NM_SETTING_GSM_GET_PRIVATE(setting)->initial_eps_apn;
}
static gboolean
_verify_apn(const char *apn, gboolean allow_empty, const char *property_name, GError **error)
{
@@ -368,6 +404,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
if (!_verify_apn(priv->apn, TRUE, NM_SETTING_GSM_APN, error))
return FALSE;
if (!_verify_apn(priv->initial_eps_apn, FALSE, NM_SETTING_GSM_INITIAL_EPS_BEARER_APN, error))
return FALSE;
if (priv->username && priv->username[0] == '\0') {
g_set_error_literal(error,
NM_CONNECTION_ERROR,
@@ -764,6 +803,41 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass)
NMSettingGsmPrivate,
mtu);
/**
* NMSettingGsm:initial-eps-bearer-configure:
*
* For LTE modems, this setting determines whether the initial EPS bearer
* shall be configured when bringing up the connection. It is inferred TRUE
* if initial-eps-bearer-apn is set.
*
* Since: 1.44
**/
_nm_setting_property_define_direct_boolean(properties_override,
obj_properties,
NM_SETTING_GSM_INITIAL_EPS_BEARER_CONFIGURE,
PROP_INITIAL_EPS_CONFIG,
FALSE,
NM_SETTING_PARAM_NONE,
NMSettingGsmPrivate,
initial_eps_config);
/**
* NMSettingGsm:initial-eps-bearer-apn:
*
* For LTE modems, this sets the APN for the initial EPS bearer that is set
* up when attaching to the network. Setting this parameters implies
* initial-eps-bearer-configure to be TRUE.
*
* Since: 1.44
**/
_nm_setting_property_define_direct_string(properties_override,
obj_properties,
NM_SETTING_GSM_INITIAL_EPS_BEARER_APN,
PROP_INITIAL_EPS_APN,
NM_SETTING_PARAM_NONE,
NMSettingGsmPrivate,
initial_eps_apn);
/* Ignore incoming deprecated properties */
_nm_properties_override_dbus(properties_override,
"allowed-bands",

View File

@@ -26,19 +26,21 @@ G_BEGIN_DECLS
#define NM_SETTING_GSM_SETTING_NAME "gsm"
#define NM_SETTING_GSM_AUTO_CONFIG "auto-config"
#define NM_SETTING_GSM_USERNAME "username"
#define NM_SETTING_GSM_PASSWORD "password"
#define NM_SETTING_GSM_PASSWORD_FLAGS "password-flags"
#define NM_SETTING_GSM_APN "apn"
#define NM_SETTING_GSM_NETWORK_ID "network-id"
#define NM_SETTING_GSM_PIN "pin"
#define NM_SETTING_GSM_PIN_FLAGS "pin-flags"
#define NM_SETTING_GSM_HOME_ONLY "home-only"
#define NM_SETTING_GSM_DEVICE_ID "device-id"
#define NM_SETTING_GSM_SIM_ID "sim-id"
#define NM_SETTING_GSM_SIM_OPERATOR_ID "sim-operator-id"
#define NM_SETTING_GSM_MTU "mtu"
#define NM_SETTING_GSM_AUTO_CONFIG "auto-config"
#define NM_SETTING_GSM_USERNAME "username"
#define NM_SETTING_GSM_PASSWORD "password"
#define NM_SETTING_GSM_PASSWORD_FLAGS "password-flags"
#define NM_SETTING_GSM_APN "apn"
#define NM_SETTING_GSM_NETWORK_ID "network-id"
#define NM_SETTING_GSM_PIN "pin"
#define NM_SETTING_GSM_PIN_FLAGS "pin-flags"
#define NM_SETTING_GSM_HOME_ONLY "home-only"
#define NM_SETTING_GSM_DEVICE_ID "device-id"
#define NM_SETTING_GSM_SIM_ID "sim-id"
#define NM_SETTING_GSM_SIM_OPERATOR_ID "sim-operator-id"
#define NM_SETTING_GSM_MTU "mtu"
#define NM_SETTING_GSM_INITIAL_EPS_BEARER_CONFIGURE "initial-eps-bearer-configure"
#define NM_SETTING_GSM_INITIAL_EPS_BEARER_APN "initial-eps-bearer-apn"
/* Deprecated */
#define NM_SETTING_GSM_NUMBER "number"
@@ -67,6 +69,10 @@ NM_AVAILABLE_IN_1_2
const char *nm_setting_gsm_get_sim_operator_id(NMSettingGsm *setting);
NM_AVAILABLE_IN_1_8
guint32 nm_setting_gsm_get_mtu(NMSettingGsm *setting);
NM_AVAILABLE_IN_1_44
gboolean nm_setting_gsm_get_initial_eps_config(NMSettingGsm *setting);
NM_AVAILABLE_IN_1_44
const char *nm_setting_gsm_get_initial_eps_apn(NMSettingGsm *setting);
NM_DEPRECATED_IN_1_16
const char *nm_setting_gsm_get_number(NMSettingGsm *setting);

View File

@@ -5971,6 +5971,12 @@ static const NMMetaPropertyInfo *const property_infos_GSM[] = {
.get_fcn = MTU_GET_FCN (NMSettingGsm, nm_setting_gsm_get_mtu),
),
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_GSM_INITIAL_EPS_BEARER_CONFIGURE,
.property_type = &_pt_gobject_bool,
),
PROPERTY_INFO_WITH_DESC (NM_SETTING_GSM_INITIAL_EPS_BEARER_APN,
.property_type = &_pt_gobject_string,
),
NULL
};

View File

@@ -141,6 +141,8 @@
#define DESCRIBE_DOC_NM_SETTING_GSM_AUTO_CONFIG N_("When TRUE, the settings such as APN, username, or password will default to values that match the network the modem will register to in the Mobile Broadband Provider database.")
#define DESCRIBE_DOC_NM_SETTING_GSM_DEVICE_ID N_("The device unique identifier (as given by the WWAN management service) which this connection applies to. If given, the connection will only apply to the specified device.")
#define DESCRIBE_DOC_NM_SETTING_GSM_HOME_ONLY N_("When TRUE, only connections to the home network will be allowed. Connections to roaming networks will not be made.")
#define DESCRIBE_DOC_NM_SETTING_GSM_INITIAL_EPS_BEARER_APN N_("For LTE modems, this sets the APN for the initial EPS bearer that is set up when attaching to the network. Setting this parameters implies initial-eps-bearer-configure to be TRUE.")
#define DESCRIBE_DOC_NM_SETTING_GSM_INITIAL_EPS_BEARER_CONFIGURE N_("For LTE modems, this setting determines whether the initial EPS bearer shall be configured when bringing up the connection. It is inferred TRUE if initial-eps-bearer-apn is set.")
#define DESCRIBE_DOC_NM_SETTING_GSM_MTU N_("If non-zero, only transmit packets of the specified size or smaller, breaking larger packets up into multiple frames.")
#define DESCRIBE_DOC_NM_SETTING_GSM_NETWORK_ID N_("The Network ID (GSM LAI format, ie MCC-MNC) to force specific network registration. If the Network ID is specified, NetworkManager will attempt to force the device to register only on the specified network. This can be used to ensure that the device does not roam when direct roaming control of the device is not otherwise possible.")
#define DESCRIBE_DOC_NM_SETTING_GSM_NUMBER N_("Legacy setting that used to help establishing PPP data sessions for GSM-based modems.")

View File

@@ -588,6 +588,10 @@
description="A MCC/MNC string like &quot;310260&quot; or &quot;21601&quot; identifying the specific mobile network operator which this connection applies to. If given, the connection will apply to any device also allowed by &quot;device-id&quot; and &quot;sim-id&quot; which contains a SIM card provisioned by the given operator." />
<property name="mtu"
description="If non-zero, only transmit packets of the specified size or smaller, breaking larger packets up into multiple frames." />
<property name="initial-eps-bearer-configure"
description="For LTE modems, this setting determines whether the initial EPS bearer shall be configured when bringing up the connection. It is inferred TRUE if initial-eps-bearer-apn is set." />
<property name="initial-eps-bearer-apn"
description="For LTE modems, this sets the APN for the initial EPS bearer that is set up when attaching to the network. Setting this parameters implies initial-eps-bearer-configure to be TRUE." />
</setting>
<setting name="hostname" >
<property name="priority"

View File

@@ -182,12 +182,12 @@ id
path
uuid
<<<
size: 4990
size: 5076
location: src/tests/client/test-client.py:test_003()/14
cmd: $NMCLI con s con-gsm1
lang: C
returncode: 0
stdout: 4857 bytes
stdout: 4943 bytes
>>>
connection.id: con-gsm1
connection.uuid: UUID-con-gsm1-REPLACED-REPLACED-REPL
@@ -291,18 +291,20 @@ gsm.device-id: --
gsm.sim-id: --
gsm.sim-operator-id: --
gsm.mtu: auto
gsm.initial-eps-bearer-configure: no
gsm.initial-eps-bearer-apn: --
proxy.method: none
proxy.browser-only: no
proxy.pac-url: --
proxy.pac-script: --
<<<
size: 5028
size: 5115
location: src/tests/client/test-client.py:test_003()/15
cmd: $NMCLI con s con-gsm1
lang: pl_PL.UTF-8
returncode: 0
stdout: 4885 bytes
stdout: 4972 bytes
>>>
connection.id: con-gsm1
connection.uuid: UUID-con-gsm1-REPLACED-REPLACED-REPL
@@ -406,48 +408,50 @@ gsm.device-id: --
gsm.sim-id: --
gsm.sim-operator-id: --
gsm.mtu: automatyczne
gsm.initial-eps-bearer-configure: nie
gsm.initial-eps-bearer-apn: --
proxy.method: none
proxy.browser-only: nie
proxy.pac-url: --
proxy.pac-script: --
<<<
size: 499
size: 503
location: src/tests/client/test-client.py:test_003()/16
cmd: $NMCLI -g all con s con-gsm1
lang: C
returncode: 0
stdout: 360 bytes
stdout: 364 bytes
>>>
connection:con-gsm1:UUID-con-gsm1-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:0x0:-1:-1
ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1::0::-1
ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:default:0:auto:::0:yes::0x0:-1:
serial:5:8:even:1:100
gsm:no:::<hidden>:0:xyz.con-gsm1::<hidden>:0:no::::auto
gsm:no:::<hidden>:0:xyz.con-gsm1::<hidden>:0:no::::auto:no:
proxy:none:no::
<<<
size: 509
size: 513
location: src/tests/client/test-client.py:test_003()/17
cmd: $NMCLI -g all con s con-gsm1
lang: pl_PL.UTF-8
returncode: 0
stdout: 360 bytes
stdout: 364 bytes
>>>
connection:con-gsm1:UUID-con-gsm1-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:0x0:-1:-1
ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1::0::-1
ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:default:0:auto:::0:yes::0x0:-1:
serial:5:8:even:1:100
gsm:no:::<hidden>:0:xyz.con-gsm1::<hidden>:0:no::::auto
gsm:no:::<hidden>:0:xyz.con-gsm1::<hidden>:0:no::::auto:no:
proxy:none:no::
<<<
size: 4978
size: 5064
location: src/tests/client/test-client.py:test_003()/18
cmd: $NMCLI con s con-gsm2
lang: C
returncode: 0
stdout: 4845 bytes
stdout: 4931 bytes
>>>
connection.id: con-gsm2
connection.uuid: UUID-con-gsm2-REPLACED-REPLACED-REPL
@@ -551,18 +555,20 @@ gsm.device-id: --
gsm.sim-id: --
gsm.sim-operator-id: --
gsm.mtu: auto
gsm.initial-eps-bearer-configure: no
gsm.initial-eps-bearer-apn: --
proxy.method: none
proxy.browser-only: no
proxy.pac-url: --
proxy.pac-script: --
<<<
size: 5016
size: 5103
location: src/tests/client/test-client.py:test_003()/19
cmd: $NMCLI con s con-gsm2
lang: pl_PL.UTF-8
returncode: 0
stdout: 4873 bytes
stdout: 4960 bytes
>>>
connection.id: con-gsm2
connection.uuid: UUID-con-gsm2-REPLACED-REPLACED-REPL
@@ -666,48 +672,50 @@ gsm.device-id: --
gsm.sim-id: --
gsm.sim-operator-id: --
gsm.mtu: automatyczne
gsm.initial-eps-bearer-configure: nie
gsm.initial-eps-bearer-apn: --
proxy.method: none
proxy.browser-only: nie
proxy.pac-url: --
proxy.pac-script: --
<<<
size: 487
size: 491
location: src/tests/client/test-client.py:test_003()/20
cmd: $NMCLI -g all con s con-gsm2
lang: C
returncode: 0
stdout: 348 bytes
stdout: 352 bytes
>>>
connection:con-gsm2:UUID-con-gsm2-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:0x0:-1:-1
ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1::0::-1
ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:default:0:auto:::0:yes::0x0:-1:
serial:5:8:even:1:100
gsm:no:::<hidden>:0:::<hidden>:0:no::::auto
gsm:no:::<hidden>:0:::<hidden>:0:no::::auto:no:
proxy:none:no::
<<<
size: 497
size: 501
location: src/tests/client/test-client.py:test_003()/21
cmd: $NMCLI -g all con s con-gsm2
lang: pl_PL.UTF-8
returncode: 0
stdout: 348 bytes
stdout: 352 bytes
>>>
connection:con-gsm2:UUID-con-gsm2-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:0x0:-1:-1
ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1::0::-1
ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:default:0:auto:::0:yes::0x0:-1:
serial:5:8:even:1:100
gsm:no:::<hidden>:0:::<hidden>:0:no::::auto
gsm:no:::<hidden>:0:::<hidden>:0:no::::auto:no:
proxy:none:no::
<<<
size: 4978
size: 5064
location: src/tests/client/test-client.py:test_003()/22
cmd: $NMCLI con s con-gsm3
lang: C
returncode: 0
stdout: 4845 bytes
stdout: 4931 bytes
>>>
connection.id: con-gsm3
connection.uuid: UUID-con-gsm3-REPLACED-REPLACED-REPL
@@ -811,18 +819,20 @@ gsm.device-id: --
gsm.sim-id: --
gsm.sim-operator-id: --
gsm.mtu: auto
gsm.initial-eps-bearer-configure: no
gsm.initial-eps-bearer-apn: --
proxy.method: none
proxy.browser-only: no
proxy.pac-url: --
proxy.pac-script: --
<<<
size: 5016
size: 5103
location: src/tests/client/test-client.py:test_003()/23
cmd: $NMCLI con s con-gsm3
lang: pl_PL.UTF-8
returncode: 0
stdout: 4873 bytes
stdout: 4960 bytes
>>>
connection.id: con-gsm3
connection.uuid: UUID-con-gsm3-REPLACED-REPLACED-REPL
@@ -926,39 +936,41 @@ gsm.device-id: --
gsm.sim-id: --
gsm.sim-operator-id: --
gsm.mtu: automatyczne
gsm.initial-eps-bearer-configure: nie
gsm.initial-eps-bearer-apn: --
proxy.method: none
proxy.browser-only: nie
proxy.pac-url: --
proxy.pac-script: --
<<<
size: 488
size: 492
location: src/tests/client/test-client.py:test_003()/24
cmd: $NMCLI -g all con s con-gsm3
lang: C
returncode: 0
stdout: 349 bytes
stdout: 353 bytes
>>>
connection:con-gsm3:UUID-con-gsm3-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:0x0:-1:-1
ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1::0::-1
ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:default:0:auto:::0:yes::0x0:-1:
serial:5:8:even:1:100
gsm:no:::<hidden>:0: ::<hidden>:0:no::::auto
gsm:no:::<hidden>:0: ::<hidden>:0:no::::auto:no:
proxy:none:no::
<<<
size: 498
size: 502
location: src/tests/client/test-client.py:test_003()/25
cmd: $NMCLI -g all con s con-gsm3
lang: pl_PL.UTF-8
returncode: 0
stdout: 349 bytes
stdout: 353 bytes
>>>
connection:con-gsm3:UUID-con-gsm3-REPLACED-REPLACED-REPL::gsm::no:0:-1:0:-1:0:no:::::-1::0:unknown:default:-1:-1:-1:0x0:-1:-1
ipv4:auto::: :0::::-1:0::no:no:::0:yes:::0x0:no:yes:-1:-1::0::-1
ipv6:auto::::0::::-1:0::no:no:no:yes:-1:-1:default:0:auto:::0:yes::0x0:-1:
serial:5:8:even:1:100
gsm:no:::<hidden>:0: ::<hidden>:0:no::::auto
gsm:no:::<hidden>:0: ::<hidden>:0:no::::auto:no:
proxy:none:no::
<<<