blob: 759001c57ab16acfe44c2a912280eff7f3e32352 [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
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (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 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20
21#include <stdio.h>
Harald Welte6bfda782009-06-26 20:30:46 +020022#include <stdlib.h>
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020023
24#include <assert.h>
25
Harald Weltef98a4972010-02-20 17:29:27 +010026#include <osmocore/select.h>
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020027#include <openbsc/gsm_subscriber.h>
28#include <openbsc/abis_rsl.h>
29
30/* our handler */
31static int subscr_cb(unsigned int hook, unsigned int event, struct msgb *msg, void *data, void *param)
32{
33 assert(hook == 101);
34 assert(event == 200);
35 assert(msg == (void*)0x1323L);
36 assert(data == (void*)0x4242L);
37 assert(param == (void*)0x2342L);
38 printf("Reached, didn't crash, test passed\n");
39 return 0;
40}
41
42/* mock object for testing, directly invoke the cb... maybe later through the timer */
43void paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscriber, int type, gsm_cbfn *cbfn, void *data)
44{
45 cbfn(101, 200, (void*)0x1323L, (void*)0x4242L, data);
46}
47
48
49int main(int argc, char** argv)
50{
Harald Welte6bfda782009-06-26 20:30:46 +020051 struct gsm_network *network;
52 struct gsm_bts *bts;
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020053
54 printf("Testing the gsm_subscriber chan logic\n");
55
56 /* Create a dummy network */
Harald Welte6bfda782009-06-26 20:30:46 +020057 network = gsm_network_init(1, 1, NULL);
58 if (!network)
59 exit(1);
60 bts = gsm_bts_alloc(network, GSM_BTS_TYPE_BS11, 0, 0);
61 bts->location_area_code = 23;
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020062
63 /* Create a dummy subscriber */
64 struct gsm_subscriber *subscr = subscr_alloc();
65 subscr->lac = 23;
Holger Hans Peter Freythere4e8bf42009-08-20 13:33:51 +020066 subscr->net = network;
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020067
68 /* Ask for a channel... */
Holger Hans Peter Freythere4e8bf42009-08-20 13:33:51 +020069 subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L);
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020070
71 while (1) {
72 bsc_select_main(0);
73 }
74}
75
76void nm_state_event() {}
77void input_event() {}
Holger Hans Peter Freyther7673ce42009-08-10 06:40:05 +020078void sms_alloc() {}
Holger Hans Peter Freyther800d29d2009-06-10 12:36:38 +020079
Holger Hans Peter Freyther98657d52010-01-11 16:42:07 +010080struct tlv_definition nm_att_tlvdef;
81