blob: 5e3680cad47a68cf3a5b73e4568d3db6c2e204be [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/grpieinsttemplate.cpp.tt>
13 ******************************************************************************/
14
15#include "bearerContextsToBeModifiedInModifyBearerRequest.h"
16#include "manual/gtpV2Ie.h"
17#include "gtpV2IeFactory.h"
18#include "ebiIe.h"
19#include "fTeidIe.h"
20#include "fTeidIe.h"
21#include "fTeidIe.h"
22#include "fTeidIe.h"
23#include "fTeidIe.h"
24
25BearerContextsToBeModifiedInModifyBearerRequest::
26BearerContextsToBeModifiedInModifyBearerRequest()
27{
28 Uint16 mandIe;
29 mandIe = EbiIeType;
30 mandIe = (mandIe << 8) | 0; // epsBearerId
31 mandatoryIeSet.insert(mandIe);
32
33}
34
35BearerContextsToBeModifiedInModifyBearerRequest::
36~BearerContextsToBeModifiedInModifyBearerRequest()
37{
38
39}
40bool BearerContextsToBeModifiedInModifyBearerRequest::
41encodeBearerContextsToBeModifiedInModifyBearerRequest(MsgBuffer &buffer,
42 BearerContextsToBeModifiedInModifyBearerRequestData
43 const &data)
44{
45 bool rc = false;
46 GtpV2IeHeader header;
47 Uint16 startIndex = 0;
48 Uint16 endIndex = 0;
49 Uint16 length = 0;
50
51
52
53 // Encode the Ie Header
54 header.ieType = EbiIeType;
55 header.instance = 0;
56 header.length = 0; // We will encode the IE first and then update the length
57 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
58 startIndex = buffer.getCurrentIndex();
59 EbiIe ebi=
60 dynamic_cast<
61 EbiIe&>(GtpV2IeFactory::getInstance().getIeObject(EbiIeType));
62 rc = ebi.encodeEbiIe(buffer, data.epsBearerId);
63 endIndex = buffer.getCurrentIndex();
64 length = endIndex - startIndex;
65
66 // encode the length value now
67 buffer.goToIndex(startIndex - 3);
68 buffer.writeUint16(length, false);
69 buffer.goToIndex(endIndex);
70 if (!(rc))
71 {
72 errorStream.add((char *)"Failed to encode IE: epsBearerId\n");
73 return false;
74 }
75
76 if (data.s1EnodebFTeidIePresent)
77 {
78
79 // Encode the Ie Header
80 header.ieType = FTeidIeType;
81 header.instance = 0;
82 header.length = 0; // We will encode the IE first and then update the length
83 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
84 startIndex = buffer.getCurrentIndex();
85 FTeidIe fTeid=
86 dynamic_cast<
87 FTeidIe&>(GtpV2IeFactory::getInstance().getIeObject(FTeidIeType));
88 rc = fTeid.encodeFTeidIe(buffer, data.s1EnodebFTeid);
89 endIndex = buffer.getCurrentIndex();
90 length = endIndex - startIndex;
91
92 // encode the length value now
93 buffer.goToIndex(startIndex - 3);
94 buffer.writeUint16(length, false);
95 buffer.goToIndex(endIndex);
96
97 if (!(rc))
98 {
99 errorStream.add((char *)"Failed to encode IE: s1EnodebFTeid\n");
100 return false;
101 }
102 }
103
104 if (data.s58USgwFTeidIePresent)
105 {
106
107 // Encode the Ie Header
108 header.ieType = FTeidIeType;
109 header.instance = 1;
110 header.length = 0; // We will encode the IE first and then update the length
111 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
112 startIndex = buffer.getCurrentIndex();
113 FTeidIe fTeid=
114 dynamic_cast<
115 FTeidIe&>(GtpV2IeFactory::getInstance().getIeObject(FTeidIeType));
116 rc = fTeid.encodeFTeidIe(buffer, data.s58USgwFTeid);
117 endIndex = buffer.getCurrentIndex();
118 length = endIndex - startIndex;
119
120 // encode the length value now
121 buffer.goToIndex(startIndex - 3);
122 buffer.writeUint16(length, false);
123 buffer.goToIndex(endIndex);
124
125 if (!(rc))
126 {
127 errorStream.add((char *)"Failed to encode IE: s58USgwFTeid\n");
128 return false;
129 }
130 }
131
132 if (data.s12RncFTeidIePresent)
133 {
134
135 // Encode the Ie Header
136 header.ieType = FTeidIeType;
137 header.instance = 2;
138 header.length = 0; // We will encode the IE first and then update the length
139 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
140 startIndex = buffer.getCurrentIndex();
141 FTeidIe fTeid=
142 dynamic_cast<
143 FTeidIe&>(GtpV2IeFactory::getInstance().getIeObject(FTeidIeType));
144 rc = fTeid.encodeFTeidIe(buffer, data.s12RncFTeid);
145 endIndex = buffer.getCurrentIndex();
146 length = endIndex - startIndex;
147
148 // encode the length value now
149 buffer.goToIndex(startIndex - 3);
150 buffer.writeUint16(length, false);
151 buffer.goToIndex(endIndex);
152
153 if (!(rc))
154 {
155 errorStream.add((char *)"Failed to encode IE: s12RncFTeid\n");
156 return false;
157 }
158 }
159
160 if (data.s4USgsnFTeidIePresent)
161 {
162
163 // Encode the Ie Header
164 header.ieType = FTeidIeType;
165 header.instance = 3;
166 header.length = 0; // We will encode the IE first and then update the length
167 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
168 startIndex = buffer.getCurrentIndex();
169 FTeidIe fTeid=
170 dynamic_cast<
171 FTeidIe&>(GtpV2IeFactory::getInstance().getIeObject(FTeidIeType));
172 rc = fTeid.encodeFTeidIe(buffer, data.s4USgsnFTeid);
173 endIndex = buffer.getCurrentIndex();
174 length = endIndex - startIndex;
175
176 // encode the length value now
177 buffer.goToIndex(startIndex - 3);
178 buffer.writeUint16(length, false);
179 buffer.goToIndex(endIndex);
180
181 if (!(rc))
182 {
183 errorStream.add((char *)"Failed to encode IE: s4USgsnFTeid\n");
184 return false;
185 }
186 }
187
188 if (data.s11UMmeFTeidIePresent)
189 {
190
191 // Encode the Ie Header
192 header.ieType = FTeidIeType;
193 header.instance = 4;
194 header.length = 0; // We will encode the IE first and then update the length
195 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
196 startIndex = buffer.getCurrentIndex();
197 FTeidIe fTeid=
198 dynamic_cast<
199 FTeidIe&>(GtpV2IeFactory::getInstance().getIeObject(FTeidIeType));
200 rc = fTeid.encodeFTeidIe(buffer, data.s11UMmeFTeid);
201 endIndex = buffer.getCurrentIndex();
202 length = endIndex - startIndex;
203
204 // encode the length value now
205 buffer.goToIndex(startIndex - 3);
206 buffer.writeUint16(length, false);
207 buffer.goToIndex(endIndex);
208
209 if (!(rc))
210 {
211 errorStream.add((char *)"Failed to encode IE: s11UMmeFTeid\n");
212 return false;
213 }
214 }
215 return rc;
216}
217
218bool BearerContextsToBeModifiedInModifyBearerRequest::
219decodeBearerContextsToBeModifiedInModifyBearerRequest(MsgBuffer &buffer,
220 BearerContextsToBeModifiedInModifyBearerRequestData
221 &data, Uint16 length)
222{
223
224 bool rc = false;
225 GtpV2IeHeader ieHeader;
226 set<Uint16> mandatoryIeLocalList = mandatoryIeSet;
227 while (buffer.lengthLeft() > IE_HEADER_SIZE)
228 {
229 GtpV2Ie::decodeGtpV2IeHeader(buffer, ieHeader);
230 if (ieHeader.length > buffer.lengthLeft())
231 {
232 // We do not have enough bytes left in the message for this IE
233 errorStream.add((char *)"IE Length exceeds beyond message boundary\n");
234 errorStream.add((char *)" Offending IE Type: ");
235 errorStream.add(ieHeader.ieType);
236 errorStream.add((char *)"\n Ie Length in Header: ");
237 errorStream.add(ieHeader.length);
238 errorStream.add((char *)"\n Bytes left in message: ");
239 errorStream.add(buffer.lengthLeft());
240 errorStream.endOfLine();
241 return false;
242 }
243
244 switch (ieHeader.ieType){
245 case EbiIeType:
246 {
247 EbiIe ieObject =
248 dynamic_cast<
249 EbiIe&>(GtpV2IeFactory::getInstance().
250 getIeObject(EbiIeType));
251
252
253 if(ieHeader.instance == 0)
254 {
255
256 rc = ieObject.decodeEbiIe(buffer, data.epsBearerId, ieHeader.length);
257
258 if (!(rc))
259 {
260 errorStream.add((char *)"Failed to decode IE: epsBearerId\n");
261 return false;
262 }
263 Uint16 mandIe = EbiIeType;
264 mandIe = (mandIe << 8) | 0;
265 mandatoryIeLocalList.erase(mandIe);
266 }
267 else
268 {
269 // Unknown IE instance print error TODO
270 errorStream.add((char *)"Unknown IE Type: ");
271 errorStream.add(ieHeader.ieType);
272 errorStream.endOfLine();
273 buffer.skipBytes(ieHeader.length);
274 }
275 break;
276 }
277 case FTeidIeType:
278 {
279 FTeidIe ieObject =
280 dynamic_cast<
281 FTeidIe&>(GtpV2IeFactory::getInstance().
282 getIeObject(FTeidIeType));
283
284
285 if(ieHeader.instance == 0)
286 {
287
288 rc = ieObject.decodeFTeidIe(buffer, data.s1EnodebFTeid, ieHeader.length);
289
290 data.s1EnodebFTeidIePresent = true;
291 if (!(rc))
292 {
293 errorStream.add((char *)"Failed to decode IE: s1EnodebFTeid\n");
294 return false;
295 }
296 }
297
298 else if(ieHeader.instance == 1)
299 {
300
301 rc = ieObject.decodeFTeidIe(buffer, data.s58USgwFTeid, ieHeader.length);
302
303 data.s58USgwFTeidIePresent = true;
304 if (!(rc))
305 {
306 errorStream.add((char *)"Failed to decode IE: s58USgwFTeid\n");
307 return false;
308 }
309 }
310
311 else if(ieHeader.instance == 2)
312 {
313
314 rc = ieObject.decodeFTeidIe(buffer, data.s12RncFTeid, ieHeader.length);
315
316 data.s12RncFTeidIePresent = true;
317 if (!(rc))
318 {
319 errorStream.add((char *)"Failed to decode IE: s12RncFTeid\n");
320 return false;
321 }
322 }
323
324 else if(ieHeader.instance == 3)
325 {
326
327 rc = ieObject.decodeFTeidIe(buffer, data.s4USgsnFTeid, ieHeader.length);
328
329 data.s4USgsnFTeidIePresent = true;
330 if (!(rc))
331 {
332 errorStream.add((char *)"Failed to decode IE: s4USgsnFTeid\n");
333 return false;
334 }
335 }
336
337 else if(ieHeader.instance == 4)
338 {
339
340 rc = ieObject.decodeFTeidIe(buffer, data.s11UMmeFTeid, ieHeader.length);
341
342 data.s11UMmeFTeidIePresent = true;
343 if (!(rc))
344 {
345 errorStream.add((char *)"Failed to decode IE: s11UMmeFTeid\n");
346 return false;
347 }
348 }
349 else
350 {
351 // Unknown IE instance print error TODO
352 errorStream.add((char *)"Unknown IE Type: ");
353 errorStream.add(ieHeader.ieType);
354 errorStream.endOfLine();
355 buffer.skipBytes(ieHeader.length);
356 }
357 break;
358 }
359 default:
360 {
361 // Unknown IE print error
362 errorStream.add((char *)"Unknown IE Type: ");
363 errorStream.add(ieHeader.ieType);
364 errorStream.endOfLine();
365 buffer.skipBytes(ieHeader.length);
366 }
367 }
368 }
369 if (!mandatoryIeLocalList.empty())
370 {
371 // some mandatory IEs are missing
372 errorStream.add((char *)"Missing Mandatory IEs:");
373 errorStream.endOfLine();
374 while (!mandatoryIeLocalList.empty())
375 {
376 Uint16 missingMandIe = *mandatoryIeLocalList.begin ();
377 mandatoryIeLocalList.erase (mandatoryIeLocalList.begin ());
378 Uint16 missingInstance = missingMandIe & 0x00FF;
379 Uint16 missingIeType = (missingMandIe >> 8);
380 errorStream.add ((char *)"Missing Ie type: ");
381 errorStream.add (missingIeType);
382 errorStream.add ((char *)" Instance: ");
383 errorStream.add (missingInstance);
384 errorStream.endOfLine();
385 }
386 rc = false;
387
388 }
389 return rc;
390}
391
392void BearerContextsToBeModifiedInModifyBearerRequest::
393displayBearerContextsToBeModifiedInModifyBearerRequestData_v
394(BearerContextsToBeModifiedInModifyBearerRequestData const &data, Debug &stream)
395{
396 stream.incrIndent();
397 stream.add((char *)"BearerContextsToBeModifiedInModifyBearerRequest:");
398 stream.endOfLine();
399 stream.incrIndent();
400
401
402 if (data.s1EnodebFTeidIePresent)
403 {
404
405 stream.add((char *)"s1EnodebFTeid:");
406 stream.endOfLine();
407 FTeidIe fTeid=
408 dynamic_cast<
409 FTeidIe&>(GtpV2IeFactory::getInstance().getIeObject(FTeidIeType));
410 fTeid.displayFTeidIe_v(data.s1EnodebFTeid, stream);
411
412 }
413
414 if (data.s58USgwFTeidIePresent)
415 {
416
417 stream.add((char *)"s58USgwFTeid:");
418 stream.endOfLine();
419 FTeidIe fTeid=
420 dynamic_cast<
421 FTeidIe&>(GtpV2IeFactory::getInstance().getIeObject(FTeidIeType));
422 fTeid.displayFTeidIe_v(data.s58USgwFTeid, stream);
423
424 }
425
426 if (data.s12RncFTeidIePresent)
427 {
428
429 stream.add((char *)"s12RncFTeid:");
430 stream.endOfLine();
431 FTeidIe fTeid=
432 dynamic_cast<
433 FTeidIe&>(GtpV2IeFactory::getInstance().getIeObject(FTeidIeType));
434 fTeid.displayFTeidIe_v(data.s12RncFTeid, stream);
435
436 }
437
438 if (data.s4USgsnFTeidIePresent)
439 {
440
441 stream.add((char *)"s4USgsnFTeid:");
442 stream.endOfLine();
443 FTeidIe fTeid=
444 dynamic_cast<
445 FTeidIe&>(GtpV2IeFactory::getInstance().getIeObject(FTeidIeType));
446 fTeid.displayFTeidIe_v(data.s4USgsnFTeid, stream);
447
448 }
449
450 if (data.s11UMmeFTeidIePresent)
451 {
452
453 stream.add((char *)"s11UMmeFTeid:");
454 stream.endOfLine();
455 FTeidIe fTeid=
456 dynamic_cast<
457 FTeidIe&>(GtpV2IeFactory::getInstance().getIeObject(FTeidIeType));
458 fTeid.displayFTeidIe_v(data.s11UMmeFTeid, stream);
459
460 }
461
462 stream.decrIndent();
463 stream.decrIndent();
464}
465
466
467
468
469