diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2017-02-28 18:05:01 +0100 |
---|---|---|
committer | Daniel Willmann <daniel@totalueberwachung.de> | 2018-01-25 16:35:18 +0100 |
commit | 0167c96cc5d4f51e7b34d92fdb5c226287b77c94 (patch) | |
tree | 945018a609c42f09d6aff4597ab73cfe3119e6c3 /openbsc/src/osmo-bsc_nat | |
parent | a2243aeb67ecf2893ae17dd0fa4197f0627a0aca (diff) |
osmo-bsc_nat: Add functions to alloc/find/free MSC config
Change-Id: I5879d4d9ee0e1a0a6424ee3e9b214afb07319071
Ticket: SYS#3208
Sponsored-by: On-Waves ehf.
Diffstat (limited to 'openbsc/src/osmo-bsc_nat')
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index c12b29f1f..6746518e3 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c @@ -210,6 +210,65 @@ void bsc_config_free(struct bsc_config *cfg) talloc_free(cfg); } +struct msc_config *msc_config_alloc(struct bsc_nat *nat) +{ + struct msc_config *conf = talloc_zero(nat, struct msc_config); + if (!conf) + return NULL; + + conf->main_dest = talloc_zero(conf, struct bsc_msc_dest); + if (!conf->main_dest) { + talloc_free(conf); + return NULL; + } + + conf->nr = nat->num_msc; + conf->nat = nat; + + INIT_LLIST_HEAD(&conf->dests); + + llist_add(&conf->main_dest->list, &conf->dests); + conf->main_dest->ip = talloc_strdup(conf, "127.0.0.1"); + conf->main_dest->port = 5000; + + llist_add_tail(&conf->entry, &nat->msc_configs); + ++nat->num_msc; + + + return conf; +} + +struct msc_config *msc_config_num(struct bsc_nat *nat, int num) +{ + struct msc_config *conf; + + llist_for_each_entry(conf, &nat->msc_configs, entry) + if (conf->nr == num) + return conf; + + return NULL; +} + +struct msc_config *msc_config_by_con(struct bsc_nat *nat, struct bsc_msc_connection *msc_con) +{ + struct msc_config *conf; + + llist_for_each_entry(conf, &nat->msc_configs, entry) + if (conf->msc_con == msc_con) + return conf; + + return NULL; +} + +void msc_config_free(struct msc_config *cfg) +{ + llist_del(&cfg->entry); + + /* Shutdown any connections to the MSC? */ + + talloc_free(cfg); +} + static void _add_lac(void *ctx, struct llist_head *list, int _lac) { struct bsc_lac_entry *lac; |