use libosmocore osmo_tdef

Move the T_defs API to libosmocore as osmo_tdefs: remove the local T_defs API
and use libosmocore's osmo_tdef* API instead.

The root reason is moving the mgw_endpoint_fsm to libosmo-mgcp-client to be
able to use it in osmo-msc for inter-MSC handover.

When adding osmo_tdef, the new concept of timer groups was added to the API. It
would make sense to apply group names here as well, but do not modify the VTY
configuration for timers. The future might bring separate groups (or not).

Depends: Ibd6b1ed7f1bd6e1f2e0fde53352055a4468f23e5 (libosmocore)
Change-Id: I66674a5d8403d820038762888c846bae10ceac58
diff --git a/include/osmocom/bsc/Makefile.am b/include/osmocom/bsc/Makefile.am
index 044fdc9..21e53d7 100644
--- a/include/osmocom/bsc/Makefile.am
+++ b/include/osmocom/bsc/Makefile.am
@@ -20,7 +20,6 @@
 	gsm_04_08_rr.h \
 	gsm_04_80.h \
 	gsm_data.h \
-	gsm_timers.h \
 	handover.h \
 	handover_cfg.h \
 	handover_decision.h \
diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index dc133e1..7b813a6 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -17,6 +17,7 @@
 #include <osmocom/gsm/gsm0808.h>
 #include <osmocom/gsm/gsm48.h>
 #include <osmocom/core/fsm.h>
+#include <osmocom/core/tdef.h>
 
 #include <osmocom/crypt/auth.h>
 
@@ -31,7 +32,6 @@
 #include <osmocom/bsc/meas_rep.h>
 #include <osmocom/bsc/bsc_msg_filter.h>
 #include <osmocom/bsc/acc_ramp.h>
-#include <osmocom/bsc/gsm_timers.h>
 #include <osmocom/bsc/neighbor_ident.h>
 
 #define GSM_T3122_DEFAULT 10
@@ -1495,7 +1495,7 @@
 	struct llist_head bts_rejected;
 
 	/* shall reference gsm_network_T[] */
-	struct T_def *T_defs;
+	struct osmo_tdef *T_defs;
 
 	enum gsm_chan_t ctype_by_chreq[_NUM_CHREQ_T];
 
diff --git a/include/osmocom/bsc/gsm_timers.h b/include/osmocom/bsc/gsm_timers.h
deleted file mode 100644
index 699c461..0000000
--- a/include/osmocom/bsc/gsm_timers.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* API to define Tnnn timers globally, configure in VTY and use for FSM state changes. */
-#pragma once
-
-#include <stdint.h>
-#include <osmocom/core/utils.h>
-
-struct osmo_fsm_inst;
-struct vty;
-
-enum T_unit {
-	T_S = 0,	/*< most T are in seconds, keep 0 as default. */
-	T_MS,		/*< milliseconds */
-	T_M,		/*< minutes */
-	T_CUSTOM,
-};
-
-extern const struct value_string T_unit_names[];
-static inline const char *T_unit_name(enum T_unit val)
-{ return get_value_string(T_unit_names, val); }
-
-/* Define a GSM timer of the form Tnnn, with unit, default value and doc string. */
-struct T_def {
-	const int T; /*< T1234 number */
-	const int default_val; /*< timeout duration (according to unit), default value. */
-	const enum T_unit unit;
-	const char *desc;
-	int val; /*< currently active value, e.g. set by user config. */
-};
-
-/* Iterate an array of struct T_def, the last item should be fully zero, i.e. "{}" */
-#define for_each_T_def(d, T_defs) \
-	for (d = T_defs; d && (d->T || d->default_val || d->desc); d++)
-
-int T_def_get(const struct T_def *T_defs, int T, enum T_unit as_unit, int val_if_not_present);
-void T_defs_reset(struct T_def *T_defs);
-struct T_def *T_def_get_entry(struct T_def *T_defs, int T);
-
-void T_defs_vty_init(struct T_def *T_defs, int cfg_parent_node);
-void T_defs_vty_write(struct vty *vty, const char *indent);
-struct T_def *parse_T_arg(struct vty *vty, const char *T_str);
-
-struct state_timeout {
-	int T;
-	bool keep_timer;
-};
-
-const struct state_timeout *get_state_timeout(uint32_t state,
-					      const struct state_timeout *timeouts_array);
-
-#define fsm_inst_state_chg_T(fi, state, timeouts_array, T_defs, default_timeout) \
-	_fsm_inst_state_chg_T(fi, state, timeouts_array, T_defs, default_timeout, \
-			      __FILE__, __LINE__)
-int _fsm_inst_state_chg_T(struct osmo_fsm_inst *fi, uint32_t state,
-			  const struct state_timeout *timeouts_array,
-			  const struct T_def *T_defs, int default_timeout,
-			  const char *file, int line);
diff --git a/include/osmocom/bsc/mgw_endpoint_fsm.h b/include/osmocom/bsc/mgw_endpoint_fsm.h
index e264a3c..f86a7cd 100644
--- a/include/osmocom/bsc/mgw_endpoint_fsm.h
+++ b/include/osmocom/bsc/mgw_endpoint_fsm.h
@@ -24,9 +24,9 @@
 
 struct mgw_endpoint;
 struct mgwep_ci;
-struct T_def;
+struct osmo_tdef;
 
-void mgw_endpoint_fsm_init(struct T_def *T_defs);
+void mgw_endpoint_fsm_init(struct osmo_tdef *T_defs);
 
 struct mgw_endpoint *mgw_endpoint_alloc(struct osmo_fsm_inst *parent, uint32_t parent_term_event,
 					struct mgcp_client *mgcp_client,