aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/mgcp/mgcp_vty.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/openbsc/src/mgcp/mgcp_vty.c b/openbsc/src/mgcp/mgcp_vty.c
index 88c097d9c..81cc68b26 100644
--- a/openbsc/src/mgcp/mgcp_vty.c
+++ b/openbsc/src/mgcp/mgcp_vty.c
@@ -37,12 +37,16 @@
static struct mgcp_config *g_cfg = NULL;
-static struct mgcp_trunk_config *find_trunk(struct mgcp_config *cfg, int trunk)
+static struct mgcp_trunk_config *find_trunk(struct mgcp_config *cfg, int nr)
{
- if (trunk != 0)
- return NULL;
+ struct mgcp_trunk_config *trunk;
+
+ if (nr == 0)
+ trunk = &cfg->trunk;
+ else
+ trunk = mgcp_trunk_num(cfg, nr);
- return &cfg->trunk;
+ return trunk;
}
/*
@@ -466,6 +470,12 @@ DEFUN(loop_endp,
return CMD_WARNING;
}
+ if (!trunk->endpoints) {
+ vty_out(vty, "%%Trunk %d has no endpoints allocated.%s",
+ trunk->trunk_nr, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
int endp_no = strtoul(argv[1], NULL, 16);
if (endp_no < 1 || endp_no >= trunk->number_endpoints) {
vty_out(vty, "Loopback number %s/%d is invalid.%s",
@@ -509,6 +519,12 @@ DEFUN(tap_call,
return CMD_WARNING;
}
+ if (!trunk->endpoints) {
+ vty_out(vty, "%%Trunk %d has no endpoints allocated.%s",
+ trunk->trunk_nr, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
int endp_no = strtoul(argv[1], NULL, 16);
if (endp_no < 1 || endp_no >= trunk->number_endpoints) {
vty_out(vty, "Endpoint number %s/%d is invalid.%s",
@@ -554,6 +570,12 @@ DEFUN(free_endp, free_endp_cmd,
return CMD_WARNING;
}
+ if (!trunk->endpoints) {
+ vty_out(vty, "%%Trunk %d has no endpoints allocated.%s",
+ trunk->trunk_nr, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
int endp_no = strtoul(argv[1], NULL, 16);
if (endp_no < 1 || endp_no >= trunk->number_endpoints) {
vty_out(vty, "Endpoint number %s/%d is invalid.%s",