From 11c316f5dd081d3a695812da2ab1e553ebb3be1b Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Fri, 15 Sep 2017 13:52:04 +0200 Subject: [PATCH] libmgcp: Pass the pointer to the mgcp list on init, don't copy it Change-Id: I2d51589670bb602422ec98521eec620948752e36 --- openbsc/include/openbsc/bsc_nat.h | 2 +- openbsc/include/openbsc/mgcp.h | 2 +- openbsc/src/libmgcp/mgcp_vty.c | 5 +++-- openbsc/src/osmo-bsc_mgcp/mgcp_main.c | 6 +++--- openbsc/src/osmo-bsc_nat/bsc_mgcp_utils.c | 6 +++--- openbsc/src/osmo-bsc_nat/bsc_nat.c | 4 ++-- openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 1 - 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 0531d6e0c..3d240c125 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -260,7 +260,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 e86046886..99d0b9a2f 100644 --- a/openbsc/src/libmgcp/mgcp_vty.c +++ b/openbsc/src/libmgcp/mgcp_vty.c @@ -1681,7 +1681,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; @@ -1722,7 +1722,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 87154c298..08a675120 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,10 @@ int main(int argc, char **argv) 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); rc = telnet_init(tall_bsc_ctx, &dummy_network, OSMO_VTY_PORT_BSC_MGCP); if (rc < 0) 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 c3838542a..ca2d42562 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -1167,7 +1167,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; @@ -1651,7 +1651,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; nat->ctrl = bsc_nat_controlif_setup(nat, 4250); diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index 634f57963..0997aa6f9 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");