blob: c52b96c952ef411fac844809b0db98de4806d637 [file] [log] [blame]
Harald Weltef6543322017-07-16 07:35:10 +02001/* LAPDm definitiona according to 3GPP TS 44.006 */
2/* (C) 2017 bh Harald Welte <laforge@gnumonks.org> */
3module LAPDm_Types {
4
5 import from General_Types all;
6 import from Osmocom_Types all;
7
8 type uint3_t LapdmSapi;
9 type BIT2 LapdmSBits;
10 type BIT3 LapdmUBits;
11 type BIT2 LapdmU2Bits;
12
13 type record LapdmLengthIndicator {
14 uint6_t len,
15 boolean m,
16 uint1_t el
17 } with { variant "" };
18
19 /* TS 44.006 Figure 4 */
20 type record LapdmAddressField {
21 BIT1 spare,
22 uint2_t lpd (0),
23 LapdmSapi sapi,
24 boolean c_r,
25 boolean ea
26 } with { variant "" };
27
28 template LapdmAddressField tr_LapdmAddr(LapdmSapi sapi, boolean c_r) := {
29 spare := '0'B,
30 lpd := 0,
31 sapi := sapi,
32 c_r := c_r,
33 ea := true
34 };
35
36 type record LapdmCtrlI {
37 uint3_t n_r,
38 boolean p,
39 uint3_t n_s,
40 BIT1 spare ('0'B)
41 } with { variant "" };
42
43 type record LapdmCtrlS {
44 uint3_t n_r,
45 boolean p_f,
46 LapdmSBits s,
47 BIT2 spare ('01'B)
48 } with { variant "" };
49
50 type record LapdmCtrlU {
51 LapdmUBits u,
52 boolean p_f,
53 LapdmU2Bits u2,
54 BIT2 spare ('11'B)
55 } with { variant "" };
56
57 /* TS 44.006 Table 3 */
58 type union LapdmCtrl {
59 LapdmCtrlI i,
60 LapdmCtrlS s,
61 LapdmCtrlU u
62 } with { variant "TAG(i, spare = '0'B;
63 s, spare = '01'B;
64 u, spare = '11'B)" };
65
66 template LapdmCtrl t_LapdmCtrlS := {
67 s := { n_r := ?, p_f := ?, s:= ?, spare := '01'B }
68 };
69
70 template LapdmCtrl t_LapdmCtrlU := {
71 u := { u := ?, p_f := ?, u2 := ?, spare := '11'B }
72 };
73
74 /* TS 44.006 Table 4 */
75 template LapdmCtrl t_LapdmCtrlI(template uint3_t nr, template uint3_t ns, template boolean p) := {
76 i := { n_r := nr, p := p, n_s := ns, spare := '0'B }
77 };
78
79 template LapdmCtrl t_LapdmCtrlRR(template uint3_t nr, template boolean pf) modifies t_LapdmCtrlS := {
80 s := { n_r := nr, p_f := pf, s := '00'B }
81 };
82
83 template LapdmCtrl t_LapdmCtrlRNR(template uint3_t nr, template boolean pf) modifies t_LapdmCtrlS := {
84 s := { n_r := nr, p_f := pf, s := '01'B }
85 };
86
87 template LapdmCtrl t_LapdmCtrlREJ(template uint3_t nr, template boolean pf) modifies t_LapdmCtrlS := {
88 s := { n_r := nr, p_f := pf, s := '10'B }
89 };
90
91 template LapdmCtrl t_LapdmCtrlSABM(template boolean p) modifies t_LapdmCtrlU := {
92 u := { u := '001'B, p_f := p, u2 := '11'B }
93 };
94
95 template LapdmCtrl t_LapdmCtrlDM(template boolean f) modifies t_LapdmCtrlU := {
96 u := { u := '000'B, p_f := f, u2 := '11'B }
97 };
98
99 template LapdmCtrl t_LapdmCtrlUI(template boolean p) modifies t_LapdmCtrlU := {
100 u := { u := '000'B, p_f := p, u2 := '00'B }
101 };
102
103 template LapdmCtrl t_LapdmCtrlDISC(template boolean p) modifies t_LapdmCtrlU := {
104 u := { u := '010'B, p_f := p, u2 := '00'B }
105 };
106
107 template LapdmCtrl t_LapdmCtrlUA(template boolean f) modifies t_LapdmCtrlU := {
108 u := { u := '011'B, p_f := f, u2 := '00'B }
109 };
110
111 /* Format A is used on DCCHs for frames where there is no information field */
112 type record LapdmFrameA {
113 LapdmAddressField addr,
114 LapdmCtrl ctrl,
115 LapdmLengthIndicator len
116 } with { variant "" };
117
118 external function enc_LapdmFrameA(in LapdmFrameA si) return octetstring
119 with { extension "prototype(convert) encode(RAW)" };
120 external function dec_LapdmFrameA(in octetstring stream) return LapdmFrameA
121 with { extension "prototype(convert) decode(RAW)" };
122
123 /* Formats B, Bter and B4 are used on DCCHs for frames containing an information field:
124 /* - format Bter is used on request of higher layers if and only if short L2 header type 1 is
125 * supported and a UI command is to be transmitted on SAPI 0 */
126 /* - format B4 is used for UI frames transmitted by the network on SACCH; */
127 /* - format B is applied in all other cases. */
128 /* Format Bbis is used only on BCCH, PCH, NCH, and AGCH.
129
130 /* Format B */
131 type record LapdmFrameB {
132 LapdmAddressField addr,
133 LapdmCtrl ctrl,
134 LapdmLengthIndicator len,
135 octetstring payload
136 } with { variant "" };
137
138 external function enc_LapdmFrameB(in LapdmFrameB si) return octetstring
139 with { extension "prototype(convert) encode(RAW)" };
140 external function dec_LapdmFrameB(in octetstring stream) return LapdmFrameB
141 with { extension "prototype(convert) decode(RAW)" };
142
143
144 /* Format B4 */
145 type record LapdmFrameB4 {
146 LapdmAddressField addr,
147 LapdmCtrl ctrl,
148 octetstring payload
149 } with { variant "" };
150
151 external function enc_LapdmFrameB4(in LapdmFrameB4 si) return octetstring
152 with { extension "prototype(convert) encode(RAW)" };
153 external function dec_LapdmFrameB4(in octetstring stream) return LapdmFrameB4
154 with { extension "prototype(convert) decode(RAW)" };
155
156} with { encode "RAW" };