From 601a9c7d3266770c4637e909a8578c32c923f21d Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 16 Aug 2011 14:17:49 +0200 Subject: E1 Input: Add VTY command to specify the name of a Line So far, there was no way to set the line->name field at all. --- src/e1_input_vty.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c index d832cc5..1b6ea1f 100644 --- a/src/e1_input_vty.c +++ b/src/e1_input_vty.c @@ -39,9 +39,11 @@ "IPA TCP/IP input" \ "HSL TCP/IP input" +#define E1_LINE_HELP "Configure E1/T1/J1 Line\n" "Line Number\n" + DEFUN(cfg_e1line_driver, cfg_e1_line_driver_cmd, "e1_line <0-255> driver " E1_DRIVER_NAMES, - "Configure E1/T1/J1 Line\n" "Line Number\n" "Set driver for this line\n" + E1_LINE_HELP "Set driver for this line\n" E1_DRIVER_HELP) { struct e1inp_line *line; @@ -61,6 +63,27 @@ DEFUN(cfg_e1line_driver, cfg_e1_line_driver_cmd, return CMD_SUCCESS; } +DEFUN(cfg_e1line_name, cfg_e1_line_name_cmd, + "e1_line <0-255> name .LINE", + E1_LINE_HELP "Set name for this line\n" "Human readable name\n") +{ + struct e1inp_line *line; + int e1_nr = atoi(argv[0]); + + line = e1inp_line_find(e1_nr); + if (!line) { + vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE); + return CMD_WARNING; + } + if (line->name) { + talloc_free((void *)line->name); + line->name = NULL; + } + line->name = talloc_strdup(line, argv[1]); + + return CMD_SUCCESS; +} + DEFUN(cfg_e1inp, cfg_e1inp_cmd, "e1_input", "Configure E1/T1/J1 TDM input\n") @@ -82,6 +105,9 @@ static int e1inp_config_write(struct vty *vty) llist_for_each_entry(line, &e1inp_line_list, list) { vty_out(vty, " e1_line %u driver %s%s", line->num, line->driver->name, VTY_NEWLINE); + if (line->name) + vty_out(vty, " e1_line %u name %s%s", line->num, + line->name, VTY_NEWLINE); } return CMD_SUCCESS; } @@ -97,6 +123,7 @@ int e1inp_vty_init(void) install_element(CONFIG_NODE, &cfg_e1inp_cmd); install_node(&e1inp_node, e1inp_config_write); install_element(L_E1INP_NODE, &cfg_e1_line_driver_cmd); + install_element(L_E1INP_NODE, &cfg_e1_line_name_cmd); return 0; } -- cgit v1.2.3-55-g7522