This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
pespin gerrit-no-reply at lists.osmocom.orgpespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/15418
Change subject: tdef: Introduce API osmo_tdef_set()
......................................................................
tdef: Introduce API osmo_tdef_set()
This API is already useful for users willing to set a given timer to a
given value. It will also contain code later that checks for value being
inside valid range for that timer.
Related: OS#4190
Change-Id: Id56a1226d724a374f04231df85fe5b49ffd2c43c
---
M include/osmocom/core/tdef.h
M src/tdef.c
2 files changed, 20 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/18/15418/1
diff --git a/include/osmocom/core/tdef.h b/include/osmocom/core/tdef.h
index 566f5dd..ae4f646 100644
--- a/include/osmocom/core/tdef.h
+++ b/include/osmocom/core/tdef.h
@@ -97,6 +97,7 @@
unsigned long osmo_tdef_get(const struct osmo_tdef *tdefs, int T, enum osmo_tdef_unit as_unit,
long val_if_not_present);
struct osmo_tdef *osmo_tdef_get_entry(struct osmo_tdef *tdefs, int T);
+int osmo_tdef_set(struct osmo_tdef *tdefs, int T, unsigned long val);
/*! Using osmo_tdef for osmo_fsm_inst: array entry for a mapping of state numbers to timeout definitions.
* For a usage example, see osmo_tdef_get_state_timeout() and test_tdef_state_timeout() in tdef_test.c. */
diff --git a/src/tdef.c b/src/tdef.c
index 40a9900..315a208 100644
--- a/src/tdef.c
+++ b/src/tdef.c
@@ -25,6 +25,7 @@
*/
#include <limits.h>
+#include <errno.h>
#include <osmocom/core/fsm.h>
#include <osmocom/core/tdef.h>
@@ -210,6 +211,24 @@
return NULL;
}
+/*! Set value in entry matching T.
+ * \param[in] tdefs Array of timer definitions, last entry being fully zero.
+ * \param[in] T Timer number to set the value for.
+ * \param[in] val The new timer value to set.
+ * \return 0 on success, negative on error.
+ */
+int osmo_tdef_set(struct osmo_tdef *tdefs, int T, unsigned long val)
+{
+ struct osmo_tdef *t;
+ osmo_tdef_for_each(t, tdefs) {
+ if (t->T == T) {
+ t->val = val;
+ return 0;
+ }
+ }
+ return -EEXIST;
+}
+
/*! Using osmo_tdef for osmo_fsm_inst: find a given state's osmo_tdef_state_timeout entry.
*
* The timeouts_array shall contain exactly 32 elements, regardless whether only some of them are actually populated
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/15418
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id56a1226d724a374f04231df85fe5b49ffd2c43c
Gerrit-Change-Number: 15418
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190905/bdec65b2/attachment.htm>