From 0cbe8f01003ca71209c12eacac3abaeb9a7df862 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 17 Sep 2019 13:13:52 +0200 Subject: tdef: Introduce min_val and max_val fields This is useful for timers expected to have a range of valid or expected values. Validation is done at runtime when timer values are set by the app or by the user through the VTY. Related: OS#4190 Change-Id: I4661ac41c29a009a1d5fc57d87aaee6041c7d1b2 --- include/osmocom/core/tdef.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/osmocom') diff --git a/include/osmocom/core/tdef.h b/include/osmocom/core/tdef.h index 81556883..54819d95 100644 --- a/include/osmocom/core/tdef.h +++ b/include/osmocom/core/tdef.h @@ -77,6 +77,10 @@ struct osmo_tdef { /*! Currently active timeout value, e.g. set by user config. This is the only mutable member: a user may * configure the timeout value, but neither unit nor any other field. */ unsigned long val; + /*! Minimum timer value (in this tdef unit), checked if set (not zero). */ + unsigned long min_val; + /*! Maximum timer value (in this tdef unit), checked if set (not zero). */ + unsigned long max_val; }; /*! Iterate an array of struct osmo_tdef, the last item should be fully zero, i.e. "{}". @@ -98,6 +102,8 @@ unsigned long osmo_tdef_get(const struct osmo_tdef *tdefs, int T, enum osmo_tdef 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, enum osmo_tdef_unit val_unit); +bool osmo_tdef_val_in_range(struct osmo_tdef *tdef, unsigned long new_val); +int osmo_tdef_range_str_buf(char *buf, size_t buf_len, struct osmo_tdef *t); /*! 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. */ -- cgit v1.2.3