blob: b8d93deaba41c124df9b3bc45903a26ead99de83 [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 "throttlingIe.h"
15#include "dataTypeCodecUtils.h"
16
17ThrottlingIe::ThrottlingIe()
18{
19 ieType = 154;
20 // TODO
21
22}
23
24ThrottlingIe::~ThrottlingIe() {
25 // TODO Auto-generated destructor stub
26}
27
28bool ThrottlingIe::encodeThrottlingIe(MsgBuffer &buffer, ThrottlingIeData const &data)
29{
30 if(!(buffer.writeBits(data.throttlingDelayUnit, 3)))
31 {
32 errorStream.add((char *)"Encoding of throttlingDelayUnit failed\n");
33 return false;
34 }
35 if(!(buffer.writeBits(data.throttlingDelayValue, 5)))
36 {
37 errorStream.add((char *)"Encoding of throttlingDelayValue failed\n");
38 return false;
39 }
40 if (!(data.throttlingFactor>= 0 && data.throttlingFactor<= 100))
41 {
42 errorStream.add((char *)"Data validation failure: throttlingFactor\n");
43 return false;
44 }
45 if (!(buffer.writeUint8(data.throttlingFactor)))
46 {
47 errorStream.add((char *)"Encoding of throttlingFactor failed\n");
48 return false;
49 }
50
51 return true;
52}
53
54bool ThrottlingIe::decodeThrottlingIe(MsgBuffer &buffer, ThrottlingIeData &data, Uint16 length)
55{
56 // TODO optimize the length checks
57
58 Uint16 ieBoundary = buffer.getCurrentIndex() + length;
59 data.throttlingDelayUnit = buffer.readBits(3);
60 // confirm that we are not reading beyond the IE boundary
61 if (buffer.getCurrentIndex() > ieBoundary)
62 {
63 errorStream.add((char *)"Attempt to read beyond IE boundary: throttlingDelayUnit\n");
64 return false;
65 }
66 data.throttlingDelayValue = buffer.readBits(5);
67 // confirm that we are not reading beyond the IE boundary
68 if (buffer.getCurrentIndex() > ieBoundary)
69 {
70 errorStream.add((char *)"Attempt to read beyond IE boundary: throttlingDelayValue\n");
71 return false;
72 }
73
74 buffer.readUint8(data.throttlingFactor);
75 if (buffer.getCurrentIndex() > ieBoundary)
76 {
77 errorStream.add((char *)"Attempt to read beyond IE boundary: throttlingFactor\n");
78 return false;
79 }
80 if (!(data.throttlingFactor>= 0 && data.throttlingFactor<= 100))
81 {
82 errorStream.add((char *)"Data validation failure : throttlingFactor\n");
83 return false; //TODO need to add validations
84 }
85
86 // The IE is decoded now. The buffer index should be pointing to the
87 // IE Boundary. If not, we have some more data left for the IE which we don't know
88 // how to decode
89 if (ieBoundary == buffer.getCurrentIndex())
90 {
91 return true;
92 }
93 else
94 {
95 errorStream.add((char *)"Unable to decode IE ThrottlingIe\n");
96 return false;
97 }
98}
99void ThrottlingIe::displayThrottlingIe_v(ThrottlingIeData const &data, Debug &stream)
100{
101 stream.incrIndent();
102 stream.add((char *)"ThrottlingIeData:");
103 stream.incrIndent();
104 stream.endOfLine();
105
106 stream.add( (char *)"throttlingDelayUnit: ");
107 stream.add((Uint8)data.throttlingDelayUnit);
108 stream.endOfLine();
109
110 stream.add( (char *)"throttlingDelayValue: ");
111 stream.add((Uint8)data.throttlingDelayValue);
112 stream.endOfLine();
113
114 stream.add((char *)"throttlingFactor: ");
115 stream.add(data.throttlingFactor);
116 stream.endOfLine();
117 stream.decrIndent();
118 stream.decrIndent();
119}