blob: fbbb73bdc4731566088b32fdc2eb8d52a83d1cf9 [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 "servingNetworkIe.h"
15#include "dataTypeCodecUtils.h"
16
17ServingNetworkIe::ServingNetworkIe()
18{
19 ieType = 83;
20 // TODO
21
22}
23
24ServingNetworkIe::~ServingNetworkIe() {
25 // TODO Auto-generated destructor stub
26}
27
28bool ServingNetworkIe::encodeServingNetworkIe(MsgBuffer &buffer, ServingNetworkIeData const &data)
29{
30 if(!(buffer.writeBits(data.mccDigit2, 4)))
31 {
32 errorStream.add((char *)"Encoding of mccDigit2 failed\n");
33 return false;
34 }
35 if(!(buffer.writeBits(data.mccDigit1, 4)))
36 {
37 errorStream.add((char *)"Encoding of mccDigit1 failed\n");
38 return false;
39 }
40 if(!(buffer.writeBits(data.mncDigit3, 4)))
41 {
42 errorStream.add((char *)"Encoding of mncDigit3 failed\n");
43 return false;
44 }
45 if(!(buffer.writeBits(data.mccDigit3, 4)))
46 {
47 errorStream.add((char *)"Encoding of mccDigit3 failed\n");
48 return false;
49 }
50 if(!(buffer.writeBits(data.mncDigit2, 4)))
51 {
52 errorStream.add((char *)"Encoding of mncDigit2 failed\n");
53 return false;
54 }
55 if(!(buffer.writeBits(data.mncDigit1, 4)))
56 {
57 errorStream.add((char *)"Encoding of mncDigit1 failed\n");
58 return false;
59 }
60
61 return true;
62}
63
64bool ServingNetworkIe::decodeServingNetworkIe(MsgBuffer &buffer, ServingNetworkIeData &data, Uint16 length)
65{
66 // TODO optimize the length checks
67
68 Uint16 ieBoundary = buffer.getCurrentIndex() + length;
69 data.mccDigit2 = buffer.readBits(4);
70 // confirm that we are not reading beyond the IE boundary
71 if (buffer.getCurrentIndex() > ieBoundary)
72 {
73 errorStream.add((char *)"Attempt to read beyond IE boundary: mccDigit2\n");
74 return false;
75 }
76 data.mccDigit1 = buffer.readBits(4);
77 // confirm that we are not reading beyond the IE boundary
78 if (buffer.getCurrentIndex() > ieBoundary)
79 {
80 errorStream.add((char *)"Attempt to read beyond IE boundary: mccDigit1\n");
81 return false;
82 }
83 data.mncDigit3 = buffer.readBits(4);
84 // confirm that we are not reading beyond the IE boundary
85 if (buffer.getCurrentIndex() > ieBoundary)
86 {
87 errorStream.add((char *)"Attempt to read beyond IE boundary: mncDigit3\n");
88 return false;
89 }
90 data.mccDigit3 = buffer.readBits(4);
91 // confirm that we are not reading beyond the IE boundary
92 if (buffer.getCurrentIndex() > ieBoundary)
93 {
94 errorStream.add((char *)"Attempt to read beyond IE boundary: mccDigit3\n");
95 return false;
96 }
97 data.mncDigit2 = buffer.readBits(4);
98 // confirm that we are not reading beyond the IE boundary
99 if (buffer.getCurrentIndex() > ieBoundary)
100 {
101 errorStream.add((char *)"Attempt to read beyond IE boundary: mncDigit2\n");
102 return false;
103 }
104 data.mncDigit1 = buffer.readBits(4);
105 // confirm that we are not reading beyond the IE boundary
106 if (buffer.getCurrentIndex() > ieBoundary)
107 {
108 errorStream.add((char *)"Attempt to read beyond IE boundary: mncDigit1\n");
109 return false;
110 }
111
112 // The IE is decoded now. The buffer index should be pointing to the
113 // IE Boundary. If not, we have some more data left for the IE which we don't know
114 // how to decode
115 if (ieBoundary == buffer.getCurrentIndex())
116 {
117 return true;
118 }
119 else
120 {
121 errorStream.add((char *)"Unable to decode IE ServingNetworkIe\n");
122 return false;
123 }
124}
125void ServingNetworkIe::displayServingNetworkIe_v(ServingNetworkIeData const &data, Debug &stream)
126{
127 stream.incrIndent();
128 stream.add((char *)"ServingNetworkIeData:");
129 stream.incrIndent();
130 stream.endOfLine();
131
132 stream.add( (char *)"mccDigit2: ");
133 stream.add((Uint8)data.mccDigit2);
134 stream.endOfLine();
135
136 stream.add( (char *)"mccDigit1: ");
137 stream.add((Uint8)data.mccDigit1);
138 stream.endOfLine();
139
140 stream.add( (char *)"mncDigit3: ");
141 stream.add((Uint8)data.mncDigit3);
142 stream.endOfLine();
143
144 stream.add( (char *)"mccDigit3: ");
145 stream.add((Uint8)data.mccDigit3);
146 stream.endOfLine();
147
148 stream.add( (char *)"mncDigit2: ");
149 stream.add((Uint8)data.mncDigit2);
150 stream.endOfLine();
151
152 stream.add( (char *)"mncDigit1: ");
153 stream.add((Uint8)data.mncDigit1);
154 stream.endOfLine();
155 stream.decrIndent();
156 stream.decrIndent();
157}