aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-03-31 09:16:56 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-03-31 09:16:56 +0200
commit790db1e01b495fa1a54d41d68264d4d8d592c33a (patch)
tree5471849cadfe739409967f6ce95a9d4943472a70
parent81a8975662dcff9c40798ee4b6ff459fd058d1c0 (diff)
nat: In the case of losing the MSC, reset all endpoints
When losing the SCCP connection make sure that we free all endpoints. The disconnection of the BSC should already make sure they are closed but this makes sure everything is properly reset.
-rw-r--r--openbsc/include/openbsc/bsc_nat.h1
-rw-r--r--openbsc/src/nat/bsc_mgcp_utils.c10
-rw-r--r--openbsc/src/nat/bsc_nat.c1
-rw-r--r--openbsc/tests/bsc-nat/Makefile.am2
4 files changed, 14 insertions, 0 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index 835a2ae88..a5d3b1c79 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -179,5 +179,6 @@ struct sccp_connections *patch_sccp_src_ref_to_msc(struct msgb *, struct bsc_nat
int bsc_write_mgcp(struct bsc_connection *bsc, const u_int8_t *data, unsigned int length);
int bsc_mgcp_assign(struct sccp_connections *, struct msgb *msg);
void bsc_mgcp_clear(struct sccp_connections *);
+void bsc_mgcp_free_endpoints(struct bsc_nat *nat);
#endif
diff --git a/openbsc/src/nat/bsc_mgcp_utils.c b/openbsc/src/nat/bsc_mgcp_utils.c
index 55dad380a..38f1abfab 100644
--- a/openbsc/src/nat/bsc_mgcp_utils.c
+++ b/openbsc/src/nat/bsc_mgcp_utils.c
@@ -23,6 +23,8 @@
#include <openbsc/gsm_data.h>
#include <openbsc/bssap.h>
#include <openbsc/debug.h>
+#include <openbsc/mgcp.h>
+#include <openbsc/mgcp_internal.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -64,3 +66,11 @@ void bsc_mgcp_clear(struct sccp_connections *con)
con->msc_timeslot = -1;
con->bsc_timeslot = -1;
}
+
+void bsc_mgcp_free_endpoints(struct bsc_nat *nat)
+{
+ int i;
+
+ for (i = 1; i < nat->mgcp_cfg->number_endpoints; ++i)
+ mgcp_free_endp(&nat->mgcp_cfg->endpoints[i]);
+}
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index b23c3954f..b2fc2c7c9 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -304,6 +304,7 @@ static void msc_connection_was_lost(struct bsc_msc_connection *con)
llist_for_each_entry_safe(bsc, tmp, &nat->bsc_connections, list_entry)
remove_bsc_connection(bsc);
+ bsc_mgcp_free_endpoints(nat);
bsc_msc_schedule_connect(con);
}
diff --git a/openbsc/tests/bsc-nat/Makefile.am b/openbsc/tests/bsc-nat/Makefile.am
index 80fb0046c..5a066a491 100644
--- a/openbsc/tests/bsc-nat/Makefile.am
+++ b/openbsc/tests/bsc-nat/Makefile.am
@@ -10,6 +10,8 @@ bsc_nat_test_SOURCES = bsc_nat_test.c \
$(top_srcdir)/src/nat/bsc_sccp.c \
$(top_srcdir)/src/nat/bsc_nat_utils.c \
$(top_srcdir)/src/nat/bsc_mgcp_utils.c \
+ $(top_srcdir)/src/mgcp/mgcp_protocol.c \
+ $(top_srcdir)/src/mgcp/mgcp_network.c \
$(top_srcdir)/src/bssap.c
bsc_nat_test_LDADD = $(top_builddir)/src/libbsc.a $(top_builddir)/src/libsccp.a $(LIBOSMOCORE_LIBS)