blob: 532b06433b05aa8929d5177446b289e3234dcb8f [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 "bearerContextsMarkedForRemovalInCreateSessionResponse.h"
16#include "manual/gtpV2Ie.h"
17#include "gtpV2IeFactory.h"
18#include "ebiIe.h"
19#include "causeIe.h"
20
21BearerContextsMarkedForRemovalInCreateSessionResponse::
22BearerContextsMarkedForRemovalInCreateSessionResponse()
23{
24 Uint16 mandIe;
25 mandIe = EbiIeType;
26 mandIe = (mandIe << 8) | 0; // epsBearerId
27 mandatoryIeSet.insert(mandIe);
28 mandIe = CauseIeType;
29 mandIe = (mandIe << 8) | 0; // cause
30 mandatoryIeSet.insert(mandIe);
31
32}
33
34BearerContextsMarkedForRemovalInCreateSessionResponse::
35~BearerContextsMarkedForRemovalInCreateSessionResponse()
36{
37
38}
39bool BearerContextsMarkedForRemovalInCreateSessionResponse::
40encodeBearerContextsMarkedForRemovalInCreateSessionResponse(MsgBuffer &buffer,
41 BearerContextsMarkedForRemovalInCreateSessionResponseData
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
52 // Encode the Ie Header
53 header.ieType = EbiIeType;
54 header.instance = 0;
55 header.length = 0; // We will encode the IE first and then update the length
56 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
57 startIndex = buffer.getCurrentIndex();
58 EbiIe ebi=
59 dynamic_cast<
60 EbiIe&>(GtpV2IeFactory::getInstance().getIeObject(EbiIeType));
61 rc = ebi.encodeEbiIe(buffer, data.epsBearerId);
62 endIndex = buffer.getCurrentIndex();
63 length = endIndex - startIndex;
64
65 // encode the length value now
66 buffer.goToIndex(startIndex - 3);
67 buffer.writeUint16(length, false);
68 buffer.goToIndex(endIndex);
69 if (!(rc))
70 {
71 errorStream.add((char *)"Failed to encode IE: epsBearerId\n");
72 return false;
73 }
74
75
76
77 // Encode the Ie Header
78 header.ieType = CauseIeType;
79 header.instance = 0;
80 header.length = 0; // We will encode the IE first and then update the length
81 GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
82 startIndex = buffer.getCurrentIndex();
83 CauseIe cause=
84 dynamic_cast<
85 CauseIe&>(GtpV2IeFactory::getInstance().getIeObject(CauseIeType));
86 rc = cause.encodeCauseIe(buffer, data.cause);
87 endIndex = buffer.getCurrentIndex();
88 length = endIndex - startIndex;
89
90 // encode the length value now
91 buffer.goToIndex(startIndex - 3);
92 buffer.writeUint16(length, false);
93 buffer.goToIndex(endIndex);
94 if (!(rc))
95 {
96 errorStream.add((char *)"Failed to encode IE: cause\n");
97 return false;
98 }
99 return rc;
100}
101
102bool BearerContextsMarkedForRemovalInCreateSessionResponse::
103decodeBearerContextsMarkedForRemovalInCreateSessionResponse(MsgBuffer &buffer,
104 BearerContextsMarkedForRemovalInCreateSessionResponseData
105 &data, Uint16 length)
106{
107
108 bool rc = false;
109 GtpV2IeHeader ieHeader;
110 set<Uint16> mandatoryIeLocalList = mandatoryIeSet;
111 while (buffer.lengthLeft() > IE_HEADER_SIZE)
112 {
113 GtpV2Ie::decodeGtpV2IeHeader(buffer, ieHeader);
114 if (ieHeader.length > buffer.lengthLeft())
115 {
116 // We do not have enough bytes left in the message for this IE
117 errorStream.add((char *)"IE Length exceeds beyond message boundary\n");
118 errorStream.add((char *)" Offending IE Type: ");
119 errorStream.add(ieHeader.ieType);
120 errorStream.add((char *)"\n Ie Length in Header: ");
121 errorStream.add(ieHeader.length);
122 errorStream.add((char *)"\n Bytes left in message: ");
123 errorStream.add(buffer.lengthLeft());
124 errorStream.endOfLine();
125 return false;
126 }
127
128 switch (ieHeader.ieType){
129 case EbiIeType:
130 {
131 EbiIe ieObject =
132 dynamic_cast<
133 EbiIe&>(GtpV2IeFactory::getInstance().
134 getIeObject(EbiIeType));
135
136
137 if(ieHeader.instance == 0)
138 {
139
140 rc = ieObject.decodeEbiIe(buffer, data.epsBearerId, ieHeader.length);
141
142 if (!(rc))
143 {
144 errorStream.add((char *)"Failed to decode IE: epsBearerId\n");
145 return false;
146 }
147 Uint16 mandIe = EbiIeType;
148 mandIe = (mandIe << 8) | 0;
149 mandatoryIeLocalList.erase(mandIe);
150 }
151 else
152 {
153 // Unknown IE instance print error TODO
154 errorStream.add((char *)"Unknown IE Type: ");
155 errorStream.add(ieHeader.ieType);
156 errorStream.endOfLine();
157 buffer.skipBytes(ieHeader.length);
158 }
159 break;
160 }
161 case CauseIeType:
162 {
163 CauseIe ieObject =
164 dynamic_cast<
165 CauseIe&>(GtpV2IeFactory::getInstance().
166 getIeObject(CauseIeType));
167
168
169 if(ieHeader.instance == 0)
170 {
171
172 rc = ieObject.decodeCauseIe(buffer, data.cause, ieHeader.length);
173
174 if (!(rc))
175 {
176 errorStream.add((char *)"Failed to decode IE: cause\n");
177 return false;
178 }
179 Uint16 mandIe = CauseIeType;
180 mandIe = (mandIe << 8) | 0;
181 mandatoryIeLocalList.erase(mandIe);
182 }
183 else
184 {
185 // Unknown IE instance print error TODO
186 errorStream.add((char *)"Unknown IE Type: ");
187 errorStream.add(ieHeader.ieType);
188 errorStream.endOfLine();
189 buffer.skipBytes(ieHeader.length);
190 }
191 break;
192 }
193 default:
194 {
195 // Unknown IE print error
196 errorStream.add((char *)"Unknown IE Type: ");
197 errorStream.add(ieHeader.ieType);
198 errorStream.endOfLine();
199 buffer.skipBytes(ieHeader.length);
200 }
201 }
202 }
203 if (!mandatoryIeLocalList.empty())
204 {
205 // some mandatory IEs are missing
206 errorStream.add((char *)"Missing Mandatory IEs:");
207 errorStream.endOfLine();
208 while (!mandatoryIeLocalList.empty())
209 {
210 Uint16 missingMandIe = *mandatoryIeLocalList.begin ();
211 mandatoryIeLocalList.erase (mandatoryIeLocalList.begin ());
212 Uint16 missingInstance = missingMandIe & 0x00FF;
213 Uint16 missingIeType = (missingMandIe >> 8);
214 errorStream.add ((char *)"Missing Ie type: ");
215 errorStream.add (missingIeType);
216 errorStream.add ((char *)" Instance: ");
217 errorStream.add (missingInstance);
218 errorStream.endOfLine();
219 }
220 rc = false;
221
222 }
223 return rc;
224}
225
226void BearerContextsMarkedForRemovalInCreateSessionResponse::
227displayBearerContextsMarkedForRemovalInCreateSessionResponseData_v
228(BearerContextsMarkedForRemovalInCreateSessionResponseData const &data, Debug &stream)
229{
230 stream.incrIndent();
231 stream.add((char *)"BearerContextsMarkedForRemovalInCreateSessionResponse:");
232 stream.endOfLine();
233 stream.incrIndent();
234
235
236
237 stream.decrIndent();
238 stream.decrIndent();
239}
240
241
242
243
244