blob: ee4867ab949ce81af66b6d8a5ad78190b6791f60 [file] [log] [blame]
Harald Weltea814f262017-07-24 13:21:35 +02001///////////////////////////////////////////////////////////////////////////////
2// //
3// Copyright Test Competence Center (TCC) ETH 2016 //
4// //
5// The copyright to the computer program(s) herein is the property of TCC. //
6// The program(s) may be used and/or copied only with the written permission //
7// of TCC or in accordance with the terms and conditions stipulated in the //
8// agreement/contract under which the program(s) has been supplied. //
9// //
10///////////////////////////////////////////////////////////////////////////////
11//
12// File: SS_PDU_Defs.asn
13// Rev: R1B
14// Prodnr: CNL 113 832
15// Contact: http://ttcn.ericsson.se
16// Reference: 3GPP TS 24.008 v13.4.0
17
18#include "SS_PDU_Defs.hh"
19#include "SS_Types.hh"
20
21namespace SS__Types
22{
23using namespace SS__PDU__Defs;
24TTCN_Module SS__EncDec("SS_EncDec", __DATE__, __TIME__);
25
26//Type definitions to transfer data between coding functions
27struct SS_Invoke_for_dec
28{
29 INTEGER invokeId;
30 OPTIONAL<INTEGER> linkedId;
31 Remote__Operations__Information__Objects::Code opcode;
32 OPTIONAL<OCTETSTRING> stream;
33};
34
35struct SS_ReturnResult_for_dec
36{
37 INTEGER invokeId;
38 OPTIONAL<Remote__Operations__Information__Objects::Code> opcode;
39 OPTIONAL<OCTETSTRING> stream;
40};
41
42struct SS_ReturnError_for_dec
43{
44 INTEGER invokeId;
45 Remote__Operations__Information__Objects::Code errorCode;
46 OPTIONAL<OCTETSTRING> stream;
47};
48
49struct SS_Reject_for_dec
50{
51 OPTIONAL<INTEGER> invokeId;
52 Remote__Operations__Generic__ROS__PDUs::ProblemType problem;
53};
54
55
56//////////////////////////////////
57// Encoding function for SS__Invoke
58//////////////////////////////////
59OCTETSTRING enc_SS_Invoke(const SS__Invoke& pdu)
60{
61 TTCN_Buffer buf;
62
63 OCTETSTRING ret_val;
64 pdu.encode(SS__Invoke_descr_, buf, TTCN_EncDec::CT_BER, BER_ENCODE_DER);
65 buf.get_string(ret_val);
66 ret_val[0] = int2oct(161,1);
67
68 return ret_val;
69}
70//////////////////////////////////
71// Encoding function for SS__ReturnResult
72//////////////////////////////////
73OCTETSTRING enc_SS_ReturnResult(const SS__ReturnResult& pdu)
74{
75 TTCN_Buffer buf;
76
77 OCTETSTRING ret_val;
78 pdu.encode(SS__ReturnResult_descr_, buf, TTCN_EncDec::CT_BER, BER_ENCODE_DER);
79 buf.get_string(ret_val);
80 ret_val[0] = int2oct(162,1);
81
82 return ret_val;
83}
84//////////////////////////////////
85// Encoding function for SS__ReturnError
86//////////////////////////////////
87OCTETSTRING enc_SS_ReturnError(const SS__ReturnError& pdu)
88{
89 TTCN_Buffer buf;
90
91 OCTETSTRING ret_val;
92 pdu.encode(SS__ReturnError_descr_, buf, TTCN_EncDec::CT_BER, BER_ENCODE_DER);
93 buf.get_string(ret_val);
94 ret_val[0] = int2oct(163,1);
95
96 return ret_val;
97}
98//////////////////////////////////
99// Encoding function for SS__Reject
100//////////////////////////////////
101OCTETSTRING enc_SS_Reject(const SS__Reject& pdu)
102{
103 TTCN_Buffer buf;
104
105 OCTETSTRING ret_val;
106 pdu.encode(SS__Reject_descr_, buf, TTCN_EncDec::CT_BER, BER_ENCODE_DER);
107 buf.get_string(ret_val);
108 ret_val[0] = int2oct(164,1);
109
110 return ret_val;
111}
112
113//////////////////////////////////
114// Decoding function for SS__Invoke
115//////////////////////////////////
116int dec_SS_Invoke(const SS_Invoke_for_dec& params, SS__Invoke& pdu)
117{
118 SS__Invoke__help help_pdu;
119
120 if(params.stream.ispresent())
121 {
122 help_pdu.invokeId().present__() = params.invokeId;
123 if(params.linkedId.ispresent())
124 help_pdu.linkedId()().present__().present__() = params.linkedId;
125 else
126 help_pdu.linkedId() = OMIT_VALUE;
127
128 help_pdu.opcode() = params.opcode;
129
130 OCTETSTRING oct_stream = params.stream;
131 help_pdu.argument() = oct_stream;
132 TTCN_Buffer buf;
133 help_pdu.encode(SS__Invoke__help_descr_, buf, TTCN_EncDec::CT_BER, BER_ENCODE_DER);
134
135 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_IGNORE);
136 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_WARNING);
137 TTCN_EncDec::clear_error();
138
139 pdu.decode(SS__Invoke_descr_, buf, TTCN_EncDec::CT_BER, BER_ACCEPT_ALL);
140
141 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
142
143 if(TTCN_EncDec::get_last_error_type() != 0) return 1;
144 }
145 else
146 {
147 pdu.invokeId().present__() = params.invokeId;
148
149 if(params.linkedId.ispresent())
150 pdu.linkedId()().present__().present__() = params.linkedId;
151 else
152 pdu.linkedId() = OMIT_VALUE;
153
154 pdu.opcode() = params.opcode;
155
156 pdu.argument() = OMIT_VALUE;
157 }
158
159 return 0;
160}
161
162//////////////////////////////////
163// Decoding function for SS__ReturnResult
164//////////////////////////////////
165int dec_SS_ReturnResult(const SS_ReturnResult_for_dec& params, SS__ReturnResult& pdu)
166{
167 SS__ReturnResult__help help_pdu;
168
169
170 if(params.opcode.ispresent() && params.stream.ispresent())
171 {
172 help_pdu.invokeId().present__() = params.invokeId;
173 help_pdu.result()().opcode() = params.opcode;
174 OCTETSTRING oct_stream = params.stream;
175 help_pdu.result()().result() = oct_stream;
176 TTCN_Buffer buf;
177 help_pdu.encode(SS__ReturnResult__help_descr_, buf, TTCN_EncDec::CT_BER, BER_ENCODE_DER);
178
179 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_IGNORE);
180 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_WARNING);
181 TTCN_EncDec::clear_error();
182
183 pdu.decode(SS__ReturnResult_descr_, buf, TTCN_EncDec::CT_BER, BER_ACCEPT_ALL);
184
185 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
186
187 if(TTCN_EncDec::get_last_error_type() != 0) return 1;
188 }
189 else
190 {
191 pdu.invokeId().present__() = params.invokeId;
192 pdu.result() = OMIT_VALUE;
193 }
194
195 return 0;
196}
197
198//////////////////////////////////
199// Decoding function for SS__ReturnError
200//////////////////////////////////
201int dec_SS_ReturnError(const SS_ReturnError_for_dec& params, SS__ReturnError& pdu)
202{
203
204 SS__ReturnError__help help_pdu;
205
206 if(params.stream.ispresent())
207 {
208 help_pdu.invokeId().present__() = params.invokeId;
209 help_pdu.errcode() = params.errorCode;
210 OCTETSTRING oct_stream = params.stream;
211 help_pdu.parameter()() = oct_stream;
212
213 TTCN_Buffer buf;
214
215 help_pdu.encode(SS__ReturnError__help_descr_, buf, TTCN_EncDec::CT_BER, BER_ENCODE_DER);
216
217 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_IGNORE);
218 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_WARNING);
219 TTCN_EncDec::clear_error();
220
221 pdu.decode(SS__ReturnError_descr_, buf, TTCN_EncDec::CT_BER, BER_ACCEPT_ALL);
222
223 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
224
225 if(TTCN_EncDec::get_last_error_type() != 0) return 1;
226 }
227 else
228 {
229 pdu.invokeId().present__() = params.invokeId;
230 pdu.errcode() = params.errorCode;
231 pdu.parameter() = OMIT_VALUE;
232 }
233
234 return 0;
235}
236
237//////////////////////////////////
238// Decoding function for SS__Reject
239//////////////////////////////////
240int dec_SS_Reject(const SS_Reject_for_dec& params, SS__Reject& pdu)
241{
242 if(params.invokeId.ispresent())
243 pdu.invokeId().present__() = params.invokeId;
244 else
245 pdu.invokeId().absent() = ASN_NULL_VALUE;
246
247 pdu.problem() = params.problem;
248
249 return 0;
250}
251
252////////////////////////////////////////////////////////////////////
253// Decoding function for internal SS_TCAP_ComponentPortion
254////////////////////////////////////////////////////////////////////
255int dec__SS__TCAP__ComponentPortion(const OCTETSTRING& stream, SS__TCAP__ComponentPortion& pdu)
256{
257 if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC))
258 {
259 TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
260 TTCN_Logger::log_event_str("dec_SS_TCAP_ComponentPortion(): Stream before decoding: ");
261 stream.log();
262 TTCN_Logger::end_event();
263 }
264
265 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_IGNORE);
266 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_WARNING);
267 TTCN_EncDec::clear_error();
268
269 TTCN_Buffer ttcn_buffer(stream);
270 SS__TCAP__Component ret_sub_val;
271 int i = 0;
272
273 if(!ttcn_buffer.contains_complete_TLV()) {
274 if (TTCN_Logger::log_this_event(TTCN_Logger::TTCN_WARNING))
275 {
276 TTCN_Logger::begin_event(TTCN_Logger::TTCN_WARNING);
277 TTCN_Logger::log_event_str("dec_SS_TCAP_ComponentPortion(): there is no complete TLV in the incoming stream!");
278 TTCN_Logger::end_event();
279 }
280 return 1;
281 }
282
283 while(ttcn_buffer.contains_complete_TLV())
284 {
285 ret_sub_val.decode(SS__TCAP__Component_descr_, ttcn_buffer, TTCN_EncDec::CT_BER, BER_ACCEPT_ALL);
286 pdu[i] = ret_sub_val;
287 i++;
288 ttcn_buffer.cut();
289 }
290
291 TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT);
292
293 if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC))
294 {
295 TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
296 TTCN_Logger::log_event_str("dec_SS_TCAP_ComponentPortion(): Decoded @SS_Types.SS_TCAP_ComponentPortion: ");
297 pdu.log();
298 TTCN_Logger::end_event();
299 }
300
301 return TTCN_EncDec::get_last_error_type() == TTCN_EncDec::ET_NONE ? 0 : 1;
302}
303
304
305//////////////////////////////////////////////////////////////////////////////////////////////////////
306// Main encoding function for SS_FacilityInformation. This is called from TTCN-3
307//////////////////////////////////////////////////////////////////////////////////////////////////////
308OCTETSTRING enc__SS__FacilityInformation(const SS__FacilityInformation& pdu)
309{
310 if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC))
311 {
312 TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
313 TTCN_Logger::log_event_str("enc_SS_FacilityInformation(): SS_FacilityInformation before encoding: ");
314 pdu.log();
315 TTCN_Logger::end_event();
316 }
317 SS__TCAP__ComponentPortion temp_val;
318 OCTETSTRING ret_val(0,NULL);
319
320 for (int i = 0; i < pdu.size_of(); i++)
321 {
322 if (pdu[i].get_selection() == SS__Component::ALT_invoke)
323 {
324 ret_val = ret_val + enc_SS_Invoke(pdu[i].invoke());
325 }
326 else if (pdu[i].get_selection() == SS__Component::ALT_returnResult)
327 {
328 ret_val = ret_val + enc_SS_ReturnResult(pdu[i].returnResult());
329 }
330 else if (pdu[i].get_selection() == SS__Component::ALT_returnError)
331 {
332 ret_val = ret_val + enc_SS_ReturnError(pdu[i].returnError());
333 }
334 else if (pdu[i].get_selection() == SS__Component::ALT_reject)
335 {
336 ret_val = ret_val + enc_SS_Reject(pdu[i].reject());
337 }
338 }
339 if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC))
340 {
341 TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
342 TTCN_Logger::log_event_str("enc_SS_FacilityInformation(): stream after encoding: ");
343 ret_val.log();
344 TTCN_Logger::end_event();
345 }
346 return ret_val;
347}
348
349//////////////////////////////////////////////////////////////////////////////////////////////////////
350// Main decoding function for SS_FacilityInformation. This is called from TTCN-3
351//////////////////////////////////////////////////////////////////////////////////////////////////////
352INTEGER dec__SS__FacilityInformation__backtrack(const OCTETSTRING& stream, SS__FacilityInformation& pdu)
353{
354 if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC))
355 {
356 TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
357 TTCN_Logger::log_event_str("dec_SS_FacilityInformation__backtrack(): Stream before decoding: ");
358 stream.log();
359 TTCN_Logger::end_event();
360 }
361
362 SS__TCAP__ComponentPortion temp_val;
363 int decode = dec__SS__TCAP__ComponentPortion(stream, temp_val);
364
365 if(decode == 0) {
366
367 for (int i = 0; i < temp_val.size_of() && decode == 0; i++)
368 {
369 if (temp_val[i].get_selection() == SS__TCAP__Component::ALT_invoke)
370 {
371 SS_Invoke_for_dec par_val;
372 par_val.invokeId = temp_val[i].invoke().invokeID();
373 par_val.linkedId = temp_val[i].invoke().linkedID();
374 par_val.opcode = temp_val[i].invoke().operationCode();
375 par_val.stream = temp_val[i].invoke().parameter();
376 decode = dec_SS_Invoke(par_val, pdu[i].invoke());
377 }
378 else if (temp_val[i].get_selection() == SS__TCAP__Component::ALT_returnResult)
379 {
380 SS_ReturnResult_for_dec par_val;
381 par_val.invokeId = temp_val[i].returnResult().invokeID();
382
383 if(temp_val[i].returnResult().result().ispresent())
384 {
385 SS__TCAP__ReturnResult__Result temp_res = temp_val[i].returnResult().result();
386 par_val.opcode = temp_res.operationCode();
387 par_val.stream = temp_res.parameter();
388 }
389 else
390 {
391 par_val.opcode = OMIT_VALUE;
392 par_val.stream = OMIT_VALUE;
393 }
394 decode = dec_SS_ReturnResult(par_val, pdu[i].returnResult());
395 }
396 else if (temp_val[i].get_selection() == SS__TCAP__Component::ALT_returnError)
397 {
398 SS_ReturnError_for_dec par_val;
399 par_val.invokeId = temp_val[i].returnError().invokeID();
400 par_val.errorCode = temp_val[i].returnError().errorCode();
401 par_val.stream = temp_val[i].returnError().parameter();
402
403 decode = dec_SS_ReturnError(par_val, pdu[i].returnError());
404 }
405 else if (temp_val[i].get_selection() == SS__TCAP__Component::ALT_reject)
406 {
407 SS_Reject_for_dec par_val;
408 if( temp_val[i].reject().invokeID().get_selection() == SS__TCAP__Reject_invokeID::ALT_derivable)
409 par_val.invokeId = temp_val[i].reject().invokeID().derivable();
410 else
411 par_val.invokeId = OMIT_VALUE;
412 par_val.problem = temp_val[i].reject().problem();
413
414 decode = dec_SS_Reject(par_val, pdu[i].reject());
415 }
416 }
417 }
418
419 if (TTCN_Logger::log_this_event(TTCN_Logger::DEBUG_ENCDEC))
420 {
421 TTCN_Logger::begin_event(TTCN_Logger::DEBUG_ENCDEC);
422 TTCN_Logger::log_event_str("dec_SS_FacilityInformation__backtrack(): Decoded @SS_Types.SS_FacilityInformation: ");
423 pdu.log();
424 TTCN_Logger::end_event();
425 }
426
427 return decode;
428}
429
430SS__FacilityInformation dec__SS__FacilityInformation(const OCTETSTRING& stream)
431{
432 SS__FacilityInformation ret;
433 dec__SS__FacilityInformation__backtrack(stream, ret);
434 return ret;
435}
436
437}//namespace
438