Holger Hans Peter Freyther | 090a4d8 | 2010-06-15 18:48:01 +0800 | [diff] [blame^] | 1 | |
| 2 | /* BSC Multiplexer/NAT Utilities */ |
| 3 | |
| 4 | /* |
| 5 | * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 6 | * (C) 2010 by On-Waves |
| 7 | * All Rights Reserved |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License along |
| 20 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <openbsc/bsc_nat.h> |
| 26 | #include <openbsc/gsm_data.h> |
| 27 | |
| 28 | #include <osmocore/talloc.h> |
| 29 | |
| 30 | struct bsc_nat *bsc_nat_alloc(void) |
| 31 | { |
| 32 | struct bsc_nat *nat = talloc_zero(tall_bsc_ctx, struct bsc_nat); |
| 33 | if (!nat) |
| 34 | return NULL; |
| 35 | |
| 36 | INIT_LLIST_HEAD(&nat->sccp_connections); |
| 37 | INIT_LLIST_HEAD(&nat->bsc_connections); |
| 38 | INIT_LLIST_HEAD(&nat->bsc_configs); |
| 39 | return nat; |
| 40 | } |
| 41 | |
| 42 | struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat) |
| 43 | { |
| 44 | struct bsc_connection *con = talloc_zero(nat, struct bsc_connection); |
| 45 | if (!con) |
| 46 | return NULL; |
| 47 | |
| 48 | return con; |
| 49 | } |
| 50 | |
| 51 | struct bsc_config *bsc_config_alloc(struct bsc_nat *nat, const char *token, unsigned int lac) |
| 52 | { |
| 53 | struct bsc_config *conf = talloc_zero(nat, struct bsc_config); |
| 54 | if (!conf) |
| 55 | return NULL; |
| 56 | |
| 57 | conf->token = talloc_strdup(conf, token); |
| 58 | conf->lac = lac; |
| 59 | conf->nr = nat->num_bsc; |
| 60 | conf->nat = nat; |
| 61 | |
| 62 | llist_add(&conf->entry, &nat->bsc_configs); |
| 63 | ++nat->num_bsc; |
| 64 | |
| 65 | return conf; |
| 66 | } |