anjana_sreekumar@infosys.com | 991c206 | 2020-01-08 11:42:57 +0530 | [diff] [blame^] | 1 | /* |
| 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 "arpIe.h" |
| 15 | #include "dataTypeCodecUtils.h" |
| 16 | |
| 17 | ArpIe::ArpIe() |
| 18 | { |
| 19 | ieType = 155; |
| 20 | // TODO |
| 21 | |
| 22 | } |
| 23 | |
| 24 | ArpIe::~ArpIe() { |
| 25 | // TODO Auto-generated destructor stub |
| 26 | } |
| 27 | |
| 28 | bool ArpIe::encodeArpIe(MsgBuffer &buffer, ArpIeData const &data) |
| 29 | { |
| 30 | buffer.skipBits(1); |
| 31 | |
| 32 | if(!(buffer.writeBits(data.pci, 1))) |
| 33 | { |
| 34 | errorStream.add((char *)"Encoding of pci failed\n"); |
| 35 | return false; |
| 36 | } |
| 37 | if(!(buffer.writeBits(data.pl, 4))) |
| 38 | { |
| 39 | errorStream.add((char *)"Encoding of pl failed\n"); |
| 40 | return false; |
| 41 | } |
| 42 | buffer.skipBits(1); |
| 43 | |
| 44 | if(!(buffer.writeBits(data.pvi, 1))) |
| 45 | { |
| 46 | errorStream.add((char *)"Encoding of pvi failed\n"); |
| 47 | return false; |
| 48 | } |
| 49 | |
| 50 | return true; |
| 51 | } |
| 52 | |
| 53 | bool ArpIe::decodeArpIe(MsgBuffer &buffer, ArpIeData &data, Uint16 length) |
| 54 | { |
| 55 | // TODO optimize the length checks |
| 56 | |
| 57 | Uint16 ieBoundary = buffer.getCurrentIndex() + length; |
| 58 | buffer.skipBits(1); |
| 59 | if (buffer.getCurrentIndex() > ieBoundary) |
| 60 | { |
| 61 | errorStream.add((char *)"Attempt to read beyond IE boundary: \n"); |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | data.pci = buffer.readBits(1); |
| 66 | // confirm that we are not reading beyond the IE boundary |
| 67 | if (buffer.getCurrentIndex() > ieBoundary) |
| 68 | { |
| 69 | errorStream.add((char *)"Attempt to read beyond IE boundary: pci\n"); |
| 70 | return false; |
| 71 | } |
| 72 | data.pl = buffer.readBits(4); |
| 73 | // confirm that we are not reading beyond the IE boundary |
| 74 | if (buffer.getCurrentIndex() > ieBoundary) |
| 75 | { |
| 76 | errorStream.add((char *)"Attempt to read beyond IE boundary: pl\n"); |
| 77 | return false; |
| 78 | } |
| 79 | buffer.skipBits(1); |
| 80 | if (buffer.getCurrentIndex() > ieBoundary) |
| 81 | { |
| 82 | errorStream.add((char *)"Attempt to read beyond IE boundary: \n"); |
| 83 | return false; |
| 84 | } |
| 85 | |
| 86 | data.pvi = buffer.readBits(1); |
| 87 | // confirm that we are not reading beyond the IE boundary |
| 88 | if (buffer.getCurrentIndex() > ieBoundary) |
| 89 | { |
| 90 | errorStream.add((char *)"Attempt to read beyond IE boundary: pvi\n"); |
| 91 | return false; |
| 92 | } |
| 93 | |
| 94 | // The IE is decoded now. The buffer index should be pointing to the |
| 95 | // IE Boundary. If not, we have some more data left for the IE which we don't know |
| 96 | // how to decode |
| 97 | if (ieBoundary == buffer.getCurrentIndex()) |
| 98 | { |
| 99 | return true; |
| 100 | } |
| 101 | else |
| 102 | { |
| 103 | errorStream.add((char *)"Unable to decode IE ArpIe\n"); |
| 104 | return false; |
| 105 | } |
| 106 | } |
| 107 | void ArpIe::displayArpIe_v(ArpIeData const &data, Debug &stream) |
| 108 | { |
| 109 | stream.incrIndent(); |
| 110 | stream.add((char *)"ArpIeData:"); |
| 111 | stream.incrIndent(); |
| 112 | stream.endOfLine(); |
| 113 | |
| 114 | stream.add( (char *)"pci: "); |
| 115 | stream.add((Uint8)data.pci); |
| 116 | stream.endOfLine(); |
| 117 | |
| 118 | stream.add( (char *)"pl: "); |
| 119 | stream.add((Uint8)data.pl); |
| 120 | stream.endOfLine(); |
| 121 | |
| 122 | stream.add( (char *)"pvi: "); |
| 123 | stream.add((Uint8)data.pvi); |
| 124 | stream.endOfLine(); |
| 125 | stream.decrIndent(); |
| 126 | stream.decrIndent(); |
| 127 | } |