Osmocom_Gb_Types: Differentiate send (value) and receive templates

Change-Id: I90400c42d3dff0a1de0022320d76f10ac748a206
This commit is contained in:
Harald Welte 2018-06-30 10:27:06 +02:00
parent a7377d8c74
commit 387ab37dfd
2 changed files with 96 additions and 34 deletions

View File

@ -127,7 +127,7 @@ module NS_Emulation {
}
private function f_sendReset() runs on NS_CT {
NSCP.send(t_NS_Send(g_conn_id, t_NS_RESET(NS_CAUSE_OM_INTERVENTION, config.nsvci, config.nsei)));
NSCP.send(t_NS_Send(g_conn_id, ts_NS_RESET(NS_CAUSE_OM_INTERVENTION, config.nsvci, config.nsei)));
g_state := NSE_S_WAIT_RESET;
}
@ -142,7 +142,7 @@ module NS_Emulation {
}
private function f_sendBlock(NsCause cause) runs on NS_CT {
NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK(cause, config.nsvci)));
NSCP.send(t_NS_Send(g_conn_id, ts_NS_BLOCK(cause, config.nsvci)));
Tns_block.start;
}
@ -175,19 +175,19 @@ module NS_Emulation {
}
/* Respond to BLOCK for wrong NSVCI */
[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, ?))) -> value rf {
[] NSCP.receive(t_NS_RecvFrom(tr_NS_BLOCK(?, ?))) -> value rf {
log("Rx NS-BLOCK for unknown NSVCI");
/* FIXME */
}
/* Respond to RESET with correct NSEI/NSVCI */
[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET(?, config.nsvci, config.nsei))) -> value rf {
[] NSCP.receive(t_NS_RecvFrom(tr_NS_RESET(?, config.nsvci, config.nsei))) -> value rf {
f_change_state(NSE_S_ALIVE_BLOCKED);
NSCP.send(t_NS_Send(g_conn_id, t_NS_RESET_ACK(config.nsvci, config.nsei)));
NSCP.send(t_NS_Send(g_conn_id, ts_NS_RESET_ACK(config.nsvci, config.nsei)));
}
/* Respond to RESET with wrong NSEI/NSVCI */
[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET(?, ?, ?))) -> value rf {
[] NSCP.receive(t_NS_RecvFrom(tr_NS_RESET(?, ?, ?))) -> value rf {
log("Rx NS-RESET for unknown NSEI/NSVCI");
/* FIXME */
}
@ -215,7 +215,7 @@ module NS_Emulation {
}
} else if (g_state == NSE_S_WAIT_RESET) {
alt {
[] NSCP.receive(t_NS_RecvFrom(t_NS_RESET_ACK(config.nsvci, config.nsei))) -> value rf {
[] NSCP.receive(t_NS_RecvFrom(tr_NS_RESET_ACK(config.nsvci, config.nsei))) -> value rf {
f_change_state(NSE_S_ALIVE_BLOCKED);
f_sendAlive();
f_sendUnblock();
@ -224,8 +224,8 @@ module NS_Emulation {
} else if (g_state == NSE_S_ALIVE_BLOCKED) {
alt {
/* bogus block, just respond with ACK */
[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, config.nsvci))) -> value rf {
NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK_ACK(config.nsvci)));
[] NSCP.receive(t_NS_RecvFrom(tr_NS_BLOCK(?, config.nsvci))) -> value rf {
NSCP.send(t_NS_Send(g_conn_id, ts_NS_BLOCK_ACK(config.nsvci)));
}
/* Respond to UNBLOCK with UNBLOCK-ACK + change state */
[] NSCP.receive(t_NS_RecvFrom(t_NS_UNBLOCK)) -> value rf {
@ -249,16 +249,16 @@ module NS_Emulation {
NSCP.send(t_NS_Send(g_conn_id, t_NS_UNBLOCK_ACK));
}
/* Respond to BLOCK with BLOCK-ACK + change state */
[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK(?, config.nsvci))) -> value rf {
NSCP.send(t_NS_Send(g_conn_id, t_NS_BLOCK_ACK(config.nsvci)));
[] NSCP.receive(t_NS_RecvFrom(tr_NS_BLOCK(?, config.nsvci))) -> value rf {
NSCP.send(t_NS_Send(g_conn_id, ts_NS_BLOCK_ACK(config.nsvci)));
Tns_block.stop;
f_change_state(NSE_S_ALIVE_BLOCKED);
}
[] NSCP.receive(t_NS_RecvFrom(t_NS_BLOCK_ACK(config.nsvci))) -> value rf {
[] NSCP.receive(t_NS_RecvFrom(tr_NS_BLOCK_ACK(config.nsvci))) -> value rf {
Tns_block.stop;
}
/* NS-UNITDATA PDU from network to NS-UNITDATA.ind to user */
[] NSCP.receive(t_NS_RecvFrom(t_NS_UNITDATA(?, ?, ?))) -> value rf {
[] NSCP.receive(t_NS_RecvFrom(tr_NS_UNITDATA(?, ?, ?))) -> value rf {
NS_SP.send(t_NsUdInd(config.nsei,
oct2int(rf.msg.pDU_NS_Unitdata.bVCI),
rf.msg.pDU_NS_Unitdata.nS_SDU));
@ -266,12 +266,12 @@ module NS_Emulation {
/* NS-UNITDATA.req from user to NS-UNITDATA PDU on network */
[] NS_SP.receive(t_NsUdReq(config.nsei, ?, ?, omit)) -> value ud_req {
/* using raw octetstring PDU */
NSCP.send(t_NS_Send(g_conn_id, t_NS_UNITDATA(t_SduCtrlB, ud_req.bvci, ud_req.sdu)));
NSCP.send(t_NS_Send(g_conn_id, ts_NS_UNITDATA(t_SduCtrlB, ud_req.bvci, ud_req.sdu)));
}
[] NS_SP.receive(t_NsUdReq(config.nsei, ?, omit, ?)) -> value ud_req {
/* using decoded BSSGP PDU that we need to encode first */
var octetstring enc := enc_PDU_BSSGP(ud_req.bssgp);
NSCP.send(t_NS_Send(g_conn_id, t_NS_UNITDATA(t_SduCtrlB, ud_req.bvci, enc)));
NSCP.send(t_NS_Send(g_conn_id, ts_NS_UNITDATA(t_SduCtrlB, ud_req.bvci, enc)));
}
}
}

View File

@ -67,13 +67,22 @@ module Osmocom_Gb_Types {
NS_CAUSE_IP_TEST_FAILEDA ('00010100'B)
} with { variant "FIELDLENGTH(8)" };
template NS_SDU_ControlBits t_SduCtrlB := {
template (value) NS_SDU_ControlBits t_SduCtrlB := {
rBit := '0'B,
cBit := '0'B,
spare := '000000'B
}
function t_NS_IE_CAUSE(template NsCause cause) return template CauseNS {
template (value) CauseNS ts_NS_IE_CAUSE(NsCause cause) := {
iEI := '00'O,
ext := '1'B,
lengthIndicator := {
length1 := 1
},
cause := int2oct(enum2int(valueof(cause)), 1)
}
function tr_NS_IE_CAUSE(template NsCause cause) return template CauseNS {
var template CauseNS ret;
ret.iEI := '00'O;
ret.ext := '1'B;
@ -94,7 +103,15 @@ module Osmocom_Gb_Types {
}
}
template NS_VCI t_NS_IE_NSVCI(template Nsvci nsvci) := {
template (value) NS_VCI ts_NS_IE_NSVCI(Nsvci nsvci) := {
iEI := '01'O,
ext := '1'B,
lengthIndicator := {
length1 := 2
},
nS_VCI := int2oct(nsvci, 2)
}
template NS_VCI tr_NS_IE_NSVCI(template Nsvci nsvci) := {
iEI := '01'O,
ext := '1'B,
lengthIndicator := {
@ -103,7 +120,15 @@ module Osmocom_Gb_Types {
nS_VCI := f_oct_or_wc(nsvci, 2)
}
template NSEI_NS t_NS_IE_NSEI(template Nsei nsei) := {
template (value) NSEI_NS ts_NS_IE_NSEI(Nsei nsei) := {
iEI:= '04'O,
ext := '1'B,
lengthIndicator := {
length1 := 2
},
nSEI := int2oct(nsei, 2)
}
template NSEI_NS tr_NS_IE_NSEI(template Nsei nsei) := {
iEI:= '04'O,
ext := '1'B,
lengthIndicator := {
@ -112,35 +137,64 @@ module Osmocom_Gb_Types {
nSEI := f_oct_or_wc(nsei, 2)
}
template PDU_NS t_NS_RESET(template NsCause cause, template Nsvci nsvci, template Nsei nsei) := {
template (value) PDU_NS ts_NS_RESET(NsCause cause, Nsvci nsvci, Nsei nsei) := {
pDU_NS_Reset := {
nsPduType := '02'O,
causeNS := t_NS_IE_CAUSE(cause),
nS_VCI := t_NS_IE_NSVCI(nsvci),
nSEI_NS := t_NS_IE_NSEI(nsei)
causeNS := ts_NS_IE_CAUSE(cause),
nS_VCI := ts_NS_IE_NSVCI(nsvci),
nSEI_NS := ts_NS_IE_NSEI(nsei)
}
}
template PDU_NS tr_NS_RESET(template NsCause cause, template Nsvci nsvci, template Nsei nsei) := {
pDU_NS_Reset := {
nsPduType := '02'O,
causeNS := tr_NS_IE_CAUSE(cause),
nS_VCI := tr_NS_IE_NSVCI(nsvci),
nSEI_NS := tr_NS_IE_NSEI(nsei)
}
}
template PDU_NS t_NS_RESET_ACK(template Nsvci nsvci, template Nsei nsei) := {
template (value) PDU_NS ts_NS_RESET_ACK(Nsvci nsvci, Nsei nsei) := {
pDU_NS_Reset_Ack := {
nsPduType := '03'O,
nS_VCI := t_NS_IE_NSVCI(nsvci),
nSEI_NS := t_NS_IE_NSEI(nsei)
nS_VCI := ts_NS_IE_NSVCI(nsvci),
nSEI_NS := ts_NS_IE_NSEI(nsei)
}
}
template PDU_NS tr_NS_RESET_ACK(template Nsvci nsvci, template Nsei nsei) := {
pDU_NS_Reset_Ack := {
nsPduType := '03'O,
nS_VCI := tr_NS_IE_NSVCI(nsvci),
nSEI_NS := tr_NS_IE_NSEI(nsei)
}
}
template PDU_NS t_NS_BLOCK(template NsCause cause, template Nsvci nsvci) := {
template (value) PDU_NS ts_NS_BLOCK(NsCause cause, Nsvci nsvci) := {
pDU_NS_Block := {
nsPduType := '04'O,
causeNS := t_NS_IE_CAUSE(cause),
nS_VCI := t_NS_IE_NSVCI(nsvci)
causeNS := ts_NS_IE_CAUSE(cause),
nS_VCI := ts_NS_IE_NSVCI(nsvci)
}
}
template PDU_NS tr_NS_BLOCK(template NsCause cause, template Nsvci nsvci) := {
pDU_NS_Block := {
nsPduType := '04'O,
causeNS := tr_NS_IE_CAUSE(cause),
nS_VCI := tr_NS_IE_NSVCI(nsvci)
}
}
template PDU_NS t_NS_BLOCK_ACK(template Nsvci nsvci) := {
template (value) PDU_NS ts_NS_BLOCK_ACK(Nsvci nsvci) := {
pDU_NS_Block_Ack := {
nsPduType := '05'O,
nS_VCI := t_NS_IE_NSVCI(nsvci)
nS_VCI := ts_NS_IE_NSVCI(nsvci)
}
}
template PDU_NS tr_NS_BLOCK_ACK(template Nsvci nsvci) := {
pDU_NS_Block_Ack := {
nsPduType := '05'O,
nS_VCI := tr_NS_IE_NSVCI(nsvci)
}
}
@ -168,10 +222,10 @@ module Osmocom_Gb_Types {
}
}
template PDU_NS ts_NS_STATUS(NsCause cause, PDU_NS pdu) := {
template (value) PDU_NS ts_NS_STATUS(NsCause cause, PDU_NS pdu) := {
pDU_NS_Status := {
nsPduType := '08'O,
causeNS := t_NS_IE_CAUSE(cause),
causeNS := ts_NS_IE_CAUSE(cause),
nS_VCI := omit,
nS_PDU := {
iEI := '02'O,
@ -187,7 +241,15 @@ module Osmocom_Gb_Types {
}
}
template PDU_NS t_NS_UNITDATA(template NS_SDU_ControlBits bits, template BssgpBvci bvci, template
template (value) PDU_NS ts_NS_UNITDATA(template (value) NS_SDU_ControlBits bits, BssgpBvci bvci, octetstring sdu) := {
pDU_NS_Unitdata := {
nsPduType := '00'O,
nS_SDU_ControlBits := bits,
bVCI := int2oct(bvci, 2),
nS_SDU := sdu
}
}
template PDU_NS tr_NS_UNITDATA(template NS_SDU_ControlBits bits, template BssgpBvci bvci, template
octetstring sdu) := {
pDU_NS_Unitdata := {
nsPduType := '00'O,