blob: 8b9f4a9f90e3d47155099c544b442396e730a184 [file] [log] [blame]
anjana_sreekumar@infosys.com991c2062020-01-08 11:42:57 +05301/*
2 * Copyright 2019-present Infosys Limited  
3 *   
4 * SPDX-License-Identifier: Apache-2.0    
5 */
6
7/******************************************************************************
8 *
9 * This is an auto generated file.
10 * Please do not edit this file.
11 * All edits to be made through template source file
12 * <TOP-DIR/scripts/GtpV2StackCodeGen/tts/msgtemplate.cpp.tt>
13 ******************************************************************************/
14
15#include "releaseAccessBearersResponseMsg.h"
16#include "../ieClasses/manual/gtpV2Ie.h"
17#include "../ieClasses/gtpV2IeFactory.h"
18#include "../ieClasses/causeIe.h"
19#include "../ieClasses/recoveryIe.h"
20#include "../ieClasses/indicationIe.h"
21#include "../ieClasses/loadControlInformationIe.h"
22#include "../ieClasses/sgwsNodeLevelLoadControlInformationInReleaseAccessBearersResponse.h"
23#include "../ieClasses/overloadControlInformationIe.h"
24#include "../ieClasses/sgwsOverloadControlInformationInReleaseAccessBearersResponse.h"
25
26ReleaseAccessBearersResponseMsg::ReleaseAccessBearersResponseMsg()
27{
28 msgType = ReleaseAccessBearersResponseMsgType;
29 Uint16 mandIe;
30 mandIe = CauseIeType;
31 mandIe = (mandIe << 8) | 0; // cause
32 mandatoryIeSet.insert(mandIe);
33}
34
35ReleaseAccessBearersResponseMsg::~ReleaseAccessBearersResponseMsg()
36{
37
38}
39
40bool ReleaseAccessBearersResponseMsg::encodeReleaseAccessBearersResponseMsg(MsgBuffer &buffer,
41 ReleaseAccessBearersResponseMsgData
42 const &data)
43{
44 bool rc = false;
45 GtpV2IeHeader header;
46 Uint16 startIndex = 0;
47 Uint16 endIndex = 0;
48 Uint16 length = 0;
49
50
51 // Encode the Ie Header
52 header.ieType = CauseIeType;
53 header.instance = 0;
54 header.length = 0; // We will encode the IE first and then update the length
55 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
56 startIndex = buffer.getCurrentIndex();
57 CauseIe cause=
58 dynamic_cast<
59 CauseIe&>(GtpV2IeFactory::getInstance().getIeObject(CauseIeType));
60 rc = cause.encodeCauseIe(buffer, data.cause);
61 endIndex = buffer.getCurrentIndex();
62 length = endIndex - startIndex;
63
64 // encode the length value now
65 buffer.goToIndex(startIndex - 3);
66 buffer.writeUint16(length, false);
67 buffer.goToIndex(endIndex);
68
69 if (!(rc))
70 {
71 errorStream.add((char *)"Failed to encode IE: cause\n");
72 return false;
73 }
74
75 if (data.recoveryIePresent)
76 {
77
78 // Encode the Ie Header
79 header.ieType = RecoveryIeType;
80 header.instance = 0;
81 header.length = 0; // We will encode the IE first and then update the length
82 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
83 startIndex = buffer.getCurrentIndex();
84 RecoveryIe recovery=
85 dynamic_cast<
86 RecoveryIe&>(GtpV2IeFactory::getInstance().getIeObject(RecoveryIeType));
87 rc = recovery.encodeRecoveryIe(buffer, data.recovery);
88 endIndex = buffer.getCurrentIndex();
89 length = endIndex - startIndex;
90
91 // encode the length value now
92 buffer.goToIndex(startIndex - 3);
93 buffer.writeUint16(length, false);
94 buffer.goToIndex(endIndex);
95
96 if (!(rc))
97 {
98 errorStream.add((char *)"Failed to encode IE: recovery\n");
99 return false;
100 }
101 }
102
103 if (data.indicationFlagsIePresent)
104 {
105
106 // Encode the Ie Header
107 header.ieType = IndicationIeType;
108 header.instance = 0;
109 header.length = 0; // We will encode the IE first and then update the length
110 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
111 startIndex = buffer.getCurrentIndex();
112 IndicationIe indication=
113 dynamic_cast<
114 IndicationIe&>(GtpV2IeFactory::getInstance().getIeObject(IndicationIeType));
115 rc = indication.encodeIndicationIe(buffer, data.indicationFlags);
116 endIndex = buffer.getCurrentIndex();
117 length = endIndex - startIndex;
118
119 // encode the length value now
120 buffer.goToIndex(startIndex - 3);
121 buffer.writeUint16(length, false);
122 buffer.goToIndex(endIndex);
123
124 if (!(rc))
125 {
126 errorStream.add((char *)"Failed to encode IE: indicationFlags\n");
127 return false;
128 }
129 }
130
131 if (data.sgwsNodeLevelLoadControlInformationIePresent)
132 {
133
134 // Encode the Ie Header
135 header.ieType = LoadControlInformationIeType;
136 header.instance = 0;
137 header.length = 0; // We will encode the IE first and then update the length
138 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
139 startIndex = buffer.getCurrentIndex();
140 LoadControlInformationIe loadControlInformation=
141 dynamic_cast<
142 LoadControlInformationIe&>(GtpV2IeFactory::getInstance().getIeObject(LoadControlInformationIeType));
143 SgwsNodeLevelLoadControlInformationInReleaseAccessBearersResponse groupedIeInstance =
144 dynamic_cast<
145 SgwsNodeLevelLoadControlInformationInReleaseAccessBearersResponse&>(loadControlInformation.getGroupedIe(msgType, 0));
146 rc = groupedIeInstance.encodeSgwsNodeLevelLoadControlInformationInReleaseAccessBearersResponse(buffer, data.sgwsNodeLevelLoadControlInformation);
147 endIndex = buffer.getCurrentIndex();
148 length = endIndex - startIndex;
149
150 // encode the length value now
151 buffer.goToIndex(startIndex - 3);
152 buffer.writeUint16(length, false);
153 buffer.goToIndex(endIndex);
154
155 if (!(rc))
156 {
157 errorStream.add((char *)"Failed to encode IE: sgwsNodeLevelLoadControlInformation\n");
158 return false;
159 }
160 }
161
162 if (data.sgwsOverloadControlInformationIePresent)
163 {
164
165 // Encode the Ie Header
166 header.ieType = OverloadControlInformationIeType;
167 header.instance = 0;
168 header.length = 0; // We will encode the IE first and then update the length
169 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
170 startIndex = buffer.getCurrentIndex();
171 OverloadControlInformationIe overloadControlInformation=
172 dynamic_cast<
173 OverloadControlInformationIe&>(GtpV2IeFactory::getInstance().getIeObject(OverloadControlInformationIeType));
174 SgwsOverloadControlInformationInReleaseAccessBearersResponse groupedIeInstance =
175 dynamic_cast<
176 SgwsOverloadControlInformationInReleaseAccessBearersResponse&>(overloadControlInformation.getGroupedIe(msgType, 0));
177 rc = groupedIeInstance.encodeSgwsOverloadControlInformationInReleaseAccessBearersResponse(buffer, data.sgwsOverloadControlInformation);
178 endIndex = buffer.getCurrentIndex();
179 length = endIndex - startIndex;
180
181 // encode the length value now
182 buffer.goToIndex(startIndex - 3);
183 buffer.writeUint16(length, false);
184 buffer.goToIndex(endIndex);
185
186 if (!(rc))
187 {
188 errorStream.add((char *)"Failed to encode IE: sgwsOverloadControlInformation\n");
189 return false;
190 }
191 }
192 return rc;
193
194}
195
196bool ReleaseAccessBearersResponseMsg::decodeReleaseAccessBearersResponseMsg(MsgBuffer &buffer,
197 ReleaseAccessBearersResponseMsgData
198 &data, Uint16 length)
199{
200
201 bool rc = false;
202 GtpV2IeHeader ieHeader;
203
204 set<Uint16> mandatoryIeLocalList = mandatoryIeSet;
205 while (buffer.lengthLeft() > IE_HEADER_SIZE)
206 {
207 GtpV2Ie::decodeGtpV2IeHeader(buffer, ieHeader);
208 if (ieHeader.length > buffer.lengthLeft())
209 {
210 // We do not have enough bytes left in the message for this IE
211 errorStream.add((char *)"IE Length exceeds beyond message boundary\n");
212 errorStream.add((char *)" Offending IE Type: ");
213 errorStream.add(ieHeader.ieType);
214 errorStream.add((char *)"\n Ie Length in Header: ");
215 errorStream.add(ieHeader.length);
216 errorStream.add((char *)"\n Bytes left in message: ");
217 errorStream.add(buffer.lengthLeft());
218 errorStream.endOfLine();
219 return false;
220 }
221
222 switch (ieHeader.ieType){
223
224 case CauseIeType:
225 {
226 CauseIe ieObject =
227 dynamic_cast<
228 CauseIe&>(GtpV2IeFactory::getInstance().getIeObject(CauseIeType));
229
230 if(ieHeader.instance == 0)
231 {
232 rc = ieObject.decodeCauseIe(buffer, data.cause, ieHeader.length);
233
234 if (!(rc))
235 {
236 errorStream.add((char *)"Failed to decode IE: cause\n");
237 return false;
238 }
239 }
240
241 else
242 {
243 // Unknown IE instance print error
244 errorStream.add((char *)"Unknown IE Type: ");
245 errorStream.add(ieHeader.ieType);
246 errorStream.endOfLine();
247 buffer.skipBytes(ieHeader.length);
248 }
249 break;
250 }
251
252 case RecoveryIeType:
253 {
254 RecoveryIe ieObject =
255 dynamic_cast<
256 RecoveryIe&>(GtpV2IeFactory::getInstance().getIeObject(RecoveryIeType));
257
258 if(ieHeader.instance == 0)
259 {
260 rc = ieObject.decodeRecoveryIe(buffer, data.recovery, ieHeader.length);
261
262 data.recoveryIePresent = true;
263 if (!(rc))
264 {
265 errorStream.add((char *)"Failed to decode IE: recovery\n");
266 return false;
267 }
268 }
269
270 else
271 {
272 // Unknown IE instance print error
273 errorStream.add((char *)"Unknown IE Type: ");
274 errorStream.add(ieHeader.ieType);
275 errorStream.endOfLine();
276 buffer.skipBytes(ieHeader.length);
277 }
278 break;
279 }
280
281 case IndicationIeType:
282 {
283 IndicationIe ieObject =
284 dynamic_cast<
285 IndicationIe&>(GtpV2IeFactory::getInstance().getIeObject(IndicationIeType));
286
287 if(ieHeader.instance == 0)
288 {
289 rc = ieObject.decodeIndicationIe(buffer, data.indicationFlags, ieHeader.length);
290
291 data.indicationFlagsIePresent = true;
292 if (!(rc))
293 {
294 errorStream.add((char *)"Failed to decode IE: indicationFlags\n");
295 return false;
296 }
297 }
298
299 else
300 {
301 // Unknown IE instance print error
302 errorStream.add((char *)"Unknown IE Type: ");
303 errorStream.add(ieHeader.ieType);
304 errorStream.endOfLine();
305 buffer.skipBytes(ieHeader.length);
306 }
307 break;
308 }
309
310 case LoadControlInformationIeType:
311 {
312 LoadControlInformationIe ieObject =
313 dynamic_cast<
314 LoadControlInformationIe&>(GtpV2IeFactory::getInstance().getIeObject(LoadControlInformationIeType));
315
316 if(ieHeader.instance == 0)
317 {
318 SgwsNodeLevelLoadControlInformationInReleaseAccessBearersResponse groupedIeInstance =
319 dynamic_cast<
320 SgwsNodeLevelLoadControlInformationInReleaseAccessBearersResponse&>(ieObject.getGroupedIe(msgType, 0));
321 rc = groupedIeInstance.decodeSgwsNodeLevelLoadControlInformationInReleaseAccessBearersResponse(buffer, data.sgwsNodeLevelLoadControlInformation, ieHeader.length);
322
323 data.sgwsNodeLevelLoadControlInformationIePresent = true;
324 if (!(rc))
325 {
326 errorStream.add((char *)"Failed to decode IE: sgwsNodeLevelLoadControlInformation\n");
327 return false;
328 }
329 }
330
331 else
332 {
333 // Unknown IE instance print error
334 errorStream.add((char *)"Unknown IE Type: ");
335 errorStream.add(ieHeader.ieType);
336 errorStream.endOfLine();
337 buffer.skipBytes(ieHeader.length);
338 }
339 break;
340 }
341
342 case OverloadControlInformationIeType:
343 {
344 OverloadControlInformationIe ieObject =
345 dynamic_cast<
346 OverloadControlInformationIe&>(GtpV2IeFactory::getInstance().getIeObject(OverloadControlInformationIeType));
347
348 if(ieHeader.instance == 0)
349 {
350 SgwsOverloadControlInformationInReleaseAccessBearersResponse groupedIeInstance =
351 dynamic_cast<
352 SgwsOverloadControlInformationInReleaseAccessBearersResponse&>(ieObject.getGroupedIe(msgType, 0));
353 rc = groupedIeInstance.decodeSgwsOverloadControlInformationInReleaseAccessBearersResponse(buffer, data.sgwsOverloadControlInformation, ieHeader.length);
354
355 data.sgwsOverloadControlInformationIePresent = true;
356 if (!(rc))
357 {
358 errorStream.add((char *)"Failed to decode IE: sgwsOverloadControlInformation\n");
359 return false;
360 }
361 }
362
363 else
364 {
365 // Unknown IE instance print error
366 errorStream.add((char *)"Unknown IE Type: ");
367 errorStream.add(ieHeader.ieType);
368 errorStream.endOfLine();
369 buffer.skipBytes(ieHeader.length);
370 }
371 break;
372 }
373
374 default:
375 {
376 // Unknown IE print error
377 errorStream.add((char *)"Unknown IE Type: ");
378 errorStream.add(ieHeader.ieType);
379 errorStream.endOfLine();
380 buffer.skipBytes(ieHeader.length);
381 }
382 }
383 }
384 return rc; // TODO validations
385}
386
387void ReleaseAccessBearersResponseMsg::
388displayReleaseAccessBearersResponseMsgData_v(ReleaseAccessBearersResponseMsgData const &data, Debug &stream)
389{
390 stream.incrIndent();
391 stream.add((char *)"ReleaseAccessBearersResponseMsg:");
392 stream.endOfLine();
393 stream.incrIndent();
394
395
396 stream.add((char *)"IE - cause:");
397 stream.endOfLine();
398 CauseIe cause=
399 dynamic_cast<
400 CauseIe&>(GtpV2IeFactory::getInstance().getIeObject(CauseIeType));
401 cause.displayCauseIe_v(data.cause, stream);
402
403 if (data.recoveryIePresent)
404 {
405
406
407 stream.add((char *)"IE - recovery:");
408 stream.endOfLine();
409 RecoveryIe recovery=
410 dynamic_cast<
411 RecoveryIe&>(GtpV2IeFactory::getInstance().getIeObject(RecoveryIeType));
412 recovery.displayRecoveryIe_v(data.recovery, stream);
413
414 }
415 if (data.indicationFlagsIePresent)
416 {
417
418
419 stream.add((char *)"IE - indicationFlags:");
420 stream.endOfLine();
421 IndicationIe indication=
422 dynamic_cast<
423 IndicationIe&>(GtpV2IeFactory::getInstance().getIeObject(IndicationIeType));
424 indication.displayIndicationIe_v(data.indicationFlags, stream);
425
426 }
427 if (data.sgwsNodeLevelLoadControlInformationIePresent)
428 {
429
430
431 stream.add((char *)"IE - sgwsNodeLevelLoadControlInformation:");
432 stream.endOfLine();
433 LoadControlInformationIe loadControlInformation=
434 dynamic_cast<
435 LoadControlInformationIe&>(GtpV2IeFactory::getInstance().getIeObject(LoadControlInformationIeType));
436 SgwsNodeLevelLoadControlInformationInReleaseAccessBearersResponse groupedIeInstance =
437 dynamic_cast<
438 SgwsNodeLevelLoadControlInformationInReleaseAccessBearersResponse&>(loadControlInformation.getGroupedIe(msgType, 0));
439 groupedIeInstance.displaySgwsNodeLevelLoadControlInformationInReleaseAccessBearersResponseData_v(data.sgwsNodeLevelLoadControlInformation, stream);
440
441 }
442 if (data.sgwsOverloadControlInformationIePresent)
443 {
444
445
446 stream.add((char *)"IE - sgwsOverloadControlInformation:");
447 stream.endOfLine();
448 OverloadControlInformationIe overloadControlInformation=
449 dynamic_cast<
450 OverloadControlInformationIe&>(GtpV2IeFactory::getInstance().getIeObject(OverloadControlInformationIeType));
451 SgwsOverloadControlInformationInReleaseAccessBearersResponse groupedIeInstance =
452 dynamic_cast<
453 SgwsOverloadControlInformationInReleaseAccessBearersResponse&>(overloadControlInformation.getGroupedIe(msgType, 0));
454 groupedIeInstance.displaySgwsOverloadControlInformationInReleaseAccessBearersResponseData_v(data.sgwsOverloadControlInformation, stream);
455
456 }
457
458 stream.decrIndent();
459 stream.decrIndent();
460}
461
462