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