aboutsummaryrefslogtreecommitdiffstats
path: root/include/osmocom
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-02-12 16:45:39 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-16 16:11:16 +0100
commitcbdfb78f7bf156f9df020d3a5096f591752cd981 (patch)
tree692014d54b4b57bbc0f544a09a863cd9200bd1c5 /include/osmocom
parentcbc999cb93ce5cf5fcc4e169ef3db7f1ef074c5d (diff)
HO: move penalty timers to own file as proper API
Separate penalty timers API from specific struct members and move to own .h/.c file, so that future code may re-use the API arbitrarily. Change-Id: Ife975a1c7c17a500b1693be620475a8bea72f86f
Diffstat (limited to 'include/osmocom')
-rw-r--r--include/osmocom/bsc/Makefile.am1
-rw-r--r--include/osmocom/bsc/gsm_data.h10
-rw-r--r--include/osmocom/bsc/penalty_timers.h36
3 files changed, 38 insertions, 9 deletions
diff --git a/include/osmocom/bsc/Makefile.am b/include/osmocom/bsc/Makefile.am
index b99607042..924711999 100644
--- a/include/osmocom/bsc/Makefile.am
+++ b/include/osmocom/bsc/Makefile.am
@@ -49,4 +49,5 @@ noinst_HEADERS = \
ussd.h \
vty.h \
bsc_api.h \
+ penalty_timers.h \
$(NULL)
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 3da4fff6f..b8f8f81f8 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -79,13 +79,6 @@ struct gsm_classmark {
uint8_t classmark3[14]; /* if cm3 gets extended by spec, it will be truncated */
};
-/* penalty timers for handover */
-struct ho_penalty_timer {
- struct llist_head entry;
- uint8_t bts;
- time_t timeout;
-};
-
/* active radio connection of a mobile subscriber */
struct gsm_subscriber_connection {
/* global linked list of subscriber_connections */
@@ -117,8 +110,7 @@ struct gsm_subscriber_connection {
struct llist_head ho_dtap_cache;
unsigned int ho_dtap_cache_len;
- /* penalty timers for handover */
- struct llist_head ho_penalty_timers;
+ struct penalty_timers *ho_penalty_timers;
};
diff --git a/include/osmocom/bsc/penalty_timers.h b/include/osmocom/bsc/penalty_timers.h
new file mode 100644
index 000000000..4b1dcce55
--- /dev/null
+++ b/include/osmocom/bsc/penalty_timers.h
@@ -0,0 +1,36 @@
+/* Manage a list of penalty timers per BTS;
+ * initially used by handover algorithm 2 to keep per-BTS timers for each subscriber connection. */
+#pragma once
+
+/* Opaque struct to manage penalty timers */
+struct penalty_timers;
+
+/* Initialize a list of penalty timers.
+ * param ctx: talloc context to allocate in.
+ * returns an empty struct penalty_timers. */
+struct penalty_timers *penalty_timers_init(void *ctx);
+
+/* Add a penalty timer for a BTS.
+ * param pt: penalty timers list as from penalty_timers_init().
+ * param for_object: arbitrary pointer reference to store a penalty timer for (passing NULL is possible,
+ * but note that penalty_timers_clear() will clear all timers if given for_object=NULL).
+ * param timeout: penalty time in seconds. */
+void penalty_timers_add(struct penalty_timers *pt, void *for_object, int timeout);
+
+/* Return the amount of penalty time remaining for a BTS.
+ * param pt: penalty timers list as from penalty_timers_init().
+ * param for_object: arbitrary pointer reference to query penalty timers for.
+ * returns seconds remaining until all penalty time has expired. */
+unsigned int penalty_timers_remaining(struct penalty_timers *pt, void *for_object);
+
+/* Clear penalty timers for one or all BTS.
+ * param pt: penalty timers list as from penalty_timers_init().
+ * param for_object: arbitrary pointer reference to clear penalty time for,
+ * or NULL to clear all timers. */
+void penalty_timers_clear(struct penalty_timers *pt, void *for_object);
+
+/* Free a struct as returned from penalty_timers_init().
+ * Clear all timers from the list, deallocate the list and set the pointer to NULL.
+ * param pt: pointer-to-pointer which references a struct penalty_timers as returned by
+ * penalty_timers_init(); *pt_p will be set to NULL. */
+void penalty_timers_free(struct penalty_timers **pt_p);