mgcp_trunk: drop "trunk 0" limitation
Due to the internal handling of the trunks it was not possible to allow an E1 trunk that has the ID 0. However this limitation is no longer present, so we now can allow an E1 trunk with ID 0. Change-Id: I302c2007628f607033686e277c407232351e66ad Related: OS#2659
This commit is contained in:
parent
246233d0d4
commit
0653cc8a7c
|
@ -190,7 +190,7 @@ int e1_trunk_nr_from_epname(const char *epname)
|
|||
|
||||
errno = 0;
|
||||
trunk_nr = strtoul(epname + prefix_len, &str_trunk_nr_end, 10);
|
||||
if (errno == ERANGE || trunk_nr > 64 || trunk_nr == 0
|
||||
if (errno == ERANGE || trunk_nr > 64
|
||||
|| epname + prefix_len == str_trunk_nr_end
|
||||
|| str_trunk_nr_end[0] != '/')
|
||||
return -EINVAL;
|
||||
|
@ -217,7 +217,7 @@ struct mgcp_trunk *mgcp_trunk_by_name(const struct mgcp_config *cfg, const char
|
|||
}
|
||||
|
||||
trunk_nr = e1_trunk_nr_from_epname(epname);
|
||||
if (trunk_nr > 0)
|
||||
if (trunk_nr >= 0)
|
||||
return mgcp_trunk_by_num(cfg, MGCP_TRUNK_E1, trunk_nr);
|
||||
|
||||
/* Earlier versions of osmo-mgw were accepting endpoint names
|
||||
|
|
|
@ -866,16 +866,11 @@ ALIAS_DEPRECATED(cfg_mgcp_agent_addr, cfg_mgcp_agent_addr_cmd_old,
|
|||
"IPv4 Address of the callagent\n")
|
||||
|
||||
DEFUN(cfg_mgcp_trunk, cfg_mgcp_trunk_cmd,
|
||||
"trunk <1-64>", "Configure a SS7 trunk\n" "Trunk Nr\n")
|
||||
"trunk <0-64>", "Configure a SS7 trunk\n" "Trunk Nr\n")
|
||||
{
|
||||
struct mgcp_trunk *trunk;
|
||||
int index = atoi(argv[0]);
|
||||
|
||||
/* Due to historical reasons, the trunk id number 0 is reserved for the
|
||||
* virtual trunk. This trunk is configured with separate VTY
|
||||
* parameters, so we restrict the access to trunks with id numbers
|
||||
* greater than 0. */
|
||||
|
||||
trunk = mgcp_trunk_by_num(g_cfg, MGCP_TRUNK_E1, index);
|
||||
if (!trunk) {
|
||||
trunk = mgcp_trunk_alloc(g_cfg, MGCP_TRUNK_E1, index);
|
||||
|
|
|
@ -2124,6 +2124,8 @@ void test_e1_trunk_nr_from_epname()
|
|||
/* Note: e1_trunk_nr_from_epname does not check the text
|
||||
* after the E1 trunk number, after the delimiter
|
||||
* character "/" arbitrary text may follow. */
|
||||
trunk_nr = e1_trunk_nr_from_epname("ds/e1-0/s-1/su16-0");
|
||||
OSMO_ASSERT(trunk_nr == 0);
|
||||
trunk_nr = e1_trunk_nr_from_epname("ds/e1-1/s-1/su16-0");
|
||||
OSMO_ASSERT(trunk_nr == 1);
|
||||
trunk_nr = e1_trunk_nr_from_epname("ds/e1-2/s-2/su16-0");
|
||||
|
@ -2141,8 +2143,6 @@ void test_e1_trunk_nr_from_epname()
|
|||
* trunk number exceeds the valid range or the trunk prefix
|
||||
* is wrong. Also when the delimiter character "/" at the
|
||||
* end of the trunk is wrong the parsing should fail. */
|
||||
trunk_nr = e1_trunk_nr_from_epname("ds/e1-0/s-1/su16-0");
|
||||
OSMO_ASSERT(trunk_nr == -EINVAL);
|
||||
trunk_nr = e1_trunk_nr_from_epname("ds/e1-65/s-1/su16-0");
|
||||
OSMO_ASSERT(trunk_nr == -EINVAL);
|
||||
trunk_nr = e1_trunk_nr_from_epname("ds/e1--1/s-1/su16-0");
|
||||
|
|
Loading…
Reference in New Issue