blob: c3a216f6130f8eb923dc6311be8306d6e11e5d4e [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 "ip4cpIe.h"
15#include "dataTypeCodecUtils.h"
16
17Ip4cpIe::Ip4cpIe()
18{
19 ieType = 166;
20 // TODO
21
22}
23
24Ip4cpIe::~Ip4cpIe() {
25 // TODO Auto-generated destructor stub
26}
27
28bool Ip4cpIe::encodeIp4cpIe(MsgBuffer &buffer, Ip4cpIeData const &data)
29{
30 if (!(buffer.writeUint8(data.subnetPrefixLength)))
31 {
32 errorStream.add((char *)"Encoding of subnetPrefixLength failed\n");
33 return false;
34 }
35 if (!(DataTypeCodecUtils::encodeIpAddressV4(buffer, data.iPv4DefaultRouterAddress)))
36 {
37 errorStream.add((char *)"Encoding of iPv4DefaultRouterAddress failed\n");
38 return false;
39 }
40
41 return true;
42}
43
44bool Ip4cpIe::decodeIp4cpIe(MsgBuffer &buffer, Ip4cpIeData &data, Uint16 length)
45{
46 // TODO optimize the length checks
47
48 Uint16 ieBoundary = buffer.getCurrentIndex() + length;
49
50 buffer.readUint8(data.subnetPrefixLength);
51 if (buffer.getCurrentIndex() > ieBoundary)
52 {
53 errorStream.add((char *)"Attempt to read beyond IE boundary: subnetPrefixLength\n");
54 return false;
55 }
56
57 Uint16 lengthLeft = length;
58 lengthLeft = ieBoundary - buffer.getCurrentIndex();
59 if (!(DataTypeCodecUtils::decodeIpAddressV4(buffer, data.iPv4DefaultRouterAddress, lengthLeft)))
60 {
61 errorStream.add((char *)"Failed to decode: iPv4DefaultRouterAddress\n");
62 return false;
63 }
64
65 // The IE is decoded now. The buffer index should be pointing to the
66 // IE Boundary. If not, we have some more data left for the IE which we don't know
67 // how to decode
68 if (ieBoundary == buffer.getCurrentIndex())
69 {
70 return true;
71 }
72 else
73 {
74 errorStream.add((char *)"Unable to decode IE Ip4cpIe\n");
75 return false;
76 }
77}
78void Ip4cpIe::displayIp4cpIe_v(Ip4cpIeData const &data, Debug &stream)
79{
80 stream.incrIndent();
81 stream.add((char *)"Ip4cpIeData:");
82 stream.incrIndent();
83 stream.endOfLine();
84
85 stream.add((char *)"subnetPrefixLength: ");
86 stream.add(data.subnetPrefixLength);
87 stream.endOfLine();
88
89 stream.add((char *)"iPv4DefaultRouterAddress:");
90 stream.endOfLine();
91 DataTypeCodecUtils::displayIpAddressV4_v(data.iPv4DefaultRouterAddress, stream);
92 stream.decrIndent();
93 stream.decrIndent();
94}