aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2017-05-29 13:54:27 +0200
committerHarald Welte <laforge@gnumonks.org>2017-06-09 08:49:36 +0000
commit4a824ca8fcf13427d1560b2c866da2a2d82e3692 (patch)
tree9b85a739ddca384e56959a9bdfe0586d8e987148 /openbsc
parentaef68387ae6d78df948a6b2b3a61050c4f192c5e (diff)
don't re-implement osmo_talloc_replace_string()
osmo_talloc_replace_string() was introducd into libosmocore in 2014, see commit f3c7e85d05f7b2b7bf093162b776f71b2bc6420d There's no reason for us to re-implement this as bsc_replace_string here. Change-Id: I6d2fcaabbc74730f6f491a2b2d5c784ccafc6602
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/include/openbsc/vty.h1
-rw-r--r--openbsc/src/libbsc/bsc_vty.c2
-rw-r--r--openbsc/src/libcommon-cs/common_cs_vty.c4
-rw-r--r--openbsc/src/libcommon/common_vty.c8
-rw-r--r--openbsc/src/libmgcp/mgcp_vty.c24
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_main.c2
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_vty.c18
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c2
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_utils.c2
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_vty.c28
-rw-r--r--openbsc/tests/mgcp/mgcp_test.c2
11 files changed, 42 insertions, 51 deletions
diff --git a/openbsc/include/openbsc/vty.h b/openbsc/include/openbsc/vty.h
index f79eab58..60b7d2d7 100644
--- a/openbsc/include/openbsc/vty.h
+++ b/openbsc/include/openbsc/vty.h
@@ -41,7 +41,6 @@ enum bsc_vty_node {
};
extern int bsc_vty_is_config_node(struct vty *vty, int node);
-extern void bsc_replace_string(void *ctx, char **dst, const char *newstr);
struct log_info;
int bsc_vty_init(struct gsm_network *network);
diff --git a/openbsc/src/libbsc/bsc_vty.c b/openbsc/src/libbsc/bsc_vty.c
index 0ee23907..b05d3d9d 100644
--- a/openbsc/src/libbsc/bsc_vty.c
+++ b/openbsc/src/libbsc/bsc_vty.c
@@ -2946,7 +2946,7 @@ DEFUN(cfg_bts_pcu_sock, cfg_bts_pcu_sock_cmd,
struct gsm_bts *bts = vty->index;
int rc;
- bsc_replace_string(bts, &bts->pcu_sock_path, argv[0]);
+ osmo_talloc_replace_string(bts, &bts->pcu_sock_path, argv[0]);
pcu_sock_exit(bts);
rc = pcu_sock_init(bts->pcu_sock_path, bts);
if (rc < 0) {
diff --git a/openbsc/src/libcommon-cs/common_cs_vty.c b/openbsc/src/libcommon-cs/common_cs_vty.c
index 76336a10..bcc001d5 100644
--- a/openbsc/src/libcommon-cs/common_cs_vty.c
+++ b/openbsc/src/libcommon-cs/common_cs_vty.c
@@ -88,7 +88,7 @@ DEFUN(cfg_net_name_short,
{
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
- bsc_replace_string(gsmnet, &gsmnet->name_short, argv[0]);
+ osmo_talloc_replace_string(gsmnet, &gsmnet->name_short, argv[0]);
return CMD_SUCCESS;
}
@@ -99,7 +99,7 @@ DEFUN(cfg_net_name_long,
{
struct gsm_network *gsmnet = gsmnet_from_vty(vty);
- bsc_replace_string(gsmnet, &gsmnet->name_long, argv[0]);
+ osmo_talloc_replace_string(gsmnet, &gsmnet->name_long, argv[0]);
return CMD_SUCCESS;
}
diff --git a/openbsc/src/libcommon/common_vty.c b/openbsc/src/libcommon/common_vty.c
index 834da516..6e1c10b0 100644
--- a/openbsc/src/libcommon/common_vty.c
+++ b/openbsc/src/libcommon/common_vty.c
@@ -143,11 +143,3 @@ int bsc_vty_is_config_node(struct vty *vty, int node)
return 1;
}
}
-
-/* a talloc string replace routine */
-void bsc_replace_string(void *ctx, char **dst, const char *newstr)
-{
- if (*dst)
- talloc_free(*dst);
- *dst = talloc_strdup(ctx, newstr);
-}
diff --git a/openbsc/src/libmgcp/mgcp_vty.c b/openbsc/src/libmgcp/mgcp_vty.c
index 13f66c50..7d4b2da8 100644
--- a/openbsc/src/libmgcp/mgcp_vty.c
+++ b/openbsc/src/libmgcp/mgcp_vty.c
@@ -261,7 +261,7 @@ DEFUN(cfg_mgcp_local_ip,
IP_STR
"IPv4 Address to use in SDP record\n")
{
- bsc_replace_string(g_cfg, &g_cfg->local_ip, argv[0]);
+ osmo_talloc_replace_string(g_cfg, &g_cfg->local_ip, argv[0]);
return CMD_SUCCESS;
}
@@ -272,7 +272,7 @@ DEFUN(cfg_mgcp_bts_ip,
IP_STR
"IPv4 Address of the BTS\n")
{
- bsc_replace_string(g_cfg, &g_cfg->bts_ip, argv[0]);
+ osmo_talloc_replace_string(g_cfg, &g_cfg->bts_ip, argv[0]);
inet_aton(g_cfg->bts_ip, &g_cfg->bts_in);
return CMD_SUCCESS;
}
@@ -285,7 +285,7 @@ DEFUN(cfg_mgcp_bind_ip,
IP_STR
"IPv4 Address to bind to\n")
{
- bsc_replace_string(g_cfg, &g_cfg->source_addr, argv[0]);
+ osmo_talloc_replace_string(g_cfg, &g_cfg->source_addr, argv[0]);
return CMD_SUCCESS;
}
@@ -403,7 +403,7 @@ DEFUN(cfg_mgcp_rtp_bts_bind_ip,
"rtp bts-bind-ip A.B.C.D",
RTP_STR "Bind endpoints facing the BTS\n" "Address to bind to\n")
{
- bsc_replace_string(g_cfg, &g_cfg->bts_ports.bind_addr, argv[0]);
+ osmo_talloc_replace_string(g_cfg, &g_cfg->bts_ports.bind_addr, argv[0]);
return CMD_SUCCESS;
}
@@ -422,7 +422,7 @@ DEFUN(cfg_mgcp_rtp_net_bind_ip,
"rtp net-bind-ip A.B.C.D",
RTP_STR "Bind endpoints facing the Network\n" "Address to bind to\n")
{
- bsc_replace_string(g_cfg, &g_cfg->net_ports.bind_addr, argv[0]);
+ osmo_talloc_replace_string(g_cfg, &g_cfg->net_ports.bind_addr, argv[0]);
return CMD_SUCCESS;
}
@@ -483,7 +483,7 @@ DEFUN(cfg_mgcp_sdp_fmtp_extra,
if (!txt)
return CMD_WARNING;
- bsc_replace_string(g_cfg, &g_cfg->trunk.audio_fmtp_extra, txt);
+ osmo_talloc_replace_string(g_cfg, &g_cfg->trunk.audio_fmtp_extra, txt);
talloc_free(txt);
return CMD_SUCCESS;
}
@@ -529,7 +529,7 @@ DEFUN(cfg_mgcp_sdp_payload_name,
"sdp audio-payload name NAME",
SDP_STR AUDIO_STR "Name\n" "Payload name\n")
{
- bsc_replace_string(g_cfg, &g_cfg->trunk.audio_name, argv[0]);
+ osmo_talloc_replace_string(g_cfg, &g_cfg->trunk.audio_name, argv[0]);
return CMD_SUCCESS;
}
@@ -714,7 +714,7 @@ DEFUN(cfg_mgcp_agent_addr,
CALL_AGENT_STR IP_STR
"IPv4 Address of the callagent\n")
{
- bsc_replace_string(g_cfg, &g_cfg->call_agent_addr, argv[0]);
+ osmo_talloc_replace_string(g_cfg, &g_cfg->call_agent_addr, argv[0]);
return CMD_SUCCESS;
}
@@ -730,7 +730,7 @@ DEFUN(cfg_mgcp_transcoder,
"Use a MGW to detranscoder RTP\n"
"The IP address of the MGW")
{
- bsc_replace_string(g_cfg, &g_cfg->transcoder_ip, argv[0]);
+ osmo_talloc_replace_string(g_cfg, &g_cfg->transcoder_ip, argv[0]);
inet_aton(g_cfg->transcoder_ip, &g_cfg->transcoder_in);
return CMD_SUCCESS;
@@ -838,7 +838,7 @@ DEFUN(cfg_trunk_sdp_fmtp_extra,
if (!txt)
return CMD_WARNING;
- bsc_replace_string(g_cfg, &trunk->audio_fmtp_extra, txt);
+ osmo_talloc_replace_string(g_cfg, &trunk->audio_fmtp_extra, txt);
talloc_free(txt);
return CMD_SUCCESS;
}
@@ -866,7 +866,7 @@ DEFUN(cfg_trunk_payload_name,
{
struct mgcp_trunk_config *trunk = vty->index;
- bsc_replace_string(g_cfg, &trunk->audio_name, argv[0]);
+ osmo_talloc_replace_string(g_cfg, &trunk->audio_name, argv[0]);
return CMD_SUCCESS;
}
@@ -1289,7 +1289,7 @@ DEFUN(cfg_mgcp_osmux_ip,
"osmux bind-ip A.B.C.D",
OSMUX_STR IP_STR "IPv4 Address to bind to\n")
{
- bsc_replace_string(g_cfg, &g_cfg->osmux_addr, argv[0]);
+ osmo_talloc_replace_string(g_cfg, &g_cfg->osmux_addr, argv[0]);
return CMD_SUCCESS;
}
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c
index 2f0b96de..ee094d67 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_main.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c
@@ -253,7 +253,7 @@ int main(int argc, char **argv)
data = bsc_gsmnet->bsc_data;
if (rf_ctrl)
- bsc_replace_string(data, &data->rf_ctrl_name, rf_ctrl);
+ osmo_talloc_replace_string(data, &data->rf_ctrl_name, rf_ctrl);
data->rf_ctrl = osmo_bsc_rf_create(data->rf_ctrl_name, bsc_gsmnet);
if (!data->rf_ctrl) {
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
index 2336669e..2e2e99bf 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
@@ -230,7 +230,7 @@ DEFUN(cfg_net_bsc_token,
{
struct bsc_msc_data *data = bsc_msc_data(vty);
- bsc_replace_string(osmo_bsc_data(vty), &data->bsc_token, argv[0]);
+ osmo_talloc_replace_string(osmo_bsc_data(vty), &data->bsc_token, argv[0]);
return CMD_SUCCESS;
}
@@ -490,7 +490,7 @@ DEFUN(cfg_net_msc_welcome_ussd,
if (!str)
return CMD_WARNING;
- bsc_replace_string(osmo_bsc_data(vty), &data->ussd_welcome_txt, str);
+ osmo_talloc_replace_string(osmo_bsc_data(vty), &data->ussd_welcome_txt, str);
talloc_free(str);
return CMD_SUCCESS;
}
@@ -518,7 +518,7 @@ DEFUN(cfg_net_msc_lost_ussd,
if (!str)
return CMD_WARNING;
- bsc_replace_string(osmo_bsc_data(vty), &data->ussd_msc_lost_txt, str);
+ osmo_talloc_replace_string(osmo_bsc_data(vty), &data->ussd_msc_lost_txt, str);
talloc_free(str);
return CMD_SUCCESS;
}
@@ -546,7 +546,7 @@ DEFUN(cfg_net_msc_grace_ussd,
if (!str)
return CMD_WARNING;
- bsc_replace_string(osmo_bsc_data(vty), &data->ussd_grace_txt, str);
+ osmo_talloc_replace_string(osmo_bsc_data(vty), &data->ussd_grace_txt, str);
talloc_free(str);
return CMD_SUCCESS;
}
@@ -574,7 +574,7 @@ DEFUN(cfg_net_bsc_missing_msc_ussd,
if (!txt)
return CMD_WARNING;
- bsc_replace_string(data, &data->ussd_no_msc_txt, txt);
+ osmo_talloc_replace_string(data, &data->ussd_no_msc_txt, txt);
talloc_free(txt);
return CMD_SUCCESS;
}
@@ -666,7 +666,7 @@ DEFUN(cfg_msc_acc_lst_name,
{
struct bsc_msc_data *msc = bsc_msc_data(vty);
- bsc_replace_string(msc, &msc->acc_lst_name, argv[0]);
+ osmo_talloc_replace_string(msc, &msc->acc_lst_name, argv[0]);
return CMD_SUCCESS;
}
@@ -695,7 +695,7 @@ DEFUN(cfg_net_bsc_mid_call_text,
if (!txt)
return CMD_WARNING;
- bsc_replace_string(data, &data->mid_call_txt, txt);
+ osmo_talloc_replace_string(data, &data->mid_call_txt, txt);
talloc_free(txt);
return CMD_SUCCESS;
}
@@ -717,7 +717,7 @@ DEFUN(cfg_net_rf_socket,
{
struct osmo_bsc_data *data = osmo_bsc_data(vty);
- bsc_replace_string(data, &data->rf_ctrl_name, argv[0]);
+ osmo_talloc_replace_string(data, &data->rf_ctrl_name, argv[0]);
return CMD_SUCCESS;
}
@@ -749,7 +749,7 @@ DEFUN(cfg_bsc_acc_lst_name,
{
struct osmo_bsc_data *bsc = osmo_bsc_data(vty);
- bsc_replace_string(bsc, &bsc->acc_lst_name, argv[0]);
+ osmo_talloc_replace_string(bsc, &bsc->acc_lst_name, argv[0]);
return CMD_SUCCESS;
}
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
index 34537589..128ea651 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
@@ -362,7 +362,7 @@ static int set_net_cfg_cmd(struct ctrl_cmd *cmd, void *data)
return CTRL_CMD_ERROR;
if (strcmp(bsc_variable, "access-list-name") == 0) {
- bsc_replace_string(bsc_cfg, &bsc_cfg->acc_lst_name, cmd->value);
+ osmo_talloc_replace_string(bsc_cfg, &bsc_cfg->acc_lst_name, cmd->value);
cmd->reply = talloc_asprintf(cmd, "%s",
bsc_cfg->acc_lst_name ? bsc_cfg->acc_lst_name : "");
return CTRL_CMD_REPLY;
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
index bb0f4c4a..c12b29f1 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
@@ -139,7 +139,7 @@ void bsc_nat_free(struct bsc_nat *nat)
void bsc_nat_set_msc_ip(struct bsc_nat *nat, const char *ip)
{
- bsc_replace_string(nat, &nat->main_dest->ip, ip);
+ osmo_talloc_replace_string(nat, &nat->main_dest->ip, ip);
}
struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat)
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
index deb98fcd..a11ae151 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
@@ -479,7 +479,7 @@ DEFUN(cfg_nat_token, cfg_nat_token_cmd,
"Authentication token configuration\n"
"Token of the BSC, currently transferred in cleartext\n")
{
- bsc_replace_string(_nat, &_nat->token, argv[0]);
+ osmo_talloc_replace_string(_nat, &_nat->token, argv[0]);
return CMD_SUCCESS;
}
@@ -502,7 +502,7 @@ DEFUN(cfg_nat_acc_lst_name,
"Set the name of the access list to use.\n"
"The name of the to be used access list.")
{
- bsc_replace_string(_nat, &_nat->acc_lst_name, argv[0]);
+ osmo_talloc_replace_string(_nat, &_nat->acc_lst_name, argv[0]);
return CMD_SUCCESS;
}
@@ -518,11 +518,11 @@ DEFUN(cfg_nat_include,
struct bsc_connection *con1, *con2;
if ('/' == argv[0][0])
- bsc_replace_string(_nat, &_nat->resolved_path, argv[0]);
+ osmo_talloc_replace_string(_nat, &_nat->resolved_path, argv[0]);
else {
path = talloc_asprintf(_nat, "%s/%s", _nat->include_base,
argv[0]);
- bsc_replace_string(_nat, &_nat->resolved_path, path);
+ osmo_talloc_replace_string(_nat, &_nat->resolved_path, path);
talloc_free(path);
}
@@ -538,7 +538,7 @@ DEFUN(cfg_nat_include,
return CMD_WARNING;
}
- bsc_replace_string(_nat, &_nat->include_file, argv[0]);
+ osmo_talloc_replace_string(_nat, &_nat->include_file, argv[0]);
llist_for_each_entry_safe(con1, con2, &_nat->bsc_connections,
list_entry) {
@@ -574,7 +574,7 @@ DEFUN(cfg_nat_imsi_black_list_fn,
"IMSI black listing\n" "Filename IMSI and reject-cause\n")
{
- bsc_replace_string(_nat, &_nat->imsi_black_list_fn, argv[0]);
+ osmo_talloc_replace_string(_nat, &_nat->imsi_black_list_fn, argv[0]);
if (_nat->imsi_black_list_fn) {
int rc;
struct osmo_config_list *rewr = NULL;
@@ -609,7 +609,7 @@ static int replace_rules(struct bsc_nat *nat, char **name,
{
struct osmo_config_list *rewr = NULL;
- bsc_replace_string(nat, name, file);
+ osmo_talloc_replace_string(nat, name, file);
if (*name) {
rewr = osmo_config_list_parse(nat, *name);
bsc_nat_num_rewr_entry_adapt(nat, head, rewr);
@@ -740,7 +740,7 @@ DEFUN(cfg_nat_prefix_trie,
_nat->num_rewr_trie = NULL;
/* replace the file name */
- bsc_replace_string(_nat, &_nat->num_rewr_trie_name, argv[0]);
+ osmo_talloc_replace_string(_nat, &_nat->num_rewr_trie_name, argv[0]);
if (!_nat->num_rewr_trie_name) {
vty_out(vty, "%% prefix-tree no filename is present.%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -789,7 +789,7 @@ DEFUN(cfg_nat_ussd_lst_name,
"Set the name of the access list to check for IMSIs for USSD message\n"
"The name of the access list for HLR USSD handling")
{
- bsc_replace_string(_nat, &_nat->ussd_lst_name, argv[0]);
+ osmo_talloc_replace_string(_nat, &_nat->ussd_lst_name, argv[0]);
return CMD_SUCCESS;
}
@@ -809,7 +809,7 @@ DEFUN(cfg_nat_ussd_token,
"ussd-token TOKEN",
"Set the token used to identify the USSD module\n" "Secret key\n")
{
- bsc_replace_string(_nat, &_nat->ussd_token, argv[0]);
+ osmo_talloc_replace_string(_nat, &_nat->ussd_token, argv[0]);
return CMD_SUCCESS;
}
@@ -818,7 +818,7 @@ DEFUN(cfg_nat_ussd_local,
"ussd-local-ip A.B.C.D",
"Set the IP to listen for the USSD Provider\n" "IP Address\n")
{
- bsc_replace_string(_nat, &_nat->ussd_local, argv[0]);
+ osmo_talloc_replace_string(_nat, &_nat->ussd_local, argv[0]);
return CMD_SUCCESS;
}
@@ -884,7 +884,7 @@ DEFUN(cfg_bsc_token, cfg_bsc_token_cmd, "token TOKEN",
if (strncmp(conf->token, argv[0], 128) != 0)
conf->token_updated = true;
- bsc_replace_string(conf, &conf->token, argv[0]);
+ osmo_talloc_replace_string(conf, &conf->token, argv[0]);
return CMD_SUCCESS;
}
@@ -983,7 +983,7 @@ DEFUN(cfg_bsc_acc_lst_name,
{
struct bsc_config *conf = vty->index;
- bsc_replace_string(conf, &conf->acc_lst_name, argv[0]);
+ osmo_talloc_replace_string(conf, &conf->acc_lst_name, argv[0]);
return CMD_SUCCESS;
}
@@ -1035,7 +1035,7 @@ DEFUN(cfg_bsc_desc,
{
struct bsc_config *conf = vty->index;
- bsc_replace_string(conf, &conf->description, argv[0]);
+ osmo_talloc_replace_string(conf, &conf->description, argv[0]);
return CMD_SUCCESS;
}
diff --git a/openbsc/tests/mgcp/mgcp_test.c b/openbsc/tests/mgcp/mgcp_test.c
index b2d237ef..43a453af 100644
--- a/openbsc/tests/mgcp/mgcp_test.c
+++ b/openbsc/tests/mgcp/mgcp_test.c
@@ -532,7 +532,7 @@ static void test_messages(void)
last_endpoint = -1;
dummy_packets = 0;
- bsc_replace_string(cfg, &cfg->trunk.audio_fmtp_extra, t->extra_fmtp);
+ osmo_talloc_replace_string(cfg, &cfg->trunk.audio_fmtp_extra, t->extra_fmtp);
inp = create_msg(t->req);
msg = mgcp_handle_message(cfg, inp);