aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/channel
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-06-19 18:06:02 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-06-18 17:46:32 +0200
commit5fd3a2cd21d90027391f14466f737837dd6e6674 (patch)
tree64df9f678640465b060470600c9f2ad7b51e4eab /openbsc/tests/channel
parent9e1721f332d283cc8832d6584cff8297b41101c7 (diff)
Use libvlr in libmsc (large refactoring)
Original libvlr code is by Harald Welte <laforge@gnumonks.org>, polished and tweaked by Neels Hofmeyr <nhofmeyr@sysmocom.de>. This is a long series of development collapsed in one patch. The original history may still be available as branch neels/vlr_orig. TODO: This commit may be split in several smaller changes before merging to master. SMS: The SQL based lookup of SMS for attached subscribers no longer works since the SQL database no longer has the subscriber data. Replace with a round-robin on the SMS recipient MSISDNs paired with a VLR subscriber RAM lookup whether the subscriber is currently attached. If there are many SMS for not-attached subscribers in the SMS database, this will become inefficient: a DB hit returns a pending SMS, the RAM lookup will reveal that the subscriber is not attached, after which the DB is hit for the next SMS. It would become more efficient e.g. by having an MSISDN based hash list for the VLR subscribers and by marking non-attached SMS recipients in the SMS database so that they can be excluded with the SQL query already. There is a sanity limit to do at most 100 db hits per attempt to find a pending SMS. So if there are more than 100 stored SMS waiting for their recipients to actually attach to the MSC, it may take more than one SMS queue trigger to deliver SMS for subscribers that are actually attached. This is not very beautiful, but is merely intended to carry us over to a time when we have a proper separate SMSC entity. Introduce gsm_subscriber_connection ref-counting in libmsc. Related: OS#1592 Change-Id: I702ba504ce2de93507312c28eca8d11f09f4ee8b
Diffstat (limited to 'openbsc/tests/channel')
-rw-r--r--openbsc/tests/channel/Makefile.am1
-rw-r--r--openbsc/tests/channel/channel_test.c74
-rw-r--r--openbsc/tests/channel/channel_test.ok2
3 files changed, 11 insertions, 66 deletions
diff --git a/openbsc/tests/channel/Makefile.am b/openbsc/tests/channel/Makefile.am
index ca470ace4..c7164b475 100644
--- a/openbsc/tests/channel/Makefile.am
+++ b/openbsc/tests/channel/Makefile.am
@@ -26,6 +26,7 @@ channel_test_SOURCES = \
channel_test_LDADD = \
$(top_builddir)/src/libmsc/libmsc.a \
$(top_builddir)/src/libbsc/libbsc.a \
+ $(top_builddir)/src/libvlr/libvlr.a \
$(top_builddir)/src/libcommon-cs/libcommon-cs.a \
$(top_builddir)/src/libcommon/libcommon.a \
$(LIBOSMOCORE_LIBS) \
diff --git a/openbsc/tests/channel/channel_test.c b/openbsc/tests/channel/channel_test.c
index 88293d0a8..f6869691c 100644
--- a/openbsc/tests/channel/channel_test.c
+++ b/openbsc/tests/channel/channel_test.c
@@ -29,68 +29,7 @@
#include <openbsc/abis_rsl.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_subscriber.h>
-
-static int s_end = 0;
-static struct gsm_subscriber_connection s_conn;
-static void *s_data;
-static gsm_cbfn *s_cbfn = NULL;
-
-/* our handler */
-static int subscr_cb(unsigned int hook, unsigned int event, struct msgb *msg, void *data, void *param)
-{
- assert(hook == 101);
- assert(event == 200);
- assert(msg == (void*)0x1323L);
- assert(data == &s_conn);
- assert(param == (void*)0x2342L);
- printf("Reached, didn't crash, test passed\n");
- s_end = true;
- return 0;
-}
-
-/* mock object for testing, directly invoke the cb... maybe later through the timer */
-int paging_request(struct gsm_bts *bts, struct bsc_subscr *bsub, int type, gsm_cbfn *cbfn, void *data)
-{
- s_data = data;
- s_cbfn = cbfn;
-
- /* claim we have patched */
- return 1;
-}
-
-
-void test_request_chan(void)
-{
- struct gsm_network *network;
- struct gsm_bts *bts;
-
- printf("Testing the gsm_subscriber chan logic\n");
-
- /* Create a dummy network */
- network = bsc_network_init(tall_bsc_ctx, 1, 1, NULL);
- if (!network)
- exit(1);
- bts = gsm_bts_alloc(network);
- bts->location_area_code = 23;
- s_conn.network = network;
-
- /* Create a dummy subscriber */
- struct gsm_subscriber *subscr = subscr_alloc();
- subscr->lac = 23;
- subscr->group = network->subscr_group;
-
- OSMO_ASSERT(subscr->group);
- OSMO_ASSERT(subscr->group->net == network);
-
- /* Ask for a channel... */
- struct subscr_request *sr;
- sr = subscr_request_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L);
- OSMO_ASSERT(sr);
- OSMO_ASSERT(s_cbfn);
- s_cbfn(101, 200, (void*)0x1323L, &s_conn, s_data);
-
- OSMO_ASSERT(s_end);
-}
+#include <openbsc/vlr.h>
void test_dyn_ts_subslots(void)
{
@@ -126,7 +65,6 @@ int main(int argc, char **argv)
{
osmo_init_logging(&log_info);
- test_request_chan();
test_dyn_ts_subslots();
return EXIT_SUCCESS;
@@ -140,5 +78,13 @@ void gsm48_secure_channel() {}
void paging_request_stop() {}
void vty_out() {}
-struct tlv_definition nm_att_tlvdef;
+void ipa_client_conn_clear_queue() {}
+void ipa_client_conn_close() {}
+void ipa_client_conn_create() {}
+void ipa_client_conn_destroy() {}
+void ipa_client_conn_open() {}
+void ipa_client_conn_send() {}
+void ipa_msg_push_header() {}
+void ipaccess_bts_handle_ccm() {}
+struct tlv_definition nm_att_tlvdef;
diff --git a/openbsc/tests/channel/channel_test.ok b/openbsc/tests/channel/channel_test.ok
index 33c819350..e4d625a65 100644
--- a/openbsc/tests/channel/channel_test.ok
+++ b/openbsc/tests/channel/channel_test.ok
@@ -1,3 +1 @@
-Testing the gsm_subscriber chan logic
-Reached, didn't crash, test passed
Testing subslot numbers for pchan types