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