aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NetworkManager-r4160-use-modem-manager.patch346
1 files changed, 339 insertions, 7 deletions
diff --git a/NetworkManager-r4160-use-modem-manager.patch b/NetworkManager-r4160-use-modem-manager.patch
index 9e8cc6a0..653aba23 100644
--- a/NetworkManager-r4160-use-modem-manager.patch
+++ b/NetworkManager-r4160-use-modem-manager.patch
@@ -146,10 +146,10 @@ index 25024c2..f7942d6 100644
prio = nm_device_get_priority (dev);
diff --git a/src/modem-manager/Makefile.am b/src/modem-manager/Makefile.am
new file mode 100644
-index 0000000..519636b
+index 0000000..5331f65
--- /dev/null
+++ b/src/modem-manager/Makefile.am
-@@ -0,0 +1,43 @@
+@@ -0,0 +1,45 @@
+INCLUDES = \
+ -I${top_srcdir}/src \
+ -I${top_srcdir}/include \
@@ -165,6 +165,8 @@ index 0000000..519636b
+ nm-gsm-modem.h \
+ nm-gsm-modem-hso.c \
+ nm-gsm-modem-hso.h \
++ nm-gsm-modem-mbm.c \
++ nm-gsm-modem-mbm.h \
+ nm-modem-device.c \
+ nm-modem-device.h \
+ nm-modem-manager.h \
@@ -888,9 +890,335 @@ index 0000000..9b16b0b
+G_END_DECLS
+
+#endif /* NM_GSM_MODEM_HSO_H */
+diff --git a/src/modem-manager/nm-gsm-modem-mbm.c b/src/modem-manager/nm-gsm-modem-mbm.c
+new file mode 100644
+index 0000000..efa8d4f
+--- /dev/null
++++ b/src/modem-manager/nm-gsm-modem-mbm.c
+@@ -0,0 +1,260 @@
++/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
++/*
++ Additions to NetworkManager, network-manager-applet and modemmanager
++ for supporting Ericsson modules like F3507g.
++
++ Author: Per Hallsmark <per@hallsmark.se>
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program; if not, write to the Free Software
++ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++
++*/
++
++#include "nm-gsm-modem-mbm.h"
++#include "nm-device-private.h"
++#include "nm-device-interface.h"
++#include "NetworkManagerSystem.h"
++#include "nm-setting-connection.h"
++#include "nm-setting-gsm.h"
++#include "nm-modem-types.h"
++#include "nm-utils.h"
++
++G_DEFINE_TYPE (NMGsmModemMbm, nm_gsm_modem_mbm, NM_TYPE_GSM_MODEM)
++
++#define NM_GSM_MODEM_MBM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_GSM_MODEM_MBM, NMGsmModemMbmPrivate))
++
++typedef struct {
++ char *netdev_iface;
++ NMIP4Config *pending_ip4_config;
++} NMGsmModemMbmPrivate;
++
++#define MBM_SECRETS_TRIES "gsm-secrets-tries"
++
++static char *
++get_network_device (NMDevice *device)
++{
++ char *result = NULL;
++ GError *error = NULL;
++ GValue value = { 0, };
++
++ if (!dbus_g_proxy_call (nm_modem_device_get_proxy (NM_MODEM_DEVICE (device), "org.freedesktop.DBus.Properties"),
++ "Get", &error,
++ G_TYPE_STRING, MM_DBUS_INTERFACE_MODEM_GSM_MBM,
++ G_TYPE_STRING, "NetworkDevice",
++ G_TYPE_INVALID,
++ G_TYPE_VALUE, &value,
++ G_TYPE_INVALID)) {
++ nm_warning ("Could not get MBM device's network interface: %s", error->message);
++ g_error_free (error);
++ } else {
++ if (G_VALUE_HOLDS_STRING (&value))
++ result = g_value_dup_string (&value);
++ else
++ nm_warning ("Could not get MBM device's network interface: wrong type '%s'",
++ G_VALUE_TYPE_NAME (&value));
++
++ g_value_unset (&value);
++ }
++
++ return result;
++}
++
++NMDevice *
++nm_gsm_modem_mbm_new (const char *path,
++ const char *data_device,
++ const char *driver)
++{
++ NMDevice *device;
++
++ g_return_val_if_fail (path != NULL, NULL);
++ g_return_val_if_fail (data_device != NULL, NULL);
++ g_return_val_if_fail (driver != NULL, NULL);
++
++ device = (NMDevice *) g_object_new (NM_TYPE_GSM_MODEM_MBM,
++ NM_DEVICE_INTERFACE_UDI, path,
++ NM_DEVICE_INTERFACE_IFACE, data_device,
++ NM_DEVICE_INTERFACE_DRIVER, driver,
++ NM_DEVICE_INTERFACE_MANAGED, TRUE,
++ NULL);
++
++ if (device) {
++ NMGsmModemMbmPrivate *priv;
++
++ priv = NM_GSM_MODEM_MBM_GET_PRIVATE (device);
++ priv->netdev_iface = get_network_device (device);
++ if (!priv->netdev_iface) {
++ g_object_unref (device);
++ device = NULL;
++ }
++ }
++
++ return device;
++}
++
++/*****************************************************************************/
++
++#if 0
++static NMSetting *
++get_setting (NMGsmModemMbm *modem, GType setting_type)
++{
++ NMActRequest *req;
++ NMSetting *setting = NULL;
++
++ req = nm_device_get_act_request (NM_DEVICE (modem));
++ if (req) {
++ NMConnection *connection;
++
++ connection = nm_act_request_get_connection (req);
++ if (connection)
++ setting = nm_connection_get_setting (connection, setting_type);
++ }
++
++ return setting;
++}
++#endif
++
++#if 0
++static NMActStageReturn
++real_act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
++{
++ NMActRequest *req;
++ NMConnection *connection;
++ const char *setting_name;
++ GPtrArray *hints = NULL;
++ const char *hint1 = NULL, *hint2 = NULL;
++ guint32 tries;
++
++ req = nm_device_get_act_request (device);
++ g_assert (req);
++ connection = nm_act_request_get_connection (req);
++ g_assert (connection);
++
++ setting_name = nm_connection_need_secrets (connection, &hints);
++ if (!setting_name) {
++ // do_mbm_auth (NM_GSM_MODEM_MBM (device));
++ return NM_ACT_STAGE_RETURN_POSTPONE;
++ }
++
++ if (hints) {
++ if (hints->len > 0)
++ hint1 = g_ptr_array_index (hints, 0);
++ if (hints->len > 1)
++ hint2 = g_ptr_array_index (hints, 1);
++ }
++
++ nm_device_state_changed (device, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE);
++
++ tries = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (connection), MBM_SECRETS_TRIES));
++ nm_act_request_request_connection_secrets (req,
++ setting_name,
++ tries ? TRUE : FALSE,
++ SECRETS_CALLER_MBM_GSM,
++ hint1,
++ hint2);
++ g_object_set_data (G_OBJECT (connection), MBM_SECRETS_TRIES, GUINT_TO_POINTER (++tries));
++
++ if (hints)
++ g_ptr_array_free (hints, TRUE);
++
++ return NM_ACT_STAGE_RETURN_POSTPONE;
++}
++#endif
++
++static void
++real_deactivate (NMDevice *device)
++{
++ NMGsmModemMbmPrivate *priv = NM_GSM_MODEM_MBM_GET_PRIVATE (device);
++
++ if (priv->pending_ip4_config) {
++ g_object_unref (priv->pending_ip4_config);
++ priv->pending_ip4_config = NULL;
++ }
++
++ if (priv->netdev_iface) {
++ nm_system_device_flush_ip4_routes_with_iface (priv->netdev_iface);
++ nm_system_device_flush_ip4_addresses_with_iface (priv->netdev_iface);
++ nm_system_device_set_up_down_with_iface (priv->netdev_iface, FALSE, NULL);
++ }
++ nm_device_set_ip_iface (device, NULL);
++
++ if (NM_DEVICE_CLASS (nm_gsm_modem_mbm_parent_class)->deactivate)
++ NM_DEVICE_CLASS (nm_gsm_modem_mbm_parent_class)->deactivate (device);
++}
++
++static gboolean
++real_hw_is_up (NMDevice *device)
++{
++ NMGsmModemMbmPrivate *priv = NM_GSM_MODEM_MBM_GET_PRIVATE (device);
++
++ if (priv->netdev_iface)
++ return nm_system_device_is_up_with_iface (priv->netdev_iface);
++
++ return TRUE;
++}
++
++static gboolean
++real_hw_bring_up (NMDevice *device, gboolean *no_firmware)
++{
++ NMGsmModemMbmPrivate *priv = NM_GSM_MODEM_MBM_GET_PRIVATE (device);
++
++ if (priv->netdev_iface)
++ return nm_system_device_set_up_down_with_iface (priv->netdev_iface, TRUE, no_firmware);
++
++ return TRUE;
++}
++
++static void
++real_connect (NMModemDevice *modem, const char *number)
++{
++ nm_device_activate_schedule_stage2_device_config (NM_DEVICE (modem));
++}
++
++/*****************************************************************************/
++
++static void
++nm_gsm_modem_mbm_init (NMGsmModemMbm *self)
++{
++}
++
++static void
++finalize (GObject *object)
++{
++ NMGsmModemMbmPrivate *priv = NM_GSM_MODEM_MBM_GET_PRIVATE (object);
++
++ g_free (priv->netdev_iface);
++
++ G_OBJECT_CLASS (nm_gsm_modem_mbm_parent_class)->finalize (object);
++}
++
++static void
++nm_gsm_modem_mbm_class_init (NMGsmModemMbmClass *klass)
++{
++ GObjectClass *object_class = G_OBJECT_CLASS (klass);
++ NMDeviceClass *device_class = NM_DEVICE_CLASS (klass);
++ NMModemDeviceClass *modem_class = NM_MODEM_DEVICE_CLASS (klass);
++
++ g_type_class_add_private (object_class, sizeof (NMGsmModemMbmPrivate));
++
++ object_class->finalize = finalize;
++
++#if 0
++ device_class->act_stage2_config = real_act_stage2_config;
++#endif
++ device_class->deactivate = real_deactivate;
++ device_class->hw_is_up = real_hw_is_up;
++ device_class->hw_bring_up = real_hw_bring_up;
++
++ modem_class->connect = real_connect;
++}
+diff --git a/src/modem-manager/nm-gsm-modem-mbm.h b/src/modem-manager/nm-gsm-modem-mbm.h
+new file mode 100644
+index 0000000..1f49fda
+--- /dev/null
++++ b/src/modem-manager/nm-gsm-modem-mbm.h
+@@ -0,0 +1,54 @@
++/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
++/*
++ Additions to NetworkManager, network-manager-applet and modemmanager
++ for supporting Ericsson modules like F3507g.
++
++ Author: Per Hallsmark <per@hallsmark.se>
++
++ This program is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License, or
++ (at your option) any later version.
++
++ This program is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this program; if not, write to the Free Software
++ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
++
++*/
++
++#ifndef NM_GSM_MODEM_MBM_H
++#define NM_GSM_MODEM_MBM_H
++
++#include <nm-gsm-modem.h>
++
++G_BEGIN_DECLS
++
++#define NM_TYPE_GSM_MODEM_MBM (nm_gsm_modem_mbm_get_type ())
++#define NM_GSM_MODEM_MBM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_GSM_MODEM_MBM, NMGsmModemMbm))
++#define NM_GSM_MODEM_MBM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_GSM_MODEM_MBM, NMGsmModemMbmClass))
++#define NM_IS_GSM_MODEM_MBM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_GSM_MODEM_MBM))
++#define NM_IS_GSM_MODEM_MBM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_GSM_MODEM_MBM))
++#define NM_GSM_MODEM_MBM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_GSM_MODEM_MBM, NMGsmModemMbmClass))
++
++typedef struct {
++ NMGsmModem parent;
++} NMGsmModemMbm;
++
++typedef struct {
++ NMGsmModemClass parent;
++} NMGsmModemMbmClass;
++
++GType nm_gsm_modem_mbm_get_type (void);
++
++NMDevice *nm_gsm_modem_mbm_new (const char *path, const char *data_device,
++ const char *driver);
++
++G_END_DECLS
++
++#endif /* NM_GSM_MODEM_MBM_H */
diff --git a/src/modem-manager/nm-gsm-modem.c b/src/modem-manager/nm-gsm-modem.c
new file mode 100644
-index 0000000..691f189
+index 0000000..9a77abf
--- /dev/null
+++ b/src/modem-manager/nm-gsm-modem.c
@@ -0,0 +1,342 @@
@@ -1804,10 +2132,10 @@ index 0000000..fae6d74
+#endif /* NM_MODEM_DEVICE_H */
diff --git a/src/modem-manager/nm-modem-manager.c b/src/modem-manager/nm-modem-manager.c
new file mode 100644
-index 0000000..66db012
+index 0000000..aac68c1
--- /dev/null
+++ b/src/modem-manager/nm-modem-manager.c
-@@ -0,0 +1,388 @@
+@@ -0,0 +1,391 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
+#include <string.h>
@@ -1815,6 +2143,7 @@ index 0000000..66db012
+#include "nm-modem-device.h"
+#include "nm-gsm-modem.h"
+#include "nm-gsm-modem-hso.h"
++#include "nm-gsm-modem-mbm.h"
+#include "nm-cdma-modem.h"
+#include "nm-dbus-manager.h"
+#include "nm-utils.h"
@@ -1958,6 +2287,8 @@ index 0000000..66db012
+ if (modem_type == MM_MODEM_TYPE_GSM) {
+ if (!strcmp (driver, "hso"))
+ device = nm_gsm_modem_hso_new (path, data_device, driver);
++ else if (!strcmp (driver, "mbm"))
++ device = nm_gsm_modem_mbm_new (path, data_device, driver);
+ else
+ device = nm_gsm_modem_new (path, data_device, driver);
+ } else if (modem_type == MM_MODEM_TYPE_CDMA)
@@ -2239,10 +2570,10 @@ index 0000000..ec62f84
+#endif /* NM_MODEM_MANAGER_H */
diff --git a/src/modem-manager/nm-modem-types.h b/src/modem-manager/nm-modem-types.h
new file mode 100644
-index 0000000..f5cbe10
+index 0000000..de1d2de
--- /dev/null
+++ b/src/modem-manager/nm-modem-types.h
-@@ -0,0 +1,89 @@
+@@ -0,0 +1,90 @@
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
+
+#ifndef NM_MODEM_TYPES_H
@@ -2257,6 +2588,7 @@ index 0000000..f5cbe10
+#define MM_DBUS_INTERFACE_MODEM_GSM_CARD "org.freedesktop.ModemManager.Modem.Gsm.Card"
+#define MM_DBUS_INTERFACE_MODEM_GSM_NETWORK "org.freedesktop.ModemManager.Modem.Gsm.Network"
+#define MM_DBUS_INTERFACE_MODEM_GSM_HSO "org.freedesktop.ModemManager.Modem.Gsm.Hso"
++#define MM_DBUS_INTERFACE_MODEM_GSM_MBM "org.freedesktop.ModemManager.Modem.Gsm.Mbm"
+
+#define MM_MODEM_TYPE_UNKNOWN 0
+#define MM_MODEM_TYPE_GSM 1