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
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index cfe4456..2c7a182 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -611,6 +611,8 @@ libmm_plugin_cinterion_la_SOURCES = \
611 cinterion/mm-broadband-modem-cinterion.h \611 cinterion/mm-broadband-modem-cinterion.h \
612 cinterion/mm-broadband-bearer-cinterion.c \612 cinterion/mm-broadband-bearer-cinterion.c \
613 cinterion/mm-broadband-bearer-cinterion.h \613 cinterion/mm-broadband-bearer-cinterion.h \
614 cinterion/mm-broadband-bearer-pls62.c \
615 cinterion/mm-broadband-bearer-pls62.h \
614 $(NULL)616 $(NULL)
615if WITH_QMI617if WITH_QMI
616libmm_plugin_cinterion_la_SOURCES += \618libmm_plugin_cinterion_la_SOURCES += \
diff --git a/plugins/cinterion/mm-broadband-bearer-pls62.c b/plugins/cinterion/mm-broadband-bearer-pls62.c
617new file mode 100644619new file mode 100644
index 0000000..e902ce2
--- /dev/null
+++ b/plugins/cinterion/mm-broadband-bearer-pls62.c
@@ -0,0 +1,455 @@
1/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details:
12 *
13 * Copyright (C) 2018 Canonical Ltd
14 * Author: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
15 */
16
17#include <config.h>
18#include <stdio.h>
19#include <stdlib.h>
20#include <unistd.h>
21#include <string.h>
22#include <ctype.h>
23#include <arpa/inet.h>
24#include <ModemManager.h>
25#include "mm-base-modem-at.h"
26#include "mm-broadband-bearer-pls62.h"
27#include "mm-log.h"
28#include "mm-modem-helpers.h"
29#include "mm-modem-helpers-cinterion.h"
30#include "mm-daemon-enums-types.h"
31
32G_DEFINE_TYPE (MMBroadbandBearerPls62, mm_broadband_bearer_pls62, MM_TYPE_BROADBAND_BEARER)
33
34/*****************************************************************************/
35/* Auth helpers */
36
37typedef enum {
38 BEARER_PLS62_AUTH_UNKNOWN = -1,
39 BEARER_PLS62_AUTH_NONE = 0,
40 BEARER_PLS62_AUTH_PAP = 1,
41 BEARER_PLS62_AUTH_CHAP = 2,
42 BEARER_PLS62_AUTH_MSCHAPV2 = 3,
43} BearerPls62AuthType;
44
45static BearerPls62AuthType
46parse_auth_type (MMBearerAllowedAuth mm_auth)
47{
48 switch (mm_auth) {
49 case MM_BEARER_ALLOWED_AUTH_NONE:
50 return BEARER_PLS62_AUTH_NONE;
51 case MM_BEARER_ALLOWED_AUTH_PAP:
52 return BEARER_PLS62_AUTH_PAP;
53 case MM_BEARER_ALLOWED_AUTH_CHAP:
54 return BEARER_PLS62_AUTH_CHAP;
55 case MM_BEARER_ALLOWED_AUTH_MSCHAPV2:
56 return BEARER_PLS62_AUTH_MSCHAPV2;
57 default:
58 return BEARER_PLS62_AUTH_UNKNOWN;
59 }
60}
61
62/* AT^SGAUTH=<cid>[, <auth_type>[, <passwd>, <user>]] */
63static gchar *
64build_auth_string (MMBearerProperties *config,
65 guint cid)
66{
67 const gchar *user;
68 const gchar *passwd;
69 gboolean has_user;
70 gboolean has_passwd;
71 MMBearerAllowedAuth auth;
72 BearerPls62AuthType encoded_auth = BEARER_PLS62_AUTH_UNKNOWN;
73
74 user = mm_bearer_properties_get_user (config);
75 passwd = mm_bearer_properties_get_password (config);
76 auth = mm_bearer_properties_get_allowed_auth (config);
77
78 has_user = (user && user[0]);
79 has_passwd = (passwd && passwd[0]);
80 encoded_auth = parse_auth_type (auth);
81
82 /* When 'none' requested, we won't require user/password */
83 if (encoded_auth == BEARER_PLS62_AUTH_NONE) {
84 if (has_user || has_passwd)
85 mm_warn ("APN user/password given but 'none' authentication requested");
86 return g_strdup_printf ("^SGAUTH=%u,%d", cid, encoded_auth);
87 }
88
89 /* No explicit auth type requested? */
90 if (encoded_auth == BEARER_PLS62_AUTH_UNKNOWN) {
91 /* If no user/passwd given, do nothing */
92 if (!has_user && !has_passwd)
93 return NULL;
94
95 /* If user/passwd given, default to PAP */
96 mm_dbg ("APN user/password given but no authentication type explicitly requested: defaulting to 'PAP'");
97 encoded_auth = BEARER_PLS62_AUTH_PAP;
98 }
99
100 return g_strdup_printf ("^SGAUTH=%u,%d,%s,%s", cid, encoded_auth, passwd, user);
101}
102
103/******************************************************************************/
104/* Dial 3GPP */
105
106typedef enum {
107 DIAL_3GPP_CONTEXT_STEP_FIRST = 0,
108 DIAL_3GPP_CONTEXT_STEP_AUTH,
109 DIAL_3GPP_CONTEXT_STEP_START_CONNECTION,
110 DIAL_3GPP_CONTEXT_STEP_LAST,
111} Dial3gppContextStep;
112
113typedef struct {
114 MMBroadbandBearerPls62 *self;
115 MMBaseModem *modem;
116 MMPortSerialAt *primary;
117 guint cid;
118 MMPort *data;
119 Dial3gppContextStep step;
120} Dial3gppContext;
121
122static void
123dial_3gpp_context_free (Dial3gppContext *ctx)
124{
125 g_object_unref (ctx->modem);
126 g_object_unref (ctx->self);
127 g_object_unref (ctx->primary);
128 g_clear_object (&ctx->data);
129 g_slice_free (Dial3gppContext, ctx);
130}
131
132static MMPort *
133dial_3gpp_finish (MMBroadbandBearer *self,
134 GAsyncResult *res,
135 GError **error)
136{
137 return MM_PORT (g_task_propagate_pointer (G_TASK (res), error));
138}
139
140static void dial_3gpp_context_step (GTask *task);
141
142static void
143common_dial_operation_ready (MMBaseModem *modem,
144 GAsyncResult *res,
145 GTask *task)
146{
147 Dial3gppContext *ctx;
148 GError *error = NULL;
149
150 ctx = (Dial3gppContext *) g_task_get_task_data (task);
151
152 if (!mm_base_modem_at_command_full_finish (modem, res, &error)) {
153 g_task_return_error (task, error);
154 g_object_unref (task);
155 return;
156 }
157
158 /* Go to next step */
159 ctx->step++;
160 dial_3gpp_context_step (task);
161}
162
163static void
164parent_dial_3gpp_ready (MMBroadbandBearer *self,
165 GAsyncResult *res,
166 GTask *task)
167{
168 Dial3gppContext *ctx;
169 GError *error = NULL;
170
171 ctx = g_task_get_task_data (task);
172
173 ctx->data = MM_BROADBAND_BEARER_CLASS (mm_broadband_bearer_pls62_parent_class)->dial_3gpp_finish (self, res, &error);
174 if (!ctx->data) {
175 g_task_return_error (task, error);
176 g_object_unref (task);
177 return;
178 }
179
180 /* Go on */
181 ctx->step++;
182 dial_3gpp_context_step (task);
183}
184
185static void
186handle_cancel_dial (GTask *task)
187{
188 Dial3gppContext *ctx;
189 gchar *command;
190
191 ctx = g_task_get_task_data (task);
192
193 /* Disconnect, may not succeed. Will not check response on cancel */
194 command = g_strdup_printf ("+CGACT=0,%u", ctx->cid);
195 mm_base_modem_at_command_full (ctx->modem,
196 ctx->primary,
197 command,
198 3,
199 FALSE,
200 FALSE,
201 NULL,
202 NULL,
203 NULL);
204 g_free (command);
205}
206
207static void
208deactivate_ready (MMBaseModem *modem,
209 GAsyncResult *res,
210 GTask *task)
211{
212 Dial3gppContext *ctx;
213
214 /* Do note check +CGATT errors, that and following commands are best-effort */
215 ctx = (Dial3gppContext *)g_task_get_task_data (task);
216
217 mm_dbg ("cinterion activate context again");
218 mm_base_modem_at_command_full (ctx->modem,
219 ctx->primary,
220 "+CGATT=1",
221 90,
222 FALSE,
223 FALSE,
224 NULL,
225 NULL,
226 task);
227
228 /* We return with error now and wait for next re-try */
229 g_task_return_new_error (
230 task,
231 MM_CORE_ERROR,
232 MM_CORE_ERROR_FAILED,
233 "cinterion: not CID one, things should work on next re-try");
234 g_object_unref (task);
235}
236
237static void
238detach_ready (MMBaseModem *modem,
239 GAsyncResult *res,
240 GTask *task)
241{
242 Dial3gppContext *ctx;
243
244 /* Do note check +CGATT errors, that and following commands are best-effort */
245 ctx = (Dial3gppContext *)g_task_get_task_data (task);
246
247 mm_dbg ("cinterion deactivate context");
248 mm_base_modem_at_command_full (ctx->modem,
249 ctx->primary,
250 "+CGACT=0",
251 90,
252 FALSE,
253 FALSE,
254 NULL,
255 (GAsyncReadyCallback)deactivate_ready,
256 task);
257}
258
259static void
260set_apn_ready (MMBaseModem *modem,
261 GAsyncResult *res,
262 GTask *task)
263{
264 Dial3gppContext *ctx;
265 GError *error = NULL;
266
267 ctx = (Dial3gppContext *)g_task_get_task_data (task);
268
269 if (!mm_base_modem_at_command_full_finish (modem, res, &error)) {
270 g_task_return_error (task, error);
271 g_object_unref (task);
272 return;
273 }
274
275 mm_dbg ("cinterion dettaching so CID changes apply");
276 mm_base_modem_at_command_full (ctx->modem,
277 ctx->primary,
278 "+CGATT=0",
279 90,
280 FALSE,
281 FALSE,
282 NULL,
283 (GAsyncReadyCallback)detach_ready,
284 task);
285}
286
287static void
288dial_3gpp_context_step (GTask *task)
289{
290 Dial3gppContext *ctx;
291
292 ctx = g_task_get_task_data (task);
293
294 /* Check for cancellation */
295 if (g_task_return_error_if_cancelled (task)) {
296 handle_cancel_dial (task);
297 g_object_unref (task);
298 return;
299 }
300
301 switch (ctx->step) {
302 case DIAL_3GPP_CONTEXT_STEP_FIRST:
303 if (ctx->cid != 1) {
304 /* We always want CID 1 so LTE auto-attach works. Change CID 1 and re-attach. */
305 gchar *command;
306 const gchar *apn;
307
308 apn = mm_bearer_properties_get_apn (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self)));
309 mm_dbg ("cinterion dial step %u/%u: setting CID 1 to APN %s",
310 ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST, apn);
311 command = g_strdup_printf ("+CGDCONT=1,\"IPV4V6\",\"%s\"", apn);
312 mm_base_modem_at_command_full (ctx->modem,
313 ctx->primary,
314 command,
315 90,
316 FALSE,
317 FALSE,
318 NULL,
319 (GAsyncReadyCallback)set_apn_ready,
320 task);
321 g_free (command);
322 return;
323 }
324 /* Fall down to next step */
325 ctx->step++;
326 case DIAL_3GPP_CONTEXT_STEP_AUTH: {
327 gchar *command;
328
329 command = build_auth_string (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self)), ctx->cid);
330 if (command) {
331 mm_dbg ("cinterion dial step %u/%u: authenticating...", ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST);
332 /* Send SGAUTH write, if User & Pass are provided.
333 * advance to next state by callback */
334 mm_base_modem_at_command_full (ctx->modem,
335 ctx->primary,
336 command,
337 10,
338 FALSE,
339 FALSE,
340 NULL,
341 (GAsyncReadyCallback)common_dial_operation_ready,
342 task);
343 g_free (command);
344 return;
345 }
346
347 /* Fall down to next step */
348 mm_dbg ("cinterion dial step %u/%u: authentication not required", ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST);
349 ctx->step++;
350 }
351 case DIAL_3GPP_CONTEXT_STEP_START_CONNECTION:
352 /* Chain up to parent's dialling */
353 MM_BROADBAND_BEARER_CLASS (mm_broadband_bearer_pls62_parent_class)->dial_3gpp (
354 MM_BROADBAND_BEARER (ctx->self),
355 ctx->modem,
356 ctx->primary,
357 ctx->cid,
358 g_task_get_cancellable (task),
359 (GAsyncReadyCallback)parent_dial_3gpp_ready,
360 task);
361
362 return;
363 case DIAL_3GPP_CONTEXT_STEP_LAST:
364 mm_dbg ("cinterion dial step %u/%u: finished", ctx->step, DIAL_3GPP_CONTEXT_STEP_LAST);
365 g_task_return_pointer (task, g_object_ref (ctx->data), g_object_unref);
366 g_object_unref (task);
367 return;
368 }
369}
370
371static void
372dial_3gpp (MMBroadbandBearer *self,
373 MMBaseModem *modem,
374 MMPortSerialAt *primary,
375 guint cid,
376 GCancellable *cancellable,
377 GAsyncReadyCallback callback,
378 gpointer user_data)
379{
380 GTask *task;
381 Dial3gppContext *ctx;
382
383 g_assert (primary != NULL);
384
385 /* Setup task and create connection context */
386 task = g_task_new (self, cancellable, callback, user_data);
387 ctx = g_slice_new0 (Dial3gppContext);
388 g_task_set_task_data (task, ctx, (GDestroyNotify) dial_3gpp_context_free);
389
390 /* Setup context */
391 ctx->self = g_object_ref (self);
392 ctx->modem = g_object_ref (modem);
393 ctx->primary = g_object_ref (primary);
394 ctx->cid = cid;
395 ctx->step = DIAL_3GPP_CONTEXT_STEP_FIRST;
396
397 /* Run! */
398 dial_3gpp_context_step (task);
399}
400
401/*****************************************************************************/
402/* Setup and Init Bearers */
403
404MMBaseBearer *
405mm_broadband_bearer_pls62_new_finish (GAsyncResult *res,
406 GError **error)
407{
408 GObject *bearer;
409 GObject *source;
410
411 source = g_async_result_get_source_object (res);
412 bearer = g_async_initable_new_finish (G_ASYNC_INITABLE (source), res, error);
413 g_object_unref (source);
414
415 if (!bearer)
416 return NULL;
417
418 /* Only export valid bearers */
419 mm_base_bearer_export (MM_BASE_BEARER (bearer));
420
421 return MM_BASE_BEARER (bearer);
422}
423
424void
425mm_broadband_bearer_pls62_new (MMBroadbandModemCinterion *modem,
426 MMBearerProperties *config,
427 GCancellable *cancellable,
428 GAsyncReadyCallback callback,
429 gpointer user_data)
430{
431 g_async_initable_new_async (
432 MM_TYPE_BROADBAND_BEARER_PLS62,
433 G_PRIORITY_DEFAULT,
434 cancellable,
435 callback,
436 user_data,
437 MM_BASE_BEARER_MODEM, modem,
438 MM_BASE_BEARER_CONFIG, config,
439 "ip-timeout", BEARER_PLS62_IP_TIMEOUT_DEFAULT,
440 NULL);
441}
442
443static void
444mm_broadband_bearer_pls62_init (MMBroadbandBearerPls62 *self)
445{
446}
447
448static void
449mm_broadband_bearer_pls62_class_init (MMBroadbandBearerPls62Class *klass)
450{
451 MMBroadbandBearerClass *broadband_bearer_class = MM_BROADBAND_BEARER_CLASS (klass);
452
453 broadband_bearer_class->dial_3gpp = dial_3gpp;
454 broadband_bearer_class->dial_3gpp_finish = dial_3gpp_finish;
455}
diff --git a/plugins/cinterion/mm-broadband-bearer-pls62.h b/plugins/cinterion/mm-broadband-bearer-pls62.h
0new file mode 100644456new file mode 100644
index 0000000..59e77ef
--- /dev/null
+++ b/plugins/cinterion/mm-broadband-bearer-pls62.h
@@ -0,0 +1,57 @@
1/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details:
12 *
13 * Copyright (C) 2018 Canonical Ltd
14 * Author: Alfonso Sanchez-Beato <alfonso.sanchez-beato@canonical.com>
15 */
16
17#ifndef MM_BROADBAND_BEARER_PLS62_H
18#define MM_BROADBAND_BEARER_PLS62_H
19
20#include <glib.h>
21#include <glib-object.h>
22
23#include "mm-broadband-bearer.h"
24#include "mm-broadband-modem-cinterion.h"
25
26/* Allow up to 90s to get a proper IP connection */
27#define BEARER_PLS62_IP_TIMEOUT_DEFAULT 90
28
29#define MM_TYPE_BROADBAND_BEARER_PLS62 (mm_broadband_bearer_pls62_get_type ())
30#define MM_BROADBAND_BEARER_PLS62(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_BEARER_PLS62, MMBroadbandBearerPls62))
31#define MM_BROADBAND_BEARER_PLS62_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_BEARER_PLS62, MMBroadbandBearerPls62Class))
32#define MM_IS_BROADBAND_BEARER_PLS62(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_BEARER_PLS62))
33#define MM_IS_BROADBAND_BEARER_PLS62_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_BEARER_PLS62))
34#define MM_BROADBAND_BEARER_PLS62_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_BEARER_PLS62, MMBroadbandBearerPls62Class))
35
36typedef struct _MMBroadbandBearerPls62 MMBroadbandBearerPls62;
37typedef struct _MMBroadbandBearerPls62Class MMBroadbandBearerPls62Class;
38
39struct _MMBroadbandBearerPls62 {
40 MMBroadbandBearer parent;
41};
42
43struct _MMBroadbandBearerPls62Class {
44 MMBroadbandBearerClass parent;
45};
46
47GType mm_broadband_bearer_pls62_get_type (void);
48
49void mm_broadband_bearer_pls62_new (MMBroadbandModemCinterion *modem,
50 MMBearerProperties *config,
51 GCancellable *cancellable,
52 GAsyncReadyCallback callback,
53 gpointer user_data);
54MMBaseBearer *mm_broadband_bearer_pls62_new_finish (GAsyncResult *res,
55 GError **error);
56
57#endif /* MM_BROADBAND_BEARER_PLS62_H */
diff --git a/plugins/cinterion/mm-broadband-modem-cinterion.c b/plugins/cinterion/mm-broadband-modem-cinterion.c
index 99dabde..fe4cdb1 100644
--- a/plugins/cinterion/mm-broadband-modem-cinterion.c
+++ b/plugins/cinterion/mm-broadband-modem-cinterion.c
@@ -40,6 +40,7 @@
40#include "mm-modem-helpers-cinterion.h"40#include "mm-modem-helpers-cinterion.h"
41#include "mm-common-cinterion.h"41#include "mm-common-cinterion.h"
42#include "mm-broadband-bearer-cinterion.h"42#include "mm-broadband-bearer-cinterion.h"
43#include "mm-broadband-bearer-pls62.h"
4344
44static void iface_modem_init (MMIfaceModem *iface);45static void iface_modem_init (MMIfaceModem *iface);
45static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);46static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
@@ -1684,6 +1685,23 @@ broadband_bearer_cinterion_new_ready (GObject *unused,
1684}1685}
16851686
1686static void1687static void
1688broadband_bearer_pls62_new_ready (GObject *unused,
1689 GAsyncResult *res,
1690 GTask *task)
1691{
1692 MMBaseBearer *bearer;
1693 GError *error = NULL;
1694
1695 bearer = mm_broadband_bearer_pls62_new_finish (res, &error);
1696 if (!bearer)
1697 g_task_return_error (task, error);
1698 else
1699 g_task_return_pointer (task, bearer, g_object_unref);
1700 g_object_unref (task);
1701}
1702
1703#if 0
1704static void
1687broadband_bearer_new_ready (GObject *unused,1705broadband_bearer_new_ready (GObject *unused,
1688 GAsyncResult *res,1706 GAsyncResult *res,
1689 GTask *task)1707 GTask *task)
@@ -1725,6 +1743,7 @@ broadband_bearer_no_swwan_new (MMBroadbandModem *modem,
1725 "ip-timeout", BEARER_CINTERION_IP_TIMEOUT_DEFAULT,1743 "ip-timeout", BEARER_CINTERION_IP_TIMEOUT_DEFAULT,
1726 NULL);1744 NULL);
1727}1745}
1746#endif
17281747
1729static void1748static void
1730common_create_bearer (GTask *task)1749common_create_bearer (GTask *task)
@@ -1735,11 +1754,11 @@ common_create_bearer (GTask *task)
17351754
1736 switch (self->priv->swwan_support) {1755 switch (self->priv->swwan_support) {
1737 case FEATURE_NOT_SUPPORTED:1756 case FEATURE_NOT_SUPPORTED:
1738 mm_dbg ("^SWWAN not supported, creating default bearer...");1757 mm_dbg ("^SWWAN not supported, creating PLS62 bearer...");
1739 broadband_bearer_no_swwan_new (MM_BROADBAND_MODEM (self),1758 mm_broadband_bearer_pls62_new (MM_BROADBAND_MODEM_CINTERION (self),
1740 g_task_get_task_data (task),1759 g_task_get_task_data (task),
1741 NULL, /* cancellable */1760 NULL, /* cancellable */
1742 (GAsyncReadyCallback)broadband_bearer_new_ready,1761 (GAsyncReadyCallback)broadband_bearer_pls62_new_ready,
1743 task);1762 task);
1744 return;1763 return;
1745 case FEATURE_SUPPORTED:1764 case FEATURE_SUPPORTED:
diff --git a/src/mm-broadband-bearer.c b/src/mm-broadband-bearer.c
index 6321de2..454b9dc 100644
--- a/src/mm-broadband-bearer.c
+++ b/src/mm-broadband-bearer.c
@@ -892,6 +892,32 @@ parse_pdp_list (MMBaseModem *modem,
892 pdp->cid);892 pdp->cid);
893 cid = pdp->cid;893 cid = pdp->cid;
894 }894 }
895 } else {
896 const gchar *apn;
897
898 apn = mm_bearer_properties_get_apn (mm_base_bearer_peek_config (MM_BASE_BEARER (ctx->self)));
899 /* Check if we have a case of APN overwritten by modem */
900 if (apn != NULL && pdp->apn != NULL && apn[0] != '\0' && pdp->apn[0] != '\0') {
901 size_t requested_len = strlen (apn);
902 if (g_ascii_strncasecmp (pdp->apn, apn, requested_len) == 0) {
903 size_t existing_len = strlen (pdp->apn);
904 if ((existing_len > (requested_len + 14)) &&
905 g_ascii_strncasecmp (&pdp->apn[requested_len], ".mnc", 4) == 0 &&
906 g_ascii_strncasecmp (&pdp->apn[requested_len + 7], ".mcc", 4) == 0) {
907 gchar *ip_family_str;
908
909 /* Found a PDP context with the same APN and re-formatted by modem. */
910 ip_family_str = mm_bearer_ip_family_build_string_from_mask (pdp->pdp_type);
911 mm_dbg ("Found PDP context created by modem with CID %u and PDP type %s for APN '%s'",
912 pdp->cid, ip_family_str, apn ? apn : "");
913 cid = pdp->cid;
914 ctx->use_existing_cid = TRUE;
915 g_free (ip_family_str);
916 /* In this case, stop searching */
917 break;
918 }
919 }
920 }
895 }921 }
896922
897 if (ctx->max_cid < pdp->cid)923 if (ctx->max_cid < pdp->cid)

Subscribers

People subscribed via source and target branches