3
3
* oFono - Open Source Telephony
5
* Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
5
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
7
7
* This program is free software; you can redistribute it and/or modify
8
8
* it under the terms of the GNU General Public License version 2 as
64
64
char password[OFONO_GPRS_MAX_PASSWORD_LENGTH + 1];
67
enum ofono_gprs_proto proto;
71
ofono_gprs_context_cb_t down_cb; /* Down callback */
72
ofono_gprs_context_up_cb_t up_cb; /* Up callback */
71
ofono_gprs_context_cb_t cb;
74
72
void *cb_data; /* Callback data */
123
121
gcd->state = STATE_IDLE;
125
123
if (result == NULL) {
126
CALLBACK_WITH_FAILURE(gcd->up_cb, NULL, 0, NULL, NULL,
127
NULL, NULL, gcd->cb_data);
124
CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
131
128
decode_at_error(&error, g_at_result_final_response(result));
132
gcd->up_cb(&error, NULL, 0, NULL, NULL, NULL, NULL, gcd->cb_data);
129
gcd->cb(&error, gcd->cb_data);
135
132
static void session_cb(gboolean ok, GAtResult *result, gpointer user_data)
157
154
if (interface == NULL)
158
155
interface = "invalid";
160
CALLBACK_WITH_SUCCESS(gcd->up_cb, interface, TRUE, gcd->address,
161
STATIC_IP_NETMASK, NULL, dns, gcd->cb_data);
157
ofono_gprs_context_set_interface(gc, interface);
158
ofono_gprs_context_set_ipv4_address(gc, gcd->address, TRUE);
159
ofono_gprs_context_set_ipv4_netmask(gc, STATIC_IP_NETMASK);
160
ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
162
CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
164
165
gcd->cb_data = NULL;
301
302
if (g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL) == 0)
304
sprintf(buf, "AT+XDNS=%u,1", gcd->active_context);
305
g_at_chat_send(gcd->chat, "AT+XDNS=?", none_prefix, NULL, NULL, NULL);
307
switch (gcd->proto) {
308
case OFONO_GPRS_PROTO_IP:
309
sprintf(buf, "AT+XDNS=%u,1", gcd->active_context);
311
case OFONO_GPRS_PROTO_IPV6:
312
sprintf(buf, "AT+XDNS=%u,2", gcd->active_context);
314
case OFONO_GPRS_PROTO_IPV4V6:
315
sprintf(buf, "AT+XDNS=%u,3", gcd->active_context);
305
319
if (g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL) == 0)
308
322
sprintf(buf, "AT+CGACT=1,%u", gcd->active_context);
309
324
if (g_at_chat_send(gcd->chat, buf, none_prefix,
310
325
activate_cb, gc, NULL) > 0)
317
332
static void ifx_gprs_activate_primary(struct ofono_gprs_context *gc,
318
333
const struct ofono_gprs_primary_context *ctx,
319
ofono_gprs_context_up_cb_t cb, void *data)
334
ofono_gprs_context_cb_t cb, void *data)
321
336
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
322
337
char buf[OFONO_GPRS_MAX_APN_LENGTH + 128];
325
340
DBG("cid %u", ctx->cid);
327
342
gcd->active_context = ctx->cid;
329
344
gcd->cb_data = data;
330
345
memcpy(gcd->username, ctx->username, sizeof(ctx->username));
331
346
memcpy(gcd->password, ctx->password, sizeof(ctx->password));
333
348
gcd->state = STATE_ENABLING;
349
gcd->proto = ctx->proto;
335
len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IP\"", ctx->cid);
351
switch (ctx->proto) {
352
case OFONO_GPRS_PROTO_IP:
353
len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IP\"",
356
case OFONO_GPRS_PROTO_IPV6:
357
len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IPV6\"",
360
case OFONO_GPRS_PROTO_IPV4V6:
361
len = snprintf(buf, sizeof(buf), "AT+CGDCONT=%u,\"IPV4V6\"",
338
367
snprintf(buf + len, sizeof(buf) - len - 3,
342
371
setup_cb, gc, NULL) > 0)
345
CALLBACK_WITH_FAILURE(cb, NULL, 0, NULL, NULL, NULL, NULL, data);
374
CALLBACK_WITH_FAILURE(cb, data);
348
377
static void deactivate_cb(gboolean ok, GAtResult *result, gpointer user_data)
361
390
g_at_chat_resume(gcd->chat);
363
CALLBACK_WITH_SUCCESS(gcd->down_cb, gcd->cb_data);
392
CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
366
395
static void ifx_gprs_deactivate_primary(struct ofono_gprs_context *gc,