aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-04-16 20:07:56 +0200
committerHarald Welte <laforge@gnumonks.org>2012-04-19 09:39:15 +0200
commitf4f69ee6fc19b9f8d4d0af615e752cb88b96eae7 (patch)
tree641dd0beeec1a4872828cd838cde1c9e3d1616ff
parentf1052b812deb55f9645ae2b7cdf1fa7313599c28 (diff)
lchan: Similar to OpenBSC use a set method to change the state
By making all modifications through lchan_set_state we can easily add code to verify the state transition.
-rw-r--r--include/osmo-bts/gsm_data.h3
-rw-r--r--src/common/Makefile.am2
-rw-r--r--src/common/lchan.c27
-rw-r--r--src/osmo-bts-sysmo/oml.c12
4 files changed, 37 insertions, 7 deletions
diff --git a/include/osmo-bts/gsm_data.h b/include/osmo-bts/gsm_data.h
index b6eab7a..d600cf6 100644
--- a/include/osmo-bts/gsm_data.h
+++ b/include/osmo-bts/gsm_data.h
@@ -69,4 +69,7 @@ static inline struct femtol1_hdl *trx_femtol1_hdl(struct gsm_bts_trx *trx)
return trx->role_bts.l1h;
}
+
+void lchan_set_state(struct gsm_lchan *lchan, enum gsm_lchan_state state);
+
#endif /* _GSM_DATA_H */
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
index 75cd740..b92aecd 100644
--- a/src/common/Makefile.am
+++ b/src/common/Makefile.am
@@ -4,4 +4,4 @@ LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOTRAU_LIBS)
noinst_LIBRARIES = libbts.a
libbts_a_SOURCES = gsm_data_shared.c sysinfo.c logging.c abis.c oml.c bts.c \
- rsl.c vty.c paging.c measurement.c amr.c
+ rsl.c vty.c paging.c measurement.c amr.c lchan.c
diff --git a/src/common/lchan.c b/src/common/lchan.c
new file mode 100644
index 0000000..5b6786a
--- /dev/null
+++ b/src/common/lchan.c
@@ -0,0 +1,27 @@
+/* OsmoBTS lchan interface */
+
+/* (C) 2012 by Holger Hans Peter Freyther
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include <osmo-bts/gsm_data.h>
+
+void lchan_set_state(struct gsm_lchan *lchan, enum gsm_lchan_state state)
+{
+ lchan->state = state;
+}
diff --git a/src/osmo-bts-sysmo/oml.c b/src/osmo-bts-sysmo/oml.c
index bb5b9a9..b59f11f 100644
--- a/src/osmo-bts-sysmo/oml.c
+++ b/src/osmo-bts-sysmo/oml.c
@@ -427,12 +427,12 @@ static int lchan_act_compl_cb(struct msgb *l1_msg, void *data)
if (ic->status == GsmL1_Status_Success) {
DEBUGP(DL1C, "Successful activation of L1 SAPI %s on TS %u\n",
get_value_string(femtobts_l1sapi_names, ic->sapi), ic->u8Tn);
- lchan->state = LCHAN_S_ACTIVE;
+ lchan_set_state(lchan, LCHAN_S_ACTIVE);
} else {
LOGP(DL1C, LOGL_ERROR, "Error activating L1 SAPI %s on TS %u: %s\n",
get_value_string(femtobts_l1sapi_names, ic->sapi), ic->u8Tn,
get_value_string(femtobts_l1status_names, ic->status));
- lchan->state = LCHAN_S_NONE;
+ lchan_set_state(lchan, LCHAN_S_NONE);
}
switch (ic->sapi) {
@@ -663,7 +663,7 @@ int lchan_activate(struct gsm_lchan *lchan)
/* FIXME: check if encryption parameters are present, and issue
* MPH-CONFIG.req */
}
- lchan->state = LCHAN_S_ACT_REQ;
+ lchan_set_state(lchan, LCHAN_S_ACT_REQ);
lchan_init_lapdm(lchan);
@@ -858,12 +858,12 @@ static int lchan_deact_compl_cb(struct msgb *l1_msg, void *data)
if (ic->status == GsmL1_Status_Success) {
DEBUGP(DL1C, "Successful deactivation of L1 SAPI %s on TS %u\n",
get_value_string(femtobts_l1sapi_names, ic->sapi), ic->u8Tn);
- lchan->state = LCHAN_S_ACTIVE;
+ lchan_set_state(lchan, LCHAN_S_ACTIVE);
} else {
LOGP(DL1C, LOGL_ERROR, "Error deactivating L1 SAPI %s on TS %u: %s\n",
get_value_string(femtobts_l1sapi_names, ic->sapi), ic->u8Tn,
get_value_string(femtobts_l1status_names, ic->status));
- lchan->state = LCHAN_S_NONE;
+ lchan_set_state(lchan, LCHAN_S_NONE);
}
switch (ic->sapi) {
@@ -908,7 +908,7 @@ int lchan_deactivate(struct gsm_lchan *lchan)
l1if_req_compl(fl1h, msg, 0, lchan_deact_compl_cb, lchan);
}
- lchan->state = LCHAN_S_ACT_REQ;
+ lchan_set_state(lchan, LCHAN_S_ACT_REQ);
lchan->ciph_state = 0; /* FIXME: do this in common/\*.c */
return 0;