Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 1 | /* |
| 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 Welte | 6bfda78 | 2009-06-26 20:30:46 +0200 | [diff] [blame] | 22 | #include <stdlib.h> |
Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 23 | |
| 24 | #include <assert.h> |
| 25 | |
| 26 | #include <openbsc/select.h> |
| 27 | #include <openbsc/gsm_subscriber.h> |
| 28 | #include <openbsc/abis_rsl.h> |
| 29 | |
| 30 | /* our handler */ |
| 31 | static 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 */ |
| 43 | void 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 | |
| 49 | int main(int argc, char** argv) |
| 50 | { |
Harald Welte | 6bfda78 | 2009-06-26 20:30:46 +0200 | [diff] [blame] | 51 | struct gsm_network *network; |
| 52 | struct gsm_bts *bts; |
Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 53 | |
| 54 | printf("Testing the gsm_subscriber chan logic\n"); |
| 55 | |
| 56 | /* Create a dummy network */ |
Harald Welte | 6bfda78 | 2009-06-26 20:30:46 +0200 | [diff] [blame] | 57 | 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 Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 62 | |
| 63 | /* Create a dummy subscriber */ |
| 64 | struct gsm_subscriber *subscr = subscr_alloc(); |
| 65 | subscr->lac = 23; |
Holger Hans Peter Freyther | e4e8bf4 | 2009-08-20 13:33:51 +0200 | [diff] [blame] | 66 | subscr->net = network; |
Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 67 | |
| 68 | /* Ask for a channel... */ |
Holger Hans Peter Freyther | e4e8bf4 | 2009-08-20 13:33:51 +0200 | [diff] [blame] | 69 | subscr_get_channel(subscr, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L); |
Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 70 | |
| 71 | while (1) { |
| 72 | bsc_select_main(0); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | void nm_state_event() {} |
| 77 | void input_event() {} |
Holger Hans Peter Freyther | 7673ce4 | 2009-08-10 06:40:05 +0200 | [diff] [blame] | 78 | void sms_alloc() {} |
Holger Hans Peter Freyther | 800d29d | 2009-06-10 12:36:38 +0200 | [diff] [blame] | 79 | |