NS_Emulation: Add minimal support for SGSN-side SNS handling

Change-Id: I1edf739d6fd39478f662a28a7d9334ca51c270a3
This commit is contained in:
Harald Welte 2018-07-05 00:01:45 +02:00
parent 8a581d2409
commit 5e514fa3db
3 changed files with 57 additions and 5 deletions

View File

@ -116,7 +116,9 @@ module NS_Emulation {
PortNumber remote_udp_port,
charstring remote_ip,
Nsvci nsvci,
Nsvci nsei
Nsvci nsei,
boolean role_sgsn,
boolean handle_sns
}
private function f_change_state(NseState new_state) runs on NS_CT {
@ -192,6 +194,8 @@ module NS_Emulation {
/* FIXME */
}
[config.role_sgsn and config.handle_sns] as_sns_sgsn();
/* default case of handling unknown PDUs */
[] NSCP.receive(t_NS_RecvFrom(?)) -> value rf {
log("Rx Unexpected NS PDU ", rf.msg," in state ", g_state);
@ -201,6 +205,46 @@ module NS_Emulation {
[] NSCP.receive(ASP_Event:?) -> value evt { NS_SP.send(evt); }
}
/* simple IP Sub-Network Service responder for the SGSN side. This is not a full implementation
* of the protocol, merely sufficient to make the PCU/BSS side happy to proceed */
altstep as_sns_sgsn() runs on NS_CT {
var NS_RecvFrom rf;
[] NSCP.receive(t_NS_RecvFrom(tr_SNS_SIZE(config.nsei))) -> value rf {
/* blindly acknowledge whatever the PCU sends */
NSCP.send(t_NS_Send(g_conn_id, ts_SNS_SIZE_ACK(config.nsei, omit)));
}
[] NSCP.receive(t_NS_RecvFrom(tr_SNS_SIZE(?))) {
setverdict(fail, "SNS-SIZE from unexpected NSEI");
self.stop;
}
[] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG(config.nsei, true,
{tr_SNS_IPv4(config.remote_ip, config.remote_udp_port)}))) -> value rf {
/* blindly acknowledge whatever the PCU sends */
NSCP.send(t_NS_Send(g_conn_id, ts_SNS_CONFIG_ACK(config.nsei, omit)));
/* send a SNS-CONFIG in response and expect a SNS-CONFIG-ACK */
var IP4_Elements v4 := { valueof(ts_SNS_IPv4(config.local_ip, config.local_udp_port)) };
NSCP.send(t_NS_Send(g_conn_id, ts_SNS_CONFIG(config.nsei, true, v4)));
alt {
[] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG_ACK(config.nsei, omit))) {
/* success */
}
[] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG_ACK(config.nsei, ?))) {
setverdict(fail, "Unexpected SNS-CONFIG-NACK");
self.stop;
}
}
}
[] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG(config.nsei, false, ?))) { /* ignore */}
[] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG(config.nsei, true, ?))) {
setverdict(fail, "Unexpected SNS-CONFIG content");
self.stop;
}
[] NSCP.receive(t_NS_RecvFrom(tr_SNS_CONFIG(?, ?, ?))) {
setverdict(fail, "SNS-CONFIG from unexpected NSEI");
self.stop;
}
}
private function f_ScanEvents() runs on NS_CT {
var NsUnitdataRequest ud_req;
var NS_RecvFrom rf;

View File

@ -43,7 +43,9 @@ module PCU_Tests {
remote_udp_port := 21000,
remote_ip := "127.0.0.1",
nsvci := 0,
nsei := 2342
nsei := 2342,
role_sgsn := true,
handle_sns := true
};
}

View File

@ -51,7 +51,9 @@ modulepar {
remote_udp_port := 23000,
remote_ip := "127.0.0.1",
nsvci := 97,
nsei := 96
nsei := 96,
role_sgsn := false,
handle_sns := false
},
{
local_udp_port := 21011,
@ -59,7 +61,9 @@ modulepar {
remote_udp_port := 23000,
remote_ip := "127.0.0.1",
nsvci := 98,
nsei := 97
nsei := 97,
role_sgsn := false,
handle_sns := false
},
{
local_udp_port := 21012,
@ -67,7 +71,9 @@ modulepar {
remote_udp_port := 23000,
remote_ip := "127.0.0.1",
nsvci := 99,
nsei := 98
nsei := 98,
role_sgsn := false,
handle_sns := false
}
};
};