aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Makefile.am4
-rw-r--r--plugins/samsung/mm-broadband-bearer-samsung.c88
-rw-r--r--plugins/samsung/mm-broadband-bearer-samsung.h56
-rw-r--r--plugins/samsung/mm-broadband-modem-samsung.c61
4 files changed, 206 insertions, 3 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index d8c61425..7485336d 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -255,7 +255,9 @@ libmm_plugin_samsung_la_SOURCES = \
samsung/mm-plugin-samsung.c \
samsung/mm-plugin-samsung.h \
samsung/mm-broadband-modem-samsung.c \
- samsung/mm-broadband-modem-samsung.h
+ samsung/mm-broadband-modem-samsung.h \
+ samsung/mm-broadband-bearer-samsung.c \
+ samsung/mm-broadband-bearer-samsung.h
libmm_plugin_samsung_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) $(ICERA_COMMON_COMPILER_FLAGS)
libmm_plugin_samsung_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
libmm_plugin_samsung_la_LIBADD = $(ICERA_COMMON_LIBADD_FLAGS)
diff --git a/plugins/samsung/mm-broadband-bearer-samsung.c b/plugins/samsung/mm-broadband-bearer-samsung.c
new file mode 100644
index 00000000..96e0cd9c
--- /dev/null
+++ b/plugins/samsung/mm-broadband-bearer-samsung.c
@@ -0,0 +1,88 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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:
+ *
+ * Copyright (C) 2012 Google, Inc.
+ * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org>
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <ctype.h>
+#include <arpa/inet.h>
+
+#include <ModemManager.h>
+#include <libmm-common.h>
+
+#include "mm-broadband-bearer-samsung.h"
+#include "mm-error-helpers.h"
+
+G_DEFINE_TYPE (MMBroadbandBearerSamsung, mm_broadband_bearer_samsung, MM_TYPE_BROADBAND_BEARER_ICERA);
+
+/*****************************************************************************/
+
+MMBearer *
+mm_broadband_bearer_samsung_new_finish (GAsyncResult *res,
+ GError **error)
+{
+ GObject *source;
+ GObject *bearer;
+
+ source = g_async_result_get_source_object (res);
+ bearer = g_async_initable_new_finish (G_ASYNC_INITABLE (source), res, error);
+ g_object_unref (source);
+
+ if (!bearer)
+ return NULL;
+
+ /* Only export valid bearers */
+ mm_bearer_export (MM_BEARER (bearer));
+
+ return MM_BEARER (bearer);
+}
+
+void
+mm_broadband_bearer_samsung_new (MMBroadbandModem *modem,
+ MMBearerProperties *config,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_async_initable_new_async (
+ MM_TYPE_BROADBAND_BEARER_SAMSUNG,
+ G_PRIORITY_DEFAULT,
+ cancellable,
+ callback,
+ user_data,
+ MM_BEARER_MODEM, modem,
+ MM_BEARER_CONFIG, config,
+ NULL);
+}
+
+static void
+mm_broadband_bearer_samsung_init (MMBroadbandBearerSamsung *self)
+{
+}
+
+static void
+mm_broadband_bearer_samsung_class_init (MMBroadbandBearerSamsungClass *klass)
+{
+ MMBroadbandBearerClass *broadband_bearer_class = MM_BROADBAND_BEARER_CLASS (klass);
+
+ /* Clean the parent Icera method to get the IP config, as this modem wants
+ * the default DHCP */
+ broadband_bearer_class->get_ip_config_3gpp = NULL;
+ broadband_bearer_class->get_ip_config_3gpp_finish = NULL;
+}
diff --git a/plugins/samsung/mm-broadband-bearer-samsung.h b/plugins/samsung/mm-broadband-bearer-samsung.h
new file mode 100644
index 00000000..793e34f5
--- /dev/null
+++ b/plugins/samsung/mm-broadband-bearer-samsung.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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:
+ *
+ * Copyright (C) 2012 Google, Inc.
+ * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org>
+ */
+
+#ifndef MM_BROADBAND_BEARER_SAMSUNG_H
+#define MM_BROADBAND_BEARER_SAMSUNG_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmm-common.h>
+
+#include "mm-broadband-bearer-icera.h"
+
+#define MM_TYPE_BROADBAND_BEARER_SAMSUNG (mm_broadband_bearer_samsung_get_type ())
+#define MM_BROADBAND_BEARER_SAMSUNG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_BEARER_SAMSUNG, MMBroadbandBearerSamsung))
+#define MM_BROADBAND_BEARER_SAMSUNG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_BEARER_SAMSUNG, MMBroadbandBearerSamsungClass))
+#define MM_IS_BROADBAND_BEARER_SAMSUNG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_BEARER_SAMSUNG))
+#define MM_IS_BROADBAND_BEARER_SAMSUNG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_BEARER_SAMSUNG))
+#define MM_BROADBAND_BEARER_SAMSUNG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_BEARER_SAMSUNG, MMBroadbandBearerSamsungClass))
+
+typedef struct _MMBroadbandBearerSamsung MMBroadbandBearerSamsung;
+typedef struct _MMBroadbandBearerSamsungClass MMBroadbandBearerSamsungClass;
+
+struct _MMBroadbandBearerSamsung {
+ MMBroadbandBearerIcera parent;
+};
+
+struct _MMBroadbandBearerSamsungClass {
+ MMBroadbandBearerIceraClass parent;
+};
+
+GType mm_broadband_bearer_samsung_get_type (void);
+
+/* Samsung bearer creation implementation */
+void mm_broadband_bearer_samsung_new (MMBroadbandModem *modem,
+ MMBearerProperties *config,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+MMBearer *mm_broadband_bearer_samsung_new_finish (GAsyncResult *res,
+ GError **error);
+
+#endif /* MM_BROADBAND_BEARER_SAMSUNG_H */
diff --git a/plugins/samsung/mm-broadband-modem-samsung.c b/plugins/samsung/mm-broadband-modem-samsung.c
index d378e16b..c981c755 100644
--- a/plugins/samsung/mm-broadband-modem-samsung.c
+++ b/plugins/samsung/mm-broadband-modem-samsung.c
@@ -26,6 +26,7 @@
#include "ModemManager.h"
#include "mm-base-modem-at.h"
#include "mm-broadband-modem-samsung.h"
+#include "mm-broadband-bearer-samsung.h"
#include "mm-iface-icera.h"
#include "mm-iface-modem.h"
#include "mm-iface-modem-3gpp.h"
@@ -47,6 +48,62 @@ G_DEFINE_TYPE_EXTENDED (MMBroadbandModemSamsung, mm_broadband_modem_samsung, MM_
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_ICERA, iface_icera_init));
/*****************************************************************************/
+/* Create bearer (Modem interface) */
+
+static MMBearer *
+create_bearer_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
+ return NULL;
+
+ return MM_BEARER (g_object_ref (
+ g_simple_async_result_get_op_res_gpointer (
+ G_SIMPLE_ASYNC_RESULT (res))));
+}
+
+static void
+broadband_bearer_samsung_new_ready (GObject *source,
+ GAsyncResult *res,
+ GSimpleAsyncResult *simple)
+{
+ MMBearer *bearer = NULL;
+ GError *error = NULL;
+
+ bearer = mm_broadband_bearer_samsung_new_finish (res, &error);
+ if (!bearer)
+ g_simple_async_result_take_error (simple, error);
+ else
+ g_simple_async_result_set_op_res_gpointer (simple,
+ bearer,
+ (GDestroyNotify)g_object_unref);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+}
+
+static void
+create_bearer (MMIfaceModem *self,
+ MMBearerProperties *properties,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+
+ /* Set a new ref to the bearer object as result */
+ result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ create_bearer);
+
+ mm_broadband_bearer_samsung_new (MM_BROADBAND_MODEM (self),
+ properties,
+ NULL, /* cancellable */
+ (GAsyncReadyCallback)broadband_bearer_samsung_new_ready,
+ result);
+}
+
+/*****************************************************************************/
/* Load supported bands (Modem interface) */
typedef struct {
@@ -761,6 +818,8 @@ iface_modem_init (MMIfaceModem *iface)
iface->load_unlock_retries_finish = load_unlock_retries_finish;
iface->modem_power_down = modem_power_down;
iface->modem_power_down_finish = modem_power_down_finish;
+ iface->create_bearer = create_bearer;
+ iface->create_bearer_finish = create_bearer_finish;
/* Use default Icera implementation */
iface->load_allowed_modes = mm_iface_icera_modem_load_allowed_modes;
@@ -769,8 +828,6 @@ iface_modem_init (MMIfaceModem *iface)
iface->set_allowed_modes_finish = mm_iface_icera_modem_set_allowed_modes_finish;
iface->load_access_technologies = mm_iface_icera_modem_load_access_technologies;
iface->load_access_technologies_finish = mm_iface_icera_modem_load_access_technologies_finish;
- iface->create_bearer = mm_iface_icera_modem_create_bearer;
- iface->create_bearer_finish = mm_iface_icera_modem_create_bearer_finish;
}
static void