aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorDaniel Willmann <daniel@totalueberwachung.de>2011-02-18 14:30:25 +0100
committerHarald Welte <laforge@gnumonks.org>2011-07-13 14:07:10 +0200
commitf7d557cdf2af0e39d5b9592dcb74d3d1c79030a9 (patch)
tree66d75df1d4dd90657b031cd87d66fd55ac692546 /openbsc/src
parente8aef2a84bc6617b733e92d02fe8a9059e656037 (diff)
osmo_bsc: Use libctrl, handle ctrl cmds on port 4249 or from the nat
This patch initializes libctrl to listen for connections on port 4249. Additionally, control messages arriving from the nat will also be processed.
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/osmo-bsc/Makefile.am1
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_main.c4
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_msc.c34
3 files changed, 39 insertions, 0 deletions
diff --git a/openbsc/src/osmo-bsc/Makefile.am b/openbsc/src/osmo-bsc/Makefile.am
index 9a7619ba2..f32705c01 100644
--- a/openbsc/src/osmo-bsc/Makefile.am
+++ b/openbsc/src/osmo-bsc/Makefile.am
@@ -15,4 +15,5 @@ osmo_bsc_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
$(top_builddir)/src/libabis/libabis.a \
$(top_builddir)/src/libtrau/libtrau.a \
$(top_builddir)/src/libcommon/libcommon.a \
+ $(top_builddir)/src/libctrl/libctrl.a \
$(LIBOSMOSCCP_LIBS)
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c
index 42c74cc60..6deed3009 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_main.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c
@@ -50,6 +50,8 @@ static const char *rf_ctl = NULL;
extern const char *openbsc_copyright;
static int daemonize = 0;
+extern void controlif_setup(struct gsm_network *gsmnet, uint16_t port);
+
static void print_usage()
{
printf("Usage: osmo-bsc\n");
@@ -204,6 +206,8 @@ int main(int argc, char **argv)
}
bsc_api_init(bsc_gsmnet, osmo_bsc_api());
+ controlif_setup(bsc_gsmnet, 4249);
+
data = bsc_gsmnet->msc_data;
if (rf_ctl)
bsc_replace_string(data, &data->rf_ctrl_name, rf_ctl);
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_msc.c b/openbsc/src/osmo-bsc/osmo_bsc_msc.c
index 445ce12fe..f4d6cf2eb 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_msc.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_msc.c
@@ -21,12 +21,15 @@
*/
#include <openbsc/bsc_nat.h>
+#include <openbsc/control_cmd.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/ipaccess.h>
#include <openbsc/osmo_msc_data.h>
#include <openbsc/signal.h>
+#include <osmocom/core/talloc.h>
+
#include <osmocom/gsm/gsm0808.h>
#include <osmocom/sccp/sccp.h>
@@ -189,6 +192,35 @@ static int msc_alink_do_write(struct osmo_fd *fd, struct msgb *msg)
return ret;
}
+static void handle_ctrl(struct osmo_msc_data *msc, struct msgb *msg)
+{
+ int ret;
+ struct ctrl_cmd *cmd;
+
+ cmd = ctrl_cmd_parse(msc->msc_con, msg);
+ if (!cmd) {
+ LOGP(DMSC, LOGL_ERROR, "Failed to parse control message.\n");
+ cmd = talloc_zero(msc->msc_con, struct ctrl_cmd);
+ if (!cmd) {
+ LOGP(DMSC, LOGL_ERROR, "OOM!\n");
+ return;
+ }
+ cmd->type = CTRL_TYPE_ERROR;
+ cmd->id = "err";
+ cmd->reply = "Failed to parse control message.";
+
+ ctrl_cmd_send(&msc->msc_con->write_queue, cmd);
+ talloc_free(cmd);
+
+ return;
+ }
+
+ ret = ctrl_cmd_handle(cmd, msc->network);
+ if (ret != CTRL_CMD_HANDLED)
+ ctrl_cmd_send(&msc->msc_con->write_queue, cmd);
+ talloc_free(cmd);
+}
+
static void osmo_ext_handle(struct osmo_msc_data *msc, struct msgb *msg)
{
struct ipaccess_head *hh;
@@ -206,6 +238,8 @@ static void osmo_ext_handle(struct osmo_msc_data *msc, struct msgb *msg)
mgcp_forward(msc, msg);
else if (hh_ext->proto == IPAC_PROTO_EXT_LAC)
send_lacs(msc->network, msc->msc_con);
+ else if (hh_ext->proto == IPAC_PROTO_EXT_CTRL)
+ handle_ctrl(msc, msg);
}
static int ipaccess_a_fd_cb(struct osmo_fd *bfd)