Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/modem-manager:gemalto-lte-fix into ~snappy-hwe-team/snappy-hwe-snaps/+git/modem-manager:modem-manager/1.8.0

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Konrad Zapałowicz
Approved revision: ce0b3009990ae054761991d8dc750d4d66465cd4
Merged at revision: ce0b3009990ae054761991d8dc750d4d66465cd4
Proposed branch: ~alfonsosanchezbeato/snappy-hwe-snaps/+git/modem-manager:gemalto-lte-fix
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/modem-manager:modem-manager/1.8.0
Diff against target: 633 lines (+562/-3)
5 files modified
plugins/Makefile.am (+2/-0)
plugins/cinterion/mm-broadband-bearer-pls62.c (+455/-0)
plugins/cinterion/mm-broadband-bearer-pls62.h (+57/-0)
plugins/cinterion/mm-broadband-modem-cinterion.c (+22/-3)
src/mm-broadband-bearer.c (+26/-0)
Reviewer Review Type Date Requested Status
Konrad Zapałowicz (community) code Approve
System Enablement Bot continuous-integration Needs Fixing
Review via email: mp+359110@code.launchpad.net

Commit message

Add support for PLS62 LTE connectivity. Fixes LP: #1801398

Description of the change

Add support for PLS62 LTE connectivity. Fixes LP: #1801398

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Konrad Zapałowicz (kzapalowicz) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/plugins/Makefile.am b/plugins/Makefile.am
2index cfe4456..2c7a182 100644
3--- a/plugins/Makefile.am
4+++ b/plugins/Makefile.am
5@@ -611,6 +611,8 @@ libmm_plugin_cinterion_la_SOURCES = \
6 cinterion/mm-broadband-modem-cinterion.h \
7 cinterion/mm-broadband-bearer-cinterion.c \
8 cinterion/mm-broadband-bearer-cinterion.h \
9+ cinterion/mm-broadband-bearer-pls62.c \
10+ cinterion/mm-broadband-bearer-pls62.h \
11 $(NULL)
12 if WITH_QMI
13 libmm_plugin_cinterion_la_SOURCES += \
14diff --git a/plugins/cinterion/mm-broadband-bearer-pls62.c b/plugins/cinterion/mm-broadband-bearer-pls62.c
15new file mode 100644
16index 0000000..e902ce2
17--- /dev/null
18+++ b/plugins/cinterion/mm-broadband-bearer-pls62.c
19@@ -0,0 +1,455 @@
20+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
21+/*
22+ * This program is free software; you can redistribute it and/or modify
23+ * it under the terms of the GNU General Public License as published by
24+ * the Free Software Foundation; either version 2 of the License, or
25+ * (at your option) any later version.
26+ *
27+ * This program is distributed in the hope that it will be useful,
28+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
29+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30+ * GNU General Public License for more details:
31+ *
32+ * Copyright (C) 2018 Canonical Ltd
33+ * Author: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
34+ */
35+
36+#include <config.h>
37+#include <stdio.h>
38+#include <stdlib.h>
39+#include <unistd.h>
40+#include <string.h>
41+#include <ctype.h>
42+#include <arpa/inet.h>
43+#include <ModemManager.h>
44+#include "mm-base-modem-at.h"
45+#include "mm-broadband-bearer-pls62.h"
46+#include "mm-log.h"
47+#include "mm-modem-helpers.h"
48+#include "mm-modem-helpers-cinterion.h"
49+#include "mm-daemon-enums-types.h"
50+
51+G_DEFINE_TYPE (MMBroadbandBearerPls62, mm_broadband_bearer_pls62, MM_TYPE_BROADBAND_BEARER)
52+
53+/*****************************************************************************/
54+/* Auth helpers */
55+
56+typedef enum {
57+ BEARER_PLS62_AUTH_UNKNOWN = -1,
58+ BEARER_PLS62_AUTH_NONE = 0,
59+ BEARER_PLS62_AUTH_PAP = 1,
60+ BEARER_PLS62_AUTH_CHAP = 2,
61+ BEARER_PLS62_AUTH_MSCHAPV2 = 3,
62+} BearerPls62AuthType;
63+
64+static BearerPls62AuthType
65+parse_auth_type (MMBearerAllowedAuth mm_auth)
66+{
67+ switch (mm_auth) {
68+ case MM_BEARER_ALLOWED_AUTH_NONE:
69+ return BEARER_PLS62_AUTH_NONE;
70+ case MM_BEARER_ALLOWED_AUTH_PAP:
71+ return BEARER_PLS62_AUTH_PAP;
72+ case MM_BEARER_ALLOWED_AUTH_CHAP:
73+ return BEARER_PLS62_AUTH_CHAP;
74+ case MM_BEARER_ALLOWED_AUTH_MSCHAPV2:
75+ return BEARER_PLS62_AUTH_MSCHAPV2;
76+ default:
77+ return BEARER_PLS62_AUTH_UNKNOWN;
78+ }
79+}
80+
81+/* AT^SGAUTH=<cid>[, <auth_type>[, <passwd>, <user>]] */
82+static gchar *
83+build_auth_string (MMBearerProperties *config,
84+ guint cid)
85+{
86+ const gchar *user;
87+ const gchar *passwd;
88+ gboolean has_user;
89+ gboolean has_passwd;
90+ MMBearerAllowedAuth auth;
91+ BearerPls62AuthType encoded_auth = BEARER_PLS62_AUTH_UNKNOWN;
92+
93+ user = mm_bearer_properties_get_user (config);
94+ passwd = mm_bearer_properties_get_password (config);
95+ auth = mm_bearer_properties_get_allowed_auth (config);
96+
97+ has_user = (user && user[0]);
98+ has_passwd = (passwd && passwd[0]);
99+ encoded_auth = parse_auth_type (auth);
100+
101+ /* When 'none' requested, we won't require user/password */
102+ if (encoded_auth == BEARER_PLS62_AUTH_NONE) {
103+ if (has_user || has_passwd)
104+ mm_warn ("APN user/password given but 'none' authentication requested");
105+ return g_strdup_printf ("^SGAUTH=%u,%d", cid, encoded_auth);
106+ }
107+
108+ /* No explicit auth type requested? */
109+ if (encoded_auth == BEARER_PLS62_AUTH_UNKNOWN) {
110+ /* If no user/passwd given, do nothing */
111+ if (!has_user && !has_passwd)
112+ return NULL;
113+
114+ /* If user/passwd given, default to PAP */
115+ mm_dbg ("APN user/password given but no authentication type explicitly requested: defaulting to 'PAP'");
116+ encoded_auth = BEARER_PLS62_AUTH_PAP;
117+ }
118+
119+ return g_strdup_printf ("^SGAUTH=%u,%d,%s,%s", cid, encoded_auth, passwd, user);
120+}
121+
122+/******************************************************************************/
123+/* Dial 3GPP */
124+
125+typedef enum {
126+ DIAL_3GPP_CONTEXT_STEP_FIRST = 0,
127+ DIAL_3GPP_CONTEXT_STEP_AUTH,
128+ DIAL_3GPP_CONTEXT_STEP_START_CONNECTION,
129+ DIAL_3GPP_CONTEXT_STEP_LAST,
130+} Dial3gppContextStep;
131+
132+typedef struct {
133+ MMBroadbandBearerPls62 *self;
134+ MMBaseModem *modem;
135+ MMPortSerialAt *primary;
136+ guint cid;
137+ MMPort *data;
138+ Dial3gppContextStep step;
139+} Dial3gppContext;
140+
141+static void
142+dial_3gpp_context_free (Dial3gppContext *ctx)
143+{
144+ g_object_unref (ctx->modem);
145+ g_object_unref (ctx->self);
146+ g_object_unref (ctx->primary);
147+ g_clear_object (&ctx->data);
148+ g_slice_free (Dial3gppContext, ctx);
149+}
150+
151+static MMPort *
152+dial_3gpp_finish (MMBroadbandBearer *self,
153+ GAsyncResult *res,
154+ GError **error)
155+{
156+ return MM_PORT (g_task_propagate_pointer (G_TASK (res), error));
157+}
158+
159+static void dial_3gpp_context_step (GTask *task);
160+
161+static void
162+common_dial_operation_ready (MMBaseModem *modem,
163+ GAsyncResult *res,
164+ GTask *task)
165+{
166+ Dial3gppContext *ctx;
167+ GError *error = NULL;
168+
169+ ctx = (Dial3gppContext *) g_task_get_task_data (task);
170+
171+ if (!mm_base_modem_at_command_full_finish (modem, res, &error)) {
172+ g_task_return_error (task, error);
173+ g_object_unref (task);
174+ return;
175+ }
176+
177+ /* Go to next step */
178+ ctx->step++;
179+ dial_3gpp_context_step (task);
180+}
181+
182+static void
183+parent_dial_3gpp_ready (MMBroadbandBearer *self,
184+ GAsyncResult *res,
185+ GTask *task)
186+{
187+ Dial3gppContext *ctx;
188+ GError *error = NULL;
189+
190+ ctx = g_task_get_task_data (task);
191+
192+ ctx->data = MM_BROADBAND_BEARER_CLASS (mm_broadband_bearer_pls62_parent_class)->dial_3gpp_finish (self, res, &error);
193+ if (!ctx->data) {
194+ g_task_return_error (task, error);
195+ g_object_unref (task);
196+ return;
197+ }
198+
199+ /* Go on */
200+ ctx->step++;
201+ dial_3gpp_context_step (task);
202+}
203+
204+static void
205+handle_cancel_dial (GTask *task)
206+{
207+ Dial3gppContext *ctx;
208+ gchar *command;
209+
210+ ctx = g_task_get_task_data (task);
211+
212+ /* Disconnect, may not succeed. Will not check response on cancel */
213+ command = g_strdup_printf ("+CGACT=0,%u", ctx->cid);
214+ mm_base_modem_at_command_full (ctx->modem,
215+ ctx->primary,
216+ command,
217+ 3,
218+ FALSE,
219+ FALSE,
220+ NULL,
221+ NULL,
222+ NULL);
223+ g_free (command);
224+}
225+
226+static void
227+deactivate_ready (MMBaseModem *modem,
228+ GAsyncResult *res,
229+ GTask *task)
230+{
231+ Dial3gppContext *ctx;
232+
233+ /* Do note check +CGATT errors, that and following commands are best-effort */
234+ ctx = (Dial3gppContext *)g_task_get_task_data (task);
235+
236+ mm_dbg ("cinterion activate context again");
237+ mm_base_modem_at_command_full (ctx->modem,
238+ ctx->primary,
239+ "+CGATT=1",
240+ 90,
241+ FALSE,
242+ FALSE,
243+ NULL,
244+ NULL,
245+ task);
246+
247+ /* We return with error now and wait for next re-try */
248+ g_task_return_new_error (
249+ task,
250+ MM_CORE_ERROR,
251+ MM_CORE_ERROR_FAILED,
252+ "cinterion: not CID one, things should work on next re-try");
253+ g_object_unref (task);
254+}
255+
256+static void
257+detach_ready (MMBaseModem *modem,
258+ GAsyncResult *res,
259+ GTask *task)
260+{
261+ Dial3gppContext *ctx;
262+
263+ /* Do note check +CGATT errors, that and following commands are best-effort */
264+ ctx = (Dial3gppContext *)g_task_get_task_data (task);
265+
266+ mm_dbg ("cinterion deactivate context");
267+ mm_base_modem_at_command_full (ctx->modem,
268+ ctx->primary,
269+ "+CGACT=0",
270+ 90,
271+ FALSE,
272+ FALSE,
273+ NULL,
274+ (GAsyncReadyCallback)deactivate_ready,
275+ task);
276+}
277+
278+static void
279+set_apn_ready (MMBaseModem *modem,
280+ GAsyncResult *res,
281+ GTask *task)
282+{
283+ Dial3gppContext *ctx;
284+ GError *error = NULL;
285+
286+ ctx = (Dial3gppContext *)g_task_get_task_data (task);
287+
288+ if (!mm_base_modem_at_command_full_finish (modem, res, &error)) {
289+ g_task_return_error (task, error);
290+ g_object_unref (task);
291+ return;
292+ }
293+
294+ mm_dbg ("cinterion dettaching so CID changes apply");
295+ mm_base_modem_at_command_full (ctx->modem,
296+ ctx->primary,
297+ "+CGATT=0",
298+ 90,
299+ FALSE,
300+ FALSE,
301+ NULL,
302+ (GAsyncReadyCallback)detach_ready,
303+ task);
304+}
305+
306+static void
307+dial_3gpp_context_step (GTask *task)
308+{
309+ Dial3gppContext *ctx;
310+
311+ ctx = g_task_get_task_data (task);
312+
313+ /* Check for cancellation */
314+ if (g_task_return_error_if_cancelled (task)) {
315+ handle_cancel_dial (task);
316+ g_object_unref (task);
317+ return;
318+ }
319+
320+ switch (ctx->step) {
321+ case DIAL_3GPP_CONTEXT_STEP_FIRST:
322+ if (ctx->cid != 1) {
323+ /* We always want CID 1 so LTE auto-attach works. Change CID 1 and re-attach. */
324+ gchar *command;
325+ const gchar *apn;
326+
327+ apn = mm_bearer_properties_get_apn (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self)));
328+ mm_dbg ("cinterion dial step %u/%u: setting CID 1 to APN %s",
329+ ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST, apn);
330+ command = g_strdup_printf ("+CGDCONT=1,\"IPV4V6\",\"%s\"", apn);
331+ mm_base_modem_at_command_full (ctx->modem,
332+ ctx->primary,
333+ command,
334+ 90,
335+ FALSE,
336+ FALSE,
337+ NULL,
338+ (GAsyncReadyCallback)set_apn_ready,
339+ task);
340+ g_free (command);
341+ return;
342+ }
343+ /* Fall down to next step */
344+ ctx->step++;
345+ case DIAL_3GPP_CONTEXT_STEP_AUTH: {
346+ gchar *command;
347+
348+ command = build_auth_string (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self)), ctx->cid);
349+ if (command) {
350+ mm_dbg ("cinterion dial step %u/%u: authenticating...", ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST);
351+ /* Send SGAUTH write, if User & Pass are provided.
352+ * advance to next state by callback */
353+ mm_base_modem_at_command_full (ctx->modem,
354+ ctx->primary,
355+ command,
356+ 10,
357+ FALSE,
358+ FALSE,
359+ NULL,
360+ (GAsyncReadyCallback)common_dial_operation_ready,
361+ task);
362+ g_free (command);
363+ return;
364+ }
365+
366+ /* Fall down to next step */
367+ mm_dbg ("cinterion dial step %u/%u: authentication not required", ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST);
368+ ctx->step++;
369+ }
370+ case DIAL_3GPP_CONTEXT_STEP_START_CONNECTION:
371+ /* Chain up to parent's dialling */
372+ MM_BROADBAND_BEARER_CLASS (mm_broadband_bearer_pls62_parent_class)->dial_3gpp (
373+ MM_BROADBAND_BEARER (ctx->self),
374+ ctx->modem,
375+ ctx->primary,
376+ ctx->cid,
377+ g_task_get_cancellable (task),
378+ (GAsyncReadyCallback)parent_dial_3gpp_ready,
379+ task);
380+
381+ return;
382+ case DIAL_3GPP_CONTEXT_STEP_LAST:
383+ mm_dbg ("cinterion dial step %u/%u: finished", ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST);
384+ g_task_return_pointer (task, g_object_ref (ctx->data), g_object_unref);
385+ g_object_unref (task);
386+ return;
387+ }
388+}
389+
390+static void
391+dial_3gpp (MMBroadbandBearer *self,
392+ MMBaseModem *modem,
393+ MMPortSerialAt *primary,
394+ guint cid,
395+ GCancellable *cancellable,
396+ GAsyncReadyCallback callback,
397+ gpointer user_data)
398+{
399+ GTask *task;
400+ Dial3gppContext *ctx;
401+
402+ g_assert (primary != NULL);
403+
404+ /* Setup task and create connection context */
405+ task = g_task_new (self, cancellable, callback, user_data);
406+ ctx = g_slice_new0 (Dial3gppContext);
407+ g_task_set_task_data (task, ctx, (GDestroyNotify) dial_3gpp_context_free);
408+
409+ /* Setup context */
410+ ctx->self = g_object_ref (self);
411+ ctx->modem = g_object_ref (modem);
412+ ctx->primary = g_object_ref (primary);
413+ ctx->cid = cid;
414+ ctx->step = DIAL_3GPP_CONTEXT_STEP_FIRST;
415+
416+ /* Run! */
417+ dial_3gpp_context_step (task);
418+}
419+
420+/*****************************************************************************/
421+/* Setup and Init Bearers */
422+
423+MMBaseBearer *
424+mm_broadband_bearer_pls62_new_finish (GAsyncResult *res,
425+ GError **error)
426+{
427+ GObject *bearer;
428+ GObject *source;
429+
430+ source = g_async_result_get_source_object (res);
431+ bearer = g_async_initable_new_finish (G_ASYNC_INITABLE (source), res, error);
432+ g_object_unref (source);
433+
434+ if (!bearer)
435+ return NULL;
436+
437+ /* Only export valid bearers */
438+ mm_base_bearer_export (MM_BASE_BEARER (bearer));
439+
440+ return MM_BASE_BEARER (bearer);
441+}
442+
443+void
444+mm_broadband_bearer_pls62_new (MMBroadbandModemCinterion *modem,
445+ MMBearerProperties *config,
446+ GCancellable *cancellable,
447+ GAsyncReadyCallback callback,
448+ gpointer user_data)
449+{
450+ g_async_initable_new_async (
451+ MM_TYPE_BROADBAND_BEARER_PLS62,
452+ G_PRIORITY_DEFAULT,
453+ cancellable,
454+ callback,
455+ user_data,
456+ MM_BASE_BEARER_MODEM, modem,
457+ MM_BASE_BEARER_CONFIG, config,
458+ "ip-timeout", BEARER_PLS62_IP_TIMEOUT_DEFAULT,
459+ NULL);
460+}
461+
462+static void
463+mm_broadband_bearer_pls62_init (MMBroadbandBearerPls62 *self)
464+{
465+}
466+
467+static void
468+mm_broadband_bearer_pls62_class_init (MMBroadbandBearerPls62Class *klass)
469+{
470+ MMBroadbandBearerClass *broadband_bearer_class = MM_BROADBAND_BEARER_CLASS (klass);
471+
472+ broadband_bearer_class->dial_3gpp = dial_3gpp;
473+ broadband_bearer_class->dial_3gpp_finish = dial_3gpp_finish;
474+}
475diff --git a/plugins/cinterion/mm-broadband-bearer-pls62.h b/plugins/cinterion/mm-broadband-bearer-pls62.h
476new file mode 100644
477index 0000000..59e77ef
478--- /dev/null
479+++ b/plugins/cinterion/mm-broadband-bearer-pls62.h
480@@ -0,0 +1,57 @@
481+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
482+/*
483+ * This program is free software; you can redistribute it and/or modify
484+ * it under the terms of the GNU General Public License as published by
485+ * the Free Software Foundation; either version 2 of the License, or
486+ * (at your option) any later version.
487+ *
488+ * This program is distributed in the hope that it will be useful,
489+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
490+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
491+ * GNU General Public License for more details:
492+ *
493+ * Copyright (C) 2018 Canonical Ltd
494+ * Author: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
495+ */
496+
497+#ifndef MM_BROADBAND_BEARER_PLS62_H
498+#define MM_BROADBAND_BEARER_PLS62_H
499+
500+#include <glib.h>
501+#include <glib-object.h>
502+
503+#include "mm-broadband-bearer.h"
504+#include "mm-broadband-modem-cinterion.h"
505+
506+/* Allow up to 90s to get a proper IP connection */
507+#define BEARER_PLS62_IP_TIMEOUT_DEFAULT 90
508+
509+#define MM_TYPE_BROADBAND_BEARER_PLS62 (mm_broadband_bearer_pls62_get_type ())
510+#define MM_BROADBAND_BEARER_PLS62(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_BEARER_PLS62, MMBroadbandBearerPls62))
511+#define MM_BROADBAND_BEARER_PLS62_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_BEARER_PLS62, MMBroadbandBearerPls62Class))
512+#define MM_IS_BROADBAND_BEARER_PLS62(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_BEARER_PLS62))
513+#define MM_IS_BROADBAND_BEARER_PLS62_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_BEARER_PLS62))
514+#define MM_BROADBAND_BEARER_PLS62_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_BEARER_PLS62, MMBroadbandBearerPls62Class))
515+
516+typedef struct _MMBroadbandBearerPls62 MMBroadbandBearerPls62;
517+typedef struct _MMBroadbandBearerPls62Class MMBroadbandBearerPls62Class;
518+
519+struct _MMBroadbandBearerPls62 {
520+ MMBroadbandBearer parent;
521+};
522+
523+struct _MMBroadbandBearerPls62Class {
524+ MMBroadbandBearerClass parent;
525+};
526+
527+GType mm_broadband_bearer_pls62_get_type (void);
528+
529+void mm_broadband_bearer_pls62_new (MMBroadbandModemCinterion *modem,
530+ MMBearerProperties *config,
531+ GCancellable *cancellable,
532+ GAsyncReadyCallback callback,
533+ gpointer user_data);
534+MMBaseBearer *mm_broadband_bearer_pls62_new_finish (GAsyncResult *res,
535+ GError **error);
536+
537+#endif /* MM_BROADBAND_BEARER_PLS62_H */
538diff --git a/plugins/cinterion/mm-broadband-modem-cinterion.c b/plugins/cinterion/mm-broadband-modem-cinterion.c
539index 99dabde..fe4cdb1 100644
540--- a/plugins/cinterion/mm-broadband-modem-cinterion.c
541+++ b/plugins/cinterion/mm-broadband-modem-cinterion.c
542@@ -40,6 +40,7 @@
543 #include "mm-modem-helpers-cinterion.h"
544 #include "mm-common-cinterion.h"
545 #include "mm-broadband-bearer-cinterion.h"
546+#include "mm-broadband-bearer-pls62.h"
547
548 static void iface_modem_init (MMIfaceModem *iface);
549 static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
550@@ -1684,6 +1685,23 @@ broadband_bearer_cinterion_new_ready (GObject *unused,
551 }
552
553 static void
554+broadband_bearer_pls62_new_ready (GObject *unused,
555+ GAsyncResult *res,
556+ GTask *task)
557+{
558+ MMBaseBearer *bearer;
559+ GError *error = NULL;
560+
561+ bearer = mm_broadband_bearer_pls62_new_finish (res, &error);
562+ if (!bearer)
563+ g_task_return_error (task, error);
564+ else
565+ g_task_return_pointer (task, bearer, g_object_unref);
566+ g_object_unref (task);
567+}
568+
569+#if 0
570+static void
571 broadband_bearer_new_ready (GObject *unused,
572 GAsyncResult *res,
573 GTask *task)
574@@ -1725,6 +1743,7 @@ broadband_bearer_no_swwan_new (MMBroadbandModem *modem,
575 "ip-timeout", BEARER_CINTERION_IP_TIMEOUT_DEFAULT,
576 NULL);
577 }
578+#endif
579
580 static void
581 common_create_bearer (GTask *task)
582@@ -1735,11 +1754,11 @@ common_create_bearer (GTask *task)
583
584 switch (self->priv->swwan_support) {
585 case FEATURE_NOT_SUPPORTED:
586- mm_dbg ("^SWWAN not supported, creating default bearer...");
587- broadband_bearer_no_swwan_new (MM_BROADBAND_MODEM (self),
588+ mm_dbg ("^SWWAN not supported, creating PLS62 bearer...");
589+ mm_broadband_bearer_pls62_new (MM_BROADBAND_MODEM_CINTERION (self),
590 g_task_get_task_data (task),
591 NULL, /* cancellable */
592- (GAsyncReadyCallback)broadband_bearer_new_ready,
593+ (GAsyncReadyCallback)broadband_bearer_pls62_new_ready,
594 task);
595 return;
596 case FEATURE_SUPPORTED:
597diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
598index 6321de2..454b9dc 100644
599--- a/src/mm-broadband-bearer.c
600+++ b/src/mm-broadband-bearer.c
601@@ -892,6 +892,32 @@ parse_pdp_list (MMBaseModem *modem,
602 pdp->cid);
603 cid = pdp->cid;
604 }
605+ } else {
606+ const gchar *apn;
607+
608+ apn = mm_bearer_properties_get_apn (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self)));
609+ /* Check if we have a case of APN overwritten by modem */
610+ if (apn != NULL && pdp->apn != NULL && apn[0] != '\0' && pdp->apn[0] != '\0') {
611+ size_t requested_len = strlen (apn);
612+ if (g_ascii_strncasecmp (pdp->apn, apn, requested_len) == 0) {
613+ size_t existing_len = strlen (pdp->apn);
614+ if ((existing_len > (requested_len + 14)) &&
615+ g_ascii_strncasecmp (&pdp->apn[requested_len], ".mnc", 4) == 0 &&
616+ g_ascii_strncasecmp (&pdp->apn[requested_len + 7], ".mcc", 4) == 0) {
617+ gchar *ip_family_str;
618+
619+ /* Found a PDP context with the same APN and re-formatted by modem. */
620+ ip_family_str = mm_bearer_ip_family_build_string_from_mask (pdp->pdp_type);
621+ mm_dbg ("Found PDP context created by modem with CID %u and PDP type %s for APN '%s'",
622+ pdp->cid, ip_family_str, apn ? apn : "");
623+ cid = pdp->cid;
624+ ctx->use_existing_cid = TRUE;
625+ g_free (ip_family_str);
626+ /* In this case, stop searching */
627+ break;
628+ }
629+ }
630+ }
631 }
632
633 if (ctx->max_cid < pdp->cid)

Subscribers

People subscribed via source and target branches