[PATCH] osmo-ttcn3-hacks[master]: sgsn: Add user plane GTP testing (GTP->Gb and Gb->GTP)
Hello Jenkins Builder, I'd like you to reexamine a change. Please visit https://gerrit.osmocom.org/6581 to look at the new patch set (#2). sgsn: Add user plane GTP testing (GTP->Gb and Gb->GTP) Change-Id: Ifd62cca8cd9dbcffe4eac957db210ac13b8c633f --- M library/BSSGP_Emulation.ttcn M library/LLC_Templates.ttcn M sgsn/SGSN_Tests.ttcn 3 files changed, 144 insertions(+), 6 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/81/6581/2 diff --git a/library/BSSGP_Emulation.ttcn b/library/BSSGP_Emulation.ttcn index 9a48918..c4628be 100644 --- a/library/BSSGP_Emulation.ttcn +++ b/library/BSSGP_Emulation.ttcn @@ -702,6 +702,15 @@ sndcp := omit } +template BssgpDecoded tr_BD_SNDCP(template BIT4 sapi, template PDU_SN sn) := { + bssgp := ?, + llc := tr_LLC_UI(?, sapi), + l3_mo := omit, + l3_mt := omit, + sndcp := sn +} + + } diff --git a/library/LLC_Templates.ttcn b/library/LLC_Templates.ttcn index 7bc4088..086207c 100644 --- a/library/LLC_Templates.ttcn +++ b/library/LLC_Templates.ttcn @@ -20,6 +20,12 @@ pM := bool2bit(protected) } +template (value) Control_field_U ts_LLC_CtrlU(BIT4 m_bits, BIT1 p_f) := { + mBits := m_bits, + pF := p_f, + format := '111'B +} + template Control_field_UI tr_LLC_CtrlUI(template uint9_t n_u, template boolean encrypted := ?, template boolean protected := ?) := { @@ -29,6 +35,14 @@ e := bool2bit_tmpl(encrypted), pM := bool2bit_tmpl(protected) } + +template Control_field_U tr_LLC_CtrlU(template BIT4 m_bits := ?, + template BIT1 p_f := ?) := { + mBits := m_bits, + pF := p_f, + format := '111'B +} + template PDU_LLC ts_LLC_UI(octetstring payload, BIT4 sapi, BIT1 cr, uint9_t n_u, boolean encrypted := false, boolean protected := false) := { @@ -51,6 +65,19 @@ } } +template PDU_LLC tr_LLC_XID(template XID_Information xid, template BIT4 sapi := ?, + template BIT1 cr := ?, template BIT1 p_f := ?) := { + pDU_LLC_U := { + address_field := t_LLC_Addr(sapi, cr), + control_field := tr_LLC_CtrlU('1011'B, p_f), + information_field_U := { + xID := xid + }, + fCS := '00'O /* provided by decoder if FCS OK */ + } +} + + const BIT4 c_LLC_SAPI_LLGMM := '0001'B; const BIT4 c_LLC_SAPI_TOM2 := '0010'B; const BIT4 c_LLC_SAPI_LL3 := '0011'B; diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn index a02d3a9..1652407 100644 --- a/sgsn/SGSN_Tests.ttcn +++ b/sgsn/SGSN_Tests.ttcn @@ -2,6 +2,7 @@ import from General_Types all; import from Osmocom_Types all; +import from Native_Functions all; import from NS_Types all; import from NS_Emulation all; import from BSSGP_Types all; @@ -781,7 +782,7 @@ octetstring sgsn_ip_u optional }; -function f_pdp_ctx_act(PdpActPars apars) runs on BSSGP_ConnHdlr { +function f_pdp_ctx_act(inout PdpActPars apars) runs on BSSGP_ConnHdlr { var boolean exp_rej := ispresent(apars.exp_rej_cause); var Gtp1cUnitdata g_ud; @@ -795,6 +796,8 @@ apars.sgsn_tei_u := gtpc_rx.createPDPContextRequest.teidDataI.teidDataI; apars.sgsn_ip_c := gtpc_rx.createPDPContextRequest.sgsn_addr_signalling.addressf; apars.sgsn_ip_u := gtpc_rx.createPDPContextRequest.sgsn_addr_traffic.addressf; + f_gtp_register_teid(apars.ggsn_tei_c); + f_gtp_register_teid(apars.ggsn_tei_u); var OCT1 cause := int2oct(128, 1); GTP.send(ts_GTPC_CreatePdpResp(g_ud.peer, seq_nr, apars.sgsn_tei_c, cause, @@ -868,7 +871,7 @@ addressInfo := omit } -template (value) PdpActPars t_PdpActPars := { +template (value) PdpActPars t_PdpActPars(charstring ggsn_ip) := { tid := '000'B, nsapi := '0101'B, /* < 5 are reserved */ sapi := '0011'B, /* 3/5/9/11 */ @@ -882,8 +885,8 @@ /* FIXME: make below dynamic !! */ ggsn_tei_c := '0001'O, ggsn_tei_u := '0002'O, - ggsn_ip_c := '7F02'O, - ggsn_ip_u := '7F02'O, + ggsn_ip_c := f_inet_addr(ggsn_ip), + ggsn_ip_u := f_inet_addr(ggsn_ip), sgsn_tei_c := omit, sgsn_tei_u := omit, @@ -891,8 +894,87 @@ sgsn_ip_u := omit } +template (value) GtpPeer ts_GtpPeerU(octetstring ip) := { + connId := 1, + remName := f_inet_ntoa(ip), + remPort := GTP1U_PORT +} + +template (value) GtpPeer ts_GtpPeerC(octetstring ip) := { + connId := 1, + remName := f_inet_ntoa(ip), + remPort := GTP1C_PORT +} + +private function f_gtpu_send(inout PdpActPars apars,
[PATCH] osmo-ttcn3-hacks[master]: sgsn: Add user plane GTP testing (GTP->Gb and Gb->GTP)
Review at https://gerrit.osmocom.org/6581 sgsn: Add user plane GTP testing (GTP->Gb and Gb->GTP) Change-Id: Ifd62cca8cd9dbcffe4eac957db210ac13b8c633f --- M library/BSSGP_Emulation.ttcn M library/LLC_Templates.ttcn M sgsn/SGSN_Tests.ttcn 3 files changed, 139 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/81/6581/1 diff --git a/library/BSSGP_Emulation.ttcn b/library/BSSGP_Emulation.ttcn index 9a48918..c4628be 100644 --- a/library/BSSGP_Emulation.ttcn +++ b/library/BSSGP_Emulation.ttcn @@ -702,6 +702,15 @@ sndcp := omit } +template BssgpDecoded tr_BD_SNDCP(template BIT4 sapi, template PDU_SN sn) := { + bssgp := ?, + llc := tr_LLC_UI(?, sapi), + l3_mo := omit, + l3_mt := omit, + sndcp := sn +} + + } diff --git a/library/LLC_Templates.ttcn b/library/LLC_Templates.ttcn index 7bc4088..086207c 100644 --- a/library/LLC_Templates.ttcn +++ b/library/LLC_Templates.ttcn @@ -20,6 +20,12 @@ pM := bool2bit(protected) } +template (value) Control_field_U ts_LLC_CtrlU(BIT4 m_bits, BIT1 p_f) := { + mBits := m_bits, + pF := p_f, + format := '111'B +} + template Control_field_UI tr_LLC_CtrlUI(template uint9_t n_u, template boolean encrypted := ?, template boolean protected := ?) := { @@ -29,6 +35,14 @@ e := bool2bit_tmpl(encrypted), pM := bool2bit_tmpl(protected) } + +template Control_field_U tr_LLC_CtrlU(template BIT4 m_bits := ?, + template BIT1 p_f := ?) := { + mBits := m_bits, + pF := p_f, + format := '111'B +} + template PDU_LLC ts_LLC_UI(octetstring payload, BIT4 sapi, BIT1 cr, uint9_t n_u, boolean encrypted := false, boolean protected := false) := { @@ -51,6 +65,19 @@ } } +template PDU_LLC tr_LLC_XID(template XID_Information xid, template BIT4 sapi := ?, + template BIT1 cr := ?, template BIT1 p_f := ?) := { + pDU_LLC_U := { + address_field := t_LLC_Addr(sapi, cr), + control_field := tr_LLC_CtrlU('1011'B, p_f), + information_field_U := { + xID := xid + }, + fCS := '00'O /* provided by decoder if FCS OK */ + } +} + + const BIT4 c_LLC_SAPI_LLGMM := '0001'B; const BIT4 c_LLC_SAPI_TOM2 := '0010'B; const BIT4 c_LLC_SAPI_LL3 := '0011'B; diff --git a/sgsn/SGSN_Tests.ttcn b/sgsn/SGSN_Tests.ttcn index a02d3a9..f41817f 100644 --- a/sgsn/SGSN_Tests.ttcn +++ b/sgsn/SGSN_Tests.ttcn @@ -2,6 +2,7 @@ import from General_Types all; import from Osmocom_Types all; +import from Native_Functions all; import from NS_Types all; import from NS_Emulation all; import from BSSGP_Types all; @@ -781,7 +782,7 @@ octetstring sgsn_ip_u optional }; -function f_pdp_ctx_act(PdpActPars apars) runs on BSSGP_ConnHdlr { +function f_pdp_ctx_act(inout PdpActPars apars) runs on BSSGP_ConnHdlr { var boolean exp_rej := ispresent(apars.exp_rej_cause); var Gtp1cUnitdata g_ud; @@ -795,6 +796,8 @@ apars.sgsn_tei_u := gtpc_rx.createPDPContextRequest.teidDataI.teidDataI; apars.sgsn_ip_c := gtpc_rx.createPDPContextRequest.sgsn_addr_signalling.addressf; apars.sgsn_ip_u := gtpc_rx.createPDPContextRequest.sgsn_addr_traffic.addressf; + f_gtp_register_teid(apars.ggsn_tei_c); + f_gtp_register_teid(apars.ggsn_tei_u); var OCT1 cause := int2oct(128, 1); GTP.send(ts_GTPC_CreatePdpResp(g_ud.peer, seq_nr, apars.sgsn_tei_c, cause, @@ -891,6 +894,85 @@ sgsn_ip_u := omit } +template (value) GtpPeer ts_GtpPeerU(octetstring ip) := { + connId := 1, + remName := f_inet_ntoa(ip), + remPort := GTP1U_PORT +} + +template (value) GtpPeer ts_GtpPeerC(octetstring ip) := { + connId := 1, + remName := f_inet_ntoa(ip), + remPort := GTP1C_PORT +} + +private function f_gtpu_send(inout PdpActPars apars, octetstring payload) runs on BSSGP_ConnHdlr { + var GtpPeer peer := valueof(ts_GtpPeerU(apars.sgsn_ip_u)); + GTP.send(ts_GTP1U_GPDU(peer, 0 /*seq*/, apars.sgsn_tei_u, payload)); +} + +private altstep as_xid(PdpActPars apars) runs on BSSGP_ConnHdlr { + [] BSSGP.receive(tr_BD_LLC(tr_LLC_XID(?, apars.sapi))) { + repeat; + } +} + +template PDU_SN tr_SN_UD(template BIT4 nsapi, template octetstring payload) := { + pDU_SN_UNITDATA := { + nsapi := nsapi, + moreBit := ?, + snPduType := '1'B, + firstSegmentIndicator := ?, + spareBit := ?, + pcomp := ?, + dcomp := ?, + npduNumber :=