2009-06-10 10:36:38 +00:00
|
|
|
/*
|
|
|
|
* (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2009-06-10 10:36:38 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-06-10 10:36:38 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2009-06-26 18:30:46 +00:00
|
|
|
#include <stdlib.h>
|
2009-06-10 10:36:38 +00:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
2012-01-06 13:06:56 +00:00
|
|
|
#include <osmocom/core/application.h>
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/core/select.h>
|
2012-01-06 13:06:56 +00:00
|
|
|
|
2009-06-10 10:36:38 +00:00
|
|
|
#include <openbsc/abis_rsl.h>
|
2012-01-06 13:06:56 +00:00
|
|
|
#include <openbsc/debug.h>
|
|
|
|
#include <openbsc/gsm_subscriber.h>
|
|
|
|
|
|
|
|
static int s_end = 0;
|
|
|
|
static struct gsm_subscriber_connection s_conn;
|
2015-04-06 10:03:45 +00:00
|
|
|
static void *s_data;
|
2016-03-03 15:12:04 +00:00
|
|
|
static gsm_cbfn *s_cbfn = NULL;
|
2009-06-10 10:36:38 +00:00
|
|
|
|
|
|
|
/* 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);
|
2012-01-06 13:06:56 +00:00
|
|
|
assert(data == &s_conn);
|
2009-06-10 10:36:38 +00:00
|
|
|
assert(param == (void*)0x2342L);
|
|
|
|
printf("Reached, didn't crash, test passed\n");
|
2012-01-06 13:06:56 +00:00
|
|
|
s_end = true;
|
2009-06-10 10:36:38 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* mock object for testing, directly invoke the cb... maybe later through the timer */
|
channel_test: Return a positive number to claim it was paged
This addresses an ASAN issue where the request was already deleted
by our callback function.
(gdb) where
#0 0xb69e7810 in __asan_report_error () from /usr/lib/i386-linux-gnu/libasan.so.0
#1 0xb69e0aff in __asan_report_store4 () from /usr/lib/i386-linux-gnu/libasan.so.0
#2 0x0804ea64 in subscr_send_paging_request (subscr=subscr@entry=0xb5103cb0)
at gsm_subscriber.c:212
#3 0x0804edac in subscr_get_channel (subscr=subscr@entry=0xb5103cb0, type=type@entry=2,
cbfn=cbfn@entry=0x804969d <subscr_cb>, param=param@entry=0x2342) at gsm_subscriber.c:246
#4 0x080498f7 in main (argc=1, argv=0xbffff804) at channel_test.c:77
Breakpoint 3, subscr_paging_dispatch (hooknum=hooknum@entry=101, event=event@entry=200,
msg=msg@entry=0x1323, data=<optimized out>, data@entry=0x8063900 <s_conn>,
param=<optimized out>, param@entry=0xb5103cb0) at gsm_subscriber.c:126
126 llist_del(&request->entry);
(gdb) b llist_del
(gdb) bt
#0 subscr_paging_dispatch (hooknum=hooknum@entry=101, event=event@entry=200,
msg=msg@entry=0x1323, data=<optimized out>, data@entry=0x8063900 <s_conn>,
param=<optimized out>, param@entry=0xb5103cb0) at gsm_subscriber.c:126
#1 0x0804e8a9 in subscr_paging_cb (hooknum=101, event=200, msg=0x1323,
data=0x8063900 <s_conn>, param=0xb5103cb0) at gsm_subscriber.c:187
#2 0x080497e9 in paging_request (bts=0xb5b03e70, subscriber=subscriber@entry=0xb5103cb0,
type=2, cbfn=cbfn@entry=0x804e881 <subscr_paging_cb>, data=data@entry=0xb5103cb0)
at channel_test.c:51
#3 0x0804ea39 in subscr_send_paging_request (subscr=subscr@entry=0xb5103cb0)
at gsm_subscriber.c:207
#4 0x0804edac in subscr_get_channel (subscr=subscr@entry=0xb5103cb0, type=type@entry=2,
cbfn=cbfn@entry=0x804969d <subscr_cb>, param=param@entry=0x2342) at gsm_subscriber.c:246
#5 0x080498f7 in main (argc=1, argv=0xbffff804) at channel_test.c:77
(gdb) q
2014-05-28 14:39:50 +00:00
|
|
|
int paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscriber, int type, gsm_cbfn *cbfn, void *data)
|
2009-06-10 10:36:38 +00:00
|
|
|
{
|
2015-04-06 10:03:45 +00:00
|
|
|
s_data = data;
|
|
|
|
s_cbfn = cbfn;
|
channel_test: Return a positive number to claim it was paged
This addresses an ASAN issue where the request was already deleted
by our callback function.
(gdb) where
#0 0xb69e7810 in __asan_report_error () from /usr/lib/i386-linux-gnu/libasan.so.0
#1 0xb69e0aff in __asan_report_store4 () from /usr/lib/i386-linux-gnu/libasan.so.0
#2 0x0804ea64 in subscr_send_paging_request (subscr=subscr@entry=0xb5103cb0)
at gsm_subscriber.c:212
#3 0x0804edac in subscr_get_channel (subscr=subscr@entry=0xb5103cb0, type=type@entry=2,
cbfn=cbfn@entry=0x804969d <subscr_cb>, param=param@entry=0x2342) at gsm_subscriber.c:246
#4 0x080498f7 in main (argc=1, argv=0xbffff804) at channel_test.c:77
Breakpoint 3, subscr_paging_dispatch (hooknum=hooknum@entry=101, event=event@entry=200,
msg=msg@entry=0x1323, data=<optimized out>, data@entry=0x8063900 <s_conn>,
param=<optimized out>, param@entry=0xb5103cb0) at gsm_subscriber.c:126
126 llist_del(&request->entry);
(gdb) b llist_del
(gdb) bt
#0 subscr_paging_dispatch (hooknum=hooknum@entry=101, event=event@entry=200,
msg=msg@entry=0x1323, data=<optimized out>, data@entry=0x8063900 <s_conn>,
param=<optimized out>, param@entry=0xb5103cb0) at gsm_subscriber.c:126
#1 0x0804e8a9 in subscr_paging_cb (hooknum=101, event=200, msg=0x1323,
data=0x8063900 <s_conn>, param=0xb5103cb0) at gsm_subscriber.c:187
#2 0x080497e9 in paging_request (bts=0xb5b03e70, subscriber=subscriber@entry=0xb5103cb0,
type=2, cbfn=cbfn@entry=0x804e881 <subscr_paging_cb>, data=data@entry=0xb5103cb0)
at channel_test.c:51
#3 0x0804ea39 in subscr_send_paging_request (subscr=subscr@entry=0xb5103cb0)
at gsm_subscriber.c:207
#4 0x0804edac in subscr_get_channel (subscr=subscr@entry=0xb5103cb0, type=type@entry=2,
cbfn=cbfn@entry=0x804969d <subscr_cb>, param=param@entry=0x2342) at gsm_subscriber.c:246
#5 0x080498f7 in main (argc=1, argv=0xbffff804) at channel_test.c:77
(gdb) q
2014-05-28 14:39:50 +00:00
|
|
|
|
|
|
|
/* claim we have patched */
|
|
|
|
return 1;
|
2009-06-10 10:36:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-09-25 13:47:36 +00:00
|
|
|
void test_request_chan(void)
|
2009-06-10 10:36:38 +00:00
|
|
|
{
|
2009-06-26 18:30:46 +00:00
|
|
|
struct gsm_network *network;
|
|
|
|
struct gsm_bts *bts;
|
2009-06-10 10:36:38 +00:00
|
|
|
|
|
|
|
printf("Testing the gsm_subscriber chan logic\n");
|
|
|
|
|
|
|
|
/* Create a dummy network */
|
2016-05-09 17:12:44 +00:00
|
|
|
network = gsm_network_init(tall_bsc_ctx, 1, 1, NULL);
|
2009-06-26 18:30:46 +00:00
|
|
|
if (!network)
|
|
|
|
exit(1);
|
2011-06-26 12:55:06 +00:00
|
|
|
bts = gsm_bts_alloc(network);
|
2009-06-26 18:30:46 +00:00
|
|
|
bts->location_area_code = 23;
|
2009-06-10 10:36:38 +00:00
|
|
|
|
|
|
|
/* Create a dummy subscriber */
|
|
|
|
struct gsm_subscriber *subscr = subscr_alloc();
|
|
|
|
subscr->lac = 23;
|
2014-12-03 08:28:24 +00:00
|
|
|
subscr->group = network->subscr_group;
|
|
|
|
|
|
|
|
OSMO_ASSERT(subscr->group);
|
|
|
|
OSMO_ASSERT(subscr->group->net == network);
|
2009-06-10 10:36:38 +00:00
|
|
|
|
|
|
|
/* Ask for a channel... */
|
2016-03-03 15:12:04 +00:00
|
|
|
struct subscr_request *sr;
|
|
|
|
sr = subscr_request_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L);
|
|
|
|
OSMO_ASSERT(sr);
|
|
|
|
OSMO_ASSERT(s_cbfn);
|
2015-04-06 10:03:45 +00:00
|
|
|
s_cbfn(101, 200, (void*)0x1323L, &s_conn, s_data);
|
2009-06-10 10:36:38 +00:00
|
|
|
|
2015-04-06 10:03:45 +00:00
|
|
|
OSMO_ASSERT(s_end);
|
2016-09-25 13:47:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
osmo_init_logging(&log_info);
|
|
|
|
|
|
|
|
test_request_chan();
|
2012-01-06 13:06:56 +00:00
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
2009-06-10 10:36:38 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 14:55:42 +00:00
|
|
|
void _abis_nm_sendmsg() {}
|
2009-08-10 04:40:05 +00:00
|
|
|
void sms_alloc() {}
|
2013-12-27 19:10:24 +00:00
|
|
|
void sms_free() {}
|
2010-09-06 01:36:02 +00:00
|
|
|
void gsm_net_update_ctype(struct gsm_network *network) {}
|
2010-12-21 12:43:52 +00:00
|
|
|
void gsm48_secure_channel() {}
|
2010-12-28 16:47:43 +00:00
|
|
|
void paging_request_stop() {}
|
2010-12-29 10:07:22 +00:00
|
|
|
void vty_out() {}
|
2013-06-30 13:30:47 +00:00
|
|
|
void* connection_for_subscr(void) { abort(); return NULL; }
|
2010-12-21 12:43:52 +00:00
|
|
|
|
2009-06-10 10:36:38 +00:00
|
|
|
|
2010-01-11 15:42:07 +00:00
|
|
|
struct tlv_definition nm_att_tlvdef;
|
|
|
|
|