Change in ...osmo-ttcn3-hacks[master]: bts: Factor out mobile-originated LAPDm establishment

2019-06-04 Thread Harald Welte
Harald Welte has posted comments on this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/14348 )

Change subject: bts: Factor out mobile-originated LAPDm establishment
..


Patch Set 3: Code-Review+2


--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/14348
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I8da753bb3d809ec09f9380bb4bac666ceaf61f00
Gerrit-Change-Number: 14348
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Tue, 04 Jun 2019 09:11:53 +
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment


Change in ...osmo-ttcn3-hacks[master]: bts: Factor out mobile-originated LAPDm establishment

2019-06-04 Thread Harald Welte
Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/14348 )

Change subject: bts: Factor out mobile-originated LAPDm establishment
..

bts: Factor out mobile-originated LAPDm establishment

which avoids us to have to copy+pate this between several test cases.

Change-Id: I8da753bb3d809ec09f9380bb4bac666ceaf61f00
---
M bts/BTS_Tests_LAPDm.ttcn
1 file changed, 29 insertions(+), 24 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/bts/BTS_Tests_LAPDm.ttcn b/bts/BTS_Tests_LAPDm.ttcn
index ffa3aa9..3c39a5a 100644
--- a/bts/BTS_Tests_LAPDm.ttcn
+++ b/bts/BTS_Tests_LAPDm.ttcn
@@ -290,6 +290,31 @@
f_lapdm_exit();
 }

+/* Mobile-Originated LAPDm establishment on given Link ID */
+private function f_establish_mo(RslLinkId link_id) runs on ConnHdlr
+{
+   var integer sapi := link_id.sapi;
+   var boolean is_sacch := false;
+   if (link_id.c == SACCH) {
+   is_sacch := true;
+   }
+
+   var octetstring l3_mo := f_rnd_octstring(5);
+
+   /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L 
≤ N201.. */
+   if (is_sacch) {
+   /* no payload permitted, as this is not contention resolution */
+   l3_mo := ''O;
+   LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, 
c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
+   RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
+   } else {
+   LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, 
c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
+   RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo));
+   }
+   /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */
+   LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, 
f:=true, l3:=l3_mo)));
+}
+
 /* Verify that the BTS is re-transmitting SABM messages after T200 timeout, 
inspired
by 3GPP TS 51.010-1 25.2.1.1.2.1 + 25.2.1.2.4 */
 private function f_TC_sabm_retransmit_bts(charstring id) runs on ConnHdlr {
@@ -547,11 +572,7 @@
RSL.clear;
LAPDM.clear;

-   /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L 
≤ N201.. */
-   LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, 
p:=true, l3:=l3)));
-   RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
-   /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */
-   LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, 
l3:=l3)));
+   f_establish_mo(link_id);

var integer last_ns_rx := 0;

@@ -804,22 +825,9 @@
RSL.clear;
LAPDM.clear;

-   var octetstring l3_mo := f_rnd_octstring(5);
+   f_establish_mo(link_id);

-   /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L 
≤ N201.. */
-   if (is_sacch) {
-   /* no payload permitted, as this is not contention resolution */
-   l3_mo := ''O;
-   LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, 
c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
-   RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
-   } else {
-   LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, 
c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
-   RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo));
-   }
-   /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */
-   LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, 
f:=true, l3:=l3_mo)));
-
-   l3_mo := f_rnd_octstring(c_TS0406_MAX_L3_OCTETS);
+   var octetstring l3_mo := f_rnd_octstring(c_TS0406_MAX_L3_OCTETS);

deactivate(d);

@@ -882,10 +890,7 @@
RSL.clear;
LAPDM.clear;

-   var octetstring l3_mo := f_rnd_octstring(20);
-   LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, 
p:=true, l3:=l3_mo)));
-   RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo));
-   LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, 
f:=true, l3:=l3_mo)));
+   f_establish_mo(link_id);

var octetstring l3_mt := f_rnd_octstring(20);
RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt));

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/14348
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I8da753bb3d809ec09f9380bb4bac666ceaf61f00
Gerrit-Change-Number: 14348
Gerrit-PatchSet: 4
Gerrit-Owner: Harald Welte 
Gerrit-Reviewer: Harald Welte 
Gerrit-Reviewer: Jenkins Builder
Gerrit-MessageType: merged


Change in ...osmo-ttcn3-hacks[master]: bts: Factor out mobile-originated LAPDm establishment

2019-06-02 Thread Harald Welte
Harald Welte has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/14348


Change subject: bts: Factor out mobile-originated LAPDm establishment
..

bts: Factor out mobile-originated LAPDm establishment

which avoids us to have to copy+pate this between several test cases.

Change-Id: I8da753bb3d809ec09f9380bb4bac666ceaf61f00
---
M bts/BTS_Tests_LAPDm.ttcn
1 file changed, 29 insertions(+), 24 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks 
refs/changes/48/14348/1

diff --git a/bts/BTS_Tests_LAPDm.ttcn b/bts/BTS_Tests_LAPDm.ttcn
index b98ef80..6ba0968 100644
--- a/bts/BTS_Tests_LAPDm.ttcn
+++ b/bts/BTS_Tests_LAPDm.ttcn
@@ -292,6 +292,31 @@
f_lapdm_exit();
 }

+/* Mobile-Originated LAPDm establishment on given Link ID */
+private function f_establish_mo(RslLinkId link_id) runs on ConnHdlr
+{
+   var integer sapi := link_id.sapi;
+   var boolean is_sacch := false;
+   if (link_id.c == SACCH) {
+   is_sacch := true;
+   }
+
+   var octetstring l3_mo := f_rnd_octstring(5);
+
+   /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L 
≤ N201.. */
+   if (is_sacch) {
+   /* no payload permitted, as this is not contention resolution */
+   l3_mo := ''O;
+   LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, 
c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
+   RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
+   } else {
+   LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, 
c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
+   RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo));
+   }
+   /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */
+   LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, 
f:=true, l3:=l3_mo)));
+}
+
 /* Verify that the BTS is re-transmitting SABM messages after T200 timeout, 
inspired
by 3GPP TS 51.010-1 25.2.1.1.2.1 + 25.2.1.2.4 */
 private function f_TC_sabm_retransmit_bts(charstring id) runs on ConnHdlr {
@@ -549,11 +574,7 @@
RSL.clear;
LAPDM.clear;

-   /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L 
≤ N201.. */
-   LAPDM.send(t_PH_DATA(0, false, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, 
p:=true, l3:=l3)));
-   RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3));
-   /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */
-   LAPDM.receive(t_PH_DATA(0, false, tr_LAPDm_UA(sapi, cr_MT_RSP, f:=true, 
l3:=l3)));
+   f_establish_mo(link_id);

var integer last_ns_rx := 0;

@@ -806,22 +827,9 @@
RSL.clear;
LAPDM.clear;

-   var octetstring l3_mo := f_rnd_octstring(5);
+   f_establish_mo(link_id);

-   /* MO Establish Request via LADPm: SAPI = 0, C = 0, P = 1, M = 0, 0 ≤ L 
≤ N201.. */
-   if (is_sacch) {
-   /* no payload permitted, as this is not contention resolution */
-   l3_mo := ''O;
-   LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, 
c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
-   RSL.receive(tr_RSL_EST_IND_NOL3(g_chan_nr, link_id));
-   } else {
-   LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, 
c_r:=cr_MO_CMD, p:=true, l3:=l3_mo)));
-   RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo));
-   }
-   /* UA: SAPI = 0, R = 0, F = 1, M = 0, L = L of SABM. */
-   LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, 
f:=true, l3:=l3_mo)));
-
-   l3_mo := f_rnd_octstring(c_TS0406_MAX_L3_OCTETS);
+   var octetstring l3_mo := f_rnd_octstring(c_TS0406_MAX_L3_OCTETS);

deactivate(d);

@@ -884,10 +892,7 @@
RSL.clear;
LAPDM.clear;

-   var octetstring l3_mo := f_rnd_octstring(20);
-   LAPDM.send(t_PH_DATA(0, is_sacch, ts_LAPDm_SABM(sapi, c_r:=cr_MO_CMD, 
p:=true, l3:=l3_mo)));
-   RSL.receive(tr_RSL_EST_IND(g_chan_nr, link_id, l3_mo));
-   LAPDM.receive(t_PH_DATA(0, is_sacch, tr_LAPDm_UA(sapi, cr_MT_RSP, 
f:=true, l3:=l3_mo)));
+   f_establish_mo(link_id);

var octetstring l3_mt := f_rnd_octstring(20);
RSL.send(ts_RSL_DATA_REQ(g_chan_nr, link_id, l3_mt));

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/14348
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I8da753bb3d809ec09f9380bb4bac666ceaf61f00
Gerrit-Change-Number: 14348
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte 
Gerrit-MessageType: newchange