Harald Welte | 52b1f98 | 2008-12-23 20:25:15 +0000 | [diff] [blame] | 1 | /* (C) 2008 by Harald Welte <laforge@gnumonks.org> |
| 2 | * All Rights Reserved |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along |
| 15 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | |
| 21 | #include <stdlib.h> |
| 22 | #include <string.h> |
| 23 | |
| 24 | #include "gsm_data.h" |
| 25 | |
| 26 | struct gsm_network *gsm_network_init(unsigned int num_bts, u_int8_t country_code, |
| 27 | u_int8_t network_code) |
| 28 | { |
| 29 | int i; |
| 30 | struct gsm_network *net; |
| 31 | |
| 32 | if (num_bts > GSM_MAX_BTS) |
| 33 | return NULL; |
| 34 | |
| 35 | net = malloc(sizeof(*net)); |
| 36 | if (!net) |
| 37 | return NULL; |
| 38 | memset(net, 0, sizeof(*net)); |
| 39 | |
| 40 | net->country_code = country_code; |
| 41 | net->network_code = network_code; |
| 42 | net->num_bts = num_bts; |
| 43 | |
| 44 | for (i = 0; i < num_bts; i++) { |
| 45 | struct gsm_bts *bts = &net->bts[i]; |
| 46 | int j; |
| 47 | |
| 48 | bts->network = net; |
| 49 | bts->nr = i; |
| 50 | |
| 51 | for (j = 0; j < BTS_MAX_TRX; j++) { |
| 52 | struct gsm_bts_trx *trx = &bts->trx[j]; |
| 53 | int k; |
| 54 | |
| 55 | trx->bts = bts; |
| 56 | trx->nr = j; |
| 57 | |
| 58 | for (k = 0; k < 8; k++) { |
| 59 | struct gsm_bts_trx_ts *ts = &trx->ts[k]; |
| 60 | |
| 61 | ts->trx = trx; |
| 62 | ts->nr = k; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | bts->num_trx = 1; /* FIXME */ |
| 67 | } |
| 68 | } |