static void test_reply_data_call_valid(gconstpointer data) { /* TODO: fix de-const cast... */ struct ril_msg *message = (struct ril_msg *) data; struct ofono_error error; struct reply_setup_data_call *reply; reply = g_ril_reply_parse_data_call(NULL, message, &error); g_assert(reply != NULL); g_ril_reply_free_setup_data_call(reply); g_assert(error.type == OFONO_ERROR_TYPE_NO_ERROR && error.error == 0); }
static void ril_setup_data_call_cb(struct ril_msg *message, gpointer user_data) { struct cb_data *cbd = user_data; ofono_gprs_context_cb_t cb = cbd->cb; struct ofono_gprs_context *gc = cbd->user; struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc); struct ofono_error error; struct reply_setup_data_call *reply = NULL; char **split_ip_addr = NULL; ofono_info("setting up data call"); if (message->error != RIL_E_SUCCESS) { ofono_error("GPRS context: Reply failure: %s", ril_error_to_string(message->error)); error.type = OFONO_ERROR_TYPE_FAILURE; error.error = message->error; set_context_disconnected(gcd); goto error; } reply = g_ril_reply_parse_data_call(gcd->ril, message, &error); gcd->active_rild_cid = reply->cid; if (error.type != OFONO_ERROR_TYPE_NO_ERROR) { if (gcd->active_rild_cid != -1) { ofono_error("no active context. disconnect"); disconnect_context(gc); } goto error; } if (reply->status != 0) { ofono_error("%s: reply->status is non-zero: %d", __func__, reply->status); error.type = OFONO_ERROR_TYPE_FAILURE; error.error = reply->status; set_context_disconnected(gcd); goto error; } /* * TODO: consier moving this into parse_data_reply * * Note - the address may optionally include a prefix size * ( Eg. "/30" ). As this confuses NetworkManager, we * explicitly strip any prefix after calculating the netmask. */ split_ip_addr = g_strsplit(reply->ip_addrs[0], "/", 2); /* TODO: see note above re: invalid messages... */ if (split_ip_addr[0] == NULL) { ofono_error("%s: invalid IP address field returned: %s", __func__, reply->ip_addrs[0]); error.type = OFONO_ERROR_TYPE_FAILURE; error.error = EINVAL; set_context_disconnected(gcd); goto error; } gcd->state = STATE_ACTIVE; ofono_gprs_context_set_interface(gc, reply->ifname); /* TODO: * RILD can return multiple addresses; oFono only supports * setting a single IPv4 address. At this time, we only * use the first address. It's possible that a RIL may * just specify the end-points of the point-to-point * connection, in which case this code will need to * changed to handle such a device. */ ofono_gprs_context_set_ipv4_netmask(gc, ril_util_get_netmask(reply->ip_addrs[0])); ofono_gprs_context_set_ipv4_address(gc, split_ip_addr[0], TRUE); ofono_gprs_context_set_ipv4_gateway(gc, reply->gateways[0]); ofono_gprs_context_set_ipv4_dns_servers(gc, (const char **) reply->dns_addresses); error: g_ril_reply_free_setup_data_call(reply); g_strfreev(split_ip_addr); cb(&error, cbd->data); }