[PATCH] osmo-ttcn3-hacks[master]: LAPDm: Re-structure: Merge Frame type A+B which are really t...

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Mar 12 14:07:47 UTC 2018


Review at  https://gerrit.osmocom.org/7254

LAPDm: Re-structure: Merge Frame type A+B which are really the same

A is B with zero-length payload.  No need to separate them.

Change-Id: I7b3079899f42a61d67be03e3a17346af80d7b3be
---
M bts/BTS_Tests.ttcn
M lapdm/L1CTL_Test.ttcn
M library/LAPDm_RAW_PT.ttcn
M library/LAPDm_Types.ttcn
4 files changed, 65 insertions(+), 71 deletions(-)


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

diff --git a/bts/BTS_Tests.ttcn b/bts/BTS_Tests.ttcn
index c5bcfcd..0faf92d 100644
--- a/bts/BTS_Tests.ttcn
+++ b/bts/BTS_Tests.ttcn
@@ -1038,9 +1038,9 @@
 	ea := true
 }
 
-template LapdmFrameB ts_LAPDm_B(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
+template LapdmFrameAB ts_LAPDm_AB(LapdmSapi sapi, boolean c_r, boolean p, octetstring pl) := {
 	addr := ts_LapdmAddr(sapi, c_r),
-	ctrl := t_LapdmCtrlUI(p),
+	ctrl := ts_LapdmCtrlUI(p),
 	len := 0, /* overwritten */
 	m := false,
 	el := 1,
@@ -1053,9 +1053,9 @@
 	[] L1CTL.receive(tr_L1CTL_DATA_IND(g_chan_nr, tr_RslLinkID_SACCH(?))) -> value l1_dl {
 		log("SACCH received: ", l1_dl.payload.data_ind.payload);
 		var GsmRrL3Message meas_rep := valueof(ts_MEAS_REP(true, 23, 23, 0, 0, omit));
-		var LapdmFrameB lb := valueof(ts_LAPDm_B(0, false, false, enc_GsmRrL3Message(meas_rep)));
+		var LapdmFrameAB lb := valueof(ts_LAPDm_AB(0, false, false, enc_GsmRrL3Message(meas_rep)));
 		log("LAPDm: ", lb);
-		var octetstring pl := '0000'O & enc_LapdmFrameB(lb);
+		var octetstring pl := '0000'O & enc_LapdmFrameAB(lb);
 		L1CTL.send(ts_L1CTL_DATA_REQ(g_chan_nr, ts_RslLinkID_SACCH(0), pl));
 		repeat;
 		}
diff --git a/lapdm/L1CTL_Test.ttcn b/lapdm/L1CTL_Test.ttcn
index 98dc43b..97704ac 100644
--- a/lapdm/L1CTL_Test.ttcn
+++ b/lapdm/L1CTL_Test.ttcn
@@ -45,9 +45,9 @@
 	}
 	/* template for a valid SABM frame */
 	template LapdmFrame LAPDm_B_SABM(template GsmSapi sapi, octetstring payload)  := {
-		b := {
+		ab := {
 			addr := tr_LapdmAddr(sapi, false),
-			ctrl := t_LapdmCtrlSABM(true),
+			ctrl := tr_LapdmCtrlSABM(true),
 			len := lengthof(payload),
 			m := false,
 			el := 1,
@@ -57,9 +57,9 @@
 
 	/* template for a valid UA frame */
 	template LapdmFrame tr_LAPDm_B_UA(template GsmSapi sapi, template octetstring payload)  := {
-		b := {
+		ab := {
 			addr := tr_LapdmAddr(sapi, false),
-			ctrl := t_LapdmCtrlUA(true),
+			ctrl := tr_LapdmCtrlUA(true),
 			len := ?,
 			m := false,
 			el := 1,
@@ -69,9 +69,9 @@
 
 	/* template for a valid UA frame */
 	template LapdmFrame LAPDm_B_UA(template GsmSapi sapi, octetstring payload)  := {
-		b := {
+		ab := {
 			addr := tr_LapdmAddr(sapi, false),
-			ctrl := t_LapdmCtrlUA(true),
+			ctrl := tr_LapdmCtrlUA(true),
 			len := lengthof(payload),
 			m := false,
 			el := 1,
@@ -81,9 +81,9 @@
 
 	/* template for a valid UI frame */
 	template LapdmFrame LAPDm_B_UI(template GsmSapi sapi, octetstring payload)  := {
-		b := {
+		ab := {
 			addr := tr_LapdmAddr(sapi, true),
-			ctrl := t_LapdmCtrlUI(false),
+			ctrl := tr_LapdmCtrlUI(false),
 			len := lengthof(payload),
 			m := false,
 			el := 1,
@@ -92,7 +92,7 @@
 	}
 
 	template LapdmFrame t_nopayload(template GsmSapi sapi) := {
-		b := {
+		ab := {
 			addr := tr_LapdmAddr(sapi, true),
 			ctrl := ?,
 			len := 0,
@@ -103,14 +103,14 @@
 	}
 
 	template LapdmFrame LAPDm_B_DISC(template GsmSapi sapi) modifies t_nopayload := {
-		b := {
-			ctrl := t_LapdmCtrlDISC(true)
+		ab := {
+			ctrl := tr_LapdmCtrlDISC(true)
 		}
 	}
 
 	template LapdmFrame LAPDm_B_RR(template GsmSapi sapi, template uint3_t nr) modifies t_nopayload := {
-		b := {
-			ctrl := t_LapdmCtrlRR(nr, false)
+		ab := {
+			ctrl := tr_LapdmCtrlRR(nr, false)
 		}
 	}
 
@@ -232,12 +232,12 @@
 		log("DEC UI CU: ", dec_LapdmCtrlU('03'O));
 		log("DEC UI CT: ", dec_LapdmCtrl('03'O));
 
-		log("DEC UA: ", dec_LapdmFrameB('017301'O));
-		log("DEC UI: ", dec_LapdmFrameA('030301'O));
-		log("DEC I: ", dec_LapdmFrameA('030001'O));
-		log("DEC S: ", dec_LapdmFrameA('030101'O));
-		log("DEC: ", dec_LapdmFrameB('030301'O));
-		log("DEC: ", dec_LapdmFrameB('0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O));
+		log("DEC UA: ", dec_LapdmFrameAB('017301'O));
+		log("DEC UI: ", dec_LapdmFrameAB('030301'O));
+		log("DEC I: ", dec_LapdmFrameAB('030001'O));
+		log("DEC S: ", dec_LapdmFrameAB('030101'O));
+		log("DEC: ", dec_LapdmFrameAB('030301'O));
+		log("DEC: ", dec_LapdmFrameAB('0303012B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B2B'O));
 	}
 
 	control {
diff --git a/library/LAPDm_RAW_PT.ttcn b/library/LAPDm_RAW_PT.ttcn
index d6d3be4..bdfc50b 100644
--- a/library/LAPDm_RAW_PT.ttcn
+++ b/library/LAPDm_RAW_PT.ttcn
@@ -433,7 +433,7 @@
 					lpd.sacch := false;
 				}
 				lpd.sapi := dl.dl_info.link_id.sapi;
-				lpd.lapdm.b := dec_LapdmFrameB(dl.payload.data_ind.payload);
+				lpd.lapdm.ab := dec_LapdmFrameAB(dl.payload.data_ind.payload);
 				LAPDM_SP.send(lpd);
 			}
 
diff --git a/library/LAPDm_Types.ttcn b/library/LAPDm_Types.ttcn
index 98f6956..91f55fa 100644
--- a/library/LAPDm_Types.ttcn
+++ b/library/LAPDm_Types.ttcn
@@ -1,5 +1,5 @@
 /* LAPDm definitiona according to 3GPP TS 44.006 */
-/* (C) 2017 bh Harald Welte <laforge at gnumonks.org> */
+/* (C) 2017-2018 bh Harald Welte <laforge at gnumonks.org> */
 module LAPDm_Types {
 
 	import from General_Types all;
@@ -9,18 +9,6 @@
 	type BIT2 LapdmSBits;
 	type BIT3 LapdmUBits;
 	type BIT2 LapdmU2Bits;
-
-	type record LapdmLengthIndicator {
-		uint6_t len,
-		boolean m,
-		uint1_t el
-	} with { variant "FIELDORDER(msb)" };
-
-	template LapdmLengthIndicator t_LapdmLengthIndicator(template uint6_t len, boolean m := false) := {
-		len := len,
-		m := m,
-		el := 1
-	};
 
 	/* TS 44.006 Figure 4 */
 	type record LapdmAddressField {
@@ -32,6 +20,14 @@
 	} with { variant "FIELDORDER(msb)" };
 
 	template LapdmAddressField tr_LapdmAddr(template LapdmSapi sapi, template boolean c_r) := {
+		spare := '0'B,
+		lpd := 0,
+		sapi := sapi,
+		c_r := c_r,
+		ea := true
+	};
+
+	template (value) LapdmAddressField ts_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
 		spare := '0'B,
 		lpd := 0,
 		sapi := sapi,
@@ -74,50 +70,64 @@
 
 	/* TS 44.006 Table 4 */
 
-	template LapdmCtrl t_LapdmCtrlS := {
+	template LapdmCtrl tr_LapdmCtrlS := {
 		s := { spare := '01'B, s := ?, p_f := ?, n_r := ? }
 	};
 
-	template LapdmCtrl t_LapdmCtrlU := {
+	template LapdmCtrl tr_LapdmCtrlU := {
 		u := { spare := '11'B, u2 := ?, p_f := ?, u := ? }
 	};
 
 	/* TS 44.006 Table 4 */
-	template LapdmCtrl t_LapdmCtrlI(template uint3_t nr, template uint3_t ns, template boolean p) := {
+	template LapdmCtrl tr_LapdmCtrlI(template uint3_t nr, template uint3_t ns, template boolean p) := {
 		i := { spare := '0'B, n_s := ns, p := p, n_r := nr }
 	};
 
-	template LapdmCtrl t_LapdmCtrlRR(template uint3_t nr, template boolean pf) modifies t_LapdmCtrlS := {
+	template LapdmCtrl tr_LapdmCtrlRR(template uint3_t nr, template boolean pf) modifies tr_LapdmCtrlS := {
 		s := { s:= '00'B, p_f := pf, n_r := nr }
 	};
 
-	template LapdmCtrl t_LapdmCtrlRNR(template uint3_t nr, template boolean pf) modifies t_LapdmCtrlS := {
+	template LapdmCtrl tr_LapdmCtrlRNR(template uint3_t nr, template boolean pf) modifies tr_LapdmCtrlS := {
 		s := { s:= '01'B, p_f := pf, n_r := nr }
 	};
 
-	template LapdmCtrl t_LapdmCtrlREJ(template uint3_t nr, template boolean pf) modifies t_LapdmCtrlS := {
+	template LapdmCtrl tr_LapdmCtrlREJ(template uint3_t nr, template boolean pf) modifies tr_LapdmCtrlS := {
 		s := { s:= '10'B, p_f := pf, n_r := nr }
 	};
 
-	template LapdmCtrl t_LapdmCtrlSABM(template boolean p) modifies t_LapdmCtrlU := {
+	template LapdmCtrl tr_LapdmCtrlSABM(template boolean p) modifies tr_LapdmCtrlU := {
 		u := { u2 := '11'B, p_f := p, u := '001'B }
 	};
+	template (value) LapdmCtrl ts_LapdmCtrlSABM(boolean p) := {
+		u := { spare := '11'B, u2 := '11'B, p_f := p, u := '001'B }
+	};
 
-	template LapdmCtrl t_LapdmCtrlDM(template boolean f) modifies t_LapdmCtrlU := {
+	template LapdmCtrl tr_LapdmCtrlDM(template boolean f) modifies tr_LapdmCtrlU := {
 		u := { u2 := '11'B, p_f := f, u := '000'B }
 	};
 
-	template LapdmCtrl t_LapdmCtrlUI(template boolean p) modifies t_LapdmCtrlU := {
+	template LapdmCtrl tr_LapdmCtrlUI(template boolean p) modifies tr_LapdmCtrlU := {
 		u := { u2 := '00'B, p_f := p, u := '000'B }
 	};
+	template (value) LapdmCtrl ts_LapdmCtrlUI(boolean p) := {
+		u := { spare := '11'B, u2 := '00'B, p_f := p, u := '000'B }
+	};
 
-	template LapdmCtrl t_LapdmCtrlDISC(template boolean p) modifies t_LapdmCtrlU := {
+	template LapdmCtrl tr_LapdmCtrlDISC(template boolean p) modifies tr_LapdmCtrlU := {
 		u := { u2 := '00'B, p_f := p, u := '010'B }
 	};
+	template LapdmCtrl ts_LapdmCtrlDISC(boolean p) := {
+		u := { spare := '11'B,  u2 := '00'B, p_f := p, u := '010'B }
+	};
 
-	template LapdmCtrl t_LapdmCtrlUA(template boolean f) modifies t_LapdmCtrlU := {
+	template LapdmCtrl tr_LapdmCtrlUA(template boolean f) modifies tr_LapdmCtrlU := {
 		u := { u2 := '00'B, p_f := f, u := '011'B }
 	};
+	template (value) LapdmCtrl ts_LapdmCtrlUA(boolean f) := {
+		u := { spare := '11'B, u2 := '00'B, p_f := f, u := '011'B }
+	};
+
+
 
 	external function dec_LapdmAddressField(in octetstring stream) return LapdmAddressField
 		with { extension "prototype(convert) decode(RAW)" };
@@ -128,21 +138,6 @@
 	external function dec_LapdmCtrlU(in octetstring stream) return LapdmCtrlU
 		with { extension "prototype(convert) decode(RAW)" };
 
-	external function dec_LapdmLengthIndicator(in octetstring stream) return LapdmLengthIndicator
-		with { extension "prototype(convert) decode(RAW)" };
-
-	/* Format A is used on DCCHs for frames where there is no information field */
-	type record LapdmFrameA {
-		LapdmAddressField	addr,
-		LapdmCtrl		ctrl,
-		LapdmLengthIndicator	len
-	} with { variant "" };
-
-	external function enc_LapdmFrameA(in LapdmFrameA si) return octetstring
-		with { extension "prototype(convert) encode(RAW)" };
-	external function dec_LapdmFrameA(in octetstring stream) return LapdmFrameA
-		with { extension "prototype(convert) decode(RAW)" };
-
 	/* Formats B, Bter and B4 are used on DCCHs for frames containing an information field: 
 	/* - format Bter is used on request of higher layers if and only if short L2 header type 1 is
 	 *   supported and a UI command is to be transmitted on SAPI 0 */
@@ -151,19 +146,19 @@
 	/* Format Bbis is used only on BCCH, PCH, NCH, and AGCH.
 
 	/* Format B */
-	type record LapdmFrameB {
+	type record LapdmFrameAB {
 		LapdmAddressField	addr,
 		LapdmCtrl		ctrl,
-		uint6_t			len,
+		uint6_t 		len,
 		boolean			m,
-		uint1_t			el (1),
-		octetstring		payload
+		uint1_t			el,
+		octetstring		payload	/* zero-length in Frame A */
 	} with { variant (len) "LENGTHTO(payload)"
 		 variant "FIELDORDER(msb)" };
 
-	external function enc_LapdmFrameB(in LapdmFrameB si) return octetstring
+	external function enc_LapdmFrameAB(in LapdmFrameAB si) return octetstring
 		with { extension "prototype(convert) encode(RAW)" };
-	external function dec_LapdmFrameB(in octetstring stream) return LapdmFrameB
+	external function dec_LapdmFrameAB(in octetstring stream) return LapdmFrameAB
 		with { extension "prototype(convert) decode(RAW)" };
 
 	/* Format B4 */
@@ -188,8 +183,7 @@
 		with { extension "prototype(convert) decode(RAW)" };
 
 	type union LapdmFrame {
-		LapdmFrameA	a,
-		LapdmFrameB	b,
+		LapdmFrameAB	ab,
 		LapdmFrameBbis	bbis,
 		LapdmFrameB4	b4
 	} with { variant "" };

-- 
To view, visit https://gerrit.osmocom.org/7254
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b3079899f42a61d67be03e3a17346af80d7b3be
Gerrit-PatchSet: 1
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list