void ril_request_setup_data_call(RIL_Token t, void *data, int length)
{
	struct ril_gprs_connection *gprs_connection = NULL;
	struct ipc_client_gprs_capabilities gprs_capabilities;
	struct ipc_gprs_port_list port_list;
	struct ipc_client *ipc_client;

	char *username = NULL;
	char *password = NULL;
	char *apn = NULL;

	ipc_client = ((struct ipc_client_object *) ipc_fmt_client->object)->ipc_client;

	apn = ((char **) data)[2];
	username = ((char **) data)[3];
	password = ((char **) data)[4];

	LOGD("Requesting data connection to APN '%s'\n", apn);

	gprs_connection = ril_gprs_connection_add();

	if(!gprs_connection) {
		LOGE("Unable to create GPRS connection, aborting");

		RIL_onRequestComplete(t, RIL_E_GENERIC_FAILURE, NULL, 0);
		return;
	}

	gprs_connection->token = t;

	// Create the structs with the apn
	ipc_gprs_define_pdp_context_setup(&(gprs_connection->define_context),
		gprs_connection->cid, 1, apn);

	// Create the structs with the username/password tuple
	ipc_gprs_pdp_context_setup(&(gprs_connection->context),
		gprs_connection->cid, 1, username, password);

	ipc_client_gprs_get_capabilities(ipc_client, &gprs_capabilities);

	// If the device has the capability, deal with port list
	if(gprs_capabilities.port_list) {
		ipc_gprs_port_list_setup(&port_list);

		ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_GPRS_PORT_LIST,
			ipc_gprs_port_list_complete);

		ipc_fmt_send(IPC_GPRS_PORT_LIST, IPC_TYPE_SET,
			(void *) &port_list, sizeof(struct ipc_gprs_port_list), reqGetId(t));
	} else {
		ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_GPRS_DEFINE_PDP_CONTEXT,
			ipc_gprs_define_pdp_context_complete);

		ipc_fmt_send(IPC_GPRS_DEFINE_PDP_CONTEXT, IPC_TYPE_SET,
			(void *) &(gprs_connection->define_context),
				sizeof(struct ipc_gprs_define_pdp_context), reqGetId(t));
	}
}
Example #2
0
void ril_request_setup_data_call(RIL_Token t, void *data, int length)
{
	char *username = NULL;
	char *password = NULL;
	char *apn = NULL;

	struct ipc_gprs_define_pdp_context setup_apn_message;
	struct ipc_gprs_pdp_context activate_message;

	/* get the apn, username and password */
	apn = ((char **) data)[2];
	username = ((char **) data)[3];

	if(username != NULL) {
		if(strlen(username) < 2)
			username = "******";
	} else {
		username = "******";
	}

	password = ((char **) data)[4];

	if(password != NULL) {
		if(strlen(password) < 2)
			password = "******";
	} else {
		password = "******";
	}

	LOGD("Requesting data connection to APN '%s'\n", apn);

	/* create the structs with the apn */
	ipc_gprs_define_pdp_context_setup(&setup_apn_message, apn);

	/* create the structs with the username/password tuple */
	ipc_gprs_pdp_context_setup(&(ril_state.gprs_context), username, password);

	/* send the struct to the modem */
	ipc_send(IPC_GPRS_DEFINE_PDP_CONTEXT, IPC_TYPE_SET, 
			(void *) &setup_apn_message, sizeof(struct ipc_gprs_define_pdp_context), reqGetId(t));

	ipc_gen_phone_res_expect_to_func(reqGetId(t), IPC_GPRS_DEFINE_PDP_CONTEXT,
		ipc_gprs_pdp_context_complete);
}