aboutsummaryrefslogtreecommitdiffstats
path: root/src/gsm_timer.h
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-06-14 20:48:19 +0800
committerHarald Welte <laforge@gnumonks.org>2012-06-14 20:48:42 +0800
commitc5187a1824b61add1cd216ef5c432d8abaab1222 (patch)
treec197bc24e9eae4f8d66a8c65d5102be9aca6b4ef /src/gsm_timer.h
parent634771173648acd39c44280e673563a53381b2f7 (diff)
move everything to src/ subdirectory
The code corresponds to commit a9aa4777cc1144897a77dfb6c5c3d7325705251e in openbts-p2.8.git (Tue Jun 12 18:14:49 2012 +0400)
Diffstat (limited to 'src/gsm_timer.h')
-rw-r--r--src/gsm_timer.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/gsm_timer.h b/src/gsm_timer.h
new file mode 100644
index 00000000..fc42cafe
--- /dev/null
+++ b/src/gsm_timer.h
@@ -0,0 +1,84 @@
+/* gsm_timer.h
+ *
+ * Copyright (C) 2012 Ivan Klyuchnikov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/*! \defgroup timer GSM timers
+ * @{
+ */
+
+/*! \file gsm_timer.h
+ * \brief GSM timer handling routines
+ */
+#ifndef GSM_TIMER_H
+#define GSM_TIMER_H
+
+extern "C" {
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/linuxrbtree.h>
+}
+/**
+ * Timer management:
+ * - Create a struct osmo_gsm_timer_list
+ * - Fill out timeout and use add_gsm_timer or
+ * use schedule_gsm_timer to schedule a timer in
+ * x frames from now...
+ * - Use del_gsm_timer to remove the timer
+ *
+ * Internally:
+ * - We hook into select.c to give a frame number of the
+ * nearest timer. On already passed timers we give
+ * it a 0 to immediately fire after the select.
+ * - update_gsm_timers will call the callbacks and remove
+ * the timers.
+ *
+ */
+/*! \brief A structure representing a single instance of a gsm timer */
+struct osmo_gsm_timer_list {
+ struct rb_node node; /*!< \brief rb-tree node header */
+ struct llist_head list; /*!< \brief internal list header */
+ int fn; /*!< \brief expiration frame number */
+ unsigned int active : 1; /*!< \brief is it active? */
+
+ void (*cb)(void*); /*!< \brief call-back called at timeout */
+ void *data; /*!< \brief user data for callback */
+};
+
+/**
+ * timer management
+ */
+
+void osmo_gsm_timer_add(struct osmo_gsm_timer_list *timer);
+
+void osmo_gsm_timer_schedule(struct osmo_gsm_timer_list *timer, int fn);
+
+void osmo_gsm_timer_del(struct osmo_gsm_timer_list *timer);
+
+int osmo_gsm_timer_pending(struct osmo_gsm_timer_list *timer);
+
+
+/*
+ * internal timer list management
+ */
+int *osmo_gsm_timers_nearest(void);
+void osmo_gsm_timers_prepare(void);
+int osmo_gsm_timers_update(void);
+int osmo_gsm_timers_check(void);
+
+/*! }@ */
+
+#endif // GSM_TIMER_H