aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2017-09-15 13:52:04 +0200
committerDaniel Willmann <dwillmann@sysmocom.de>2018-01-30 18:59:28 +0100
commit7d888c1eb908bfb53c458cd680398542edf01f89 (patch)
tree3b0805bff24da56aefdec290fff97725bdd376a6
parent25201ea5b5d7cdaf72187c7d62e06d05f91d3bd0 (diff)
libmgcp: Pass the pointer to the mgcp list on init, don't copy it
-rw-r--r--openbsc/include/openbsc/bsc_nat.h2
-rw-r--r--openbsc/include/openbsc/mgcp.h2
-rw-r--r--openbsc/src/libmgcp/mgcp_vty.c5
-rw-r--r--openbsc/src/osmo-bsc_mgcp/mgcp_main.c7
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c6
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat.c4
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_utils.c1
7 files changed, 14 insertions, 13 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index 14a41925e..c6085a133 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -265,7 +265,7 @@ struct bsc_nat {
int bsc_ip_dscp;
/* MGCP config */
- struct llist_head mgcp_cfgs;
+ struct llist_head *mgcp_cfgs;
uint8_t mgcp_msg[4096];
int mgcp_length;
int mgcp_ipa;
diff --git a/openbsc/include/openbsc/mgcp.h b/openbsc/include/openbsc/mgcp.h
index cdc6f033c..dbb9ff1ee 100644
--- a/openbsc/include/openbsc/mgcp.h
+++ b/openbsc/include/openbsc/mgcp.h
@@ -243,7 +243,7 @@ struct mgcp_config {
/* config management */
struct mgcp_config *mgcp_config_alloc(void);
struct mgcp_config *mgcp_config_by_num(struct llist_head *configs, int index);
-int mgcp_parse_config(const char *config_file, struct llist_head *cfg,
+int mgcp_parse_config(const char *config_file, struct llist_head **cfg,
enum mgcp_role role);
int mgcp_vty_init(void);
int mgcp_endpoints_allocate(struct mgcp_trunk_config *cfg);
diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c
index e9cfa1b6e..84a2f9661 100644
--- a/openbsc/src/libmgcp/mgcp_vty.c
+++ b/openbsc/src/libmgcp/mgcp_vty.c
@@ -1679,7 +1679,7 @@ static int allocate_trunk(struct mgcp_trunk_config *trunk)
return 0;
}
-int mgcp_parse_config(const char *config_file, struct llist_head *cfgs,
+int mgcp_parse_config(const char *config_file, struct llist_head **cfgs,
enum mgcp_role role)
{
int rc;
@@ -1720,7 +1720,8 @@ int mgcp_parse_config(const char *config_file, struct llist_head *cfgs,
}
cfg->role = role;
}
- memcpy(cfgs, &mgcp_configs, sizeof(struct llist_head));
+
+ *cfgs = &mgcp_configs;
return 0;
}
diff --git a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c
index d6ca0467e..71935a324 100644
--- a/openbsc/src/osmo-bsc_mgcp/mgcp_main.c
+++ b/openbsc/src/osmo-bsc_mgcp/mgcp_main.c
@@ -199,7 +199,7 @@ static struct vty_app_info vty_info = {
int main(int argc, char **argv)
{
- struct llist_head mgcp_cfgs;
+ struct llist_head *mgcp_cfgs;
struct gsm_network dummy_network;
struct sockaddr_in addr;
int on = 1, rc;
@@ -224,10 +224,11 @@ int main(int argc, char **argv)
rc = mgcp_parse_config(config_file, &mgcp_cfgs, MGCP_BSC);
if (rc < 0)
return rc;
- if (llist_empty(&mgcp_cfgs))
+
+ if (llist_empty(mgcp_cfgs))
return -1;
- cfg = llist_entry(mgcp_cfgs.next, struct mgcp_config, entry);
+ cfg = llist_entry(mgcp_cfgs->next, struct mgcp_config, entry);
/* start telnet after reading config for vty_get_bind_addr() */
rc = telnet_init_dynif(tall_bsc_ctx, &dummy_network,
diff --git a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
index 848fcd126..6b57445ab 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c
@@ -258,7 +258,7 @@ void bsc_mgcp_free_endpoints(struct bsc_nat *nat)
int i;
struct mgcp_config *mgcp_cfg;
- llist_for_each_entry(mgcp_cfg, &nat->mgcp_cfgs, entry) {
+ llist_for_each_entry(mgcp_cfg, nat->mgcp_cfgs, entry) {
for (i = 1; i < mgcp_cfg->trunk.number_endpoints; ++i){
bsc_mgcp_free_endpoint(mgcp_cfg, i);
mgcp_release_endp(&mgcp_cfg->trunk.endpoints[i]);
@@ -733,7 +733,7 @@ void bsc_mgcp_forward(struct bsc_connection *bsc, struct msgb *msg)
return;
}
- llist_for_each_entry(mgcp_cfg, &bsc->nat->mgcp_cfgs, entry) {
+ llist_for_each_entry(mgcp_cfg, bsc->nat->mgcp_cfgs, entry) {
mgcp_nat = mgcp_cfg->data;
for (i = 1; i < mgcp_cfg->trunk.number_endpoints; ++i) {
if (mgcp_nat->bsc_endpoints[i].bsc != bsc)
@@ -1175,7 +1175,7 @@ void bsc_mgcp_clear_endpoints_for(struct bsc_connection *bsc)
if (bsc->cfg)
ctr = &bsc->cfg->stats.ctrg->ctr[BCFG_CTR_DROPPED_CALLS];
- llist_for_each_entry(mgcp_cfg, &bsc->nat->mgcp_cfgs, entry) {
+ llist_for_each_entry(mgcp_cfg, bsc->nat->mgcp_cfgs, entry) {
mgcp_nat = mgcp_cfg->data;
for (i = 1; i < mgcp_cfg->trunk.number_endpoints; ++i) {
struct bsc_endpoint *bsc_endp = &mgcp_nat->bsc_endpoints[i];
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index faa65257a..8c4561133 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -1169,7 +1169,7 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
con_msc = con->msc_con;
/* Shortcuts for handling later */
con->msc_conf = msc_config_by_con(bsc->nat, con_msc);
- con->mgcp_conf = mgcp_config_by_num(&bsc->nat->mgcp_cfgs, con->msc_conf->nr);
+ con->mgcp_conf = mgcp_config_by_num(bsc->nat->mgcp_cfgs, con->msc_conf->nr);
con->filter_state.con_type = con_type;
con->filter_state.imsi_checked = filter;
@@ -1660,7 +1660,7 @@ int main(int argc, char **argv)
/*
* Setup the MGCP code..
*/
- if (bsc_mgcp_nat_init(nat, &nat->mgcp_cfgs) != 0)
+ if (bsc_mgcp_nat_init(nat, nat->mgcp_cfgs) != 0)
return -4;
/* start control interface after reading config for
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
index dda679472..5ab5fb38b 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
@@ -87,7 +87,6 @@ struct bsc_nat *bsc_nat_alloc(void)
INIT_LLIST_HEAD(&nat->tpdest_match);
INIT_LLIST_HEAD(&nat->sms_clear_tp_srr);
INIT_LLIST_HEAD(&nat->sms_num_rewr);
- INIT_LLIST_HEAD(&nat->mgcp_cfgs);
nat->stats.sccp.conn = osmo_counter_alloc("nat.sccp.conn");
nat->stats.sccp.calls = osmo_counter_alloc("nat.sccp.calls");