Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 7/9] gprs: implement ofono_gprs_cid_activated
Date: Thu, 17 Mar 2016 12:48:21 -0500	[thread overview]
Message-ID: <56EAEDE5.1010200@gmail.com> (raw)
In-Reply-To: <1458234140-7936-8-git-send-email-dragos@endocode.com>

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

On 03/17/2016 12:02 PM, Dragos Tatulea wrote:
> It works by looking for a context with the same APN and tries to use
> that. Otherwise it will create it's own.
>
> Then it assigns a gprs context driver and calls it's read_settings if
> it exists.
> ---
>   src/gprs.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 69 insertions(+)
>
> diff --git a/src/gprs.c b/src/gprs.c
> index e5e7abc..74e9104 100644
> --- a/src/gprs.c
> +++ b/src/gprs.c
> @@ -293,6 +293,11 @@ static void gprs_cid_release(struct ofono_gprs *gprs, unsigned int id)
>   	idmap_put(gprs->cid_map, id);
>   }
>
> +static gboolean gprs_cid_taken(struct ofono_gprs *gprs, unsigned int id)
> +{
> +	return idmap_find(gprs->cid_map, id) != 0;
> +}
> +
>   static gboolean assign_context(struct pri_context *ctx, int use_cid)
>   {
>   	struct idmap *cidmap = ctx->gprs->cid_map;
> @@ -1842,6 +1847,25 @@ static void write_context_settings(struct ofono_gprs *gprs,
>   	}
>   }
>
> +static struct pri_context *find_context_by_apn(struct ofono_gprs *gprs,
> +					const char *apn)
> +{
> +	GSList *l;
> +
> +	for (l = gprs->contexts; l; l = l->next) {
> +		struct pri_context *pri_ctx = l->data;
> +
> +		/* Looking only at prefix for the LTE case when a user APN is
> +		 * web.provider.com but it apepars as
> +		 * web.provider.com.mncX.mccY.gprs .
> +		 */
> +		if (g_str_has_prefix(apn, pri_ctx->context.apn))
> +			return pri_ctx;
> +	}
> +
> +	return NULL;
> +}
> +
>   static struct pri_context *add_context(struct ofono_gprs *gprs,
>   					const char *name,
>   					enum ofono_gprs_context_type type)
> @@ -1885,6 +1909,51 @@ static struct pri_context *add_context(struct ofono_gprs *gprs,
>   	return context;
>   }
>
> +void ofono_gprs_cid_activated(struct ofono_gprs  *gprs, unsigned int cid,
> +				const char *apn)
> +{
> +	struct pri_context *pri_ctx;
> +	struct ofono_gprs_context *gc;
> +
> +	DBG("");
> +
> +	if (gprs_cid_taken(gprs, cid)) {
> +		DBG("cid %u already activated", cid);
> +		return;
> +	}
> +
> +	pri_ctx = find_context_by_apn(gprs, apn);

Also, check the special case of settings provisioning failed.  It is 
signified by an a list with exactly 1 context.  The APN of that context 
will be NULL.  This is done in a couple of places by doing the following:

if (gprs->contexts == NULL) /* Automatic provisioning failed */
	add_context(gprs, NULL, OFONO_GPRS_CONTEXT_TYPE_INTERNET);

So lets high-jack that special context in this case.

> +
> +	if (!pri_ctx) {
> +		pri_ctx = add_context(gprs, "auto",
shouldn't 'auto' be the APN?
> +					OFONO_GPRS_CONTEXT_TYPE_INTERNET);
> +		if (!pri_ctx) {
> +			ofono_error("Can't find/create automatic context %d "
> +					"with APN %s.", cid, apn);
> +			return;
> +		}
> +	} else {
> +		DBusConnection *conn = ofono_dbus_get_connection();
> +		pri_set_apn(pri_ctx, conn, NULL, apn);
> +	}
> +
> +	if (assign_context(pri_ctx, cid) == FALSE) {
> +		ofono_warn("Can't assign context to driver for APN.");
> +		release_context(pri_ctx);
> +		return;
> +	}
> +
> +	gc = pri_ctx->context_driver;
> +
> +	if (gc->driver->read_settings)
> +		gc->driver->read_settings(gc, &pri_ctx->context,
> +					     pri_activate_callback, pri_ctx);
> +	else
> +		ofono_warn("Context activated for driver that doesn't support "
> +				"automatic context activation.");

Lets check this part right away and not assign contexts or do anything 
if the read_settings method is not implemented

> +

And another spurious whitespace :)
> +}
> +
>   static void send_context_added_signal(struct ofono_gprs *gprs,
>   					struct pri_context *context,
>   					DBusConnection *conn)
>

Regards,
-Denis

  reply	other threads:[~2016-03-17 17:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17 17:02 [PATCH 0/9] allow automatic context activation Dragos Tatulea
2016-03-17 17:02 ` [PATCH 1/9] idmap: add api for finding a certain id in map Dragos Tatulea
2016-03-17 17:42   ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 2/9] gprs-context.h: add op for reading context config Dragos Tatulea
2016-03-17 17:29   ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 3/9] gprs.h: automatic context configuration notifier Dragos Tatulea
2016-03-17 17:33   ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 4/9] gprs: pri_activate_callback: optional msg reply Dragos Tatulea
2016-03-17 17:41   ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 5/9] gprs: pri_set_apn: make reply msg optional Dragos Tatulea
2016-03-17 17:39   ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 6/9] gprs: custom cid for assign_context Dragos Tatulea
2016-03-17 17:27   ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 7/9] gprs: implement ofono_gprs_cid_activated Dragos Tatulea
2016-03-17 17:48   ` Denis Kenzior [this message]
2016-03-17 17:02 ` [PATCH 8/9] atmodem: gprs: handle automatic context activation Dragos Tatulea
2016-03-17 17:56   ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 9/9] ubloxmodem: support automatic ctx activation Dragos Tatulea

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=56EAEDE5.1010200@gmail.com \
    --to=denkenz@gmail.com \
    --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