From c9579b1bf0ff9a007368044d2acaeff37d6d42f8 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Wed, 7 Nov 2012 15:40:40 +0100 Subject: [PATCH] device-bt, device-modem: listen for data port changes in the `NMModem' The new ModemManager1-based `NMModemBroadband' objects will set the data port information only after having created the bearer as part of the connection process. The devices, therefore, need to listen to changes in the `data-port' property, so that the `ip-iface' in the `NMDevice' is set before finishing the stage1 of the activation. This is required in order to have a proper ifup of the data port. --- src/nm-device-bt.c | 15 ++++++++++++++- src/nm-device-modem.c | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/nm-device-bt.c b/src/nm-device-bt.c index 9d0d63414..5bc324cc5 100644 --- a/src/nm-device-bt.c +++ b/src/nm-device-bt.c @@ -578,6 +578,14 @@ modem_ip4_config_result (NMModem *self, } } +static void +data_port_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data) +{ + NMDevice *self = NM_DEVICE (user_data); + + nm_device_set_ip_iface (self, nm_modem_get_data_port (modem)); +} + static gboolean modem_stage1 (NMDeviceBt *self, NMModem *modem, NMDeviceStateReason *reason) { @@ -672,7 +680,12 @@ 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); + /* In the old ModemManager the data port is known from the very beginning; + * while in the new ModemManager the data port is set afterwards when the bearer gets + * created */ + if (modem_data_port) + nm_device_set_ip_iface (NM_DEVICE (self), modem_data_port); + g_signal_connect (modem, "notify::" NM_MODEM_DATA_PORT, G_CALLBACK (data_port_changed_cb), self); /* Kick off the modem connection */ if (!modem_stage1 (self, modem, &reason)) diff --git a/src/nm-device-modem.c b/src/nm-device-modem.c index 0a331f899..d9ef5c83a 100644 --- a/src/nm-device-modem.c +++ b/src/nm-device-modem.c @@ -162,6 +162,16 @@ modem_ip4_config_result (NMModem *self, } } +static void +data_port_changed_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data) +{ + NMDevice *self = NM_DEVICE (user_data); + + /* We set the IP iface in the device as soon as we know it, so that we + * properly ifup it if needed */ + nm_device_set_ip_iface (self, nm_modem_get_data_port (modem)); +} + static void modem_enabled_cb (NMModem *modem, GParamSpec *pspec, gpointer user_data) { @@ -417,6 +427,11 @@ set_modem (NMDeviceModem *self, NMModem *modem) g_signal_connect (modem, NM_MODEM_AUTH_RESULT, G_CALLBACK (modem_auth_result), self); g_signal_connect (modem, "notify::" NM_MODEM_ENABLED, G_CALLBACK (modem_enabled_cb), self); g_signal_connect (modem, "notify::" NM_MODEM_CONNECTED, G_CALLBACK (modem_connected_cb), self); + + /* In the old ModemManager the data port is known from the very beginning; + * while in the new ModemManager the data port is set afterwards when the bearer gets + * created */ + g_signal_connect (modem, "notify::" NM_MODEM_DATA_PORT, G_CALLBACK (data_port_changed_cb), self); } static void