pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-mgw/+/29809 )
Change subject: mgcp-client: Refactor system keeping old users not calling mgcp_client_pool_config_write() working
......................................................................
mgcp-client: Refactor system keeping old users not calling mgcp_client_pool_config_write() working
Move the regular writing logic to a subfunction, and raise the flag only
on one of them.
This simplifies the code paths but not marking stuff true and false over
the same code path.
Change-Id: I070798863f2bdc253df004a63262d4bcd529348f
---
M src/libosmo-mgcp-client/mgcp_client_vty.c
1 file changed, 24 insertions(+), 22 deletions(-)
Approvals:
Jenkins Builder: Verified
pespin: Looks good to me, approved
diff --git a/src/libosmo-mgcp-client/mgcp_client_vty.c b/src/libosmo-mgcp-client/mgcp_client_vty.c
index 390bacb..4f71e3d 100644
--- a/src/libosmo-mgcp-client/mgcp_client_vty.c
+++ b/src/libosmo-mgcp-client/mgcp_client_vty.c
@@ -368,36 +368,16 @@
vty_init_common(talloc_ctx, node);
}
-/* Deprecated, used for backward compatibility with older users which didn't call
- * mgcp_client_pool_config_write(): */
+/* Mark whether user called mgcp_client_pool_config_write() and hence support new API */
static bool mgcp_client_pool_config_write_called = false;
-static int config_write_pool(struct vty *vty)
-{
- int rc;
- if (mgcp_client_pool_config_write_called)
- return CMD_SUCCESS;
- rc = mgcp_client_pool_config_write(vty, NULL);
- /* mgcp_client_pool_config_write sets this to true, let's reset it */
- mgcp_client_pool_config_write_called = false;
- return rc;
-}
-
-/*! Write out MGCP client config to VTY.
- * \param[in] vty VTY to which we should print.
- * \param[in] indent string used for indentation (e.g. " ").
- If NULL, indentation passed during mgcp_client_pool_vty_init() will be used.
- * \returns CMD_SUCCESS on success, CMD_WARNING on error */
-int mgcp_client_pool_config_write(struct vty *vty, const char *indent)
+static int _mgcp_client_pool_config_write(struct vty *vty, const char *indent)
{
struct mgcp_client_pool *pool = global_mgcp_client_pool;
struct mgcp_client_pool_member *pool_member;
unsigned int subindent_buf_len;
char *subindent;
- /* Tell internal node write function that the user supports calling proper API: */
- mgcp_client_pool_config_write_called = true;
-
if (!indent)
indent = pool->vty_indent ? : "";
subindent_buf_len = strlen(indent) + 1 + 1;
@@ -424,6 +404,28 @@
return CMD_SUCCESS;
}
+/* Deprecated, used for backward compatibility with older users which didn't call
+ * mgcp_client_pool_config_write(): */
+static int config_write_pool(struct vty *vty)
+{
+ if (mgcp_client_pool_config_write_called)
+ return CMD_SUCCESS;
+
+ return _mgcp_client_pool_config_write(vty, NULL);
+}
+
+/*! Write out MGCP client config to VTY.
+ * \param[in] vty VTY to which we should print.
+ * \param[in] indent string used for indentation (e.g. " ").
+ If NULL, indentation passed during mgcp_client_pool_vty_init() will be used.
+ * \returns CMD_SUCCESS on success, CMD_WARNING on error */
+int mgcp_client_pool_config_write(struct vty *vty, const char *indent)
+{
+ /* Tell internal node write function that the user supports calling proper API: */
+ mgcp_client_pool_config_write_called = true;
+ return _mgcp_client_pool_config_write(vty, indent);
+}
+
DEFUN_ATTR(cfg_mgw,
cfg_mgw_cmd, "mgw <0-255>", "Select a MGCP client config to setup\n" "reference number\n", CMD_ATTR_IMMEDIATE)
{
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/29809
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I070798863f2bdc253df004a63262d4bcd529348f
Gerrit-Change-Number: 29809
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: merged
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/29809 )
Change subject: mgcp-client: Refactor system keeping old users not calling mgcp_client_pool_config_write() working
......................................................................
mgcp-client: Refactor system keeping old users not calling mgcp_client_pool_config_write() working
Move the regular writing logic to a subfunction, and raise the flag only
on one of them.
This simplifies the code paths but not marking stuff true and false over
the same code path.
Change-Id: I070798863f2bdc253df004a63262d4bcd529348f
---
M src/libosmo-mgcp-client/mgcp_client_vty.c
1 file changed, 24 insertions(+), 22 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/09/29809/1
diff --git a/src/libosmo-mgcp-client/mgcp_client_vty.c b/src/libosmo-mgcp-client/mgcp_client_vty.c
index 390bacb..4f71e3d 100644
--- a/src/libosmo-mgcp-client/mgcp_client_vty.c
+++ b/src/libosmo-mgcp-client/mgcp_client_vty.c
@@ -368,36 +368,16 @@
vty_init_common(talloc_ctx, node);
}
-/* Deprecated, used for backward compatibility with older users which didn't call
- * mgcp_client_pool_config_write(): */
+/* Mark whether user called mgcp_client_pool_config_write() and hence support new API */
static bool mgcp_client_pool_config_write_called = false;
-static int config_write_pool(struct vty *vty)
-{
- int rc;
- if (mgcp_client_pool_config_write_called)
- return CMD_SUCCESS;
- rc = mgcp_client_pool_config_write(vty, NULL);
- /* mgcp_client_pool_config_write sets this to true, let's reset it */
- mgcp_client_pool_config_write_called = false;
- return rc;
-}
-
-/*! Write out MGCP client config to VTY.
- * \param[in] vty VTY to which we should print.
- * \param[in] indent string used for indentation (e.g. " ").
- If NULL, indentation passed during mgcp_client_pool_vty_init() will be used.
- * \returns CMD_SUCCESS on success, CMD_WARNING on error */
-int mgcp_client_pool_config_write(struct vty *vty, const char *indent)
+static int _mgcp_client_pool_config_write(struct vty *vty, const char *indent)
{
struct mgcp_client_pool *pool = global_mgcp_client_pool;
struct mgcp_client_pool_member *pool_member;
unsigned int subindent_buf_len;
char *subindent;
- /* Tell internal node write function that the user supports calling proper API: */
- mgcp_client_pool_config_write_called = true;
-
if (!indent)
indent = pool->vty_indent ? : "";
subindent_buf_len = strlen(indent) + 1 + 1;
@@ -424,6 +404,28 @@
return CMD_SUCCESS;
}
+/* Deprecated, used for backward compatibility with older users which didn't call
+ * mgcp_client_pool_config_write(): */
+static int config_write_pool(struct vty *vty)
+{
+ if (mgcp_client_pool_config_write_called)
+ return CMD_SUCCESS;
+
+ return _mgcp_client_pool_config_write(vty, NULL);
+}
+
+/*! Write out MGCP client config to VTY.
+ * \param[in] vty VTY to which we should print.
+ * \param[in] indent string used for indentation (e.g. " ").
+ If NULL, indentation passed during mgcp_client_pool_vty_init() will be used.
+ * \returns CMD_SUCCESS on success, CMD_WARNING on error */
+int mgcp_client_pool_config_write(struct vty *vty, const char *indent)
+{
+ /* Tell internal node write function that the user supports calling proper API: */
+ mgcp_client_pool_config_write_called = true;
+ return _mgcp_client_pool_config_write(vty, indent);
+}
+
DEFUN_ATTR(cfg_mgw,
cfg_mgw_cmd, "mgw <0-255>", "Select a MGCP client config to setup\n" "reference number\n", CMD_ATTR_IMMEDIATE)
{
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/29809
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I070798863f2bdc253df004a63262d4bcd529348f
Gerrit-Change-Number: 29809
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/29810 )
Change subject: mgcp-client: Fix no 'mgw ' prefix written in old VTY node
......................................................................
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
---
M src/libosmo-mgcp-client/mgcp_client_vty.c
1 file changed, 12 insertions(+), 9 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/10/29810/1
diff --git a/src/libosmo-mgcp-client/mgcp_client_vty.c b/src/libosmo-mgcp-client/mgcp_client_vty.c
index 4f71e3d..704203c 100644
--- a/src/libosmo-mgcp-client/mgcp_client_vty.c
+++ b/src/libosmo-mgcp-client/mgcp_client_vty.c
@@ -286,33 +286,36 @@
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;
}
--
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/29810
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: Ifbfb71f8864b425c1b842cdee241ce279d17a8ba
Gerrit-Change-Number: 29810
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newchange
Attention is currently required from: pespin.
osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/29801 )
Change subject: Use new mgcp-client VTY commands under mgw node
......................................................................
Patch Set 3: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/29801
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I71e49cb4d6c2fe54a895aab0b0ba5acc4e57c253
Gerrit-Change-Number: 29801
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 19 Oct 2022 15:02:19 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: osmith.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/29798 )
Change subject: Update examples to use mgw pooling VTY commands
......................................................................
Patch Set 2:
(1 comment)
File doc/examples/osmo-bsc/osmo-bsc.cfg:
https://gerrit.osmocom.org/c/osmo-bsc/+/29798/comment/360cc598_0dbe0b92
PS2, Line 23: mgw
> this extra mgw can be removed everywhere now, right?
That's done on the next commit, since they dpeend on different osmo-mgw.git commits.
Much clearer doing it in different steps.
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/29798
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Iff74a9efca2a0a2c38d5ac39df704b2b211fd906
Gerrit-Change-Number: 29798
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 19 Oct 2022 15:02:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: pespin.
osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/29798 )
Change subject: Update examples to use mgw pooling VTY commands
......................................................................
Patch Set 2: Code-Review+1
(1 comment)
File doc/examples/osmo-bsc/osmo-bsc.cfg:
https://gerrit.osmocom.org/c/osmo-bsc/+/29798/comment/267726f2_700a858d
PS2, Line 23: mgw
> this extra mgw can be removed everywhere now, right?
ah that's in the next patch.
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/29798
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Iff74a9efca2a0a2c38d5ac39df704b2b211fd906
Gerrit-Change-Number: 29798
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 19 Oct 2022 15:01:52 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: pespin.
osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/29798 )
Change subject: Update examples to use mgw pooling VTY commands
......................................................................
Patch Set 2:
(1 comment)
File doc/examples/osmo-bsc/osmo-bsc.cfg:
https://gerrit.osmocom.org/c/osmo-bsc/+/29798/comment/18d4a485_7ae6f52d
PS2, Line 23: mgw
this extra mgw can be removed everywhere now, right?
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/29798
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Iff74a9efca2a0a2c38d5ac39df704b2b211fd906
Gerrit-Change-Number: 29798
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 19 Oct 2022 15:01:02 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: pespin.
osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/29797 )
Change subject: vty: Make use of new mgcp_client_pool_config_write() API
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/29797
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ib2f04d96ca846d2d61af0b0c0ea1924609004952
Gerrit-Change-Number: 29797
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Wed, 19 Oct 2022 14:59:42 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment