summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src/mobile/primitives.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-11-16 08:17:34 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-12-03 12:58:52 +0000
commit88060f462cde2e3e6f4fc3cbf9c3708083e27dac (patch)
tree7401789e15255950ad7b73287384c2b08cad452e /src/host/layer23/src/mobile/primitives.c
parenta8726d977a67459e7bf314b4b69283f65e45cbf0 (diff)
mobile: Directly inform the primitive layer about an event
Forward started/shutdown changes to the primitive layer which will turn them into indications. The other option might be to use the signals but it seems primitives are a superset of the signals. The notify will be done per MS and then the right primitive instance will be searched and the indication be sent. The approach will be applied to other systems as well. The signal framework might be seen as a subset of the primitives A signal mostly being a different form of an indication. Change-Id: I5df20a4ab79c06b515780675b6df2929aa976f0d
Diffstat (limited to 'src/host/layer23/src/mobile/primitives.c')
-rw-r--r--src/host/layer23/src/mobile/primitives.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/host/layer23/src/mobile/primitives.c b/src/host/layer23/src/mobile/primitives.c
index efa7f3ff..dde34bcc 100644
--- a/src/host/layer23/src/mobile/primitives.c
+++ b/src/host/layer23/src/mobile/primitives.c
@@ -24,6 +24,8 @@
#include <osmocom/core/timer.h>
#include <osmocom/core/talloc.h>
+static LLIST_HEAD(s_prims);
+
struct timer_closure {
struct llist_head entry;
struct mobile_prim_intf *intf;
@@ -39,6 +41,7 @@ struct mobile_prim_intf *mobile_prim_intf_alloc(struct osmocom_ms *ms)
intf->ms = ms;
INIT_LLIST_HEAD(&intf->timers);
+ llist_add_tail(&intf->entry, &s_prims);
return intf;
}
@@ -51,6 +54,7 @@ void mobile_prim_intf_free(struct mobile_prim_intf *intf)
llist_del(&timer->entry);
talloc_free(timer);
}
+ llist_del(&intf->entry);
talloc_free(intf);
}
@@ -95,6 +99,33 @@ static int create_timer(struct mobile_prim_intf *intf, struct mobile_timer_param
return 0;
}
+static void dispatch(struct osmocom_ms *ms, struct mobile_prim *prim)
+{
+ struct mobile_prim_intf *intf, *tmp;
+
+ llist_for_each_entry_safe(intf, tmp, &s_prims, entry) {
+ if (intf->ms == ms)
+ intf->indication(intf, prim);
+ }
+}
+
+void mobile_prim_ntfy_started(struct osmocom_ms *ms, bool started)
+{
+ struct mobile_prim *prim = mobile_prim_alloc(PRIM_MOB_STARTED, PRIM_OP_INDICATION);
+
+ prim->u.started.started = started;
+ dispatch(ms, prim);
+}
+
+void mobile_prim_ntfy_shutdown(struct osmocom_ms *ms, int old_state, int new_state)
+{
+ struct mobile_prim *prim = mobile_prim_alloc(PRIM_MOB_SHUTDOWN, PRIM_OP_INDICATION);
+
+ prim->u.shutdown.old_state = old_state;
+ prim->u.shutdown.new_state = new_state;
+ dispatch(ms, prim);
+}
+
static int cancel_timer(struct mobile_prim_intf *intf, struct mobile_timer_param *param)
{
struct timer_closure *closure;