Open Source Telephony
 help / color / mirror / Atom feed
From: Dragos Tatulea <dragos@endocode.com>
To: ofono@ofono.org
Subject: [PATCH 6/9] gprs: custom cid for assign_context
Date: Thu, 17 Mar 2016 18:02:17 +0100	[thread overview]
Message-ID: <1458234140-7936-7-git-send-email-dragos@endocode.com> (raw)
In-Reply-To: <1458234140-7936-1-git-send-email-dragos@endocode.com>

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

It's optional though. If 0 a cid is picked up automatically from the
allowed range.
---
 src/gprs.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/gprs.c b/src/gprs.c
index 664c377..e5e7abc 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -283,12 +283,17 @@ static unsigned int gprs_cid_alloc(struct ofono_gprs *gprs)
 	return idmap_alloc(gprs->cid_map);
 }
 
+static void gprs_cid_take(struct ofono_gprs *gprs, unsigned int id)
+{
+	idmap_take(gprs->cid_map, id);
+}
+
 static void gprs_cid_release(struct ofono_gprs *gprs, unsigned int id)
 {
 	idmap_put(gprs->cid_map, id);
 }
 
-static gboolean assign_context(struct pri_context *ctx)
+static gboolean assign_context(struct pri_context *ctx, int use_cid)
 {
 	struct idmap *cidmap = ctx->gprs->cid_map;
 	GSList *l;
@@ -296,7 +301,12 @@ static gboolean assign_context(struct pri_context *ctx)
 	if (cidmap == NULL)
 		return FALSE;
 
-	ctx->context.cid = gprs_cid_alloc(ctx->gprs);
+	if (use_cid > 0) {
+		gprs_cid_take(ctx->gprs, use_cid);
+		ctx->context.cid = use_cid;
+	} else
+		ctx->context.cid = gprs_cid_alloc(ctx->gprs);
+
 	if (ctx->context.cid == 0)
 		return FALSE;
 
@@ -1248,7 +1258,7 @@ static DBusMessage *pri_set_property(DBusConnection *conn,
 		if (ctx->gprs->flags & GPRS_FLAG_ATTACHING)
 			return __ofono_error_attach_in_progress(msg);
 
-		if (value && assign_context(ctx) == FALSE)
+		if (value && assign_context(ctx, 0) == FALSE)
 			return __ofono_error_not_implemented(msg);
 
 		gc = ctx->context_driver;
-- 
2.5.0


  parent reply	other threads:[~2016-03-17 17:02 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 ` Dragos Tatulea [this message]
2016-03-17 17:27   ` [PATCH 6/9] gprs: custom cid for assign_context 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
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=1458234140-7936-7-git-send-email-dragos@endocode.com \
    --to=dragos@endocode.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