gbproxy: Refuse to configure conflicting NSEIs

Currently it is possible to set the secondary SGSN NSEI to the same
value like the (primary) SGSN NSEI. This leads to undefined behaviour
and is hard to recognize.

This patch adds checks to either NSEI configuration command to refuse
conflicting values.

Ticket: OW#1306
Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2014-10-08 13:37:28 +02:00 committed by Holger Hans Peter Freyther
parent 49389178cc
commit cc8856f9d3
1 changed files with 17 additions and 3 deletions

View File

@ -150,9 +150,15 @@ DEFUN(cfg_nsip_sgsn_nsei,
"NSEI to be used in the connection with the SGSN\n"
"The NSEI\n")
{
unsigned int port = atoi(argv[0]);
unsigned int nsei = atoi(argv[0]);
g_cfg->nsip_sgsn_nsei = port;
if (g_cfg->route_to_sgsn2 && g_cfg->nsip_sgsn2_nsei == nsei) {
vty_out(vty, "SGSN NSEI %d conflicts with secondary SGSN NSEI%s",
nsei, VTY_NEWLINE);
return CMD_WARNING;
}
g_cfg->nsip_sgsn_nsei = nsei;
return CMD_SUCCESS;
}
@ -359,8 +365,16 @@ DEFUN(cfg_gbproxy_secondary_sgsn,
"NSEI to be used in the connection with the SGSN\n"
"The NSEI\n")
{
unsigned int nsei = atoi(argv[0]);
if (g_cfg->nsip_sgsn_nsei == nsei) {
vty_out(vty, "Secondary SGSN NSEI %d conflicts with primary SGSN NSEI%s",
nsei, VTY_NEWLINE);
return CMD_WARNING;
}
g_cfg->route_to_sgsn2 = 1;
g_cfg->nsip_sgsn2_nsei = atoi(argv[0]);
g_cfg->nsip_sgsn2_nsei = nsei;
g_cfg->patch_ptmsi = 1;