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> |
| 22 | |
| 23 | #include <assert.h> |
| 24 | |
| 25 | #include <openbsc/select.h> |
| 26 | #include <openbsc/gsm_subscriber.h> |
| 27 | #include <openbsc/abis_rsl.h> |
| 28 | |
| 29 | /* our handler */ |
| 30 | static 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 */ |
| 42 | void 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 | |
| 48 | int main(int argc, char** argv) |
| 49 | { |
| 50 | struct gsm_network network; |
| 51 | |
| 52 | printf("Testing the gsm_subscriber chan logic\n"); |
| 53 | |
| 54 | /* Create a dummy network */ |
| 55 | network.bts[0].location_area_code = 23; |
| 56 | network.bts[0].network = &network; |
| 57 | |
| 58 | /* Create a dummy subscriber */ |
| 59 | struct gsm_subscriber *subscr = subscr_alloc(); |
| 60 | subscr->lac = 23; |
| 61 | |
| 62 | /* Ask for a channel... */ |
| 63 | subscr_get_channel(subscr, &network, RSL_CHANNEED_TCH_F, subscr_cb, (void*)0x2342L); |
| 64 | |
| 65 | while (1) { |
| 66 | bsc_select_main(0); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | void nm_state_event() {} |
| 71 | void input_event() {} |
| 72 | |