aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/utils/bs11_config.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@gnumonks.org>2011-08-17 22:44:07 +0200
committerHarald Welte <laforge@gnumonks.org>2011-08-19 22:38:35 +0200
commited5cacb240b846c106f0fc6a3ab8e8721f4c70a5 (patch)
treeba6bffbf0c95ecc0c50b5335bed77f3a2b29120f /openbsc/src/utils/bs11_config.c
parent7abecfcfc9ef94c1367cd88ac858b79d20f75db0 (diff)
src: port openBSC over libosmo-abisopenbsc/0.9.15
This is a big patch that ports openBSC over libosmo-abis. Sorry, the changes that are included here are all dependent of libosmo-abis, splitting them into smaller pieces would leave the repository in some intermediate state, which is not desired. The main changes are: - The directory libabis/ has been removed as it now lives in libosmo-abis. - new configuration file format for nanoBTS and HSL femto, we need to define the virtual e1_line and attach it to the OML link. - all the existing BTS drivers (nanoBTS, hsl femto, Nokia site, BS11 and rbs2000) now use the new libosmo-abis framework. - use r232 input driver available in libosmo-abis for bs11_config. - use ipa_msg_recv instead of old ipaccess_read_msg function. - delete definition of gsm_e1_subslot and input_signal_data. These structures now lives in libosmo-abis. Most of this patch are deletions of libabis/ which has been moved to libosmo-abis. This patch also modifies openBSC to use all the new definitions available in libosmocore and libosmo-abis. In order to do that, we have replaced the following: - DINP, DMI, DMIB and DMUX by their respective DL* correspondences. - SS_GLOBAL by SS_L_GLOBAL - SS_INPUT by SS_L_INPUT - S_GLOBAL_SHUTDOWN by S_L_GLOBAL_SHUTDOWN - SS_INPUT by SS_L_INPUT - S_INP_* by S_L_INP_* sub-signals - E1INP_NODE by L_E1INP_NODE vty node This patch has been tested with: - one nanoBTS - the HSL femto with the examples available under libosmo-abis - BS11 with both dahdi and misdn drivers.
Diffstat (limited to 'openbsc/src/utils/bs11_config.c')
-rw-r--r--openbsc/src/utils/bs11_config.c58
1 files changed, 48 insertions, 10 deletions
diff --git a/openbsc/src/utils/bs11_config.c b/openbsc/src/utils/bs11_config.c
index ef0107292..e8acb461a 100644
--- a/openbsc/src/utils/bs11_config.c
+++ b/openbsc/src/utils/bs11_config.c
@@ -41,6 +41,12 @@
#include <osmocom/core/select.h>
#include <openbsc/rs232.h>
#include <osmocom/core/application.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/abis/abis.h>
+#include <osmocom/abis/e1_input.h>
+
+static void *tall_bs11cfg_ctx;
+static struct e1inp_sign_link *oml_link;
/* state of our bs11_config application */
enum bs11cfg_state {
@@ -638,8 +644,9 @@ static int handle_state_resp(enum abis_bs11_phase state)
}
/* handle a fully-received message/packet from the RS232 port */
-int handle_serial_msg(struct msgb *rx_msg)
+static int abis_nm_bs11cfg_rcvmsg(struct msgb *rx_msg)
{
+ struct e1inp_sign_link *link = rx_msg->dst;
struct abis_om_hdr *oh;
struct abis_om_fom_hdr *foh;
struct tlv_parsed tp;
@@ -719,6 +726,8 @@ int handle_serial_msg(struct msgb *rx_msg)
perror("ERROR in main loop");
//break;
}
+ /* flush the queue of pending messages to be sent. */
+ abis_nm_queue_send_next(link->trx->bts);
if (rc == 1)
return rc;
@@ -864,11 +873,21 @@ static void signal_handler(int signal)
}
}
+static int bs11cfg_sign_link(struct msgb *msg)
+{
+ msg->dst = oml_link;
+ return abis_nm_bs11cfg_rcvmsg(msg);
+}
+
+struct e1inp_line_ops bs11cfg_e1inp_line_ops = {
+ .sign_link = bs11cfg_sign_link,
+};
+
extern int bts_model_bs11_init(void);
int main(int argc, char **argv)
{
struct gsm_network *gsmnet;
- int rc;
+ struct e1inp_line *line;
osmo_init_logging(&log_info);
handle_options(argc, argv);
@@ -882,11 +901,35 @@ int main(int argc, char **argv)
g_bts = gsm_bts_alloc_register(gsmnet, GSM_BTS_TYPE_BS11, HARDCODED_TSC,
HARDCODED_BSIC);
- rc = rs232_setup(serial_port, delay_ms, g_bts);
- if (rc < 0) {
- fprintf(stderr, "Problem setting up serial port\n");
+ /* Override existing OML callback handler to set our own. */
+ g_bts->model->oml_rcvmsg = abis_nm_bs11cfg_rcvmsg;
+
+ libosmo_abis_init(tall_bs11cfg_ctx);
+
+ /* Initialize virtual E1 line over rs232. */
+ line = talloc_zero(tall_bs11cfg_ctx, struct e1inp_line);
+ if (!line) {
+ fprintf(stderr, "Unable to allocate memory for virtual E1 line\n");
exit(1);
}
+ /* set the serial port. */
+ bs11cfg_e1inp_line_ops.cfg.rs232.port = serial_port;
+ bs11cfg_e1inp_line_ops.cfg.rs232.delay = delay_ms;
+
+ line->driver = e1inp_driver_find("rs232");
+ if (!line->driver) {
+ fprintf(stderr, "cannot find `rs232' driver, giving up.\n");
+ exit(1);
+ }
+ e1inp_line_bind_ops(line, &bs11cfg_e1inp_line_ops);
+
+ /* configure and create signalling link for OML. */
+ e1inp_ts_config_sign(&line->ts[0], line);
+ g_bts->oml_link = oml_link =
+ e1inp_sign_link_create(&line->ts[0], E1INP_SIGN_OML,
+ g_bts->c0, TEI_OML, 0);
+
+ e1inp_line_update(line);
signal(SIGINT, &signal_handler);
@@ -904,8 +947,3 @@ int main(int argc, char **argv)
exit(0);
}
-
-/* dummy to be able to compile */
-void gsm_net_update_ctype(struct gsm_network *net)
-{
-}