mirror of git://git.sysmocom.de/ofono
gprs: custom cid for assign_context
It's optional though. If 0 a cid is picked up automatically from the allowed range.
This commit is contained in:
parent
6504e7090e
commit
02dcc2f36e
16
src/gprs.c
16
src/gprs.c
|
@ -283,12 +283,17 @@ static unsigned int gprs_cid_alloc(struct ofono_gprs *gprs)
|
||||||
return idmap_alloc(gprs->cid_map);
|
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)
|
static void gprs_cid_release(struct ofono_gprs *gprs, unsigned int id)
|
||||||
{
|
{
|
||||||
idmap_put(gprs->cid_map, 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;
|
struct idmap *cidmap = ctx->gprs->cid_map;
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
@ -296,7 +301,12 @@ static gboolean assign_context(struct pri_context *ctx)
|
||||||
if (cidmap == NULL)
|
if (cidmap == NULL)
|
||||||
return FALSE;
|
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)
|
if (ctx->context.cid == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -1245,7 +1255,7 @@ static DBusMessage *pri_set_property(DBusConnection *conn,
|
||||||
if (ctx->gprs->flags & GPRS_FLAG_ATTACHING)
|
if (ctx->gprs->flags & GPRS_FLAG_ATTACHING)
|
||||||
return __ofono_error_attach_in_progress(msg);
|
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);
|
return __ofono_error_not_implemented(msg);
|
||||||
|
|
||||||
gc = ctx->context_driver;
|
gc = ctx->context_driver;
|
||||||
|
|
Loading…
Reference in New Issue