aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2012-10-24 21:53:40 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2013-04-16 09:17:21 +0200
commit462b7d7158937b51fbb833ea3066e01fe8322f37 (patch)
tree9588a91447f6496c36ea815af62fbc48721061b0 /openbsc/tests
parentc327187259d74cf260c977f165963778de4bedb1 (diff)
nat: We want the remote to respond to our DLCX request
We want to send a TRAP with the MGCP statistics from the NAT and the connected BSC. The BSC endpoint can be either released because of a DLCX from the MGCP CallAgent or the SCCP Connection release on the A-link. This is why we need to queue the statistics when the deleting the endpoint on the BSC. The processing is continued once the response arrives. This code assumes that the response of the DLCX will be sent by the remote side. The current amount of outstanding responses can be seen on the VTY. This assumption is based on the fact that the BSC has already responded to the CRCX and maybe to the MDCX. The MGCP RFC is bended to prefix the transaction identifier with "nat-" to easily detect the response and hand it to the handler. This will then parse the response and generate the TRAP. The current version is v1. We assume that the transaction space is big enough and we will not re-assign the transaction identifier too early.
Diffstat (limited to 'openbsc/tests')
-rw-r--r--openbsc/tests/bsc-nat/Makefile.am1
-rw-r--r--openbsc/tests/bsc-nat/bsc_nat_test.c1
-rw-r--r--openbsc/tests/mgcp/mgcp_test.c25
-rw-r--r--openbsc/tests/mgcp/mgcp_test.ok3
4 files changed, 30 insertions, 0 deletions
diff --git a/openbsc/tests/bsc-nat/Makefile.am b/openbsc/tests/bsc-nat/Makefile.am
index e284851a1..9b71d095c 100644
--- a/openbsc/tests/bsc-nat/Makefile.am
+++ b/openbsc/tests/bsc-nat/Makefile.am
@@ -14,6 +14,7 @@ bsc_nat_test_SOURCES = bsc_nat_test.c \
$(top_srcdir)/src/osmo-bsc_nat/bsc_nat_rewrite.c \
$(top_srcdir)/src/osmo-bsc_nat/bsc_mgcp_utils.c
bsc_nat_test_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
+ $(top_srcdir)/src/libctrl/libctrl.a \
$(top_srcdir)/src/libmgcp/libmgcp.a \
$(top_srcdir)/src/libtrau/libtrau.a \
$(top_srcdir)/src/libcommon/libcommon.a \
diff --git a/openbsc/tests/bsc-nat/bsc_nat_test.c b/openbsc/tests/bsc-nat/bsc_nat_test.c
index 3b5c24e36..c2931f98b 100644
--- a/openbsc/tests/bsc-nat/bsc_nat_test.c
+++ b/openbsc/tests/bsc-nat/bsc_nat_test.c
@@ -514,6 +514,7 @@ static void test_mgcp_ass_tracking(void)
33);
nat->mgcp_cfg = mgcp_config_alloc();
nat->mgcp_cfg->trunk.number_endpoints = 64;
+ mgcp_endpoints_allocate(&nat->mgcp_cfg->trunk);
bsc = bsc_connection_alloc(nat);
bsc->cfg = bsc_config_alloc(nat, "foo");
diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c
index 4dfd2abe3..5565e7316 100644
--- a/openbsc/tests/mgcp/mgcp_test.c
+++ b/openbsc/tests/mgcp/mgcp_test.c
@@ -323,6 +323,30 @@ static void test_packet_loss_calc(void)
}
}
+static void test_mgcp_stats(void)
+{
+ printf("Testing stat parsing\n");
+
+ uint32_t bps, bos, pr, _or, jitter;
+ struct msgb *msg;
+ int loss;
+ int rc;
+
+ msg = create_msg(DLCX_RET);
+ rc = mgcp_parse_stats(msg, &bps, &bos, &pr, &_or, &loss, &jitter);
+ printf("Parsing result: %d\n", rc);
+ if (bps != 0 || bos != 0 || pr != 0 || _or != 0 || loss != 0 || jitter != 0)
+ printf("FAIL: Parsing failed1.\n");
+ msgb_free(msg);
+
+ msg = create_msg("250 7 OK\r\nP: PS=10, OS=20, PR=30, OR=40, PL=-3, JI=40\r\n");
+ rc = mgcp_parse_stats(msg, &bps, &bos, &pr, &_or, &loss, &jitter);
+ printf("Parsing result: %d\n", rc);
+ if (bps != 10 || bos != 20 || pr != 30 || _or != 40 || loss != -3 || jitter != 40)
+ printf("FAIL: Parsing failed2.\n");
+ msgb_free(msg);
+}
+
int main(int argc, char **argv)
{
osmo_init_logging(&log_info);
@@ -331,6 +355,7 @@ int main(int argc, char **argv)
test_retransmission();
test_packet_loss_calc();
test_rqnt_cb();
+ test_mgcp_stats();
printf("Done\n");
return EXIT_SUCCESS;
diff --git a/openbsc/tests/mgcp/mgcp_test.ok b/openbsc/tests/mgcp/mgcp_test.ok
index 224bba8d7..8711e38f2 100644
--- a/openbsc/tests/mgcp/mgcp_test.ok
+++ b/openbsc/tests/mgcp/mgcp_test.ok
@@ -25,4 +25,7 @@ Re-transmitting MDCX3
Testing DLCX
Re-transmitting DLCX
Testing packet loss calculation.
+Testing stat parsing
+Parsing result: 0
+Parsing result: 0
Done