blob: b55a2a07fe1f42e36499491575f32fe14cd9b6ca [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 * This is an auto generated file.
9 * Please do not edit this file.
10 * All edits to be made through template source file
11 * <TOP-DIR/scripts/GtpV2StackCodeGen/tts/ietemplate.cpp.tt>
12 ******************************************************************************/
13
14#include "uliIe.h"
15#include "dataTypeCodecUtils.h"
16
17UliIe::UliIe()
18{
19 ieType = 86;
20 // TODO
21
22}
23
24UliIe::~UliIe() {
25 // TODO Auto-generated destructor stub
26}
27
28bool UliIe::encodeUliIe(MsgBuffer &buffer, UliIeData const &data)
29{
30 buffer.skipBits(2);
31
32 if(!(buffer.writeBits(data.laipresent, 1)))
33 {
34 errorStream.add((char *)"Encoding of laipresent failed\n");
35 return false;
36 }
37 if(!(buffer.writeBits(data.ecgipresent, 1)))
38 {
39 errorStream.add((char *)"Encoding of ecgipresent failed\n");
40 return false;
41 }
42 if(!(buffer.writeBits(data.taipresent, 1)))
43 {
44 errorStream.add((char *)"Encoding of taipresent failed\n");
45 return false;
46 }
47 if(!(buffer.writeBits(data.raipresent, 1)))
48 {
49 errorStream.add((char *)"Encoding of raipresent failed\n");
50 return false;
51 }
52 if(!(buffer.writeBits(data.saipresent, 1)))
53 {
54 errorStream.add((char *)"Encoding of saipresent failed\n");
55 return false;
56 }
57 if(!(buffer.writeBits(data.cgipresent, 1)))
58 {
59 errorStream.add((char *)"Encoding of cgipresent failed\n");
60 return false;
61 }
62 if (data.cgipresent)
63 {
64 if (!(DataTypeCodecUtils::encodeCgiField(buffer, data.cgi)))
65 {
66 errorStream.add((char *)"Encoding of cgi failed\n");
67 return false;
68 }
69 }
70 if (data.saipresent)
71 {
72 if (!(DataTypeCodecUtils::encodeSaiField(buffer, data.sai)))
73 {
74 errorStream.add((char *)"Encoding of sai failed\n");
75 return false;
76 }
77 }
78 if (data.raipresent)
79 {
80 if (!(DataTypeCodecUtils::encodeRaiField(buffer, data.rai)))
81 {
82 errorStream.add((char *)"Encoding of rai failed\n");
83 return false;
84 }
85 }
86 if (data.taipresent)
87 {
88 if (!(DataTypeCodecUtils::encodeTaiField(buffer, data.tai)))
89 {
90 errorStream.add((char *)"Encoding of tai failed\n");
91 return false;
92 }
93 }
94 if (data.ecgipresent)
95 {
96 if (!(DataTypeCodecUtils::encodeEcgiField(buffer, data.ecgi)))
97 {
98 errorStream.add((char *)"Encoding of ecgi failed\n");
99 return false;
100 }
101 }
102 if (data.laipresent)
103 {
104 if (!(DataTypeCodecUtils::encodeLaiField(buffer, data.lai)))
105 {
106 errorStream.add((char *)"Encoding of lai failed\n");
107 return false;
108 }
109 }
110
111 return true;
112}
113
114bool UliIe::decodeUliIe(MsgBuffer &buffer, UliIeData &data, Uint16 length)
115{
116 // TODO optimize the length checks
117
118 Uint16 ieBoundary = buffer.getCurrentIndex() + length;
119 buffer.skipBits(2);
120 if (buffer.getCurrentIndex() > ieBoundary)
121 {
122 errorStream.add((char *)"Attempt to read beyond IE boundary: \n");
123 return false;
124 }
125
126 data.laipresent = buffer.readBits(1);
127 // confirm that we are not reading beyond the IE boundary
128 if (buffer.getCurrentIndex() > ieBoundary)
129 {
130 errorStream.add((char *)"Attempt to read beyond IE boundary: laipresent\n");
131 return false;
132 }
133 data.ecgipresent = buffer.readBits(1);
134 // confirm that we are not reading beyond the IE boundary
135 if (buffer.getCurrentIndex() > ieBoundary)
136 {
137 errorStream.add((char *)"Attempt to read beyond IE boundary: ecgipresent\n");
138 return false;
139 }
140 data.taipresent = buffer.readBits(1);
141 // confirm that we are not reading beyond the IE boundary
142 if (buffer.getCurrentIndex() > ieBoundary)
143 {
144 errorStream.add((char *)"Attempt to read beyond IE boundary: taipresent\n");
145 return false;
146 }
147 data.raipresent = buffer.readBits(1);
148 // confirm that we are not reading beyond the IE boundary
149 if (buffer.getCurrentIndex() > ieBoundary)
150 {
151 errorStream.add((char *)"Attempt to read beyond IE boundary: raipresent\n");
152 return false;
153 }
154 data.saipresent = buffer.readBits(1);
155 // confirm that we are not reading beyond the IE boundary
156 if (buffer.getCurrentIndex() > ieBoundary)
157 {
158 errorStream.add((char *)"Attempt to read beyond IE boundary: saipresent\n");
159 return false;
160 }
161 data.cgipresent = buffer.readBits(1);
162 // confirm that we are not reading beyond the IE boundary
163 if (buffer.getCurrentIndex() > ieBoundary)
164 {
165 errorStream.add((char *)"Attempt to read beyond IE boundary: cgipresent\n");
166 return false;
167 }
168
169 Uint16 lengthLeft = length;
170
171 if (data.cgipresent)
172 {
173 lengthLeft = ieBoundary - buffer.getCurrentIndex();
174 if (!(DataTypeCodecUtils::decodeCgiField(buffer, data.cgi, lengthLeft)))
175 {
176 errorStream.add((char *)"Failed to decode: cgi\n");
177 return false;
178 }
179 }
180
181 if (data.saipresent)
182 {
183 lengthLeft = ieBoundary - buffer.getCurrentIndex();
184 if (!(DataTypeCodecUtils::decodeSaiField(buffer, data.sai, lengthLeft)))
185 {
186 errorStream.add((char *)"Failed to decode: sai\n");
187 return false;
188 }
189 }
190
191 if (data.raipresent)
192 {
193 lengthLeft = ieBoundary - buffer.getCurrentIndex();
194 if (!(DataTypeCodecUtils::decodeRaiField(buffer, data.rai, lengthLeft)))
195 {
196 errorStream.add((char *)"Failed to decode: rai\n");
197 return false;
198 }
199 }
200
201 if (data.taipresent)
202 {
203 lengthLeft = ieBoundary - buffer.getCurrentIndex();
204 if (!(DataTypeCodecUtils::decodeTaiField(buffer, data.tai, lengthLeft)))
205 {
206 errorStream.add((char *)"Failed to decode: tai\n");
207 return false;
208 }
209 }
210
211 if (data.ecgipresent)
212 {
213 lengthLeft = ieBoundary - buffer.getCurrentIndex();
214 if (!(DataTypeCodecUtils::decodeEcgiField(buffer, data.ecgi, lengthLeft)))
215 {
216 errorStream.add((char *)"Failed to decode: ecgi\n");
217 return false;
218 }
219 }
220
221 if (data.laipresent)
222 {
223 lengthLeft = ieBoundary - buffer.getCurrentIndex();
224 if (!(DataTypeCodecUtils::decodeLaiField(buffer, data.lai, lengthLeft)))
225 {
226 errorStream.add((char *)"Failed to decode: lai\n");
227 return false;
228 }
229 }
230
231 // The IE is decoded now. The buffer index should be pointing to the
232 // IE Boundary. If not, we have some more data left for the IE which we don't know
233 // how to decode
234 if (ieBoundary == buffer.getCurrentIndex())
235 {
236 return true;
237 }
238 else
239 {
240 errorStream.add((char *)"Unable to decode IE UliIe\n");
241 return false;
242 }
243}
244void UliIe::displayUliIe_v(UliIeData const &data, Debug &stream)
245{
246 stream.incrIndent();
247 stream.add((char *)"UliIeData:");
248 stream.incrIndent();
249 stream.endOfLine();
250
251 stream.add( (char *)"laipresent: ");
252 stream.add((Uint8)data.laipresent);
253 stream.endOfLine();
254
255 stream.add( (char *)"ecgipresent: ");
256 stream.add((Uint8)data.ecgipresent);
257 stream.endOfLine();
258
259 stream.add( (char *)"taipresent: ");
260 stream.add((Uint8)data.taipresent);
261 stream.endOfLine();
262
263 stream.add( (char *)"raipresent: ");
264 stream.add((Uint8)data.raipresent);
265 stream.endOfLine();
266
267 stream.add( (char *)"saipresent: ");
268 stream.add((Uint8)data.saipresent);
269 stream.endOfLine();
270
271 stream.add( (char *)"cgipresent: ");
272 stream.add((Uint8)data.cgipresent);
273 stream.endOfLine();
274
275 if (data.cgipresent)
276 {
277 stream.add((char *)"cgi:");
278 stream.endOfLine();
279 DataTypeCodecUtils::displayCgiField_v(data.cgi, stream);
280 }
281
282 if (data.saipresent)
283 {
284 stream.add((char *)"sai:");
285 stream.endOfLine();
286 DataTypeCodecUtils::displaySaiField_v(data.sai, stream);
287 }
288
289 if (data.raipresent)
290 {
291 stream.add((char *)"rai:");
292 stream.endOfLine();
293 DataTypeCodecUtils::displayRaiField_v(data.rai, stream);
294 }
295
296 if (data.taipresent)
297 {
298 stream.add((char *)"tai:");
299 stream.endOfLine();
300 DataTypeCodecUtils::displayTaiField_v(data.tai, stream);
301 }
302
303 if (data.ecgipresent)
304 {
305 stream.add((char *)"ecgi:");
306 stream.endOfLine();
307 DataTypeCodecUtils::displayEcgiField_v(data.ecgi, stream);
308 }
309
310 if (data.laipresent)
311 {
312 stream.add((char *)"lai:");
313 stream.endOfLine();
314 DataTypeCodecUtils::displayLaiField_v(data.lai, stream);
315 }
316 stream.decrIndent();
317 stream.decrIndent();
318}