aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2022-10-18 12:34:20 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2022-10-18 12:44:52 +0200
commitd17a9de79eb7d10160fdcb0499ae2774ff73611f (patch)
tree6934805af5ded8c124986262fe76ad4f584b7bd4 /src
parent8e74c63e15a4ea91a2d764bcad3b329fc1f7cfb2 (diff)
mgcp-client: Convert users supporting new MGW Pool VTY node during write-config
If the user (app) already supports the MGW Pool VTY command set (mgcp_client_pool_vty_init() was called), then if single MGW mode is in use it's because the config file was not updated to use the new MGW Pool node. Let's convert it to the new format to help in transitioning to the new VTY command set. Related: SYS#5987 Change-Id: I2f6658cc66f8bcbd4a60ee2b932bb5dd65888233
Diffstat (limited to 'src')
-rw-r--r--src/libosmo-mgcp-client/mgcp_client_vty.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libosmo-mgcp-client/mgcp_client_vty.c b/src/libosmo-mgcp-client/mgcp_client_vty.c
index 76f8c4ff5..1672f973f 100644
--- a/src/libosmo-mgcp-client/mgcp_client_vty.c
+++ b/src/libosmo-mgcp-client/mgcp_client_vty.c
@@ -285,6 +285,11 @@ static int config_write(struct vty *vty, const char *indent, struct mgcp_client_
* \returns CMD_SUCCESS on success, CMD_WARNING on error */
int mgcp_client_config_write(struct vty *vty, const char *indent)
{
+ /* If caller supports MGW pool API (mgcp_client_pool_vty_init was
+ * called), then skip printing any config in this node and print it when
+ * the whole 'mgw' node is printed. */
+ if (global_mgcp_client_pool)
+ return CMD_SUCCESS;
return config_write(vty, indent, global_mgcp_client_conf);
}
@@ -339,6 +344,16 @@ static int config_write_pool(struct vty *vty)
config_write(vty, indent, &pool_member->conf);
}
+ /* MGW pool API is supported by user (global_mgcp_client_pool is set
+ * because mgcp_client_pool_vty_init was called). If single MGW was
+ * configured through old VTY and no mgw in the new MGW pool VTY is
+ * replacing it, then output the single MGW converted to the new MGW
+ * pool VTY. */
+ if (llist_empty(&pool->member_list) && pool->mgcp_client_single) {
+ vty_out(vty, "%smgw 0%s", pool->vty_indent, VTY_NEWLINE);
+ config_write(vty, indent, global_mgcp_client_conf);
+ }
+
talloc_free(indent);
return CMD_SUCCESS;
}