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