From 103e50a5610cf0e92ce391853a9a6171379cc36a Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Wed, 19 Oct 2022 17:22:46 +0200 Subject: [PATCH] mgcp-client: Fix no 'mgw ' prefix written in old VTY node Recent commit dropped the 'mgw ' prefix in commands under the "mgw" VTY node because it was redundant. However, for old apps still not supporting the 'mgw' node, the commands are still printed in another node and hence the 'mgw ' prefix must still be appeneded to them, to avoid breaking backward compatibility. Related: SYS#5987 Fixes: 8c138fe89cc070f860eca641481a092225b1247e Change-Id: Ifbfb71f8864b425c1b842cdee241ce279d17a8ba --- src/libosmo-mgcp-client/mgcp_client_vty.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/libosmo-mgcp-client/mgcp_client_vty.c b/src/libosmo-mgcp-client/mgcp_client_vty.c index 4f71e3dcc..704203c45 100644 --- a/src/libosmo-mgcp-client/mgcp_client_vty.c +++ b/src/libosmo-mgcp-client/mgcp_client_vty.c @@ -286,33 +286,36 @@ static int config_write(struct vty *vty, const char *indent, struct mgcp_client_ int port; struct reset_ep *reset_ep; - if (conf->description) + /* If caller doesn't the MGW pool API (mgcp_client_pool_vty_init was never called), + * then the "mgw" cmd prefix must be added since the old node always contained it. + */ + const char *mgw_prefix = global_mgcp_client_pool ? "" : "mgw "; + + if (conf->description) /* description never had "mgw" prefix even on old node: */ vty_out(vty, "%sdescription %s%s", indent, conf->description, VTY_NEWLINE); addr = conf->local_addr; if (addr) - vty_out(vty, "%slocal-ip %s%s", indent, addr, - VTY_NEWLINE); + vty_out(vty, "%s%slocal-ip %s%s", indent, mgw_prefix, addr, VTY_NEWLINE); port = conf->local_port; if (port >= 0) - vty_out(vty, "%slocal-port %u%s", indent, + vty_out(vty, "%s%slocal-port %u%s", indent, mgw_prefix, (uint16_t)port, VTY_NEWLINE); addr = conf->remote_addr; if (addr) - vty_out(vty, "%sremote-ip %s%s", indent, addr, - VTY_NEWLINE); + vty_out(vty, "%s%sremote-ip %s%s", indent, mgw_prefix, addr, VTY_NEWLINE); port = conf->remote_port; if (port >= 0) - vty_out(vty, "%sremote-port %u%s", indent, + vty_out(vty, "%s%sremote-port %u%s", indent, mgw_prefix, (uint16_t)port, VTY_NEWLINE); if (conf->endpoint_domain_name[0]) - vty_out(vty, "%sendpoint-domain %s%s", indent, + vty_out(vty, "%s%sendpoint-domain %s%s", indent, mgw_prefix, conf->endpoint_domain_name, VTY_NEWLINE); llist_for_each_entry(reset_ep, &conf->reset_epnames, list) - vty_out(vty, "%sreset-endpoint %s%s", indent, reset_ep->name, VTY_NEWLINE); + vty_out(vty, "%s%sreset-endpoint %s%s", indent, mgw_prefix, reset_ep->name, VTY_NEWLINE); return CMD_SUCCESS; }