From 553535f87b490a8b8a2ab2633417ab7c286907bd Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 17 Dec 2017 13:35:52 +0100 Subject: Add 'osmo-bts-omldummy' to bring up only OML without RSL This is used only in integration testing, where in the TTCN-3 testsuite we currently have no A-bis OML implementation, but only a RSL one. Change-Id: Id8e5f34091e6e32621d8c8673de7ea848dfd252f --- .gitignore | 1 + configure.ac | 1 + include/osmo-bts/gsm_data_shared.h | 1 + src/Makefile.am | 2 +- src/common/gsm_data_shared.c | 1 + src/common/oml.c | 9 +- src/osmo-bts-omldummy/Makefile.am | 8 ++ src/osmo-bts-omldummy/bts_model.c | 217 +++++++++++++++++++++++++++++++++++++ src/osmo-bts-omldummy/main.c | 52 +++++++++ src/osmo-bts-omldummy/respawn.sh | 6 + 10 files changed, 294 insertions(+), 4 deletions(-) create mode 100644 src/osmo-bts-omldummy/Makefile.am create mode 100644 src/osmo-bts-omldummy/bts_model.c create mode 100644 src/osmo-bts-omldummy/main.c create mode 100755 src/osmo-bts-omldummy/respawn.sh diff --git a/.gitignore b/.gitignore index 69e2c362..d81bd450 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,7 @@ src/osmo-bts-trx/osmo-bts-trx src/osmo-bts-octphy/osmo-bts-octphy src/osmo-bts-virtual/osmo-bts-virtual +src/osmo-bts-omldummy/osmo-bts-omldummy tests/atconfig tests/package.m4 diff --git a/configure.ac b/configure.ac index b3758068..1d7379f1 100644 --- a/configure.ac +++ b/configure.ac @@ -212,6 +212,7 @@ AC_OUTPUT( src/Makefile src/common/Makefile src/osmo-bts-virtual/Makefile + src/osmo-bts-omldummy/Makefile src/osmo-bts-sysmo/Makefile src/osmo-bts-litecell15/Makefile src/osmo-bts-trx/Makefile diff --git a/include/osmo-bts/gsm_data_shared.h b/include/osmo-bts/gsm_data_shared.h index aebdb656..c6557ee7 100644 --- a/include/osmo-bts/gsm_data_shared.h +++ b/include/osmo-bts/gsm_data_shared.h @@ -423,6 +423,7 @@ enum gsm_bts_type_variant { BTS_OSMO_SYSMO, BTS_OSMO_TRX, BTS_OSMO_VIRTUAL, + BTS_OSMO_OMLDUMMY, _NUM_BTS_VARIANT }; diff --git a/src/Makefile.am b/src/Makefile.am index 4f3f7605..501591d6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = common osmo-bts-virtual +SUBDIRS = common osmo-bts-virtual osmo-bts-omldummy if ENABLE_SYSMOBTS SUBDIRS += osmo-bts-sysmo diff --git a/src/common/gsm_data_shared.c b/src/common/gsm_data_shared.c index d11b1860..3fb31bf8 100644 --- a/src/common/gsm_data_shared.c +++ b/src/common/gsm_data_shared.c @@ -75,6 +75,7 @@ const struct value_string osmo_bts_variant_names[_NUM_BTS_VARIANT + 1] = { { BTS_OSMO_SYSMO, "osmo-bts-sysmo" }, { BTS_OSMO_TRX, "omso-bts-trx" }, { BTS_OSMO_VIRTUAL, "omso-bts-virtual" }, + { BTS_OSMO_OMLDUMMY, "omso-bts-omldummy" }, { 0, NULL } }; diff --git a/src/common/oml.c b/src/common/oml.c index 139210ed..9dccdfdf 100644 --- a/src/common/oml.c +++ b/src/common/oml.c @@ -173,7 +173,7 @@ static inline void add_trx_attr(struct msgb *msg, struct gsm_bts_trx *trx) { const struct phy_instance *pinst = trx_phy_instance(trx); - abis_nm_put_sw_file(msg, btsatttr2str(TRX_PHY_VERSION), strlen(pinst->version) ? pinst->version : "Unknown", + abis_nm_put_sw_file(msg, btsatttr2str(TRX_PHY_VERSION), pinst && strlen(pinst->version) ? pinst->version : "Unknown", true); } @@ -1362,8 +1362,11 @@ static int rx_oml_ipa_rsl_connect(struct gsm_bts_trx *trx, struct msgb *msg, LOGP(DOML, LOGL_INFO, "Rx IPA RSL CONNECT IP=%s PORT=%u STREAM=0x%02x\n", inet_ntoa(in), port, stream_id); - rc = e1inp_ipa_bts_rsl_connect_n(oml_link->ts->line, inet_ntoa(in), port, - trx->nr); + if (trx->bts->variant != BTS_OSMO_OMLDUMMY) { + rc = 0; + LOGP(DOML, LOGL_NOTICE, "Not connecting RSL in OML-DUMMY!\n"); + } else + rc = e1inp_ipa_bts_rsl_connect_n(oml_link->ts->line, inet_ntoa(in), port, trx->nr); if (rc < 0) { LOGP(DOML, LOGL_ERROR, "Error in abis_open(RSL): %d\n", rc); return oml_fom_ack_nack(msg, NM_NACK_CANT_PERFORM); diff --git a/src/osmo-bts-omldummy/Makefile.am b/src/osmo-bts-omldummy/Makefile.am new file mode 100644 index 00000000..4ff28f02 --- /dev/null +++ b/src/osmo-bts-omldummy/Makefile.am @@ -0,0 +1,8 @@ +AM_CFLAGS = -Wall -fno-strict-aliasing $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOTRAU_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBOSMOCTRL_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(LIBGPS_CFLAGS) $(ORTP_CFLAGS) +AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -Iinclude +COMMON_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOTRAU_LIBS) $(LIBOSMOABIS_LIBS) $(LIBOSMOCTRL_LIBS) $(ORTP_LIBS) -ldl + +bin_PROGRAMS = osmo-bts-omldummy + +osmo_bts_omldummy_SOURCES = main.c bts_model.c +osmo_bts_omldummy_LDADD = $(top_builddir)/src/common/libbts.a $(COMMON_LDADD) diff --git a/src/osmo-bts-omldummy/bts_model.c b/src/osmo-bts-omldummy/bts_model.c new file mode 100644 index 00000000..9ade2c6c --- /dev/null +++ b/src/osmo-bts-omldummy/bts_model.c @@ -0,0 +1,217 @@ +/* (C) 2015 by Harald Welte + * + * 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 . + * + */ + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* TODO: check if dummy method is sufficient, else implement */ +int bts_model_lchan_deactivate(struct gsm_lchan *lchan) +{ + LOGP(DL1C, LOGL_NOTICE, "Unimplemented %s\n", __func__); + return -1; +} + +/* TODO: check if dummy method is sufficient, else implement */ +int osmo_amr_rtp_dec(const uint8_t *rtppayload, int payload_len, uint8_t *cmr, + int8_t *cmi, enum osmo_amr_type *ft, enum osmo_amr_quality *bfi, int8_t *sti) +{ + LOGP(DL1C, LOGL_NOTICE, "Unimplemented %s\n", __func__); + return -1; +} + +int bts_model_trx_close(struct gsm_bts_trx *trx) +{ + LOGP(DL1C, LOGL_NOTICE, "Unimplemented %s\n", __func__); + return 0; +} + +int bts_model_adjst_ms_pwr(struct gsm_lchan *lchan) +{ + LOGP(DL1C, LOGL_NOTICE, "Unimplemented %s\n", __func__); + return 0; +} + +int bts_model_check_oml(struct gsm_bts *bts, uint8_t msg_type, + struct tlv_parsed *old_attr, struct tlv_parsed *new_attr, + void *obj) +{ + return 0; +} + +static uint8_t vbts_set_bts(struct gsm_bts *bts) +{ + struct gsm_bts_trx *trx; + uint8_t tn; + + llist_for_each_entry(trx, &bts->trx_list, list) { + oml_mo_state_chg(&trx->mo, NM_OPSTATE_DISABLED, NM_AVSTATE_OK); + oml_mo_state_chg(&trx->bb_transc.mo, -1, NM_AVSTATE_OK); + + for (tn = 0; tn < TRX_NR_TS; tn++) + oml_mo_state_chg(&trx->ts[tn].mo, NM_OPSTATE_DISABLED, NM_AVSTATE_DEPENDENCY); + + /* report availability of trx to the bts. this will trigger the rsl connection */ + oml_mo_tx_sw_act_rep(&trx->mo); + oml_mo_tx_sw_act_rep(&trx->bb_transc.mo); + } + return 0; +} + +static uint8_t vbts_set_trx(struct gsm_bts_trx *trx) +{ + LOGP(DL1C, LOGL_NOTICE, "Unimplemented %s\n", __func__); + return 0; +} + +static uint8_t vbts_set_ts(struct gsm_bts_trx_ts *ts) +{ + return 0; +} + +int bts_model_apply_oml(struct gsm_bts *bts, struct msgb *msg, + struct tlv_parsed *new_attr, int kind, void *obj) +{ + struct abis_om_fom_hdr *foh = msgb_l3(msg); + int cause = 0; + + switch (foh->msg_type) { + case NM_MT_SET_BTS_ATTR: + cause = vbts_set_bts(obj); + break; + case NM_MT_SET_RADIO_ATTR: + cause = vbts_set_trx(obj); + break; + case NM_MT_SET_CHAN_ATTR: + cause = vbts_set_ts(obj); + break; + } + return oml_fom_ack_nack(msg, cause); +} + +/* MO: TS 12.21 Managed Object */ +int bts_model_opstart(struct gsm_bts *bts, struct gsm_abis_mo *mo, void *obj) +{ + int rc; + + switch (mo->obj_class) { + case NM_OC_RADIO_CARRIER: + case NM_OC_CHANNEL: + case NM_OC_SITE_MANAGER: + case NM_OC_BASEB_TRANSC: + case NM_OC_BTS: + case NM_OC_GPRS_NSE: + case NM_OC_GPRS_CELL: + case NM_OC_GPRS_NSVC: + oml_mo_state_chg(mo, NM_OPSTATE_ENABLED, NM_AVSTATE_OK); + rc = oml_mo_opstart_ack(mo); + break; + default: + rc = oml_mo_opstart_nack(mo, NM_NACK_OBJCLASS_NOTSUPP); + } + return rc; +} + +int bts_model_chg_adm_state(struct gsm_bts *bts, struct gsm_abis_mo *mo, + void *obj, uint8_t adm_state) +{ + mo->nm_state.administrative = adm_state; + return oml_mo_statechg_ack(mo); +} + +int bts_model_trx_deact_rf(struct gsm_bts_trx *trx) +{ + LOGP(DL1C, LOGL_NOTICE, "Unimplemented %s\n", __func__); + return 0; +} + + +int bts_model_change_power(struct gsm_bts_trx *trx, int p_trxout_mdBm) +{ + LOGP(DL1C, LOGL_NOTICE, "Unimplemented %s\n", __func__); + return 0; +} + +int bts_model_ctrl_cmds_install(struct gsm_bts *bts) +{ + LOGP(DL1C, LOGL_NOTICE, "Unimplemented %s\n", __func__); + return 0; +} + +uint32_t trx_get_hlayer1(struct gsm_bts_trx *trx) +{ + return 0; +} + +int bts_model_init(struct gsm_bts *bts) +{ + bts->variant = BTS_OSMO_OMLDUMMY; + return 0; +} + +void bts_model_print_help() +{ +} + +void bts_model_abis_close(struct gsm_bts *bts) +{ + bts_shutdown(bts, "Abis close"); +} + +void bts_model_phy_link_set_defaults(struct phy_link *plink) +{ +} + +void bts_model_phy_instance_set_defaults(struct phy_instance *pinst) +{ +} + +int bts_model_oml_estab(struct gsm_bts *bts) +{ + return 0; +} + +int bts_model_ts_disconnect(struct gsm_bts_trx_ts *ts) +{ + return -ENOTSUP; +} + +int bts_model_ts_connect(struct gsm_bts_trx_ts *ts, enum gsm_phys_chan_config as_pchan) +{ + return -ENOTSUP; +} + +int bts_model_l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap) +{ + return 0; +} diff --git a/src/osmo-bts-omldummy/main.c b/src/osmo-bts-omldummy/main.c new file mode 100644 index 00000000..b9334b1b --- /dev/null +++ b/src/osmo-bts-omldummy/main.c @@ -0,0 +1,52 @@ + +#include +#include +#include +#include +#include + + +int main(int argc, char **argv) +{ + struct gsm_bts *bts; + struct gsm_bts_trx *trx; + struct e1inp_line *line; + int rc, i; + + char *dst_host = argv[1]; + int site_id = atoi(argv[2]); + + tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); + msgb_talloc_ctx_init(tall_bts_ctx, 10*1024); + + bts_log_init(NULL); + + bts = gsm_bts_alloc(tall_bts_ctx, 0); + if (!bts) + exit(1); + bts->ip_access.site_id = site_id; + bts->ip_access.bts_id = 0; + + /* Additional TRXs */ + for (i = 1; i < 8; i++) { + trx = gsm_bts_trx_alloc(bts); + if (!trx) + exit(1); + } + + if (bts_init(bts) < 0) + exit(1); + //btsb = bts_role_bts(bts); + abis_init(bts); + + + line = abis_open(bts, dst_host, "OMLdummy"); + if (!line) + exit(2); + + while (1) { + osmo_select_main(0); + } + + return EXIT_SUCCESS; +} diff --git a/src/osmo-bts-omldummy/respawn.sh b/src/osmo-bts-omldummy/respawn.sh new file mode 100755 index 00000000..b025d433 --- /dev/null +++ b/src/osmo-bts-omldummy/respawn.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +while [ -f /etc/passwd ]; do + ./osmo-bts-omldummy $* + sleep 1 +done -- cgit v1.2.3