Check double use of E1 interface and notify, if not defined

E1 interface may be used by one V5 link only.
Also notify user, if not created and application must be restarted when
created.
This commit is contained in:
Andreas Eversberg 2023-01-28 21:42:56 +01:00
parent 3aee692b1c
commit 8b00969b4a
1 changed files with 19 additions and 2 deletions

View File

@ -1,5 +1,6 @@
#include <osmocom/vty/command.h>
#include <osmocom/abis/e1_input.h>
#include "v5x_internal.h"
#include "v5x_protocol.h"
@ -460,9 +461,25 @@ DEFUN(cfg_e1_line, cfg_e1_line_cmd,
"e1 line <0-255>",
"E1 configuration\n" "E1 line configuration\n" "E1 line number to use for link")
{
struct v5x_link *v5l = vty->index;
struct v5x_link *v5l = vty->index, *search_v5l;
struct e1inp_line *e1l;
int e1_line = atoi(argv[0]);
v5l->e1_line = atoi(argv[0]);
llist_for_each_entry(search_v5l, &v5l->interface->links, list) {
if (search_v5l->e1_line < 0)
continue;
if (search_v5l->e1_line == e1_line) {
vty_out(vty, "%%E1 line %d already used by another link ID %d.%s", e1_line, search_v5l->id,
VTY_NEWLINE);
return CMD_WARNING;
}
}
v5l->e1_line = e1_line;
e1l = e1inp_line_find(e1_line);
if (!e1l)
vty_out(vty, "%%E1 line %d is not created. Create it and restart application.%s", e1_line,
VTY_NEWLINE);
return CMD_SUCCESS;
}