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