blob: 63ed24d2170806e84f28dc48e7c74d4d3d79961f [file] [log] [blame]
Harald Welte34b5a952019-05-27 11:54:11 +02001/* GPRS-NS type definitions in TTCN-3
2 * (C) 2017 Harald Welte <laforge@gnumonks.org>
3 * All rights reserved.
4 *
5 * Released under the terms of GNU General Public License, Version 2 or
6 * (at your option) any later version.
7 *
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
10
Harald Weltef1fd0162017-07-22 20:34:05 +020011module NS_Types {
12 import from General_Types all;
13 import from Osmocom_Types all;
14 import from GSM_Types all;
15 import from BSSGP_Types all;
Harald Welte6e594f22017-07-23 16:19:35 +020016 import from BSSGP_Helper_Functions all;
Harald Weltef1fd0162017-07-22 20:34:05 +020017
18 /* TS 48.016 10.3.7 */
19 type enumerated NsPduType {
20 NS_PDUT_NS_UNITDATA ('00000000'B),
21 NS_PDUT_NS_RESET ('00000010'B),
22 NS_PDUT_NS_RESET_ACK ('00000011'B),
23 NS_PDUT_NS_BLOCK ('00000100'B),
24 NS_PDUT_NS_BLOCK_ACK ('00000101'B),
25 NS_PDUT_NS_UNBLOCK ('00000110'B),
26 NS_PDUT_NS_UNBLOCK_ACK ('00000111'B),
27 NS_PDUT_NS_STATUS ('00001000'B),
28 NS_PDUT_NS_ALIVE ('00001010'B),
29 NS_PDUT_NS_ALIVE_ACK ('00001011'B)
30 /* FIXME: SNS */
31 } with { variant "FIELDLENGTH(8)" };
32
33 /* TS 48.016 10.3 */
34 type enumerated NsIEI {
35 NS_IEI_CAUSE ('00000000'B),
36 NS_IEI_NSVCI ('00000001'B),
37 NS_IEI_NS_PDU ('00000010'B),
38 NS_IEI_BVCI ('00000011'B),
39 NS_IEI_NSEI ('00000100'B),
40 NS_IEI_LIST_IPv4 ('00000101'B),
41 NS_IEI_LIST_IPv6 ('00000110'B),
42 NS_IEI_MAX_NUM_NSVC ('00000111'B),
43 NS_IEI_NUM_IPv4_EP ('00001000'B),
44 NS_IEI_NUM_IPv6_EP ('00001001'B),
45 NS_IEI_RESET_FLAG ('00001010'B),
46 NS_IEI_IP_ADDRESS ('00001011'B)
47 } with { variant "FIELDLENGTH(8)" };
48
49 /* TS 48.016 10.3.2 */
50 type enumerated NsCause {
51 NS_CAUSE_TRANSIT_NETWORK_FAILURE ('00000000'B),
52 NS_CAUSE_OM_INTERVENTION ('00000001'B),
53 NS_CAUSE_EQUIPMENT_FAILURE ('00000010'B),
54 NS_CAUSE_NSVC_BLOCKED ('00000011'B),
55 NS_CAUSE_NSVC_UNKNOWN ('00000100'B),
56 NS_CAUSE_BVCI_UNKNOWN_AT_NSE ('00000101'B),
57 NS_CAUSE_SEMANTICALLY_INCORRECT_PDU ('00001000'B),
58 NS_CAUSE_PDU_NOT_COMPATIBLE_WITH_PROTOCOL_STATE ('00001010'B),
Alexander Couzens619213f2021-04-20 10:54:51 +020059 NS_CAUSE_PROTOCOL_ERROR_UNSPECIFIED ('00001011'B),
Harald Weltef1fd0162017-07-22 20:34:05 +020060 NS_CAUSE_INVALID_ESSENTIAL_IE ('00001100'B),
61 NS_CAUSE_MISSING_ESSENTIAL_IE ('00001101'B),
62 NS_CAUSE_INVALID_NR_OF_IPv4_ENDPOINTS ('00001110'B),
63 NS_CAUSE_INVALID_NR_OF_IPv6_ENDPOINTS ('00001111'B),
64 NS_CAUSE_INVALID_NR_OF_NSVCS ('00010000'B),
65 NS_CAUSE_INVALID_WEIGHTS ('00010001'B),
66 NS_CAUSE_UNKNOWN_IP_ENDPOINT ('00010010'B),
67 NS_CAUSE_UNKNOWN_IP_ADDRESS ('00010011'B),
68 NS_CAUSE_IP_TEST_FAILEDA ('00010100'B)
69 } with { variant "FIELDLENGTH(8)" };
70
Harald Welte6fff3642017-07-22 21:36:13 +020071 /* TS 48.016 10.3.9 */
72 type record NsSduControlBits {
73 BIT6 spare,
74 boolean c,
75 boolean r
76 } with { variant (c) "FIELDLENGTH(1)"
77 variant (r) "FIELDLENGTH(1)"
78 };
79
Harald Welte6e594f22017-07-23 16:19:35 +020080 template NsSduControlBits t_SduCtrlB := {
81 spare := '000000'B,
82 c := false,
83 r := false
84 }
85
Harald Weltef1fd0162017-07-22 20:34:05 +020086 type uint16_t Nsvci;
87 type uint16_t Nsei;
88
89 type union NsIeUnion {
90 BssgpBvci bvci, /* 10.3.1 */
91 NsCause cause, /* 10.3.2 */
92 uint16_t max_num_nsvc, /* 10.3.2e */
93 uint16_t num_ipv4_ep, /* 10.3.2f */
94 uint16_t num_ipv6_ep, /* 10.3.2g */
95 Nsvci nsvci, /* 10.3.5 */
96 Nsei nsei, /* 10.3.6 */
97 octetstring other
98 };
99
100 type record NsTLV {
101 NsIEI iei,
102 uint16_t len,
103 NsIeUnion u
104 } with {
105 variant (u) "CROSSTAG(
106 bvci, iei = NS_IEI_BVCI;
107 cause, iei = NS_IEI_CAUSE;
108 max_num_nsvc, iei = NS_IEI_MAX_NUM_NSVC;
109 num_ipv4_ep, iei = NS_IEI_NUM_IPv4_EP;
110 num_ipv6_ep, iei = NS_IEI_NUM_IPv6_EP;
111 nsvci, iei = NS_IEI_NSVCI;
112 nsei, iei = NS_IEI_NSEI;
113 other, OTHERWISE)"
114 variant (len) "LENGTHTO(u)"
115 };
116
117 type record of NsTLV NsTLVs;
118
Harald Welte6fff3642017-07-22 21:36:13 +0200119 type record NsPduUnitdata {
120 NsSduControlBits control_bits,
121 BssgpBvci bvci,
122 octetstring sdu
123 } with { variant "" };
124
125 type record NsPduOther {
Harald Weltef1fd0162017-07-22 20:34:05 +0200126 NsTLVs tlvs optional
127 } with { variant "" };
128
Harald Welte6fff3642017-07-22 21:36:13 +0200129 type union NsPduUnion {
130 NsPduUnitdata unitdata,
131 NsPduOther other
132 } with { variant "" };
133
134 type record NsPdu {
135 NsPduType pdu_type,
136 NsPduUnion u
137 } with { variant (u) "CROSSTAG(
138 unitdata, pdu_type = NS_PDUT_NS_UNITDATA;
139 other, OTHERWISE)"
140 };
141
Harald Weltef1fd0162017-07-22 20:34:05 +0200142 external function enc_NsPdu(in NsPdu pdu) return octetstring
143 with { extension "prototype(convert) encode(RAW)" };
144 external function dec_NsPdu(in octetstring stream) return NsPdu
145 with { extension "prototype(convert) decode(RAW)" };
146
Harald Welte6e594f22017-07-23 16:19:35 +0200147
148
149 template NsTLV t_NS_IE_CAUSE(template NsCause cause) := {
150 iei := NS_IEI_CAUSE,
151 len := 1,
152 u := { cause := cause }
153 };
154
155 template NsTLV t_NS_IE_NSVCI(template Nsvci nsvci) := {
156 iei := NS_IEI_NSVCI,
157 len := 2,
158 u := { nsvci := nsvci }
159 }
160
161 template NsTLV t_NS_IE_NSEI(template Nsvci nsei) := {
162 iei := NS_IEI_NSEI,
163 len := 2,
164 u := { nsei := nsei }
165 }
166
167 template NsTLV t_NsIE(NsIEI iei, NsIeUnion u) := {
168 iei := iei,
169 u := u
170 }
171
172 template NsTLV t_NsIE_other(NsIEI iei, octetstring val) := {
173 iei := iei,
174 len := lengthof(val),
175 u := { other := val }
176 }
177
178 template NsPdu t_NS_RESET(template NsCause cause, template Nsvci nsvci, template Nsei nsei) := {
179 pdu_type := NS_PDUT_NS_RESET,
180 u := {
181 other := {
182 tlvs := { t_NS_IE_CAUSE(cause), t_NS_IE_NSVCI(nsvci), t_NS_IE_NSEI(nsei) }
183 }
184 }
185 };
186
187 template NsPdu t_NS_RESET_ACK(template Nsvci nsvci, template Nsei nsei) := {
188 pdu_type := NS_PDUT_NS_RESET_ACK,
189 u := {
190 other := {
191 tlvs := { t_NS_IE_NSVCI(nsvci), t_NS_IE_NSEI(nsei) }
192 }
193 }
194 };
195
196 template NsPdu t_NS_BLOCK(template NsCause cause, template Nsvci nsvci) := {
197 pdu_type := NS_PDUT_NS_BLOCK,
198 u := {
199 other := {
200 tlvs := { t_NS_IE_CAUSE(cause), t_NS_IE_NSVCI(nsvci) }
201 }
202 }
203 }
204
205 template NsPdu t_NS_BLOCK_ACK(template Nsvci nsvci) := {
206 pdu_type := NS_PDUT_NS_BLOCK_ACK,
207 u := {
208 other := {
209 tlvs := { t_NS_IE_NSVCI(nsvci) }
210 }
211 }
212 }
213
214 template NsPdu t_NsPduSimple(template NsPduType pdut) := { pdu_type := pdut, u := { other := { tlvs := omit } } };
215 template NsPdu t_NS_ALIVE := t_NsPduSimple(NS_PDUT_NS_ALIVE);
216 template NsPdu t_NS_ALIVE_ACK := t_NsPduSimple(NS_PDUT_NS_ALIVE_ACK);
217 template NsPdu t_NS_UNBLOCK := t_NsPduSimple(NS_PDUT_NS_UNBLOCK);
218 template NsPdu t_NS_UNBLOCK_ACK := t_NsPduSimple(NS_PDUT_NS_UNBLOCK_ACK);
219
220 template NsPdu t_NS_STATUS(NsCause cause, NsPdu pdu) := {
221 pdu_type := NS_PDUT_NS_STATUS,
222 u := {
223 other := {
224 tlvs := { t_NS_IE_CAUSE(cause), t_NsIE_other(NS_IEI_NS_PDU, f_NS_compact_len(enc_NsPdu(pdu))) }
225 }
226 }
227 }
228
229 template NsPdu t_NS_UNITDATA(template NsSduControlBits bits, template BssgpBvci bvci, template octetstring sdu) := {
230 pdu_type := NS_PDUT_NS_UNITDATA,
231 u := {
232 unitdata := {
233 control_bits := bits,
234 bvci := bvci,
235 sdu := sdu
236 }
237 }
238 }
239
Harald Weltef1fd0162017-07-22 20:34:05 +0200240} with { encode "RAW" };