aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-03-31 07:01:35 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-03-31 07:01:35 +0200
commite14ec0dab48029bb4746b6c49d22a0ee6fa6b47c (patch)
tree0fd35cc7000fdb941c9283316b004fc9f377aa89
parent8252b9b947f332692dd1446d277dffde7bcf9bab (diff)
[mgcp] Handle the RSIP with resetting all endpoints
We could change that the message came from a special ip address/port to secure this service in general but we don't do that right now.
-rw-r--r--openbsc/src/mgcp/mgcp_main.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/openbsc/src/mgcp/mgcp_main.c b/openbsc/src/mgcp/mgcp_main.c
index ff3605bb1..685285110 100644
--- a/openbsc/src/mgcp/mgcp_main.c
+++ b/openbsc/src/mgcp/mgcp_main.c
@@ -38,6 +38,7 @@
#include <openbsc/gsm_data.h>
#include <osmocore/select.h>
#include <openbsc/mgcp.h>
+#include <openbsc/mgcp_internal.h>
#include <openbsc/telnet_interface.h>
#include <vty/command.h>
@@ -54,6 +55,8 @@ void subscr_put() { abort(); }
static struct bsc_fd bfd;
static struct mgcp_config *cfg;
+static int reset_endpoints = 0;
+
const char *openbsc_version = "OpenBSC MGCP " PACKAGE_VERSION;
const char *openbsc_copyright =
"Copyright (C) 2009-2010 Holger Freyther and On-Waves\n"
@@ -116,12 +119,21 @@ static void handle_options(int argc, char** argv)
}
}
+/* simply remember this */
+static int mgcp_rsip_cb(struct mgcp_config *cfg)
+{
+ reset_endpoints = 1;
+
+ return 0;
+}
+
static int read_call_agent(struct bsc_fd *fd, unsigned int what)
{
struct sockaddr_in addr;
socklen_t slen = sizeof(addr);
struct msgb *msg;
struct msgb *resp;
+ int i;
msg = (struct msgb *) fd->data;
@@ -146,6 +158,16 @@ static int read_call_agent(struct bsc_fd *fd, unsigned int what)
sendto(bfd.fd, resp->l2h, msgb_l2len(resp), 0, (struct sockaddr *) &addr, sizeof(addr));
msgb_free(resp);
}
+
+ if (reset_endpoints) {
+ LOGP(DMGCP, LOGL_NOTICE, "Asked to reset endpoints.\n");
+ reset_endpoints = 0;
+
+ /* is checking in_addr.s_addr == INADDR_LOOPBACK making it more secure? */
+ for (i = 1; i < cfg->number_endpoints; ++i)
+ mgcp_free_endp(&cfg->endpoints[i]);
+ }
+
return 0;
}
@@ -175,6 +197,8 @@ int main(int argc, char** argv)
if (rc < 0)
return rc;
+ /* set some callbacks */
+ cfg->reset_cb = mgcp_rsip_cb;
/* we need to bind a socket */
if (rc == 0) {