mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 15:00:10 +01:00
modem-manager: rework interface related properties in `NMModem'
The logic behind the `iface' property (which actually is removed) gets split
into three new properties, as follows::
* `uid': Just defines a new string property which must contain a unique ID of
the modem, mainly for logging.
* `control-port': a string property defining which is the control port the
modem uses. This property is actually optional and may be specified as NULL.
The main purpose of this property is to allow the easy integration of the
new ModemManager into the `NMDeviceBt' object. The bluetooth device needs
to know the port used by the modem; and we cannot use the Data port
information as that is only available until the bearer is created. Instead,
for the new ModemManager we will use the control port information exposed.
* `data-port': a string property defining which is the data port to use in the
connection. This property is always defined in the `NMModemGsm' and
`NMModemCdma' objects.
This commit is contained in:
parent
1f0dbd6790
commit
a8f7a45e3f
8 changed files with 108 additions and 37 deletions
|
|
@ -71,7 +71,9 @@ nm_modem_cdma_new (const char *path,
|
|||
|
||||
return (NMModem *) g_object_new (NM_TYPE_MODEM_CDMA,
|
||||
NM_MODEM_PATH, path,
|
||||
NM_MODEM_IFACE, data_device,
|
||||
NM_MODEM_UID, data_device,
|
||||
NM_MODEM_CONTROL_PORT, NULL,
|
||||
NM_MODEM_DATA_PORT, data_device,
|
||||
NM_MODEM_IP_METHOD, ip_method,
|
||||
NM_MODEM_CONNECTED, (state == NM_MODEM_STATE_CONNECTED),
|
||||
NULL);
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ static_stage3_done (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
|
|||
addr = nm_ip4_address_new ();
|
||||
|
||||
nm_log_info (LOGD_MB, "(%s): IPv4 static configuration:",
|
||||
nm_modem_get_iface (NM_MODEM (self)));
|
||||
nm_modem_get_uid (NM_MODEM (self)));
|
||||
|
||||
/* IP address */
|
||||
nm_ip4_address_set_address (addr, g_value_get_uint (g_value_array_get_nth (ret_array, 0)));
|
||||
|
|
|
|||
|
|
@ -113,7 +113,9 @@ nm_modem_gsm_new (const char *path,
|
|||
|
||||
return (NMModem *) g_object_new (NM_TYPE_MODEM_GSM,
|
||||
NM_MODEM_PATH, path,
|
||||
NM_MODEM_IFACE, data_device,
|
||||
NM_MODEM_UID, data_device,
|
||||
NM_MODEM_CONTROL_PORT, NULL,
|
||||
NM_MODEM_DATA_PORT, data_device,
|
||||
NM_MODEM_IP_METHOD, ip_method,
|
||||
NM_MODEM_CONNECTED, (state == NM_MODEM_STATE_CONNECTED),
|
||||
NULL);
|
||||
|
|
|
|||
|
|
@ -38,8 +38,10 @@ G_DEFINE_TYPE (NMModem, nm_modem, G_TYPE_OBJECT)
|
|||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_IFACE,
|
||||
PROP_CONTROL_PORT,
|
||||
PROP_DATA_PORT,
|
||||
PROP_PATH,
|
||||
PROP_UID,
|
||||
PROP_IP_METHOD,
|
||||
PROP_IP_TIMEOUT,
|
||||
PROP_ENABLED,
|
||||
|
|
@ -49,8 +51,10 @@ enum {
|
|||
};
|
||||
|
||||
typedef struct {
|
||||
char *uid;
|
||||
char *path;
|
||||
char *iface;
|
||||
char *control_port;
|
||||
char *data_port;
|
||||
guint32 ip_method;
|
||||
|
||||
NMPPPManager *ppp_manager;
|
||||
|
|
@ -229,7 +233,7 @@ ppp_stage3_ip4_config_start (NMModem *self,
|
|||
ip_timeout = priv->mm_ip_timeout;
|
||||
}
|
||||
|
||||
priv->ppp_manager = nm_ppp_manager_new (priv->iface);
|
||||
priv->ppp_manager = nm_ppp_manager_new (priv->data_port);
|
||||
if (nm_ppp_manager_start (priv->ppp_manager, req, ppp_name, ip_timeout, &error)) {
|
||||
g_signal_connect (priv->ppp_manager, "state-changed",
|
||||
G_CALLBACK (ppp_state_changed),
|
||||
|
|
@ -592,12 +596,12 @@ nm_modem_device_state_changed (NMModem *self,
|
|||
/*****************************************************************************/
|
||||
|
||||
const char *
|
||||
nm_modem_get_iface (NMModem *self)
|
||||
nm_modem_get_uid (NMModem *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
g_return_val_if_fail (NM_IS_MODEM (self), NULL);
|
||||
|
||||
return NM_MODEM_GET_PRIVATE (self)->iface;
|
||||
return NM_MODEM_GET_PRIVATE (self)->uid;
|
||||
}
|
||||
|
||||
const char *
|
||||
|
|
@ -609,6 +613,24 @@ nm_modem_get_path (NMModem *self)
|
|||
return NM_MODEM_GET_PRIVATE (self)->path;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_modem_get_control_port (NMModem *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
g_return_val_if_fail (NM_IS_MODEM (self), NULL);
|
||||
|
||||
return NM_MODEM_GET_PRIVATE (self)->control_port;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_modem_get_data_port (NMModem *self)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, NULL);
|
||||
g_return_val_if_fail (NM_IS_MODEM (self), NULL);
|
||||
|
||||
return NM_MODEM_GET_PRIVATE (self)->data_port;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -632,8 +654,8 @@ constructor (GType type,
|
|||
|
||||
priv = NM_MODEM_GET_PRIVATE (object);
|
||||
|
||||
if (!priv->iface) {
|
||||
nm_log_err (LOGD_HW, "modem command interface not provided");
|
||||
if (!priv->data_port && !priv->control_port) {
|
||||
nm_log_err (LOGD_HW, "neither modem command nor data interface provided");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
|
@ -659,8 +681,14 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_PATH:
|
||||
g_value_set_string (value, priv->path);
|
||||
break;
|
||||
case PROP_IFACE:
|
||||
g_value_set_string (value, priv->iface);
|
||||
case PROP_CONTROL_PORT:
|
||||
g_value_set_string (value, priv->control_port);
|
||||
break;
|
||||
case PROP_DATA_PORT:
|
||||
g_value_set_string (value, priv->data_port);
|
||||
break;
|
||||
case PROP_UID:
|
||||
g_value_set_string (value, priv->uid);
|
||||
break;
|
||||
case PROP_IP_METHOD:
|
||||
g_value_set_uint (value, priv->ip_method);
|
||||
|
|
@ -691,9 +719,15 @@ set_property (GObject *object, guint prop_id,
|
|||
/* Construct only */
|
||||
priv->path = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_IFACE:
|
||||
case PROP_CONTROL_PORT:
|
||||
priv->control_port = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_DATA_PORT:
|
||||
priv->data_port = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_UID:
|
||||
/* Construct only */
|
||||
priv->iface = g_value_dup_string (value);
|
||||
priv->uid = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_IP_METHOD:
|
||||
priv->ip_method = g_value_get_uint (value);
|
||||
|
|
@ -731,8 +765,10 @@ finalize (GObject *object)
|
|||
{
|
||||
NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->iface);
|
||||
g_free (priv->uid);
|
||||
g_free (priv->path);
|
||||
g_free (priv->control_port);
|
||||
g_free (priv->data_port);
|
||||
|
||||
G_OBJECT_CLASS (nm_modem_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -756,6 +792,14 @@ nm_modem_class_init (NMModemClass *klass)
|
|||
|
||||
/* Properties */
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_UID,
|
||||
g_param_spec_string (NM_MODEM_UID,
|
||||
"UID",
|
||||
"Modem unique ID",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PATH,
|
||||
g_param_spec_string (NM_MODEM_PATH,
|
||||
|
|
@ -765,13 +809,21 @@ nm_modem_class_init (NMModemClass *klass)
|
|||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IFACE,
|
||||
g_param_spec_string (NM_MODEM_IFACE,
|
||||
"Interface",
|
||||
"Modem command interface",
|
||||
(object_class, PROP_CONTROL_PORT,
|
||||
g_param_spec_string (NM_MODEM_CONTROL_PORT,
|
||||
"Control port",
|
||||
"The port controlling the modem",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DATA_PORT,
|
||||
g_param_spec_string (NM_MODEM_DATA_PORT,
|
||||
"Data port",
|
||||
"The port to connect to",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IP_METHOD,
|
||||
g_param_spec_uint (NM_MODEM_IP_METHOD,
|
||||
|
|
|
|||
|
|
@ -36,12 +36,14 @@ G_BEGIN_DECLS
|
|||
#define NM_IS_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_MODEM))
|
||||
#define NM_MODEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_MODEM, NMModemClass))
|
||||
|
||||
#define NM_MODEM_PATH "path"
|
||||
#define NM_MODEM_IFACE "iface"
|
||||
#define NM_MODEM_IP_METHOD "ip-method"
|
||||
#define NM_MODEM_IP_TIMEOUT "ip-timeout"
|
||||
#define NM_MODEM_ENABLED "enabled"
|
||||
#define NM_MODEM_CONNECTED "connected"
|
||||
#define NM_MODEM_UID "uid"
|
||||
#define NM_MODEM_PATH "path"
|
||||
#define NM_MODEM_CONTROL_PORT "control-port"
|
||||
#define NM_MODEM_DATA_PORT "data-port"
|
||||
#define NM_MODEM_IP_METHOD "ip-method"
|
||||
#define NM_MODEM_IP_TIMEOUT "ip-timeout"
|
||||
#define NM_MODEM_ENABLED "enabled"
|
||||
#define NM_MODEM_CONNECTED "connected"
|
||||
|
||||
#define NM_MODEM_PPP_STATS "ppp-stats"
|
||||
#define NM_MODEM_PPP_FAILED "ppp-failed"
|
||||
|
|
@ -110,8 +112,10 @@ typedef struct {
|
|||
|
||||
GType nm_modem_get_type (void);
|
||||
|
||||
const char * nm_modem_get_iface (NMModem *modem);
|
||||
const char * nm_modem_get_path (NMModem *modem);
|
||||
const char *nm_modem_get_path (NMModem *modem);
|
||||
const char *nm_modem_get_uid (NMModem *modem);
|
||||
const char *nm_modem_get_control_port (NMModem *modem);
|
||||
const char *nm_modem_get_data_port (NMModem *modem);
|
||||
|
||||
NMConnection *nm_modem_get_best_auto_connection (NMModem *self,
|
||||
GSList *connections,
|
||||
|
|
|
|||
|
|
@ -611,7 +611,8 @@ nm_device_bt_modem_added (NMDeviceBt *self,
|
|||
const char *driver)
|
||||
{
|
||||
NMDeviceBtPrivate *priv;
|
||||
const char *modem_iface;
|
||||
const gchar *modem_data_port;
|
||||
const gchar *modem_control_port;
|
||||
char *base;
|
||||
NMDeviceState state;
|
||||
NMDeviceStateReason reason = NM_DEVICE_STATE_REASON_NONE;
|
||||
|
|
@ -622,14 +623,15 @@ nm_device_bt_modem_added (NMDeviceBt *self,
|
|||
g_return_val_if_fail (NM_IS_MODEM (modem), FALSE);
|
||||
|
||||
priv = NM_DEVICE_BT_GET_PRIVATE (self);
|
||||
modem_iface = nm_modem_get_iface (modem);
|
||||
g_return_val_if_fail (modem_iface != NULL, FALSE);
|
||||
modem_data_port = nm_modem_get_data_port (modem);
|
||||
modem_control_port = nm_modem_get_control_port (modem);
|
||||
g_return_val_if_fail (modem_data_port != NULL || modem_control_port != NULL, FALSE);
|
||||
|
||||
if (!priv->rfcomm_iface)
|
||||
return FALSE;
|
||||
|
||||
base = g_path_get_basename (priv->rfcomm_iface);
|
||||
if (strcmp (base, modem_iface)) {
|
||||
if (g_strcmp0 (base, modem_data_port) && g_strcmp0 (base, modem_control_port)) {
|
||||
g_free (base);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -670,6 +672,8 @@ nm_device_bt_modem_added (NMDeviceBt *self,
|
|||
g_signal_connect (modem, NM_MODEM_AUTH_REQUESTED, G_CALLBACK (modem_auth_requested), self);
|
||||
g_signal_connect (modem, NM_MODEM_AUTH_RESULT, G_CALLBACK (modem_auth_result), self);
|
||||
|
||||
nm_device_set_ip_iface (NM_DEVICE (self), modem_data_port);
|
||||
|
||||
/* Kick off the modem connection */
|
||||
if (!modem_stage1 (self, modem, &reason))
|
||||
nm_device_state_changed (NM_DEVICE (self), NM_DEVICE_STATE_FAILED, reason);
|
||||
|
|
@ -1341,7 +1345,7 @@ nm_device_bt_class_init (NMDeviceBtClass *klass)
|
|||
G_TYPE_NONE, 2,
|
||||
G_TYPE_UINT, G_TYPE_UINT);
|
||||
|
||||
signals[PROPERTIES_CHANGED] =
|
||||
signals[PROPERTIES_CHANGED] =
|
||||
nm_properties_changed_signal_new (object_class,
|
||||
G_STRUCT_OFFSET (NMDeviceBtClass, properties_changed));
|
||||
|
||||
|
|
|
|||
|
|
@ -345,7 +345,9 @@ NMDevice *
|
|||
nm_device_modem_new (NMModem *modem, const char *driver)
|
||||
{
|
||||
NMDeviceModemCapabilities caps = NM_DEVICE_MODEM_CAPABILITY_NONE;
|
||||
const char *type_desc = NULL;
|
||||
NMDeviceModemCapabilities current_caps = NM_DEVICE_MODEM_CAPABILITY_NONE;
|
||||
const gchar *type_desc = NULL;
|
||||
const gchar *ip_iface = NULL;
|
||||
|
||||
g_return_val_if_fail (modem != NULL, NULL);
|
||||
g_return_val_if_fail (NM_IS_MODEM (modem), NULL);
|
||||
|
|
@ -353,10 +355,14 @@ nm_device_modem_new (NMModem *modem, const char *driver)
|
|||
|
||||
if (NM_IS_MODEM_CDMA (modem)) {
|
||||
caps = NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO;
|
||||
current_caps = caps;
|
||||
type_desc = "CDMA/EVDO";
|
||||
ip_iface = nm_modem_get_data_port (modem);
|
||||
} else if (NM_IS_MODEM_GSM (modem)) {
|
||||
caps = NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS;
|
||||
current_caps = caps;
|
||||
type_desc = "GSM/UMTS";
|
||||
ip_iface = nm_modem_get_data_port (modem);
|
||||
} else {
|
||||
nm_log_warn (LOGD_MB, "unhandled modem type %s", G_OBJECT_TYPE_NAME (modem));
|
||||
return NULL;
|
||||
|
|
@ -364,7 +370,8 @@ nm_device_modem_new (NMModem *modem, const char *driver)
|
|||
|
||||
return (NMDevice *) g_object_new (NM_TYPE_DEVICE_MODEM,
|
||||
NM_DEVICE_UDI, nm_modem_get_path (modem),
|
||||
NM_DEVICE_IFACE, nm_modem_get_iface (modem),
|
||||
NM_DEVICE_IFACE, nm_modem_get_uid (modem),
|
||||
NM_DEVICE_IP_IFACE, ip_iface,
|
||||
NM_DEVICE_DRIVER, driver,
|
||||
NM_DEVICE_TYPE_DESC, type_desc,
|
||||
NM_DEVICE_DEVICE_TYPE, NM_DEVICE_TYPE_MODEM,
|
||||
|
|
@ -507,7 +514,7 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass)
|
|||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
/* Signals */
|
||||
signals[PROPERTIES_CHANGED] =
|
||||
signals[PROPERTIES_CHANGED] =
|
||||
nm_properties_changed_signal_new (object_class,
|
||||
G_STRUCT_OFFSET (NMDeviceModemClass, properties_changed));
|
||||
|
||||
|
|
@ -522,4 +529,3 @@ nm_device_modem_class_init (NMDeviceModemClass *mclass)
|
|||
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (mclass),
|
||||
&dbus_glib_nm_device_modem_object_info);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -387,7 +387,8 @@ modem_added (NMModemManager *modem_manager,
|
|||
const char *ip_iface;
|
||||
GSList *iter;
|
||||
|
||||
ip_iface = nm_modem_get_iface (modem);
|
||||
ip_iface = nm_modem_get_data_port (modem);
|
||||
g_assert (ip_iface);
|
||||
|
||||
replace_device = find_device_by_ip_iface (NM_MANAGER (user_data), ip_iface);
|
||||
if (replace_device) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue