<p>Neels Hofmeyr has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/9670">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">add gsm_timers, for Tnnn definitions usable by FSMs<br><br>This reverts commit c0990acd03807631fb426ca0123d9fc402e97ca1.<br><br>Change-Id: If212fcd042051b6fa53484254223614c5b93a9c6<br>---<br>M include/osmocom/bsc/Makefile.am<br>M include/osmocom/bsc/gsm_data.h<br>A include/osmocom/bsc/gsm_timers.h<br>M src/ipaccess/Makefile.am<br>M src/osmo-bsc/Makefile.am<br>M src/osmo-bsc/abis_om2000.c<br>M src/osmo-bsc/abis_rsl.c<br>M src/osmo-bsc/bsc_subscr_conn_fsm.c<br>M src/osmo-bsc/bsc_vty.c<br>M src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c<br>M src/osmo-bsc/bts_siemens_bs11.c<br>M src/osmo-bsc/gsm_data.c<br>A src/osmo-bsc/gsm_timers.c<br>A src/osmo-bsc/gsm_timers_vty.c<br>M src/osmo-bsc/net_init.c<br>M src/osmo-bsc/paging.c<br>M src/utils/Makefile.am<br>M tests/abis/Makefile.am<br>M tests/bsc/Makefile.am<br>M tests/gsm0408/Makefile.am<br>M tests/handover/Makefile.am<br>M tests/nanobts_omlattr/Makefile.am<br>M tests/nanobts_omlattr/nanobts_omlattr_test.c<br>23 files changed, 513 insertions(+), 180 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/70/9670/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/osmocom/bsc/Makefile.am b/include/osmocom/bsc/Makefile.am</span><br><span>index 18737a3..82a2e26 100644</span><br><span>--- a/include/osmocom/bsc/Makefile.am</span><br><span>+++ b/include/osmocom/bsc/Makefile.am</span><br><span>@@ -18,6 +18,7 @@</span><br><span> gsm_04_08_utils.h \</span><br><span> gsm_04_80.h \</span><br><span> gsm_data.h \</span><br><span style="color: hsl(120, 100%, 40%);">+ gsm_timers.h \</span><br><span> handover.h \</span><br><span> handover_cfg.h \</span><br><span> handover_decision.h \</span><br><span>diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h</span><br><span>index 6ee95f7..ce7a8fe 100644</span><br><span>--- a/include/osmocom/bsc/gsm_data.h</span><br><span>+++ b/include/osmocom/bsc/gsm_data.h</span><br><span>@@ -32,6 +32,8 @@</span><br><span> #include <osmocom/bsc/bsc_msg_filter.h></span><br><span> #include <osmocom/bsc/acc_ramp.h></span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+#define GSM_T3122_DEFAULT 10</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> struct mgcp_client_conf;</span><br><span> struct mgcp_client;</span><br><span> struct mgcp_ctx;</span><br><span>@@ -1189,23 +1191,6 @@</span><br><span> bsc_ctr_description,</span><br><span> };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T3101_DEFAULT 3 /* s */</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T3103_DEFAULT 5 /* s */</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T3105_DEFAULT 100 /* ms */</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T3107_DEFAULT 5 /* s */</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T3109_DEFAULT 5 /* s, must be 2s + radio_link_timeout*0.48 */</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T3111_DEFAULT 2 /* s */</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T3113_DEFAULT 10 /* s */</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T3115_DEFAULT 10</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T3117_DEFAULT 10</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T3119_DEFAULT 10</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T3122_DEFAULT 10</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T3141_DEFAULT 10</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T10_DEFAULT 6 /* RR Assignment timeout, in seconds */</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T7_DEFAULT 10 /* inter-BSC MO Handover first timeout, in seconds */</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T8_DEFAULT 10 /* inter-BSC MO Handover second timeout, in seconds */</span><br><span style="color: hsl(0, 100%, 40%);">-#define GSM_T101_DEFAULT 10 /* inter-BSC MT Handover timeout, in seconds */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> struct gsm_tz {</span><br><span> int override; /* if 0, use system's time zone instead. */</span><br><span> int hr; /* hour */</span><br><span>@@ -1237,23 +1222,8 @@</span><br><span> unsigned int num_bts;</span><br><span> struct llist_head bts_list;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* timer values */</span><br><span style="color: hsl(0, 100%, 40%);">- int T3101;</span><br><span style="color: hsl(0, 100%, 40%);">- int T3103; /*< Handover timeout */</span><br><span style="color: hsl(0, 100%, 40%);">- int T3105;</span><br><span style="color: hsl(0, 100%, 40%);">- int T3107;</span><br><span style="color: hsl(0, 100%, 40%);">- int T3109;</span><br><span style="color: hsl(0, 100%, 40%);">- int T3111;</span><br><span style="color: hsl(0, 100%, 40%);">- int T3113;</span><br><span style="color: hsl(0, 100%, 40%);">- int T3115;</span><br><span style="color: hsl(0, 100%, 40%);">- int T3117;</span><br><span style="color: hsl(0, 100%, 40%);">- int T3119;</span><br><span style="color: hsl(0, 100%, 40%);">- int T3122;</span><br><span style="color: hsl(0, 100%, 40%);">- int T3141;</span><br><span style="color: hsl(0, 100%, 40%);">- int T10; /*< RR Assignment timeout, in seconds */</span><br><span style="color: hsl(0, 100%, 40%);">- int T7; /*< inter-BSC handover MO timeout from Handover Required to Handover Command */</span><br><span style="color: hsl(0, 100%, 40%);">- int T8; /*< inter-BSC handover MO timeout from Handover Command to final Clear*/</span><br><span style="color: hsl(0, 100%, 40%);">- int T101; /*< inter-BSC handover MT timeout from Handover Request to Handover Accept */</span><br><span style="color: hsl(120, 100%, 40%);">+ /* shall reference gsm_network_T[] */</span><br><span style="color: hsl(120, 100%, 40%);">+ struct T_def *T_defs;</span><br><span> </span><br><span> enum gsm_chan_t ctype_by_chreq[_NUM_CHREQ_T];</span><br><span> </span><br><span>@@ -1287,9 +1257,6 @@</span><br><span> * pointer is NULL to indicate absence of a bsc_subscribers list. */</span><br><span> struct llist_head *bsc_subscribers;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* Periodic location update default value */</span><br><span style="color: hsl(0, 100%, 40%);">- uint8_t t3212;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /* Timer for periodic channel load measurements to maintain each BTS's T3122. */</span><br><span> struct osmo_timer_list t3122_chan_load_timer;</span><br><span> </span><br><span>diff --git a/include/osmocom/bsc/gsm_timers.h b/include/osmocom/bsc/gsm_timers.h</span><br><span>new file mode 100644</span><br><span>index 0000000..fde8c93</span><br><span>--- /dev/null</span><br><span>+++ b/include/osmocom/bsc/gsm_timers.h</span><br><span>@@ -0,0 +1,55 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* API to define Tnnn timers globally, configure in VTY and use for FSM state changes. */</span><br><span style="color: hsl(120, 100%, 40%);">+#pragma once</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <stdint.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/utils.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct osmo_fsm_inst;</span><br><span style="color: hsl(120, 100%, 40%);">+struct vty;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+enum T_unit {</span><br><span style="color: hsl(120, 100%, 40%);">+ T_S = 0, /*< most T are in seconds, keep 0 as default. */</span><br><span style="color: hsl(120, 100%, 40%);">+ T_MS, /*< milliseconds */</span><br><span style="color: hsl(120, 100%, 40%);">+ T_M, /*< minutes */</span><br><span style="color: hsl(120, 100%, 40%);">+ T_CUSTOM,</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+extern const struct value_string T_unit_names[];</span><br><span style="color: hsl(120, 100%, 40%);">+static inline const char *T_unit_name(enum T_unit val)</span><br><span style="color: hsl(120, 100%, 40%);">+{ return get_value_string(T_unit_names, val); }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Define a GSM timer of the form Tnnn, with unit, default value and doc string. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct T_def {</span><br><span style="color: hsl(120, 100%, 40%);">+ const int T; /*< T1234 number */</span><br><span style="color: hsl(120, 100%, 40%);">+ const int default_val; /*< timeout duration (according to unit), default value. */</span><br><span style="color: hsl(120, 100%, 40%);">+ const enum T_unit unit;</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *desc;</span><br><span style="color: hsl(120, 100%, 40%);">+ int val; /*< currently active value, e.g. set by user config. */</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Iterate an array of struct T_def, the last item should be fully zero, i.e. "{}" */</span><br><span style="color: hsl(120, 100%, 40%);">+#define for_each_T_def(d, T_defs) \</span><br><span style="color: hsl(120, 100%, 40%);">+ for (d = T_defs; d && (d->T || d->default_val || d->desc); d++)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+int T_def_get(struct T_def *T_defs, int T, enum T_unit as_unit, int val_if_not_present);</span><br><span style="color: hsl(120, 100%, 40%);">+void T_defs_reset(struct T_def *T_defs);</span><br><span style="color: hsl(120, 100%, 40%);">+struct T_def *T_def_get_entry(struct T_def *T_defs, int T);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void T_defs_vty_init(struct T_def *T_defs, int cfg_parent_node);</span><br><span style="color: hsl(120, 100%, 40%);">+void T_defs_vty_write(struct vty *vty, const char *indent);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct state_timeout {</span><br><span style="color: hsl(120, 100%, 40%);">+ int T;</span><br><span style="color: hsl(120, 100%, 40%);">+ bool keep_timer;</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+struct state_timeout *get_state_timeout(uint32_t state, struct state_timeout *timeouts_array);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define fsm_inst_state_chg_T(fi, state, timeouts_array, T_defs, default_timeout) \</span><br><span style="color: hsl(120, 100%, 40%);">+ _fsm_inst_state_chg_T(fi, state, timeouts_array, T_defs, default_timeout, \</span><br><span style="color: hsl(120, 100%, 40%);">+ __FILE__, __LINE__)</span><br><span style="color: hsl(120, 100%, 40%);">+int _fsm_inst_state_chg_T(struct osmo_fsm_inst *fi, uint32_t state,</span><br><span style="color: hsl(120, 100%, 40%);">+ struct state_timeout *timeouts_array,</span><br><span style="color: hsl(120, 100%, 40%);">+ struct T_def *T_defs, int default_timeout,</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *file, int line);</span><br><span>diff --git a/src/ipaccess/Makefile.am b/src/ipaccess/Makefile.am</span><br><span>index 2c6282d..ec3e027 100644</span><br><span>--- a/src/ipaccess/Makefile.am</span><br><span>+++ b/src/ipaccess/Makefile.am</span><br><span>@@ -55,6 +55,7 @@</span><br><span> $(top_builddir)/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.o \</span><br><span> $(top_builddir)/src/osmo-bsc/gsm_data.o \</span><br><span> $(top_builddir)/src/osmo-bsc/net_init.o \</span><br><span style="color: hsl(120, 100%, 40%);">+ $(top_builddir)/src/osmo-bsc/gsm_timers.o \</span><br><span> $(OSMO_LIBS) \</span><br><span> $(NULL)</span><br><span> </span><br><span>@@ -65,5 +66,6 @@</span><br><span> $(NULL)</span><br><span> </span><br><span> ipaccess_proxy_LDADD = \</span><br><span style="color: hsl(120, 100%, 40%);">+ $(top_builddir)/src/osmo-bsc/gsm_timers.o \</span><br><span> $(OSMO_LIBS) \</span><br><span> $(NULL)</span><br><span>diff --git a/src/osmo-bsc/Makefile.am b/src/osmo-bsc/Makefile.am</span><br><span>index afae0b6..86d943f 100644</span><br><span>--- a/src/osmo-bsc/Makefile.am</span><br><span>+++ b/src/osmo-bsc/Makefile.am</span><br><span>@@ -57,6 +57,8 @@</span><br><span> gsm_04_08_utils.c \</span><br><span> gsm_04_80_utils.c \</span><br><span> gsm_data.c \</span><br><span style="color: hsl(120, 100%, 40%);">+ gsm_timers.c \</span><br><span style="color: hsl(120, 100%, 40%);">+ gsm_timers_vty.c \</span><br><span> handover_cfg.c \</span><br><span> handover_decision.c \</span><br><span> handover_decision_2.c \</span><br><span>diff --git a/src/osmo-bsc/abis_om2000.c b/src/osmo-bsc/abis_om2000.c</span><br><span>index d533ea1..2934590 100644</span><br><span>--- a/src/osmo-bsc/abis_om2000.c</span><br><span>+++ b/src/osmo-bsc/abis_om2000.c</span><br><span>@@ -42,6 +42,7 @@</span><br><span> #include <osmocom/bsc/abis_rsl.h></span><br><span> #include <osmocom/bsc/abis_om2000.h></span><br><span> #include <osmocom/bsc/signal.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_timers.h></span><br><span> #include <osmocom/abis/e1_input.h></span><br><span> </span><br><span> /* FIXME: move to libosmocore */</span><br><span>@@ -1382,7 +1383,8 @@</span><br><span> msgb_tv_put(msg, OM2K_DEI_CCCH_OPTIONS, 0x01);</span><br><span> break;</span><br><span> case GSM_PCHAN_CCCH_SDCCH4:</span><br><span style="color: hsl(0, 100%, 40%);">- msgb_tv_put(msg, OM2K_DEI_T3105, ts->trx->bts->network->T3105 / 10);</span><br><span style="color: hsl(120, 100%, 40%);">+ msgb_tv_put(msg, OM2K_DEI_T3105,</span><br><span style="color: hsl(120, 100%, 40%);">+ T_def_get(ts->trx->bts->network->T_defs, 3105, T_MS, -1) / 10);</span><br><span> msgb_tv_put(msg, OM2K_DEI_NY1, 35);</span><br><span> msgb_tv_put(msg, OM2K_DEI_BA_PA_MFRMS, 0x06);</span><br><span> msgb_tv_put(msg, OM2K_DEI_CBCH_INDICATOR, 0);</span><br><span>@@ -1396,7 +1398,8 @@</span><br><span> sizeof(icm_bound_params), icm_bound_params);</span><br><span> break;</span><br><span> case GSM_PCHAN_SDCCH8_SACCH8C:</span><br><span style="color: hsl(0, 100%, 40%);">- msgb_tv_put(msg, OM2K_DEI_T3105, ts->trx->bts->network->T3105 / 10);</span><br><span style="color: hsl(120, 100%, 40%);">+ msgb_tv_put(msg, OM2K_DEI_T3105,</span><br><span style="color: hsl(120, 100%, 40%);">+ T_def_get(ts->trx->bts->network->T_defs, 3105, T_MS, -1) / 10);</span><br><span> msgb_tv_put(msg, OM2K_DEI_NY1, 35);</span><br><span> msgb_tv_put(msg, OM2K_DEI_CBCH_INDICATOR, 0);</span><br><span> msgb_tv_put(msg, OM2K_DEI_TSC, gsm_ts_tsc(ts));</span><br><span>@@ -1406,7 +1409,8 @@</span><br><span> sizeof(icm_bound_params), icm_bound_params);</span><br><span> break;</span><br><span> default:</span><br><span style="color: hsl(0, 100%, 40%);">- msgb_tv_put(msg, OM2K_DEI_T3105, ts->trx->bts->network->T3105 / 10);</span><br><span style="color: hsl(120, 100%, 40%);">+ msgb_tv_put(msg, OM2K_DEI_T3105,</span><br><span style="color: hsl(120, 100%, 40%);">+ T_def_get(ts->trx->bts->network->T_defs, 3105, T_MS, -1) / 10);</span><br><span> msgb_tv_put(msg, OM2K_DEI_NY1, 35);</span><br><span> msgb_tv_put(msg, OM2K_DEI_TSC, gsm_ts_tsc(ts));</span><br><span> /* Disable RF RESOURCE INDICATION on idle channels */</span><br><span>diff --git a/src/osmo-bsc/abis_rsl.c b/src/osmo-bsc/abis_rsl.c</span><br><span>index b6741a8..756a689 100644</span><br><span>--- a/src/osmo-bsc/abis_rsl.c</span><br><span>+++ b/src/osmo-bsc/abis_rsl.c</span><br><span>@@ -46,6 +46,7 @@</span><br><span> #include <osmocom/bsc/pcu_if.h></span><br><span> #include <osmocom/bsc/bsc_api.h></span><br><span> #include <osmocom/bsc/bsc_subscr_conn_fsm.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_timers.h></span><br><span> </span><br><span> #define RSL_ALLOC_SIZE 1024</span><br><span> #define RSL_ALLOC_HEADROOM 128</span><br><span>@@ -81,7 +82,9 @@</span><br><span> if (lchan->state == LCHAN_S_REL_ERR) {</span><br><span> osmo_timer_setup(&lchan->error_timer, error_timeout_cb, lchan);</span><br><span> osmo_timer_schedule(&lchan->error_timer,</span><br><span style="color: hsl(0, 100%, 40%);">- lchan->ts->trx->bts->network->T3111 + 2, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ T_def_get(lchan->ts->trx->bts->network->T_defs,</span><br><span style="color: hsl(120, 100%, 40%);">+ 993111, T_S, -1),</span><br><span style="color: hsl(120, 100%, 40%);">+ 0);</span><br><span> } else {</span><br><span> rsl_lchan_set_state(lchan, LCHAN_S_NONE);</span><br><span> }</span><br><span>@@ -1915,11 +1918,10 @@</span><br><span> LOGP(DRSL, LOGL_NOTICE, "(bts=%d) CHAN RQD: no resources for %s 0x%x\n",</span><br><span> msg->lchan->ts->trx->bts->nr, gsm_lchant_name(lctype), rqd_ref->ra);</span><br><span> rate_ctr_inc(&bts->bts_ctrs->ctr[BTS_CTR_CHREQ_NO_CHANNEL]);</span><br><span style="color: hsl(0, 100%, 40%);">- if (bts->T3122)</span><br><span style="color: hsl(0, 100%, 40%);">- wait_ind = bts->T3122;</span><br><span style="color: hsl(0, 100%, 40%);">- else if (bts->network->T3122)</span><br><span style="color: hsl(0, 100%, 40%);">- wait_ind = bts->network->T3122 & 0xff;</span><br><span style="color: hsl(0, 100%, 40%);">- else</span><br><span style="color: hsl(120, 100%, 40%);">+ wait_ind = bts->T3122;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!wait_ind)</span><br><span style="color: hsl(120, 100%, 40%);">+ wait_ind = T_def_get(bts->network->T_defs, 3122, T_S, -1);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!wait_ind)</span><br><span> wait_ind = GSM_T3122_DEFAULT;</span><br><span> /* The BTS will gather multiple CHAN RQD and reject up to 4 MS at the same time. */</span><br><span> rsl_send_imm_ass_rej(bts, rqd_ref, wait_ind);</span><br><span>@@ -2001,7 +2003,7 @@</span><br><span> </span><br><span> /* Start timer T3101 to wait for GSM48_MT_RR_PAG_RESP */</span><br><span> osmo_timer_setup(&lchan->T3101, t3101_expired, lchan);</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_timer_schedule(&lchan->T3101, bts->network->T3101, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_timer_schedule(&lchan->T3101, T_def_get(bts->network->T_defs, 3101, T_S, -1), 0);</span><br><span> </span><br><span> /* send IMMEDIATE ASSIGN CMD on RSL to BTS (to send on CCCH to MS) */</span><br><span> return rsl_imm_assign_cmd(bts, sizeof(*ia)+ia->mob_alloc_len, (uint8_t *) ia);</span><br><span>@@ -2161,7 +2163,7 @@</span><br><span> osmo_timer_del(&lchan->T3109);</span><br><span> osmo_timer_setup(&lchan->T3111, t3111_expired, lchan);</span><br><span> bts = lchan->ts->trx->bts;</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_timer_schedule(&lchan->T3111, bts->network->T3111, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_timer_schedule(&lchan->T3111, T_def_get(bts->network->T_defs, 3111, T_S, -1), 0);</span><br><span> }</span><br><span> </span><br><span> /* ESTABLISH INDICATION, LOCATION AREA UPDATE REQUEST</span><br><span>@@ -3000,7 +3002,7 @@</span><br><span> struct gsm_bts *bts = lchan->ts->trx->bts;</span><br><span> </span><br><span> osmo_timer_setup(&lchan->T3109, t3109_expired, lchan);</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_timer_schedule(&lchan->T3109, bts->network->T3109, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_timer_schedule(&lchan->T3109, T_def_get(bts->network->T_defs, 3109, T_S, -1), 0);</span><br><span> return 0;</span><br><span> }</span><br><span> </span><br><span>diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c</span><br><span>index e8fb6ed..6a97ce5 100644</span><br><span>--- a/src/osmo-bsc/bsc_subscr_conn_fsm.c</span><br><span>+++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c</span><br><span>@@ -36,6 +36,7 @@</span><br><span> #include <osmocom/bsc/penalty_timers.h></span><br><span> #include <osmocom/bsc/bsc_rll.h></span><br><span> #include <osmocom/bsc/abis_rsl.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_timers.h></span><br><span> #include <osmocom/mgcp_client/mgcp_client_fsm.h></span><br><span> #include <osmocom/core/byteswap.h></span><br><span> </span><br><span>@@ -122,6 +123,25 @@</span><br><span> {0, NULL}</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+struct state_timeout conn_fsm_timeouts[32] = {</span><br><span style="color: hsl(120, 100%, 40%);">+ [ST_WAIT_ASS_CMPL] = { .T = 10 },</span><br><span style="color: hsl(120, 100%, 40%);">+ [ST_WAIT_CRCX_BTS] = { .T = 992427 },</span><br><span style="color: hsl(120, 100%, 40%);">+ [ST_WAIT_MDCX_BTS] = { .T = 992427 },</span><br><span style="color: hsl(120, 100%, 40%);">+ [ST_WAIT_CRCX_MSC] = { .T = 992427 },</span><br><span style="color: hsl(120, 100%, 40%);">+ [ST_WAIT_MDCX_BTS_HO] = { .T = 992427 },</span><br><span style="color: hsl(120, 100%, 40%);">+ [ST_WAIT_CC] = { .T = 993210 },</span><br><span style="color: hsl(120, 100%, 40%);">+ [ST_CLEARING] = { .T = 999 },</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Transition to a state, using the T timer defined in conn_fsm_timeouts.</span><br><span style="color: hsl(120, 100%, 40%);">+ * The actual timeout value is in turn obtained from network->T_defs.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Assumes local variable fi exists. */</span><br><span style="color: hsl(120, 100%, 40%);">+#define conn_fsm_state_chg(state) \</span><br><span style="color: hsl(120, 100%, 40%);">+ fsm_inst_state_chg_T(conn->fi, state, \</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_timeouts, \</span><br><span style="color: hsl(120, 100%, 40%);">+ conn->network->T_defs, \</span><br><span style="color: hsl(120, 100%, 40%);">+ -1)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> /* forward MT DTAP from BSSAP side to RSL side */</span><br><span> static inline void submit_dtap(struct gsm_subscriber_connection *conn, struct msgb *msg,</span><br><span> struct osmo_fsm_inst *fi)</span><br><span>@@ -299,7 +319,7 @@</span><br><span> } else {</span><br><span> /* SCCP T(conn est) is 1-2 minutes, way too long. The MS will timeout</span><br><span> * using T3210 (20s), T3220 (5s) or T3230 (10s) */</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_WAIT_CC, 20, 993210);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_WAIT_CC);</span><br><span> }</span><br><span> break;</span><br><span> case GSCON_EV_A_CONN_IND:</span><br><span>@@ -328,11 +348,12 @@</span><br><span> /* We've sent the CONNECTION.req to the SCCP provider and are waiting for CC from MSC */</span><br><span> static void gscon_fsm_wait_cc(struct osmo_fsm_inst *fi, uint32_t event, void *data)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+ struct gsm_subscriber_connection *conn = fi->priv;</span><br><span> switch (event) {</span><br><span> case GSCON_EV_A_CONN_CFM:</span><br><span> /* MSC has confirmed the connection, we now change into the</span><br><span> * active state and wait there for further operations */</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_ACTIVE, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_ACTIVE);</span><br><span> /* if there's user payload, forward it just like EV_MT_DTAP */</span><br><span> /* FIXME: Question: if there's user payload attached to the CC, forward it like EV_MT_DTAP? */</span><br><span> break;</span><br><span>@@ -374,7 +395,7 @@</span><br><span> resp = gsm0808_create_assignment_failure(cause, NULL);</span><br><span> sigtran_send(conn, resp, fi);</span><br><span> if (fi->state != ST_ACTIVE)</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_ACTIVE, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_ACTIVE);</span><br><span> }</span><br><span> </span><br><span> /* We're on an active subscriber connection, passing DTAP back and forth */</span><br><span>@@ -410,7 +431,7 @@</span><br><span> osmo_strlcpy(conn_peer.endpoint, get_mgw_ep_name(conn), sizeof(conn_peer.endpoint));</span><br><span> </span><br><span> /* (Pre)Change state and create the connection */</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_WAIT_CRCX_BTS, MGCP_MGW_TIMEOUT, MGCP_MGW_TIMEOUT_TIMER_NR);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_WAIT_CRCX_BTS);</span><br><span> conn->user_plane.fi_bts =</span><br><span> mgcp_conn_create(conn->network->mgw.client, fi, GSCON_EV_MGW_FAIL_BTS,</span><br><span> GSCON_EV_MGW_CRCX_RESP_BTS, &conn_peer);</span><br><span>@@ -437,7 +458,7 @@</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_WAIT_ASS_CMPL, conn->network->T10, 10);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_WAIT_ASS_CMPL);</span><br><span> break;</span><br><span> default:</span><br><span> /* An unsupported channel is requested, so we have to</span><br><span>@@ -457,7 +478,7 @@</span><br><span> if (rc) {</span><br><span> resp = gsm0808_create_clear_rqst(GSM0808_CAUSE_EQUIPMENT_FAILURE);</span><br><span> sigtran_send(conn, resp, fi);</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_CLEARING, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_CLEARING);</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span>@@ -466,7 +487,7 @@</span><br><span> * handover time out, so we do not need another timeout</span><br><span> * here (maybe its worth to think about giving GSCON</span><br><span> * more power over the actual handover process). */</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_WAIT_HO_COMPL, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_WAIT_HO_COMPL);</span><br><span> break;</span><br><span> case GSCON_EV_A_HO_REQ:</span><br><span> /* FIXME: reject any handover requests with HO FAIL until implemented */</span><br><span>@@ -524,7 +545,7 @@</span><br><span> return;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_WAIT_ASS_CMPL, conn->network->T10, 10);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_WAIT_ASS_CMPL);</span><br><span> break;</span><br><span> case GSCON_EV_MO_DTAP:</span><br><span> forward_dtap(conn, (struct msgb *)data, fi);</span><br><span>@@ -569,7 +590,7 @@</span><br><span> conn_peer.port = lchan->abis_ip.bound_port;</span><br><span> </span><br><span> /* (Pre)Change state and modify the connection */</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_WAIT_MDCX_BTS, MGCP_MGW_TIMEOUT, MGCP_MGW_TIMEOUT_TIMER_NR);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_WAIT_MDCX_BTS);</span><br><span> rc = mgcp_conn_modify(conn->user_plane.fi_bts, GSCON_EV_MGW_MDCX_RESP_BTS, &conn_peer);</span><br><span> if (rc != 0) {</span><br><span> assignment_failed(fi, GSM0808_CAUSE_EQUIPMENT_FAILURE);</span><br><span>@@ -580,7 +601,7 @@</span><br><span> /* Confirm the successful assignment on BSSMAP and</span><br><span> * change back into active state */</span><br><span> send_ass_compl(lchan, fi, false);</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_ACTIVE, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_ACTIVE);</span><br><span> break;</span><br><span> default:</span><br><span> /* Unsupported modes should have been already filtered</span><br><span>@@ -642,12 +663,11 @@</span><br><span> case OSMO_SS7_ASP_PROT_IPA:</span><br><span> /* Send assignment complete message to the MSC */</span><br><span> send_ass_compl(conn->lchan, fi, true);</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_ACTIVE, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_ACTIVE);</span><br><span> break;</span><br><span> default:</span><br><span> /* (Pre)Change state and create the connection */</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_WAIT_CRCX_MSC, MGCP_MGW_TIMEOUT,</span><br><span style="color: hsl(0, 100%, 40%);">- MGCP_MGW_TIMEOUT_TIMER_NR);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_WAIT_CRCX_MSC);</span><br><span> conn->user_plane.fi_msc = mgcp_conn_create(conn->network->mgw.client, fi,</span><br><span> GSCON_EV_MGW_FAIL_MSC,</span><br><span> GSCON_EV_MGW_CRCX_RESP_MSC, &conn_peer);</span><br><span>@@ -694,7 +714,7 @@</span><br><span> /* Send assignment complete message to the MSC */</span><br><span> send_ass_compl(lchan, fi, true);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_ACTIVE, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_ACTIVE);</span><br><span> </span><br><span> break;</span><br><span> case GSCON_EV_MO_DTAP:</span><br><span>@@ -757,12 +777,12 @@</span><br><span> conn_peer.port = lchan->abis_ip.bound_port;</span><br><span> </span><br><span> /* (Pre)Change state and modify the connection */</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_WAIT_MDCX_BTS_HO, MGCP_MGW_TIMEOUT, MGCP_MGW_HO_TIMEOUT_TIMER_NR);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_WAIT_MDCX_BTS_HO);</span><br><span> rc = mgcp_conn_modify(conn->user_plane.fi_bts, GSCON_EV_MGW_MDCX_RESP_BTS, &conn_peer);</span><br><span> if (rc != 0) {</span><br><span> resp = gsm0808_create_clear_rqst(GSM0808_CAUSE_EQUIPMENT_FAILURE);</span><br><span> sigtran_send(conn, resp, fi);</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_CLEARING, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_CLEARING);</span><br><span> return;</span><br><span> }</span><br><span> break;</span><br><span>@@ -772,7 +792,7 @@</span><br><span> * some reason. This means the phone stays on the TS/BTS on</span><br><span> * which it currently is. We will change back to the active</span><br><span> * state again as there are no further operations needed */</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_ACTIVE, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_ACTIVE);</span><br><span> break;</span><br><span> default:</span><br><span> OSMO_ASSERT(false);</span><br><span>@@ -791,7 +811,7 @@</span><br><span> /* The MGW has confirmed the handover MDCX, and the handover</span><br><span> * is now also done on the RTP side. We may now change back</span><br><span> * to the active state. */</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_ACTIVE, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_ACTIVE);</span><br><span> break;</span><br><span> case GSCON_EV_MO_DTAP:</span><br><span> forward_dtap(conn, (struct msgb *)data, fi);</span><br><span>@@ -922,7 +942,7 @@</span><br><span> break;</span><br><span> case GSCON_EV_A_CLEAR_CMD:</span><br><span> /* MSC tells us to cleanly shut down */</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_CLEARING, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_CLEARING);</span><br><span> gsm0808_clear(conn);</span><br><span> /* FIXME: Release all terestrial resources in ST_CLEARING */</span><br><span> /* According to 3GPP 48.008 3.1.9.1. "The BSS need not wait for the radio channel</span><br><span>@@ -1047,7 +1067,7 @@</span><br><span> assignment_failed(fi, GSM0808_CAUSE_EQUIPMENT_FAILURE);</span><br><span> break;</span><br><span> case MGCP_MGW_HO_TIMEOUT_TIMER_NR: /* Handover failed (no response from MGW) */</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_fsm_inst_state_chg(fi, ST_ACTIVE, 0, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ conn_fsm_state_chg(ST_ACTIVE);</span><br><span> break;</span><br><span> default:</span><br><span> OSMO_ASSERT(false);</span><br><span>diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c</span><br><span>index f25f731..ababb3e 100644</span><br><span>--- a/src/osmo-bsc/bsc_vty.c</span><br><span>+++ b/src/osmo-bsc/bsc_vty.c</span><br><span>@@ -64,6 +64,7 @@</span><br><span> #include <osmocom/bsc/meas_feed.h></span><br><span> #include <osmocom/bsc/neighbor_ident.h></span><br><span> #include <osmocom/bsc/handover.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_timers.h></span><br><span> </span><br><span> #include <inttypes.h></span><br><span> </span><br><span>@@ -968,11 +969,6 @@</span><br><span> return CMD_SUCCESS;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* small helper macro for conditional dumping of timer */</span><br><span style="color: hsl(0, 100%, 40%);">-#define VTY_OUT_TIMER(number) \</span><br><span style="color: hsl(0, 100%, 40%);">- if (gsmnet->T##number != GSM_T##number##_DEFAULT) \</span><br><span style="color: hsl(0, 100%, 40%);">- vty_out(vty, " timer t"#number" %u%s", gsmnet->T##number, VTY_NEWLINE)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> static int config_write_net(struct vty *vty)</span><br><span> {</span><br><span> struct gsm_network *gsmnet = gsmnet_from_vty(vty);</span><br><span>@@ -993,22 +989,7 @@</span><br><span> </span><br><span> ho_vty_write_net(vty, gsmnet);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(3101);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(3103);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(3105);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(3107);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(3109);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(3111);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(3113);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(3115);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(3117);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(3119);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(3122);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(3141);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(10);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(7);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(8);</span><br><span style="color: hsl(0, 100%, 40%);">- VTY_OUT_TIMER(101);</span><br><span style="color: hsl(120, 100%, 40%);">+ T_defs_vty_write(vty, " ");</span><br><span> </span><br><span> if (!gsmnet->dyn_ts_allow_tch_f)</span><br><span> vty_out(vty, " dyn_ts_allow_tch_f 0%s", VTY_NEWLINE);</span><br><span>@@ -1021,11 +1002,8 @@</span><br><span> vty_out(vty, " timezone %d %d%s",</span><br><span> gsmnet->tz.hr, gsmnet->tz.mn, VTY_NEWLINE);</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- if (gsmnet->t3212 == 0)</span><br><span style="color: hsl(0, 100%, 40%);">- vty_out(vty, " no periodic location update%s", VTY_NEWLINE);</span><br><span style="color: hsl(0, 100%, 40%);">- else</span><br><span style="color: hsl(0, 100%, 40%);">- vty_out(vty, " periodic location update %u%s",</span><br><span style="color: hsl(0, 100%, 40%);">- gsmnet->t3212 * 6, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* writing T3212 from the common T_defs_vty_write() instead. */</span><br><span> </span><br><span> {</span><br><span> uint16_t meas_port;</span><br><span>@@ -1889,48 +1867,6 @@</span><br><span> return CMD_SUCCESS;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#define DEFAULT_TIMER(number) GSM_T##number##_DEFAULT</span><br><span style="color: hsl(0, 100%, 40%);">-/* Add another expansion so that DEFAULT_TIMER() becomes its value */</span><br><span style="color: hsl(0, 100%, 40%);">-#define EXPAND_AND_STRINGIFY(x) OSMO_STRINGIFY(x)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-#define DECLARE_TIMER(number, doc) \</span><br><span style="color: hsl(0, 100%, 40%);">- DEFUN(cfg_net_T##number, \</span><br><span style="color: hsl(0, 100%, 40%);">- cfg_net_T##number##_cmd, \</span><br><span style="color: hsl(0, 100%, 40%);">- "timer t" #number " (default|<1-65535>)", \</span><br><span style="color: hsl(0, 100%, 40%);">- "Configure GSM Timers\n" \</span><br><span style="color: hsl(0, 100%, 40%);">- doc " (default: " EXPAND_AND_STRINGIFY(DEFAULT_TIMER(number)) " seconds)\n" \</span><br><span style="color: hsl(0, 100%, 40%);">- "Set to default timer value" \</span><br><span style="color: hsl(0, 100%, 40%);">- " (" EXPAND_AND_STRINGIFY(DEFAULT_TIMER(number)) " seconds)\n" \</span><br><span style="color: hsl(0, 100%, 40%);">- "Timer Value in seconds\n") \</span><br><span style="color: hsl(0, 100%, 40%);">-{ \</span><br><span style="color: hsl(0, 100%, 40%);">- struct gsm_network *gsmnet = gsmnet_from_vty(vty); \</span><br><span style="color: hsl(0, 100%, 40%);">- int value; \</span><br><span style="color: hsl(0, 100%, 40%);">- if (strcmp(argv[0], "default") == 0) \</span><br><span style="color: hsl(0, 100%, 40%);">- value = DEFAULT_TIMER(number); \</span><br><span style="color: hsl(0, 100%, 40%);">- else \</span><br><span style="color: hsl(0, 100%, 40%);">- value = atoi(argv[0]); \</span><br><span style="color: hsl(0, 100%, 40%);">- \</span><br><span style="color: hsl(0, 100%, 40%);">- gsmnet->T##number = value; \</span><br><span style="color: hsl(0, 100%, 40%);">- return CMD_SUCCESS; \</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(3101, "Set the timeout value for IMMEDIATE ASSIGNMENT")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(3103, "Set the timeout value for HANDOVER")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(3105, "Set the timer for repetition of PHYSICAL INFORMATION")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(3107, "Currently not used")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(3109, "Set the RSL SACCH deactivation timeout")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(3111, "Set the RSL timeout to wait before releasing the RF Channel")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(3113, "Set the time to try paging a subscriber")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(3115, "Currently not used")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(3117, "Currently not used")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(3119, "Currently not used")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(3122, "Default waiting time (seconds) after IMM ASS REJECT")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(3141, "Currently not used")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(10, "Assignment Command timeout in seconds")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(7, "Set the outgoing inter-BSC Handover timeout, from Handover Required to Handover Command")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(8, "Set the outgoing inter-BSC Handover timeout, from Handover Command to final Clear")</span><br><span style="color: hsl(0, 100%, 40%);">-DECLARE_TIMER(101, "Set the incoming inter-BSC Handover timeout, from Handover Request to Accept")</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> DEFUN_DEPRECATED(cfg_net_dtx,</span><br><span> cfg_net_dtx_cmd,</span><br><span> "dtx-used (0|1)",</span><br><span>@@ -4734,9 +4670,11 @@</span><br><span> "Periodic Location Updating Interval in Minutes\n")</span><br><span> {</span><br><span> struct gsm_network *net = vty->index;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct T_def *d = T_def_get_entry(net->T_defs, 3212);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- net->t3212 = atoi(argv[0]) / 6;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_ASSERT(d);</span><br><span style="color: hsl(120, 100%, 40%);">+ d->val = atoi(argv[0]) / 6;</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, "T%d = %u %s (%s)%s", d->T, d->val, "* 6min", d->desc, VTY_NEWLINE);</span><br><span> return CMD_SUCCESS;</span><br><span> }</span><br><span> </span><br><span>@@ -4748,9 +4686,11 @@</span><br><span> "Periodic Location Updating Interval\n")</span><br><span> {</span><br><span> struct gsm_network *net = vty->index;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct T_def *d = T_def_get_entry(net->T_defs, 3212);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- net->t3212 = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_ASSERT(d);</span><br><span style="color: hsl(120, 100%, 40%);">+ d->val = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, "T%d = %u %s (%s)%s", d->T, d->val, "* 6min", d->desc, VTY_NEWLINE);</span><br><span> return CMD_SUCCESS;</span><br><span> }</span><br><span> </span><br><span>@@ -4842,23 +4782,9 @@</span><br><span> logging_vty_add_cmds(NULL);</span><br><span> osmo_talloc_vty_add_cmds();</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ T_defs_vty_init(network->T_defs, GSMNET_NODE);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> install_element(GSMNET_NODE, &cfg_net_neci_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T3101_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T3103_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T3105_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T3107_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T3109_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T3111_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T3113_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T3115_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T3117_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T3119_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T3122_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T3141_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T10_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T7_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T8_cmd);</span><br><span style="color: hsl(0, 100%, 40%);">- install_element(GSMNET_NODE, &cfg_net_T101_cmd);</span><br><span> install_element(GSMNET_NODE, &cfg_net_dtx_cmd);</span><br><span> install_element(GSMNET_NODE, &cfg_net_pag_any_tch_cmd);</span><br><span> /* See also handover commands added on net level from handover_vty.c */</span><br><span>diff --git a/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c b/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c</span><br><span>index 1a8d9b0..d674c18 100644</span><br><span>--- a/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c</span><br><span>+++ b/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.c</span><br><span>@@ -23,6 +23,7 @@</span><br><span> #include <osmocom/core/msgb.h></span><br><span> #include <osmocom/bsc/gsm_data.h></span><br><span> #include <osmocom/bsc/abis_nm.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_timers.h></span><br><span> </span><br><span> static void patch_16(uint8_t *data, const uint16_t val)</span><br><span> {</span><br><span>@@ -90,7 +91,7 @@</span><br><span> msgb_tv_fixed_put(msgb, NM_ATT_LDAVG_SLOTS, 2, buf);</span><br><span> </span><br><span> /* 10 milliseconds */</span><br><span style="color: hsl(0, 100%, 40%);">- msgb_tv_put(msgb, NM_ATT_BTS_AIR_TIMER, bts->network->T3105 > 0? bts->network->T3105 : 13);</span><br><span style="color: hsl(120, 100%, 40%);">+ msgb_tv_put(msgb, NM_ATT_BTS_AIR_TIMER, T_def_get(bts->network->T_defs, 3105, T_MS, -1));</span><br><span> </span><br><span> /* 10 retransmissions of physical config */</span><br><span> msgb_tv_put(msgb, NM_ATT_NY1, 10);</span><br><span>diff --git a/src/osmo-bsc/bts_siemens_bs11.c b/src/osmo-bsc/bts_siemens_bs11.c</span><br><span>index 2d23517..1da189f 100644</span><br><span>--- a/src/osmo-bsc/bts_siemens_bs11.c</span><br><span>+++ b/src/osmo-bsc/bts_siemens_bs11.c</span><br><span>@@ -27,6 +27,7 @@</span><br><span> #include <osmocom/bsc/abis_nm.h></span><br><span> #include <osmocom/abis/e1_input.h></span><br><span> #include <osmocom/bsc/signal.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_timers.h></span><br><span> </span><br><span> static int bts_model_bs11_start(struct gsm_network *net);</span><br><span> </span><br><span>@@ -358,7 +359,7 @@</span><br><span> uint8_t arfcn_high = (bts->c0->arfcn >> 8) & 0x0f;</span><br><span> </span><br><span> /* T3105 attribute in units of 10ms */</span><br><span style="color: hsl(0, 100%, 40%);">- bs11_attr_bts[2] = bts->network->T3105 / 10;</span><br><span style="color: hsl(120, 100%, 40%);">+ bs11_attr_bts[2] = T_def_get(bts->network->T_defs, 3105, T_MS, -1) / 10;</span><br><span> </span><br><span> /* patch ARFCN into BTS Attributes */</span><br><span> bs11_attr_bts[69] &= 0xf0;</span><br><span>diff --git a/src/osmo-bsc/gsm_data.c b/src/osmo-bsc/gsm_data.c</span><br><span>index 734e2fb..0ff17f2 100644</span><br><span>--- a/src/osmo-bsc/gsm_data.c</span><br><span>+++ b/src/osmo-bsc/gsm_data.c</span><br><span>@@ -39,6 +39,7 @@</span><br><span> #include <osmocom/bsc/bsc_msc_data.h></span><br><span> #include <osmocom/bsc/abis_nm.h></span><br><span> #include <osmocom/bsc/handover_cfg.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_timers.h></span><br><span> </span><br><span> void *tall_bsc_ctx = NULL;</span><br><span> </span><br><span>@@ -863,7 +864,7 @@</span><br><span> bts->si_common.chan_desc.att = 1; /* attachment required */</span><br><span> bts->si_common.chan_desc.bs_pa_mfrms = RSL_BS_PA_MFRMS_5; /* paging frames */</span><br><span> bts->si_common.chan_desc.bs_ag_blks_res = 1; /* reserved AGCH blocks */</span><br><span style="color: hsl(0, 100%, 40%);">- bts->si_common.chan_desc.t3212 = net->t3212; /* Use network's current value */</span><br><span style="color: hsl(120, 100%, 40%);">+ bts->si_common.chan_desc.t3212 = T_def_get(net->T_defs, 3212, T_CUSTOM, -1);</span><br><span> gsm_bts_set_radio_link_timeout(bts, 32); /* Use RADIO LINK TIMEOUT of 32 */</span><br><span> </span><br><span> INIT_LLIST_HEAD(&bts->abis_queue);</span><br><span>diff --git a/src/osmo-bsc/gsm_timers.c b/src/osmo-bsc/gsm_timers.c</span><br><span>new file mode 100644</span><br><span>index 0000000..2f73793</span><br><span>--- /dev/null</span><br><span>+++ b/src/osmo-bsc/gsm_timers.c</span><br><span>@@ -0,0 +1,206 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* Implementation to define Tnnn timers globally and use for FSM state changes. */</span><br><span style="color: hsl(120, 100%, 40%);">+/* (C) 2018 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Author: Neels Hofmeyr <neels@hofmeyr.de></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * All Rights Reserved</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU Affero General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; either version 3 of the License, or</span><br><span style="color: hsl(120, 100%, 40%);">+ * (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU Affero General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU Affero General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+ * along with this program. If not, see <http://www.gnu.org/licenses/>.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/core/fsm.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_timers.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* a = return_val * b. Return 0 if factor is below 1. */</span><br><span style="color: hsl(120, 100%, 40%);">+static int T_factor(enum T_unit a, enum T_unit b)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ if (b == a</span><br><span style="color: hsl(120, 100%, 40%);">+ || b == T_CUSTOM || a == T_CUSTOM)</span><br><span style="color: hsl(120, 100%, 40%);">+ return 1;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ switch (b) {</span><br><span style="color: hsl(120, 100%, 40%);">+ case T_MS:</span><br><span style="color: hsl(120, 100%, 40%);">+ switch (a) {</span><br><span style="color: hsl(120, 100%, 40%);">+ case T_S:</span><br><span style="color: hsl(120, 100%, 40%);">+ return 1000;</span><br><span style="color: hsl(120, 100%, 40%);">+ case T_M:</span><br><span style="color: hsl(120, 100%, 40%);">+ return 60*1000;</span><br><span style="color: hsl(120, 100%, 40%);">+ default:</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ case T_S:</span><br><span style="color: hsl(120, 100%, 40%);">+ switch (a) {</span><br><span style="color: hsl(120, 100%, 40%);">+ case T_M:</span><br><span style="color: hsl(120, 100%, 40%);">+ return 60;</span><br><span style="color: hsl(120, 100%, 40%);">+ default:</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ default:</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static int T_round(int val, enum T_unit from_unit, enum T_unit to_unit)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ int f;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!val)</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ f = T_factor(from_unit, to_unit);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (f < 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ f = T_factor(to_unit, from_unit);</span><br><span style="color: hsl(120, 100%, 40%);">+ return (val / f) + (val % f? 1 : 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ return val * f;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Return the value of a T timer from a list of T_defs.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Any value is rounded up to match as_unit: 1100 ms as T_S becomes 2 seconds, as T_M becomes one minute.</span><br><span style="color: hsl(120, 100%, 40%);">+ * If no such timer is defined, return the default value passed, or abort the program if default < 0.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Usage examples:</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * - Initialization:</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * struct T_def global_T_defs[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+ * { .T=7, .default_val=60, .desc="Water Boiling Timeout" }, // default is .unit=T_S == 0</span><br><span style="color: hsl(120, 100%, 40%);">+ * { .T=8, .default_val=300, .desc="Tea brewing" },</span><br><span style="color: hsl(120, 100%, 40%);">+ * { .T=9, .default_val=5, .unit=T_M, .desc="Let tea cool down before drinking" },</span><br><span style="color: hsl(120, 100%, 40%);">+ * { .T=10, .default_val=20, .unit=T_M, .desc="Forgot to drink tea while it's warm" },</span><br><span style="color: hsl(120, 100%, 40%);">+ * {} // <-- important! last entry shall be zero</span><br><span style="color: hsl(120, 100%, 40%);">+ * };</span><br><span style="color: hsl(120, 100%, 40%);">+ * T_defs_reset(global_T_defs); // make all values the default</span><br><span style="color: hsl(120, 100%, 40%);">+ * T_defs_vty_init(global_T_defs, CONFIG_NODE);</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * val = T_def_get(global_T_defs, 7, T_S, -1); // -> 10</span><br><span style="color: hsl(120, 100%, 40%);">+ * sleep(val);</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * val = T_def_get(global_T_defs, 7, T_M, -1); // 10 seconds becomes 1 minute -> 1</span><br><span style="color: hsl(120, 100%, 40%);">+ * sleep_minutes(val);</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * val = T_def_get(global_T_defs, 99, T_S, -1); // not defined, program aborts!</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * val = T_def_get(global_T_defs, 99, T_S, 3); // not defined, returns 3</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int T_def_get(struct T_def *T_defs, int T, enum T_unit as_unit, int val_if_not_present)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct T_def *d = T_def_get_entry(T_defs, T);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!d) {</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_ASSERT(val_if_not_present >= 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ return val_if_not_present;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ return T_round(d->val, d->unit, as_unit);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Set all T_def values to the default_val. */</span><br><span style="color: hsl(120, 100%, 40%);">+void T_defs_reset(struct T_def *T_defs)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct T_def *d;</span><br><span style="color: hsl(120, 100%, 40%);">+ for_each_T_def(d, T_defs)</span><br><span style="color: hsl(120, 100%, 40%);">+ d->val = d->default_val;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Return a pointer to a T_def from an array, or NULL. */</span><br><span style="color: hsl(120, 100%, 40%);">+struct T_def *T_def_get_entry(struct T_def *T_defs, int T)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct T_def *d;</span><br><span style="color: hsl(120, 100%, 40%);">+ for_each_T_def(d, T_defs) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (d->T == T)</span><br><span style="color: hsl(120, 100%, 40%);">+ return d;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Return a state_timeout entry from an array, or return NULL if the entry is zero.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * The timeouts_array shall contain exactly 32 elements, which corresponds to the number of states</span><br><span style="color: hsl(120, 100%, 40%);">+ * allowed by osmo_fsm_*. Lookup is by array index.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * For example:</span><br><span style="color: hsl(120, 100%, 40%);">+ * struct state_timeout my_fsm_timeouts[32] = {</span><br><span style="color: hsl(120, 100%, 40%);">+ * [MY_FSM_STATE_3] = { .T = 423 },</span><br><span style="color: hsl(120, 100%, 40%);">+ * [MY_FSM_STATE_7] = { .T = 235 },</span><br><span style="color: hsl(120, 100%, 40%);">+ * [MY_FSM_STATE_8] = { .keep_timer = true },</span><br><span style="color: hsl(120, 100%, 40%);">+ * // any state that is omitted will remain zero == no timeout</span><br><span style="color: hsl(120, 100%, 40%);">+ * };</span><br><span style="color: hsl(120, 100%, 40%);">+ * get_state_timeout(MY_FSM_STATE_0, &my_fsm_timeouts) -> NULL,</span><br><span style="color: hsl(120, 100%, 40%);">+ * get_state_timeout(MY_FSM_STATE_7, &my_fsm_timeouts) -> { .T = 235 }</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * The intention is then to obtain the timer like T_def_get(global_T_defs, T=235); see also</span><br><span style="color: hsl(120, 100%, 40%);">+ * fsm_inst_state_chg_T() below.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+struct state_timeout *get_state_timeout(uint32_t state, struct state_timeout *timeouts_array)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct state_timeout *t;</span><br><span style="color: hsl(120, 100%, 40%);">+ OSMO_ASSERT(state < 32);</span><br><span style="color: hsl(120, 100%, 40%);">+ t = &timeouts_array[state];</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!t->keep_timer && !t->T)</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ return t;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Call osmo_fsm_inst_state_chg() or osmo_fsm_inst_state_chg_keep_timer(), depending on the T value</span><br><span style="color: hsl(120, 100%, 40%);">+ * defined for this state in the timeouts_array, and obtaining the actual timeout value from T_defs.</span><br><span style="color: hsl(120, 100%, 40%);">+ * A T timer configured in sub-second precision is rounded up to the next full second.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * See get_state_timeout() and T_def_get().</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Should a T number be defined in timeouts_array that is not defined in T_defs, use default_timeout.</span><br><span style="color: hsl(120, 100%, 40%);">+ * This is best used by wrapping this function call in a macro suitable for a specific FSM</span><br><span style="color: hsl(120, 100%, 40%);">+ * implementation, which can become as short as: my_fsm_state_chg(fi, NEXT_STATE):</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * #define my_fsm_state_chg(fi, NEXT_STATE) \</span><br><span style="color: hsl(120, 100%, 40%);">+ * fsm_inst_state_chg_T(fi, NEXT_STATE, my_fsm_timeouts, global_T_defs, 5)</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * my_fsm_state_chg(fi, MY_FSM_STATE_1);</span><br><span style="color: hsl(120, 100%, 40%);">+ * // -> No timeout configured, will enter state without timeout.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * my_fsm_state_chg(fi, MY_FSM_STATE_3);</span><br><span style="color: hsl(120, 100%, 40%);">+ * // T423 configured for this state, will look up T423 in T_defs, or use 5 seconds if unset.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * my_fsm_state_chg(fi, MY_FSM_STATE_8);</span><br><span style="color: hsl(120, 100%, 40%);">+ * // keep_timer configured for this state, will invoke osmo_fsm_inst_state_chg_keep_timer().</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+int _fsm_inst_state_chg_T(struct osmo_fsm_inst *fi, uint32_t state,</span><br><span style="color: hsl(120, 100%, 40%);">+ struct state_timeout *timeouts_array,</span><br><span style="color: hsl(120, 100%, 40%);">+ struct T_def *T_defs, int default_timeout,</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *file, int line)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct state_timeout *t = get_state_timeout(state, timeouts_array);</span><br><span style="color: hsl(120, 100%, 40%);">+ int val;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /* No timeout defined for this state? */</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!t)</span><br><span style="color: hsl(120, 100%, 40%);">+ return _osmo_fsm_inst_state_chg(fi, state, 0, 0, file, line);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (t->keep_timer) {</span><br><span style="color: hsl(120, 100%, 40%);">+ int rc = _osmo_fsm_inst_state_chg_keep_timer(fi, state, file, line);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (t->T && !rc)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi->T = t->T;</span><br><span style="color: hsl(120, 100%, 40%);">+ return rc;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ val = T_def_get(T_defs, t->T, T_S, default_timeout);</span><br><span style="color: hsl(120, 100%, 40%);">+ return _osmo_fsm_inst_state_chg(fi, state, val, t->T, file, line);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+const struct value_string T_unit_names[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+ { T_S, "s" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { T_MS, "ms" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { T_CUSTOM, "(custom)" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { 0, NULL }</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span>diff --git a/src/osmo-bsc/gsm_timers_vty.c b/src/osmo-bsc/gsm_timers_vty.c</span><br><span>new file mode 100644</span><br><span>index 0000000..8a13259</span><br><span>--- /dev/null</span><br><span>+++ b/src/osmo-bsc/gsm_timers_vty.c</span><br><span>@@ -0,0 +1,117 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/* Implementation to configure Tnnn timers in VTY */</span><br><span style="color: hsl(120, 100%, 40%);">+/* (C) 2018 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Author: Neels Hofmeyr <neels@hofmeyr.de></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * All Rights Reserved</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU Affero General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; either version 3 of the License, or</span><br><span style="color: hsl(120, 100%, 40%);">+ * (at your option) any later version.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU Affero General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * You should have received a copy of the GNU Affero General Public License</span><br><span style="color: hsl(120, 100%, 40%);">+ * along with this program. If not, see <http://www.gnu.org/licenses/>.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <string.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/vty/vty.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/vty/command.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_timers.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Global singleton list used for the VTY configuration. See T_defs_vty_init(). */</span><br><span style="color: hsl(120, 100%, 40%);">+static struct T_def *g_vty_T_defs = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Parse an argument like "T1234", "t1234" or "1234" and return the corresponding T_def entry from</span><br><span style="color: hsl(120, 100%, 40%);">+ * g_vty_T_defs, if any. */</span><br><span style="color: hsl(120, 100%, 40%);">+static struct T_def *parse_T_arg(struct vty *vty, const char *T_str)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ int T;</span><br><span style="color: hsl(120, 100%, 40%);">+ struct T_def *d;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (T_str[0] == 't' || T_str[0] == 'T')</span><br><span style="color: hsl(120, 100%, 40%);">+ T_str++;</span><br><span style="color: hsl(120, 100%, 40%);">+ T = atoi(T_str);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ d = T_def_get_entry(g_vty_T_defs, T);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!d)</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, "No such timer: T%d%s", T, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+ return d;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Installed in the VTY on T_defs_vty_init(). */</span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(cfg_timer, cfg_timer_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+ "timer TNNNN (default|<1-65535>)",</span><br><span style="color: hsl(120, 100%, 40%);">+ "Configure GSM Timers\n"</span><br><span style="color: hsl(120, 100%, 40%);">+ "T-number, optionally preceded by 't' or 'T'."</span><br><span style="color: hsl(120, 100%, 40%);">+ "See also 'show timer' for a list of available timers.\n"</span><br><span style="color: hsl(120, 100%, 40%);">+ "Set to default timer value\n" "Timer value\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *val_str = argv[1];</span><br><span style="color: hsl(120, 100%, 40%);">+ struct T_def *d;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ d = parse_T_arg(vty, argv[0]);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!d)</span><br><span style="color: hsl(120, 100%, 40%);">+ return CMD_WARNING;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!strcmp(val_str, "default"))</span><br><span style="color: hsl(120, 100%, 40%);">+ d->val = d->default_val;</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+ d->val = atoi(val_str);</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, "T%d = %u %s (%s)%s", d->T, d->val, T_unit_name(d->unit), d->desc, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+ return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Print a T_def to the VTY. */</span><br><span style="color: hsl(120, 100%, 40%);">+static void show_one_timer(struct vty *vty, struct T_def *d)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, "T%d = %u %s (default = %u %s) \t%s%s",</span><br><span style="color: hsl(120, 100%, 40%);">+ d->T, d->val, T_unit_name(d->unit),</span><br><span style="color: hsl(120, 100%, 40%);">+ d->default_val, T_unit_name(d->unit), d->desc, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Installed in the VTY on T_defs_vty_init(). */</span><br><span style="color: hsl(120, 100%, 40%);">+DEFUN(show_timer, show_timer_cmd,</span><br><span style="color: hsl(120, 100%, 40%);">+ "show timer [TNNNN]",</span><br><span style="color: hsl(120, 100%, 40%);">+ SHOW_STR "GSM Timers\n"</span><br><span style="color: hsl(120, 100%, 40%);">+ "Specific timer to show, or all timers if omitted.\n")</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct T_def *d;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if (argc) {</span><br><span style="color: hsl(120, 100%, 40%);">+ d = parse_T_arg(vty, argv[0]);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!d)</span><br><span style="color: hsl(120, 100%, 40%);">+ return CMD_WARNING;</span><br><span style="color: hsl(120, 100%, 40%);">+ show_one_timer(vty, d);</span><br><span style="color: hsl(120, 100%, 40%);">+ return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ for_each_T_def(d, g_vty_T_defs)</span><br><span style="color: hsl(120, 100%, 40%);">+ show_one_timer(vty, d);</span><br><span style="color: hsl(120, 100%, 40%);">+ return CMD_SUCCESS;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Install GSM timer configuration commands in the VTY. */</span><br><span style="color: hsl(120, 100%, 40%);">+void T_defs_vty_init(struct T_def *T_defs, int cfg_parent_node)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ install_element_ve(&show_timer_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+ install_element(cfg_parent_node, &cfg_timer_cmd);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Write GSM timer configuration to the vty. */</span><br><span style="color: hsl(120, 100%, 40%);">+void T_defs_vty_write(struct vty *vty, const char *indent)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ struct T_def *d;</span><br><span style="color: hsl(120, 100%, 40%);">+ for_each_T_def(d, g_vty_T_defs) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (d->val != d->default_val)</span><br><span style="color: hsl(120, 100%, 40%);">+ vty_out(vty, "%stimer t%d %u%s", indent, d->T, d->val, VTY_NEWLINE);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/src/osmo-bsc/net_init.c b/src/osmo-bsc/net_init.c</span><br><span>index db3d01c..a802a7c 100644</span><br><span>--- a/src/osmo-bsc/net_init.c</span><br><span>+++ b/src/osmo-bsc/net_init.c</span><br><span>@@ -23,6 +23,34 @@</span><br><span> #include <osmocom/bsc/handover_cfg.h></span><br><span> #include <osmocom/bsc/chan_alloc.h></span><br><span> #include <osmocom/bsc/neighbor_ident.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_timers.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static struct T_def gsm_network_T_defs[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=7, .default_val=10, .desc="inter-BSC Handover MO, HO Required to HO Command" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=8, .default_val=10, .desc="inter-BSC Handover MO, HO Command to final Clear" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=10, .default_val=6, .desc="RR Assignment" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=101, .default_val=10, .desc="inter-BSC Handover MT, HO Request to HO Accept" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3101, .default_val=3, .desc="RR Immediate Assignment" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3103, .default_val=5, .desc="Handover" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3105, .default_val=100, .unit=T_MS, .desc="Physical Information" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3107, .default_val=5, .desc="(unused)" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3109, .default_val=5, .desc="RSL SACCH deactivation" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3111, .default_val=2, .desc="Wait time before RSL RF Channel Release" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=993111, .default_val=4, .desc="Wait time after lchan was released in error"</span><br><span style="color: hsl(120, 100%, 40%);">+ "(should be T3111 + 2s)" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3113, .default_val=10, .desc="Paging"},</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3115, .default_val=10, .desc="(unused)" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3117, .default_val=10, .desc="(unused)" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3119, .default_val=10, .desc="(unused)" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3122, .default_val=GSM_T3122_DEFAULT, .desc="Wait time after RR Immediate Assignment Reject" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3141, .default_val=10, .desc="(unused)" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3212, .default_val=5, .unit=T_CUSTOM,</span><br><span style="color: hsl(120, 100%, 40%);">+ .desc="Periodic Location Update timer, sent to MS (1 = 6 minutes)" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=993210, .default_val=20, .desc="After L3 Complete, wait for MSC to confirm" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=999, .default_val=60, .desc="After Clear Request, wait for MSC to Clear Command (sanity)" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=992427, .default_val=4, .desc="MGCP timeout (2427 is the default MGCP port number)" },</span><br><span style="color: hsl(120, 100%, 40%);">+ {}</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span> </span><br><span> /* Initialize the bare minimum of struct gsm_network, minimizing required dependencies.</span><br><span> * This part is shared among the thin programs in osmo-bsc/src/utils/.</span><br><span>@@ -43,9 +71,6 @@</span><br><span> /* Permit a compile-time default of A5/3 and A5/1 */</span><br><span> net->a5_encryption_mask = (1 << 3) | (1 << 1);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- /* Use 30 min periodic update interval as sane default */</span><br><span style="color: hsl(0, 100%, 40%);">- net->t3212 = 5;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> INIT_LLIST_HEAD(&net->subscr_conns);</span><br><span> </span><br><span> net->bsc_subscribers = talloc_zero(net, struct llist_head);</span><br><span>@@ -53,22 +78,9 @@</span><br><span> </span><br><span> INIT_LLIST_HEAD(&net->bts_list);</span><br><span> net->num_bts = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T3101 = GSM_T3101_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T3103 = GSM_T3103_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T3105 = GSM_T3105_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T3107 = GSM_T3107_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T3109 = GSM_T3109_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T3111 = GSM_T3111_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T3113 = GSM_T3113_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T3115 = GSM_T3115_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T3117 = GSM_T3117_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T3119 = GSM_T3119_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T3122 = GSM_T3122_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T3141 = GSM_T3141_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T10 = GSM_T10_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T7 = GSM_T7_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T8 = GSM_T8_DEFAULT;</span><br><span style="color: hsl(0, 100%, 40%);">- net->T101 = GSM_T101_DEFAULT;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ net->T_defs = gsm_network_T_defs;</span><br><span style="color: hsl(120, 100%, 40%);">+ T_defs_reset(net->T_defs);</span><br><span> </span><br><span> return net;</span><br><span> }</span><br><span>diff --git a/src/osmo-bsc/paging.c b/src/osmo-bsc/paging.c</span><br><span>index feb9fea..b75d731 100644</span><br><span>--- a/src/osmo-bsc/paging.c</span><br><span>+++ b/src/osmo-bsc/paging.c</span><br><span>@@ -51,6 +51,7 @@</span><br><span> #include <osmocom/bsc/chan_alloc.h></span><br><span> #include <osmocom/bsc/bsc_api.h></span><br><span> #include <osmocom/bsc/gsm_04_08_utils.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_timers.h></span><br><span> </span><br><span> void *tall_paging_ctx = NULL;</span><br><span> </span><br><span>@@ -315,7 +316,7 @@</span><br><span> req->chan_type = type;</span><br><span> req->msc = msc;</span><br><span> osmo_timer_setup(&req->T3113, paging_T3113_expired, req);</span><br><span style="color: hsl(0, 100%, 40%);">- osmo_timer_schedule(&req->T3113, bts->network->T3113, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ osmo_timer_schedule(&req->T3113, T_def_get(bts->network->T_defs, 3113, T_S, -1), 0);</span><br><span> llist_add_tail(&req->entry, &bts_entry->pending_requests);</span><br><span> paging_schedule_if_needed(bts_entry);</span><br><span> </span><br><span>diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am</span><br><span>index 543344b..f8b536b 100644</span><br><span>--- a/src/utils/Makefile.am</span><br><span>+++ b/src/utils/Makefile.am</span><br><span>@@ -122,6 +122,7 @@</span><br><span> </span><br><span> meas_json_LDADD = \</span><br><span> $(top_builddir)/src/osmo-bsc/gsm_data.o \</span><br><span style="color: hsl(120, 100%, 40%);">+ $(top_builddir)/src/osmo-bsc/gsm_timers.o \</span><br><span> $(LIBOSMOCORE_LIBS) \</span><br><span> $(LIBOSMOGSM_LIBS) \</span><br><span> $(LIBOSMOABIS_LIBS) \</span><br><span>diff --git a/tests/abis/Makefile.am b/tests/abis/Makefile.am</span><br><span>index 60054d9..4fc3605 100644</span><br><span>--- a/tests/abis/Makefile.am</span><br><span>+++ b/tests/abis/Makefile.am</span><br><span>@@ -27,6 +27,7 @@</span><br><span> abis_test_LDADD = \</span><br><span> $(top_builddir)/src/osmo-bsc/abis_nm.o \</span><br><span> $(top_builddir)/src/osmo-bsc/gsm_data.o \</span><br><span style="color: hsl(120, 100%, 40%);">+ $(top_builddir)/src/osmo-bsc/gsm_timers.o \</span><br><span> $(top_builddir)/src/osmo-bsc/net_init.o \</span><br><span> $(LIBOSMOCORE_LIBS) \</span><br><span> $(LIBOSMOABIS_LIBS) \</span><br><span>diff --git a/tests/bsc/Makefile.am b/tests/bsc/Makefile.am</span><br><span>index 2e34d79..57e8837 100644</span><br><span>--- a/tests/bsc/Makefile.am</span><br><span>+++ b/tests/bsc/Makefile.am</span><br><span>@@ -43,6 +43,7 @@</span><br><span> $(top_builddir)/src/osmo-bsc/gsm_04_08_utils.o \</span><br><span> $(top_builddir)/src/osmo-bsc/gsm_04_80_utils.o \</span><br><span> $(top_builddir)/src/osmo-bsc/gsm_data.o \</span><br><span style="color: hsl(120, 100%, 40%);">+ $(top_builddir)/src/osmo-bsc/gsm_timers.o \</span><br><span> $(top_builddir)/src/osmo-bsc/handover_cfg.o \</span><br><span> $(top_builddir)/src/osmo-bsc/handover_logic.o \</span><br><span> $(top_builddir)/src/osmo-bsc/neighbor_ident.o \</span><br><span>diff --git a/tests/gsm0408/Makefile.am b/tests/gsm0408/Makefile.am</span><br><span>index 3eb47f6..d790fc8 100644</span><br><span>--- a/tests/gsm0408/Makefile.am</span><br><span>+++ b/tests/gsm0408/Makefile.am</span><br><span>@@ -25,6 +25,7 @@</span><br><span> gsm0408_test_LDADD = \</span><br><span> $(top_builddir)/src/osmo-bsc/arfcn_range_encode.o \</span><br><span> $(top_builddir)/src/osmo-bsc/gsm_data.o \</span><br><span style="color: hsl(120, 100%, 40%);">+ $(top_builddir)/src/osmo-bsc/gsm_timers.o \</span><br><span> $(top_builddir)/src/osmo-bsc/net_init.o \</span><br><span> $(top_builddir)/src/osmo-bsc/rest_octets.o \</span><br><span> $(top_builddir)/src/osmo-bsc/system_information.o \</span><br><span>diff --git a/tests/handover/Makefile.am b/tests/handover/Makefile.am</span><br><span>index 2f84d7a..180bffe 100644</span><br><span>--- a/tests/handover/Makefile.am</span><br><span>+++ b/tests/handover/Makefile.am</span><br><span>@@ -52,6 +52,7 @@</span><br><span> $(top_builddir)/src/osmo-bsc/gsm_04_08_utils.o \</span><br><span> $(top_builddir)/src/osmo-bsc/gsm_04_80_utils.o \</span><br><span> $(top_builddir)/src/osmo-bsc/gsm_data.o \</span><br><span style="color: hsl(120, 100%, 40%);">+ $(top_builddir)/src/osmo-bsc/gsm_timers.o \</span><br><span> $(top_builddir)/src/osmo-bsc/handover_cfg.o \</span><br><span> $(top_builddir)/src/osmo-bsc/handover_decision.o \</span><br><span> $(top_builddir)/src/osmo-bsc/handover_decision_2.o \</span><br><span>diff --git a/tests/nanobts_omlattr/Makefile.am b/tests/nanobts_omlattr/Makefile.am</span><br><span>index aa7045e..312cf7d 100644</span><br><span>--- a/tests/nanobts_omlattr/Makefile.am</span><br><span>+++ b/tests/nanobts_omlattr/Makefile.am</span><br><span>@@ -26,6 +26,7 @@</span><br><span> $(top_builddir)/src/osmo-bsc/abis_nm.o \</span><br><span> $(top_builddir)/src/osmo-bsc/bts_ipaccess_nanobts_omlattr.o \</span><br><span> $(top_builddir)/src/osmo-bsc/gsm_data.o \</span><br><span style="color: hsl(120, 100%, 40%);">+ $(top_builddir)/src/osmo-bsc/gsm_timers.o \</span><br><span> $(LIBOSMOCORE_LIBS) \</span><br><span> $(LIBOSMOGSM_LIBS) \</span><br><span> $(LIBOSMOABIS_LIBS) \</span><br><span>diff --git a/tests/nanobts_omlattr/nanobts_omlattr_test.c b/tests/nanobts_omlattr/nanobts_omlattr_test.c</span><br><span>index 72dabe5..7a3a80e 100644</span><br><span>--- a/tests/nanobts_omlattr/nanobts_omlattr_test.c</span><br><span>+++ b/tests/nanobts_omlattr/nanobts_omlattr_test.c</span><br><span>@@ -21,6 +21,7 @@</span><br><span> </span><br><span> #include <osmocom/bsc/debug.h></span><br><span> #include <osmocom/bsc/gsm_data.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <osmocom/bsc/gsm_timers.h></span><br><span> #include <osmocom/bsc/bts_ipaccess_nanobts_omlattr.h></span><br><span> </span><br><span> #include <osmocom/core/talloc.h></span><br><span>@@ -191,6 +192,13 @@</span><br><span> .num_cat = ARRAY_SIZE(log_categories),</span><br><span> };</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static struct T_def gsm_network_T_defs[] = {</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3105, .default_val=100, .val=13, .unit=T_MS, .desc="Physical Information" },</span><br><span style="color: hsl(120, 100%, 40%);">+ { .T=3212, .default_val=5, .unit=T_CUSTOM,</span><br><span style="color: hsl(120, 100%, 40%);">+ .desc="Periodic Location Update timer, sent to MS (1 = 6 minutes)" },</span><br><span style="color: hsl(120, 100%, 40%);">+ {}</span><br><span style="color: hsl(120, 100%, 40%);">+};</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> int main(int argc, char **argv)</span><br><span> {</span><br><span> void *ctx;</span><br><span>@@ -207,6 +215,7 @@</span><br><span> /* Allocate environmental structs (bts, net, trx) */</span><br><span> net = talloc_zero(ctx, struct gsm_network);</span><br><span> INIT_LLIST_HEAD(&net->bts_list);</span><br><span style="color: hsl(120, 100%, 40%);">+ net->T_defs = gsm_network_T_defs;</span><br><span> gsm_bts_model_register(&bts_model_nanobts);</span><br><span> bts = gsm_bts_alloc_register(net, GSM_BTS_TYPE_NANOBTS, 63);</span><br><span> OSMO_ASSERT(bts);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/9670">change 9670</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/9670"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: osmo-bsc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: If212fcd042051b6fa53484254223614c5b93a9c6 </div>
<div style="display:none"> Gerrit-Change-Number: 9670 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>