Ejemplo n.º 1
0
static void lookup_apn(const char *match_mcc, const char *match_mnc,
						gboolean allow_duplicates)
{
	GSList *l;
	GSList *apns;
	GError *error = NULL;

	g_print("Searching for info for network: %s%s\n", match_mcc, match_mnc);

	apns = mbpi_lookup_apn(match_mcc, match_mnc, OFONO_GPRS_CONTEXT_TYPE_ANY,
				allow_duplicates, &error);

	if (apns == NULL) {
		if (error != NULL) {
			g_printerr("Lookup failed: %s\n", error->message);
			g_error_free(error);
		}

		return;
	}

	for (l = apns; l; l = l->next) {
		struct ofono_gprs_provision_data *ap = l->data;

		g_print("\n");
		g_print("Name: %s\n", ap->name);
		g_print("APN: %s\n", ap->apn);
		g_print("Type: %s\n", mbpi_ap_type(ap->type));
		g_print("Username: %s\n", ap->username);
		g_print("Password: %s\n", ap->password);

		mbpi_ap_free(ap);
	}

	g_slist_free(apns);
}
Ejemplo n.º 2
0
int provision_get_settings(const char *mcc, const char *mnc,
				const char *spn,
				struct ofono_gprs_provision_data **settings,
				int *count)
{
	GSList *l;
	GSList *apns;
	GError *error = NULL;
	int ap_count;
	int i;

	ofono_info("Provisioning for MCC %s, MNC %s, SPN '%s'", mcc, mnc, spn);

	/*
	 * Passing FALSE to mbpi_lookup_apn() would return
	 * an empty list if duplicates are found.
	 */
	apns = mbpi_lookup_apn(mcc, mnc, TRUE, &error);
	if (error != NULL) {
		ofono_error("%s", error->message);
		g_error_free(error);
	}

	ofono_info("Found %d APs in MBPI", g_slist_length(apns));
	apns = provision_normalize_apn_list(apns, spn);
	if (apns == NULL)
		return -ENOENT;

	ap_count = g_slist_length(apns);

	ofono_info("Provisioning %d APs", ap_count);

	*settings = g_try_new0(struct ofono_gprs_provision_data, ap_count);
	if (*settings == NULL) {
		ofono_error("Provisioning failed: %s", g_strerror(errno));

		for (l = apns; l; l = l->next)
			mbpi_ap_free(l->data);

		g_slist_free(apns);

		return -ENOMEM;
	}

	*count = ap_count;

	for (l = apns, i = 0; l; l = l->next, i++) {
		struct ofono_gprs_provision_data *ap = l->data;

		ofono_info("Name: '%s'", ap->name);
		ofono_info("APN: '%s'", ap->apn);
		ofono_info("Type: %s", mbpi_ap_type(ap->type));
		ofono_info("Username: '******'", ap->username);
		ofono_info("Password: '******'", ap->password);

		memcpy(*settings + i, ap,
			sizeof(struct ofono_gprs_provision_data));

		g_free(ap);
	}

	g_slist_free(apns);

	return 0;
}
Ejemplo n.º 3
0
static int provision_get_settings(const char *mcc, const char *mnc,
				const char *spn,
				struct ofono_gprs_provision_data **settings,
				int *count)
{
	GSList *l;
	GSList *apns;
	GError *error = NULL;
	int ap_count;
	int i;

	DBG("Provisioning for MCC %s, MNC %s, SPN '%s'", mcc, mnc, spn);

	/*
	 * TODO: review with upstream.  Default behavior was to
	 * disallow duplicate APN entries, which unfortunately exist
	 * in the mobile-broadband-provider-info db.
	 */
	apns = mbpi_lookup_apn(mcc, mnc, TRUE, &error);
	if (apns == NULL) {
		if (error != NULL) {
			ofono_error("%s", error->message);
			g_error_free(error);
		}

		return -ENOENT;
	}

	ap_count = g_slist_length(apns);

	DBG("Found %d APs", ap_count);

	*settings = g_try_new0(struct ofono_gprs_provision_data, ap_count);
	if (*settings == NULL) {
		ofono_error("Provisioning failed: %s", g_strerror(errno));

		for (l = apns; l; l = l->next)
			mbpi_ap_free(l->data);

		g_slist_free(apns);

		return -ENOMEM;
	}

	*count = ap_count;

	for (l = apns, i = 0; l; l = l->next, i++) {
		struct ofono_gprs_provision_data *ap = l->data;

		DBG("Name: '%s'", ap->name);
		DBG("APN: '%s'", ap->apn);
		DBG("Type: %s", mbpi_ap_type(ap->type));
		DBG("Username: '******'", ap->username);
		DBG("Password: '******'", ap->password);

		memcpy(*settings + i, ap,
			sizeof(struct ofono_gprs_provision_data));

		g_free(ap);
	}

	g_slist_free(apns);

	return 0;
}