blob: 84039970d8cad703133d79749aee00f319b59a50 [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
Harald Weltef98a4972010-02-20 17:29:27 +010025#include <osmocore/select.h>
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020026#include <openbsc/gsm_subscriber.h>
27#include <openbsc/abis_rsl.h>
28
29/* our handler */
30static int subscr_cb(unsigned int hook, unsigned int event, struct msgb *msg, void *data, void *param)
31{
32 assert(hook == 101);
33 assert(event == 200);
34 assert(msg == (void*)0x1323L);
35 assert(data == (void*)0x4242L);
36 assert(param == (void*)0x2342L);
37 printf("Reached, didn't crash, test passed\n");
38 return 0;
39}
40
41/* mock object for testing, directly invoke the cb... maybe later through the timer */
42void paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscriber, int type, gsm_cbfn *cbfn, void *data)
43{
44 cbfn(101, 200, (void*)0x1323L, (void*)0x4242L, data);
45}
46
47
Holger Hans Peter Freytheradb6e1c2010-09-18 06:44:24 +080048int main(int argc, char **argv)
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020049{
Harald Welte6bfda782009-06-26 20:30:46 +020050 struct gsm_network *network;
51 struct gsm_bts *bts;
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020052
53 printf("Testing the gsm_subscriber chan logic\n");
54
55 /* Create a dummy network */
Harald Welte6bfda782009-06-26 20:30:46 +020056 network = gsm_network_init(1, 1, NULL);
57 if (!network)
58 exit(1);
59 bts = gsm_bts_alloc(network, GSM_BTS_TYPE_BS11, 0, 0);
60 bts->location_area_code = 23;
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020061
62 /* Create a dummy subscriber */
63 struct gsm_subscriber *subscr = subscr_alloc();
64 subscr->lac = 23;
Holger Hans Peter Freythere4e8bf42009-08-20 13:33:51 +020065 subscr->net = network;
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020066
67 /* Ask for a channel... */
Holger Hans Peter Freythere4e8bf42009-08-20 13:33:51 +020068 subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L);
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020069
70 while (1) {
71 bsc_select_main(0);
72 }
73}
74
75void nm_state_event() {}
76void input_event() {}
Holger Hans Peter Freyther7673ce42009-08-10 06:40:05 +020077void sms_alloc() {}
Holger Hans Peter Freyther78891072010-09-06 09:36:02 +080078void gsm_net_update_ctype(struct gsm_network *network) {}
Holger Hans Peter Freytherd9cdd052010-12-21 13:43:52 +010079void gsm48_secure_channel() {}
Holger Hans Peter Freytherffccb772010-12-28 17:47:43 +010080void paging_request_stop() {}
Holger Hans Peter Freyther763b42a2010-12-29 11:07:22 +010081void vty_out() {}
Holger Hans Peter Freytherd9cdd052010-12-21 13:43:52 +010082
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020083
Holger Hans Peter Freyther98657d52010-01-11 16:42:07 +010084struct tlv_definition nm_att_tlvdef;
85