From f7d557cdf2af0e39d5b9592dcb74d3d1c79030a9 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Fri, 18 Feb 2011 14:30:25 +0100 Subject: 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. --- openbsc/src/osmo-bsc/osmo_bsc_msc.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'openbsc/src/osmo-bsc/osmo_bsc_msc.c') 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 +#include #include #include #include #include #include +#include + #include #include @@ -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) -- cgit v1.2.3