aboutsummaryrefslogtreecommitdiffstats
path: root/src/ctrl/control_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ctrl/control_vty.c')
-rw-r--r--src/ctrl/control_vty.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/ctrl/control_vty.c b/src/ctrl/control_vty.c
index ef988892..a7ebddc2 100644
--- a/src/ctrl/control_vty.c
+++ b/src/ctrl/control_vty.c
@@ -17,10 +17,6 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
*/
#include <stdlib.h>
@@ -30,16 +26,20 @@
static void *ctrl_vty_ctx = NULL;
static const char *ctrl_vty_bind_addr = NULL;
+/* Port the CTRL should bind to: -1 means not configured */
+static int ctrl_bind_port = -1;
DEFUN(cfg_ctrl_bind_addr,
cfg_ctrl_bind_addr_cmd,
- "bind A.B.C.D",
+ "bind A.B.C.D [<0-65535>]",
"Set bind address to listen for Control connections\n"
- "Local IP address (default 127.0.0.1)\n")
+ "Local IP address (default 127.0.0.1)\n"
+ "Local TCP port number\n")
{
talloc_free((char*)ctrl_vty_bind_addr);
ctrl_vty_bind_addr = NULL;
ctrl_vty_bind_addr = talloc_strdup(ctrl_vty_ctx, argv[0]);
+ ctrl_bind_port = argc > 1 ? atoi(argv[1]) : -1;
return CMD_SUCCESS;
}
@@ -50,6 +50,11 @@ const char *ctrl_vty_get_bind_addr(void)
return ctrl_vty_bind_addr;
}
+uint16_t ctrl_vty_get_bind_port(uint16_t default_port)
+{
+ return ctrl_bind_port >= 0 ? ctrl_bind_port : default_port;
+}
+
static struct cmd_node ctrl_node = {
L_CTRL_NODE,
"%s(config-ctrl)# ",
@@ -82,10 +87,10 @@ static int config_write_ctrl(struct vty *vty)
int ctrl_vty_init(void *ctx)
{
ctrl_vty_ctx = ctx;
- install_element(CONFIG_NODE, &cfg_ctrl_cmd);
+ install_lib_element(CONFIG_NODE, &cfg_ctrl_cmd);
install_node(&ctrl_node, config_write_ctrl);
- install_element(L_CTRL_NODE, &cfg_ctrl_bind_addr_cmd);
+ install_lib_element(L_CTRL_NODE, &cfg_ctrl_bind_addr_cmd);
return 0;
}