Open Source Telephony
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: ofono@ofono.org
Subject: Re: [RFC PATCH 4/4] Dummy example GPRS context provisioning driver
Date: Tue, 11 Jan 2011 22:48:54 -0800	[thread overview]
Message-ID: <1294814934.3873.73.camel@aeonflux> (raw)
In-Reply-To: <1294665072-13630-5-git-send-email-jukka.saunamaki@nokia.com>

[-- Attachment #1: Type: text/plain, Size: 3465 bytes --]

Hi Jukka,

>  Makefile.am          |    3 +
>  examples/provision.c |  198 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 201 insertions(+), 0 deletions(-)
>  create mode 100644 examples/provision.c
> 
> diff --git a/Makefile.am b/Makefile.am
> index 0f330a7..d57509d 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -305,6 +305,9 @@ builtin_sources += examples/history.c
>  
>  builtin_modules += example_nettime
>  builtin_sources += examples/nettime.c
> +
> +builtin_modules += example_gprs_provision
> +builtin_sources += examples/provision.c
>  endif

I like to have these match. So just call it example_provision.

> +struct provisioning_request {
> +	struct ofono_modem *modem;
> +	ofono_gprs_provision_cb_t cb;
> +	void *userdata;

Same as I mentioned in the other patch. Please use user_data.

> +};
> +
> +static void sim_spn_read_cb(int ok, int length, int record,
> +				const unsigned char *data,
> +				int record_length, void *userdata)
> +{
> +	struct provisioning_request *req = userdata;
> +	char *spn = NULL;
> +
> +	struct ofono_atom *sim_atom;
> +	struct ofono_sim *sim;
> +	const char *imsi;
> +
> +	unsigned char mnc_length;
> +	char mcc[OFONO_MAX_MCC_LENGTH + 1];
> +	char mnc[OFONO_MAX_MNC_LENGTH + 1];
> +
> +	GSList *settings = NULL;
> +	struct ofono_gprs_provisioning_data *entry;
> +
> +	sim_atom = __ofono_modem_find_atom(req->modem, OFONO_ATOM_TYPE_SIM);
> +
> +	if (sim_atom == NULL) {
> +		ofono_debug("No SIM atom");
> +		goto finish;
> +	}
> +
> +	sim = __ofono_atom_get_data(sim_atom);
> +	imsi = ofono_sim_get_imsi(sim);
> +	if (imsi == NULL) {
> +		ofono_debug("No IMSI available");
> +		goto finish;
> +	}
> +
> +	mnc_length = ofono_sim_get_mnc_length(sim);
> +	if (mnc_length == 0) {
> +		ofono_debug("No MNC length available");
> +		goto finish;
> +	}
> +
> +	strncpy(mcc, imsi, OFONO_MAX_MCC_LENGTH);
> +	mcc[OFONO_MAX_MCC_LENGTH] = '\0';
> +	strncpy(mnc, imsi + OFONO_MAX_MCC_LENGTH, mnc_length);
> +	mnc[mnc_length] = '\0';
> +
> +	if (ok)
> +		spn = sim_string_to_utf8(data + 1, length - 1);
> +
> +	ofono_debug("Finding settings for MCC %s, MNC %s, SPN '%s'",
> +			mcc, mnc, spn);
> +
> +	if (spn == NULL || strcmp(spn, "oFono") != 0)
> +		goto finish;

I think we need to also take some MCC and MNC into account. People will
be by accident compiling this plugin and I wanna make sure nothing bad
gets provisioned ;)

> +static void example_gprs_provision_get_settings(
> +	struct ofono_modem *modem,
> +	ofono_gprs_provision_cb_t cb,
> +	void *userdata)
> +{
> +	struct provisioning_request *req;
> +	struct ofono_atom *sim_atom;
> +	struct ofono_sim *sim = NULL;
> +
> +	ofono_debug("Provisioning...");
> +
> +	req = g_try_new0(struct provisioning_request, 1);
> +	if (req == NULL)
> +		goto error;
> +
> +	req->modem = modem;
> +	req->cb = cb;
> +	req->userdata = userdata;
> +
> +	/* Start SPN query from SIM */
> +	sim_atom = __ofono_modem_find_atom(modem, OFONO_ATOM_TYPE_SIM);
> +
> +	if (sim_atom != NULL)
> +		sim = __ofono_atom_get_data(sim_atom);
> +
> +	if (sim != NULL) {
> +		ofono_sim_read(sim, SIM_EFSPN_FILEID,
> +				OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
> +				sim_spn_read_cb, req);
> +		return;
> +	}

Should this not be provided somehow by the SIM atom?

Denis, any idea why we are not keeping this information available?

Regards

Marcel



  reply	other threads:[~2011-01-12  6:48 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-10 13:11 [RFC PATCHv3 0/4] Plugin API for provisioning of GPRS context settings Jukka Saunamaki
2011-01-10 13:11 ` [RFC PATCH 1/4] Added GPRS context provisioning driver API sources Jukka Saunamaki
2011-01-12  6:43   ` Marcel Holtmann
2011-01-12 16:43     ` Denis Kenzior
2011-01-10 13:11 ` [RFC PATCH 2/4] gprs: add automatic context settings provisioning Jukka Saunamaki
2011-01-12  6:51   ` Marcel Holtmann
2011-01-12  7:26     ` Jukka Saunamaki
2011-01-12 16:37       ` Marcel Holtmann
2011-01-10 13:11 ` [RFC PATCH 3/4] sim: add ofono_sim_get_mnc_length Jukka Saunamaki
2011-01-11  0:40   ` Marcel Holtmann
2011-01-11 15:03     ` Denis Kenzior
2011-01-10 13:11 ` [RFC PATCH 4/4] Dummy example GPRS context provisioning driver Jukka Saunamaki
2011-01-12  6:48   ` Marcel Holtmann [this message]
2011-01-12  7:41     ` Jukka Saunamaki
2011-01-12 16:46       ` Denis Kenzior
2011-01-13  6:36         ` Jukka Saunamaki
2011-01-13 15:57           ` Denis Kenzior
2011-01-14  6:53             ` Jukka Saunamaki
2011-01-14  7:47               ` =?unknown-8bit?q?R=C3=A9mi?= Denis-Courmont
2011-01-14 10:37               ` Marcel Holtmann
2011-01-14 10:46                 ` Jukka Saunamaki
2011-01-14 13:44                   ` Marcel Holtmann
2011-01-14 13:58                     ` Jukka Saunamaki
2011-01-14 14:10                       ` Marcel Holtmann
2011-01-14 14:42                         ` =?unknown-8bit?q?R=C3=A9mi?= Denis-Courmont
2011-01-15  1:30                           ` Marcel Holtmann
2011-01-17  6:20                             ` Jukka Saunamaki
2011-01-14 15:07               ` Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1294814934.3873.73.camel@aeonflux \
    --to=marcel@holtmann.org \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox