blob: ab0d9eb0b719dc9ff787bb8fedf76f03d0b48b79 [file] [log] [blame]
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +02001/*
2 * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01006 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +02008 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010015 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020017 *
18 */
19
20#include <stdio.h>
Harald Welte6bfda782009-06-26 20:30:46 +020021#include <stdlib.h>
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020022
23#include <assert.h>
24
Holger Hans Peter Freyther08e324f2012-01-06 14:06:56 +010025#include <osmocom/core/application.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010026#include <osmocom/core/select.h>
Holger Hans Peter Freyther08e324f2012-01-06 14:06:56 +010027
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020028#include <openbsc/abis_rsl.h>
Holger Hans Peter Freyther08e324f2012-01-06 14:06:56 +010029#include <openbsc/debug.h>
30#include <openbsc/gsm_subscriber.h>
31
32static int s_end = 0;
33static struct gsm_subscriber_connection s_conn;
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020034
35/* our handler */
36static int subscr_cb(unsigned int hook, unsigned int event, struct msgb *msg, void *data, void *param)
37{
38 assert(hook == 101);
39 assert(event == 200);
40 assert(msg == (void*)0x1323L);
Holger Hans Peter Freyther08e324f2012-01-06 14:06:56 +010041 assert(data == &s_conn);
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020042 assert(param == (void*)0x2342L);
43 printf("Reached, didn't crash, test passed\n");
Holger Hans Peter Freyther08e324f2012-01-06 14:06:56 +010044 s_end = true;
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020045 return 0;
46}
47
48/* mock object for testing, directly invoke the cb... maybe later through the timer */
49void paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscriber, int type, gsm_cbfn *cbfn, void *data)
50{
Holger Hans Peter Freyther08e324f2012-01-06 14:06:56 +010051 cbfn(101, 200, (void*)0x1323L, &s_conn, data);
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020052}
53
54
Holger Hans Peter Freytheradb6e1c2010-09-18 06:44:24 +080055int main(int argc, char **argv)
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020056{
Harald Welte6bfda782009-06-26 20:30:46 +020057 struct gsm_network *network;
58 struct gsm_bts *bts;
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020059
Holger Hans Peter Freyther08e324f2012-01-06 14:06:56 +010060 osmo_init_logging(&log_info);
61
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020062 printf("Testing the gsm_subscriber chan logic\n");
63
64 /* Create a dummy network */
Harald Welte6bfda782009-06-26 20:30:46 +020065 network = gsm_network_init(1, 1, NULL);
66 if (!network)
67 exit(1);
Harald Weltee31816c2011-06-26 14:55:06 +020068 bts = gsm_bts_alloc(network);
Harald Welte6bfda782009-06-26 20:30:46 +020069 bts->location_area_code = 23;
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020070
71 /* Create a dummy subscriber */
72 struct gsm_subscriber *subscr = subscr_alloc();
73 subscr->lac = 23;
Holger Hans Peter Freythere4e8bf42009-08-20 13:33:51 +020074 subscr->net = network;
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020075
76 /* Ask for a channel... */
Holger Hans Peter Freythere4e8bf42009-08-20 13:33:51 +020077 subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L);
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020078
Holger Hans Peter Freyther08e324f2012-01-06 14:06:56 +010079 while (!s_end) {
Pablo Neira Ayuso4db92992011-05-06 12:11:23 +020080 osmo_select_main(0);
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020081 }
Holger Hans Peter Freyther08e324f2012-01-06 14:06:56 +010082
83 return EXIT_SUCCESS;
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020084}
85
Harald Weltef338a032011-01-14 15:55:42 +010086void _abis_nm_sendmsg() {}
Holger Hans Peter Freyther7673ce42009-08-10 06:40:05 +020087void sms_alloc() {}
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +080088void gsm_net_update_ctype(struct gsm_network *network) {}
Holger Hans Peter Freytherd9cdd052010-12-21 13:43:52 +010089void gsm48_secure_channel() {}
Holger Hans Peter Freytherffccb772010-12-28 17:47:43 +010090void paging_request_stop() {}
Holger Hans Peter Freyther763b42a2010-12-29 11:07:22 +010091void vty_out() {}
Holger Hans Peter Freythere7bd8632013-06-30 15:30:47 +020092void* connection_for_subscr(void) { abort(); return NULL; }
Holger Hans Peter Freytherd9cdd052010-12-21 13:43:52 +010093
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020094
Holger Hans Peter Freyther98657d52010-01-11 16:42:07 +010095struct tlv_definition nm_att_tlvdef;
96