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 "secondaryRatUsageDataReportIe.h" |
| 15 | #include "dataTypeCodecUtils.h" |
| 16 | |
| 17 | SecondaryRatUsageDataReportIe::SecondaryRatUsageDataReportIe() |
| 18 | { |
| 19 | ieType = 201; |
| 20 | // TODO |
| 21 | |
| 22 | } |
| 23 | |
| 24 | SecondaryRatUsageDataReportIe::~SecondaryRatUsageDataReportIe() { |
| 25 | // TODO Auto-generated destructor stub |
| 26 | } |
| 27 | |
| 28 | bool SecondaryRatUsageDataReportIe::encodeSecondaryRatUsageDataReportIe(MsgBuffer &buffer, SecondaryRatUsageDataReportIeData const &data) |
| 29 | { |
| 30 | buffer.skipBits(4); |
| 31 | |
| 32 | if(!(buffer.writeBits(data.irsgw, 2))) |
| 33 | { |
| 34 | errorStream.add((char *)"Encoding of irsgw failed\n"); |
| 35 | return false; |
| 36 | } |
| 37 | if(!(buffer.writeBits(data.irpgw, 2))) |
| 38 | { |
| 39 | errorStream.add((char *)"Encoding of irpgw failed\n"); |
| 40 | return false; |
| 41 | } |
| 42 | if (!(data.secondaryRatType== 0 || data.secondaryRatType== 1)) |
| 43 | { |
| 44 | errorStream.add((char *)"Data validation failure: secondaryRatType\n"); |
| 45 | return false; |
| 46 | } |
| 47 | if (!(buffer.writeUint8(data.secondaryRatType))) |
| 48 | { |
| 49 | errorStream.add((char *)"Encoding of secondaryRatType failed\n"); |
| 50 | return false; |
| 51 | } |
| 52 | buffer.skipBits(4); |
| 53 | |
| 54 | if(!(buffer.writeBits(data.epsBearerId, 4))) |
| 55 | { |
| 56 | errorStream.add((char *)"Encoding of epsBearerId failed\n"); |
| 57 | return false; |
| 58 | } |
| 59 | if (!(buffer.writeUint32(data.starttimestamp))) |
| 60 | { |
| 61 | errorStream.add((char *)"Encoding of starttimestamp failed\n"); |
| 62 | return false; |
| 63 | } |
| 64 | if (!(buffer.writeUint32(data.endtimestamp))) |
| 65 | { |
| 66 | errorStream.add((char *)"Encoding of endtimestamp failed\n"); |
| 67 | return false; |
| 68 | } |
| 69 | if (!(buffer.writeUint64(data.usageDataDL))) |
| 70 | { |
| 71 | errorStream.add((char *)"Encoding of usageDataDL failed\n"); |
| 72 | return false; |
| 73 | } |
| 74 | if (!(buffer.writeUint64(data.usageDataUL))) |
| 75 | { |
| 76 | errorStream.add((char *)"Encoding of usageDataUL failed\n"); |
| 77 | return false; |
| 78 | } |
| 79 | |
| 80 | return true; |
| 81 | } |
| 82 | |
| 83 | bool SecondaryRatUsageDataReportIe::decodeSecondaryRatUsageDataReportIe(MsgBuffer &buffer, SecondaryRatUsageDataReportIeData &data, Uint16 length) |
| 84 | { |
| 85 | // TODO optimize the length checks |
| 86 | |
| 87 | Uint16 ieBoundary = buffer.getCurrentIndex() + length; |
| 88 | buffer.skipBits(4); |
| 89 | if (buffer.getCurrentIndex() > ieBoundary) |
| 90 | { |
| 91 | errorStream.add((char *)"Attempt to read beyond IE boundary: \n"); |
| 92 | return false; |
| 93 | } |
| 94 | |
| 95 | data.irsgw = buffer.readBits(2); |
| 96 | // confirm that we are not reading beyond the IE boundary |
| 97 | if (buffer.getCurrentIndex() > ieBoundary) |
| 98 | { |
| 99 | errorStream.add((char *)"Attempt to read beyond IE boundary: irsgw\n"); |
| 100 | return false; |
| 101 | } |
| 102 | data.irpgw = buffer.readBits(2); |
| 103 | // confirm that we are not reading beyond the IE boundary |
| 104 | if (buffer.getCurrentIndex() > ieBoundary) |
| 105 | { |
| 106 | errorStream.add((char *)"Attempt to read beyond IE boundary: irpgw\n"); |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | buffer.readUint8(data.secondaryRatType); |
| 111 | if (buffer.getCurrentIndex() > ieBoundary) |
| 112 | { |
| 113 | errorStream.add((char *)"Attempt to read beyond IE boundary: secondaryRatType\n"); |
| 114 | return false; |
| 115 | } |
| 116 | if (!(data.secondaryRatType== 0 || data.secondaryRatType== 1)) |
| 117 | { |
| 118 | errorStream.add((char *)"Data validation failure : secondaryRatType\n"); |
| 119 | return false; //TODO need to add validations |
| 120 | } |
| 121 | buffer.skipBits(4); |
| 122 | if (buffer.getCurrentIndex() > ieBoundary) |
| 123 | { |
| 124 | errorStream.add((char *)"Attempt to read beyond IE boundary: \n"); |
| 125 | return false; |
| 126 | } |
| 127 | |
| 128 | data.epsBearerId = buffer.readBits(4); |
| 129 | // confirm that we are not reading beyond the IE boundary |
| 130 | if (buffer.getCurrentIndex() > ieBoundary) |
| 131 | { |
| 132 | errorStream.add((char *)"Attempt to read beyond IE boundary: epsBearerId\n"); |
| 133 | return false; |
| 134 | } |
| 135 | |
| 136 | buffer.readUint32(data.starttimestamp); |
| 137 | if (buffer.getCurrentIndex() > ieBoundary) |
| 138 | { |
| 139 | errorStream.add((char *)"Attempt to read beyond IE boundary: starttimestamp\n"); |
| 140 | return false; |
| 141 | } |
| 142 | |
| 143 | buffer.readUint32(data.endtimestamp); |
| 144 | if (buffer.getCurrentIndex() > ieBoundary) |
| 145 | { |
| 146 | errorStream.add((char *)"Attempt to read beyond IE boundary: endtimestamp\n"); |
| 147 | return false; |
| 148 | } |
| 149 | |
| 150 | buffer.readUint64(data.usageDataDL); |
| 151 | if (buffer.getCurrentIndex() > ieBoundary) |
| 152 | { |
| 153 | errorStream.add((char *)"Attempt to read beyond IE boundary: usageDataDL\n"); |
| 154 | return false; |
| 155 | } |
| 156 | |
| 157 | buffer.readUint64(data.usageDataUL); |
| 158 | if (buffer.getCurrentIndex() > ieBoundary) |
| 159 | { |
| 160 | errorStream.add((char *)"Attempt to read beyond IE boundary: usageDataUL\n"); |
| 161 | return false; |
| 162 | } |
| 163 | |
| 164 | // The IE is decoded now. The buffer index should be pointing to the |
| 165 | // IE Boundary. If not, we have some more data left for the IE which we don't know |
| 166 | // how to decode |
| 167 | if (ieBoundary == buffer.getCurrentIndex()) |
| 168 | { |
| 169 | return true; |
| 170 | } |
| 171 | else |
| 172 | { |
| 173 | errorStream.add((char *)"Unable to decode IE SecondaryRatUsageDataReportIe\n"); |
| 174 | return false; |
| 175 | } |
| 176 | } |
| 177 | void SecondaryRatUsageDataReportIe::displaySecondaryRatUsageDataReportIe_v(SecondaryRatUsageDataReportIeData const &data, Debug &stream) |
| 178 | { |
| 179 | stream.incrIndent(); |
| 180 | stream.add((char *)"SecondaryRatUsageDataReportIeData:"); |
| 181 | stream.incrIndent(); |
| 182 | stream.endOfLine(); |
| 183 | |
| 184 | stream.add( (char *)"irsgw: "); |
| 185 | stream.add((Uint8)data.irsgw); |
| 186 | stream.endOfLine(); |
| 187 | |
| 188 | stream.add( (char *)"irpgw: "); |
| 189 | stream.add((Uint8)data.irpgw); |
| 190 | stream.endOfLine(); |
| 191 | |
| 192 | stream.add((char *)"secondaryRatType: "); |
| 193 | stream.add(data.secondaryRatType); |
| 194 | stream.endOfLine(); |
| 195 | |
| 196 | stream.add( (char *)"epsBearerId: "); |
| 197 | stream.add((Uint8)data.epsBearerId); |
| 198 | stream.endOfLine(); |
| 199 | |
| 200 | stream.add((char *)"starttimestamp: "); |
| 201 | stream.add(data.starttimestamp); |
| 202 | stream.endOfLine(); |
| 203 | |
| 204 | stream.add((char *)"endtimestamp: "); |
| 205 | stream.add(data.endtimestamp); |
| 206 | stream.endOfLine(); |
| 207 | |
| 208 | stream.add((char *)"usageDataDL: "); |
| 209 | stream.add(data.usageDataDL); |
| 210 | stream.endOfLine(); |
| 211 | |
| 212 | stream.add((char *)"usageDataUL: "); |
| 213 | stream.add(data.usageDataUL); |
| 214 | stream.endOfLine(); |
| 215 | stream.decrIndent(); |
| 216 | stream.decrIndent(); |
| 217 | } |