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 "twmiIe.h" |
| 15 | #include "dataTypeCodecUtils.h" |
| 16 | |
| 17 | TwmiIe::TwmiIe() |
| 18 | { |
| 19 | ieType = 174; |
| 20 | // TODO |
| 21 | |
| 22 | } |
| 23 | |
| 24 | TwmiIe::~TwmiIe() { |
| 25 | // TODO Auto-generated destructor stub |
| 26 | } |
| 27 | |
| 28 | bool TwmiIe::encodeTwmiIe(MsgBuffer &buffer, TwmiIeData const &data) |
| 29 | { |
| 30 | buffer.skipBits(4); |
| 31 | |
| 32 | if(!(buffer.writeBits(data.mcm, 2))) |
| 33 | { |
| 34 | errorStream.add((char *)"Encoding of mcm failed\n"); |
| 35 | return false; |
| 36 | } |
| 37 | if(!(buffer.writeBits(data.scm, 2))) |
| 38 | { |
| 39 | errorStream.add((char *)"Encoding of scm failed\n"); |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | return true; |
| 44 | } |
| 45 | |
| 46 | bool TwmiIe::decodeTwmiIe(MsgBuffer &buffer, TwmiIeData &data, Uint16 length) |
| 47 | { |
| 48 | // TODO optimize the length checks |
| 49 | |
| 50 | Uint16 ieBoundary = buffer.getCurrentIndex() + length; |
| 51 | buffer.skipBits(4); |
| 52 | if (buffer.getCurrentIndex() > ieBoundary) |
| 53 | { |
| 54 | errorStream.add((char *)"Attempt to read beyond IE boundary: \n"); |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | data.mcm = buffer.readBits(2); |
| 59 | // confirm that we are not reading beyond the IE boundary |
| 60 | if (buffer.getCurrentIndex() > ieBoundary) |
| 61 | { |
| 62 | errorStream.add((char *)"Attempt to read beyond IE boundary: mcm\n"); |
| 63 | return false; |
| 64 | } |
| 65 | data.scm = buffer.readBits(2); |
| 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: scm\n"); |
| 70 | return false; |
| 71 | } |
| 72 | |
| 73 | // The IE is decoded now. The buffer index should be pointing to the |
| 74 | // IE Boundary. If not, we have some more data left for the IE which we don't know |
| 75 | // how to decode |
| 76 | if (ieBoundary == buffer.getCurrentIndex()) |
| 77 | { |
| 78 | return true; |
| 79 | } |
| 80 | else |
| 81 | { |
| 82 | errorStream.add((char *)"Unable to decode IE TwmiIe\n"); |
| 83 | return false; |
| 84 | } |
| 85 | } |
| 86 | void TwmiIe::displayTwmiIe_v(TwmiIeData const &data, Debug &stream) |
| 87 | { |
| 88 | stream.incrIndent(); |
| 89 | stream.add((char *)"TwmiIeData:"); |
| 90 | stream.incrIndent(); |
| 91 | stream.endOfLine(); |
| 92 | |
| 93 | stream.add( (char *)"mcm: "); |
| 94 | stream.add((Uint8)data.mcm); |
| 95 | stream.endOfLine(); |
| 96 | |
| 97 | stream.add( (char *)"scm: "); |
| 98 | stream.add((Uint8)data.scm); |
| 99 | stream.endOfLine(); |
| 100 | stream.decrIndent(); |
| 101 | stream.decrIndent(); |
| 102 | } |