blob: fb5441abd8339796cb1883e2bdd397cb22ed12de [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 "ranNasCauseIe.h"
15#include "dataTypeCodecUtils.h"
16
17RanNasCauseIe::RanNasCauseIe()
18{
19 ieType = 172;
20 // TODO
21
22}
23
24RanNasCauseIe::~RanNasCauseIe() {
25 // TODO Auto-generated destructor stub
26}
27
28bool RanNasCauseIe::encodeRanNasCauseIe(MsgBuffer &buffer, RanNasCauseIeData const &data)
29{
30 if (!(data.protocolType>= 1 && data.protocolType<=5))
31 {
32 errorStream.add((char *)"Data validation failure: protocolType\n");
33 return false;
34 }
35 if(!(buffer.writeBits(data.protocolType, 4)))
36 {
37 errorStream.add((char *)"Encoding of protocolType failed\n");
38 return false;
39 }
40 if(!(buffer.writeBits(data.causeType, 4)))
41 {
42 errorStream.add((char *)"Encoding of causeType failed\n");
43 return false;
44 }
45 if (!(buffer.writeUint8(data.causeValue)))
46 {
47 errorStream.add((char *)"Encoding of causeValue failed\n");
48 return false;
49 }
50
51 return true;
52}
53
54bool RanNasCauseIe::decodeRanNasCauseIe(MsgBuffer &buffer, RanNasCauseIeData &data, Uint16 length)
55{
56 // TODO optimize the length checks
57
58 Uint16 ieBoundary = buffer.getCurrentIndex() + length;
59 data.protocolType = buffer.readBits(4);
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: protocolType\n");
64 return false;
65 }
66 if (!(data.protocolType>= 1 && data.protocolType<=5))
67 {
68 errorStream.add((char *)"Data validation failure : protocolType\n");
69 return false; //TODO need to add validations
70 }
71 data.causeType = buffer.readBits(4);
72 // confirm that we are not reading beyond the IE boundary
73 if (buffer.getCurrentIndex() > ieBoundary)
74 {
75 errorStream.add((char *)"Attempt to read beyond IE boundary: causeType\n");
76 return false;
77 }
78
79 buffer.readUint8(data.causeValue);
80 if (buffer.getCurrentIndex() > ieBoundary)
81 {
82 errorStream.add((char *)"Attempt to read beyond IE boundary: causeValue\n");
83 return false;
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 RanNasCauseIe\n");
96 return false;
97 }
98}
99void RanNasCauseIe::displayRanNasCauseIe_v(RanNasCauseIeData const &data, Debug &stream)
100{
101 stream.incrIndent();
102 stream.add((char *)"RanNasCauseIeData:");
103 stream.incrIndent();
104 stream.endOfLine();
105
106 stream.add( (char *)"protocolType: ");
107 stream.add((Uint8)data.protocolType);
108 stream.endOfLine();
109
110 stream.add( (char *)"causeType: ");
111 stream.add((Uint8)data.causeType);
112 stream.endOfLine();
113
114 stream.add((char *)"causeValue: ");
115 stream.add(data.causeValue);
116 stream.endOfLine();
117 stream.decrIndent();
118 stream.decrIndent();
119}