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 "bearerQosIe.h" |
| 15 | #include "dataTypeCodecUtils.h" |
| 16 | |
| 17 | BearerQosIe::BearerQosIe() |
| 18 | { |
| 19 | ieType = 80; |
| 20 | // TODO |
| 21 | |
| 22 | } |
| 23 | |
| 24 | BearerQosIe::~BearerQosIe() { |
| 25 | // TODO Auto-generated destructor stub |
| 26 | } |
| 27 | |
| 28 | bool BearerQosIe::encodeBearerQosIe(MsgBuffer &buffer, BearerQosIeData 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 | if (!(buffer.writeUint8(data.qci))) |
| 50 | { |
| 51 | errorStream.add((char *)"Encoding of qci failed\n"); |
| 52 | return false; |
| 53 | } |
| 54 | if (!(DataTypeCodecUtils::encodeUint8Array5(buffer, data.maxBitRateUl))) |
| 55 | { |
| 56 | errorStream.add((char *)"Encoding of maxBitRateUl failed\n"); |
| 57 | return false; |
| 58 | } |
| 59 | if (!(DataTypeCodecUtils::encodeUint8Array5(buffer, data.maxBitRateDl))) |
| 60 | { |
| 61 | errorStream.add((char *)"Encoding of maxBitRateDl failed\n"); |
| 62 | return false; |
| 63 | } |
| 64 | if (!(DataTypeCodecUtils::encodeUint8Array5(buffer, data.guraranteedBitRateUl))) |
| 65 | { |
| 66 | errorStream.add((char *)"Encoding of guraranteedBitRateUl failed\n"); |
| 67 | return false; |
| 68 | } |
| 69 | if (!(DataTypeCodecUtils::encodeUint8Array5(buffer, data.guaranteedBitRateDl))) |
| 70 | { |
| 71 | errorStream.add((char *)"Encoding of guaranteedBitRateDl failed\n"); |
| 72 | return false; |
| 73 | } |
| 74 | |
| 75 | return true; |
| 76 | } |
| 77 | |
| 78 | bool BearerQosIe::decodeBearerQosIe(MsgBuffer &buffer, BearerQosIeData &data, Uint16 length) |
| 79 | { |
| 80 | // TODO optimize the length checks |
| 81 | |
| 82 | Uint16 ieBoundary = buffer.getCurrentIndex() + length; |
| 83 | buffer.skipBits(1); |
| 84 | if (buffer.getCurrentIndex() > ieBoundary) |
| 85 | { |
| 86 | errorStream.add((char *)"Attempt to read beyond IE boundary: \n"); |
| 87 | return false; |
| 88 | } |
| 89 | |
| 90 | data.pci = buffer.readBits(1); |
| 91 | // confirm that we are not reading beyond the IE boundary |
| 92 | if (buffer.getCurrentIndex() > ieBoundary) |
| 93 | { |
| 94 | errorStream.add((char *)"Attempt to read beyond IE boundary: pci\n"); |
| 95 | return false; |
| 96 | } |
| 97 | data.pl = buffer.readBits(4); |
| 98 | // confirm that we are not reading beyond the IE boundary |
| 99 | if (buffer.getCurrentIndex() > ieBoundary) |
| 100 | { |
| 101 | errorStream.add((char *)"Attempt to read beyond IE boundary: pl\n"); |
| 102 | return false; |
| 103 | } |
| 104 | buffer.skipBits(1); |
| 105 | if (buffer.getCurrentIndex() > ieBoundary) |
| 106 | { |
| 107 | errorStream.add((char *)"Attempt to read beyond IE boundary: \n"); |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | data.pvi = buffer.readBits(1); |
| 112 | // confirm that we are not reading beyond the IE boundary |
| 113 | if (buffer.getCurrentIndex() > ieBoundary) |
| 114 | { |
| 115 | errorStream.add((char *)"Attempt to read beyond IE boundary: pvi\n"); |
| 116 | return false; |
| 117 | } |
| 118 | |
| 119 | buffer.readUint8(data.qci); |
| 120 | if (buffer.getCurrentIndex() > ieBoundary) |
| 121 | { |
| 122 | errorStream.add((char *)"Attempt to read beyond IE boundary: qci\n"); |
| 123 | return false; |
| 124 | } |
| 125 | |
| 126 | Uint16 lengthLeft = length; |
| 127 | lengthLeft = ieBoundary - buffer.getCurrentIndex(); |
| 128 | if (!(DataTypeCodecUtils::decodeUint8Array5(buffer, data.maxBitRateUl, lengthLeft, 5))) |
| 129 | { |
| 130 | errorStream.add((char *)"Failed to decode: maxBitRateUl\n"); |
| 131 | return false; |
| 132 | } |
| 133 | lengthLeft = ieBoundary - buffer.getCurrentIndex(); |
| 134 | if (!(DataTypeCodecUtils::decodeUint8Array5(buffer, data.maxBitRateDl, lengthLeft, 5))) |
| 135 | { |
| 136 | errorStream.add((char *)"Failed to decode: maxBitRateDl\n"); |
| 137 | return false; |
| 138 | } |
| 139 | lengthLeft = ieBoundary - buffer.getCurrentIndex(); |
| 140 | if (!(DataTypeCodecUtils::decodeUint8Array5(buffer, data.guraranteedBitRateUl, lengthLeft, 5))) |
| 141 | { |
| 142 | errorStream.add((char *)"Failed to decode: guraranteedBitRateUl\n"); |
| 143 | return false; |
| 144 | } |
| 145 | lengthLeft = ieBoundary - buffer.getCurrentIndex(); |
| 146 | if (!(DataTypeCodecUtils::decodeUint8Array5(buffer, data.guaranteedBitRateDl, lengthLeft, 5))) |
| 147 | { |
| 148 | errorStream.add((char *)"Failed to decode: guaranteedBitRateDl\n"); |
| 149 | return false; |
| 150 | } |
| 151 | |
| 152 | // The IE is decoded now. The buffer index should be pointing to the |
| 153 | // IE Boundary. If not, we have some more data left for the IE which we don't know |
| 154 | // how to decode |
| 155 | if (ieBoundary == buffer.getCurrentIndex()) |
| 156 | { |
| 157 | return true; |
| 158 | } |
| 159 | else |
| 160 | { |
| 161 | errorStream.add((char *)"Unable to decode IE BearerQosIe\n"); |
| 162 | return false; |
| 163 | } |
| 164 | } |
| 165 | void BearerQosIe::displayBearerQosIe_v(BearerQosIeData const &data, Debug &stream) |
| 166 | { |
| 167 | stream.incrIndent(); |
| 168 | stream.add((char *)"BearerQosIeData:"); |
| 169 | stream.incrIndent(); |
| 170 | stream.endOfLine(); |
| 171 | |
| 172 | stream.add( (char *)"pci: "); |
| 173 | stream.add((Uint8)data.pci); |
| 174 | stream.endOfLine(); |
| 175 | |
| 176 | stream.add( (char *)"pl: "); |
| 177 | stream.add((Uint8)data.pl); |
| 178 | stream.endOfLine(); |
| 179 | |
| 180 | stream.add( (char *)"pvi: "); |
| 181 | stream.add((Uint8)data.pvi); |
| 182 | stream.endOfLine(); |
| 183 | |
| 184 | stream.add((char *)"qci: "); |
| 185 | stream.add(data.qci); |
| 186 | stream.endOfLine(); |
| 187 | |
| 188 | stream.add((char *)"maxBitRateUl:"); |
| 189 | stream.endOfLine(); |
| 190 | DataTypeCodecUtils::displayUint8Array5_v(data.maxBitRateUl, stream); |
| 191 | |
| 192 | stream.add((char *)"maxBitRateDl:"); |
| 193 | stream.endOfLine(); |
| 194 | DataTypeCodecUtils::displayUint8Array5_v(data.maxBitRateDl, stream); |
| 195 | |
| 196 | stream.add((char *)"guraranteedBitRateUl:"); |
| 197 | stream.endOfLine(); |
| 198 | DataTypeCodecUtils::displayUint8Array5_v(data.guraranteedBitRateUl, stream); |
| 199 | |
| 200 | stream.add((char *)"guaranteedBitRateDl:"); |
| 201 | stream.endOfLine(); |
| 202 | DataTypeCodecUtils::displayUint8Array5_v(data.guaranteedBitRateDl, stream); |
| 203 | stream.decrIndent(); |
| 204 | stream.decrIndent(); |
| 205 | } |