From 6ea7e777f5edec004da8e82f0f415abb1aee2d48 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 28 Feb 2011 12:32:18 +0100 Subject: mgcp: Implement find_trunk to find the E1 trunks as well. --- openbsc/src/mgcp/mgcp_vty.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'openbsc') 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", -- cgit v1.2.3