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 | * |
| 9 | * This is an auto generated file. |
| 10 | * Please do not edit this file. |
| 11 | * All edits to be made through template source file |
| 12 | * <TOP-DIR/scripts/GtpV2StackCodeGen/tts/grpieinsttemplate.cpp.tt> |
| 13 | ******************************************************************************/ |
| 14 | |
| 15 | #include "pgwsApnLevelLoadControlInformationInDeleteSessionResponse.h" |
| 16 | #include "manual/gtpV2Ie.h" |
| 17 | #include "gtpV2IeFactory.h" |
| 18 | #include "sequenceNumberIe.h" |
| 19 | #include "metricIe.h" |
| 20 | #include "apnAndRelativeCapacityIe.h" |
| 21 | |
| 22 | PgwsApnLevelLoadControlInformationInDeleteSessionResponse:: |
| 23 | PgwsApnLevelLoadControlInformationInDeleteSessionResponse() |
| 24 | { |
| 25 | Uint16 mandIe; |
| 26 | mandIe = SequenceNumberIeType; |
| 27 | mandIe = (mandIe << 8) | 0; // loadControlSequenceNumber |
| 28 | mandatoryIeSet.insert(mandIe); |
| 29 | mandIe = MetricIeType; |
| 30 | mandIe = (mandIe << 8) | 0; // loadMetric |
| 31 | mandatoryIeSet.insert(mandIe); |
| 32 | mandIe = ApnAndRelativeCapacityIeType; |
| 33 | mandIe = (mandIe << 8) | 0; // listOfApnAndRelativeCapacity |
| 34 | mandatoryIeSet.insert(mandIe); |
| 35 | |
| 36 | } |
| 37 | |
| 38 | PgwsApnLevelLoadControlInformationInDeleteSessionResponse:: |
| 39 | ~PgwsApnLevelLoadControlInformationInDeleteSessionResponse() |
| 40 | { |
| 41 | |
| 42 | } |
| 43 | bool PgwsApnLevelLoadControlInformationInDeleteSessionResponse:: |
| 44 | encodePgwsApnLevelLoadControlInformationInDeleteSessionResponse(MsgBuffer &buffer, |
| 45 | PgwsApnLevelLoadControlInformationInDeleteSessionResponseData |
| 46 | const &data) |
| 47 | { |
| 48 | bool rc = false; |
| 49 | GtpV2IeHeader header; |
| 50 | Uint16 startIndex = 0; |
| 51 | Uint16 endIndex = 0; |
| 52 | Uint16 length = 0; |
| 53 | |
| 54 | |
| 55 | |
| 56 | // Encode the Ie Header |
| 57 | header.ieType = SequenceNumberIeType; |
| 58 | header.instance = 0; |
| 59 | header.length = 0; // We will encode the IE first and then update the length |
| 60 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 61 | startIndex = buffer.getCurrentIndex(); |
| 62 | SequenceNumberIe sequenceNumber= |
| 63 | dynamic_cast< |
| 64 | SequenceNumberIe&>(GtpV2IeFactory::getInstance().getIeObject(SequenceNumberIeType)); |
| 65 | rc = sequenceNumber.encodeSequenceNumberIe(buffer, data.loadControlSequenceNumber); |
| 66 | endIndex = buffer.getCurrentIndex(); |
| 67 | length = endIndex - startIndex; |
| 68 | |
| 69 | // encode the length value now |
| 70 | buffer.goToIndex(startIndex - 3); |
| 71 | buffer.writeUint16(length, false); |
| 72 | buffer.goToIndex(endIndex); |
| 73 | if (!(rc)) |
| 74 | { |
| 75 | errorStream.add((char *)"Failed to encode IE: loadControlSequenceNumber\n"); |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | |
| 80 | |
| 81 | // Encode the Ie Header |
| 82 | header.ieType = MetricIeType; |
| 83 | header.instance = 0; |
| 84 | header.length = 0; // We will encode the IE first and then update the length |
| 85 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 86 | startIndex = buffer.getCurrentIndex(); |
| 87 | MetricIe metric= |
| 88 | dynamic_cast< |
| 89 | MetricIe&>(GtpV2IeFactory::getInstance().getIeObject(MetricIeType)); |
| 90 | rc = metric.encodeMetricIe(buffer, data.loadMetric); |
| 91 | endIndex = buffer.getCurrentIndex(); |
| 92 | length = endIndex - startIndex; |
| 93 | |
| 94 | // encode the length value now |
| 95 | buffer.goToIndex(startIndex - 3); |
| 96 | buffer.writeUint16(length, false); |
| 97 | buffer.goToIndex(endIndex); |
| 98 | if (!(rc)) |
| 99 | { |
| 100 | errorStream.add((char *)"Failed to encode IE: loadMetric\n"); |
| 101 | return false; |
| 102 | } |
| 103 | |
| 104 | |
| 105 | |
| 106 | // Encode the Ie Header |
| 107 | header.ieType = ApnAndRelativeCapacityIeType; |
| 108 | header.instance = 0; |
| 109 | header.length = 0; // We will encode the IE first and then update the length |
| 110 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 111 | startIndex = buffer.getCurrentIndex(); |
| 112 | ApnAndRelativeCapacityIe apnAndRelativeCapacity= |
| 113 | dynamic_cast< |
| 114 | ApnAndRelativeCapacityIe&>(GtpV2IeFactory::getInstance().getIeObject(ApnAndRelativeCapacityIeType)); |
| 115 | rc = apnAndRelativeCapacity.encodeApnAndRelativeCapacityIe(buffer, data.listOfApnAndRelativeCapacity); |
| 116 | endIndex = buffer.getCurrentIndex(); |
| 117 | length = endIndex - startIndex; |
| 118 | |
| 119 | // encode the length value now |
| 120 | buffer.goToIndex(startIndex - 3); |
| 121 | buffer.writeUint16(length, false); |
| 122 | buffer.goToIndex(endIndex); |
| 123 | if (!(rc)) |
| 124 | { |
| 125 | errorStream.add((char *)"Failed to encode IE: listOfApnAndRelativeCapacity\n"); |
| 126 | return false; |
| 127 | } |
| 128 | return rc; |
| 129 | } |
| 130 | |
| 131 | bool PgwsApnLevelLoadControlInformationInDeleteSessionResponse:: |
| 132 | decodePgwsApnLevelLoadControlInformationInDeleteSessionResponse(MsgBuffer &buffer, |
| 133 | PgwsApnLevelLoadControlInformationInDeleteSessionResponseData |
| 134 | &data, Uint16 length) |
| 135 | { |
| 136 | |
| 137 | bool rc = false; |
| 138 | GtpV2IeHeader ieHeader; |
| 139 | set<Uint16> mandatoryIeLocalList = mandatoryIeSet; |
| 140 | while (buffer.lengthLeft() > IE_HEADER_SIZE) |
| 141 | { |
| 142 | GtpV2Ie::decodeGtpV2IeHeader(buffer, ieHeader); |
| 143 | if (ieHeader.length > buffer.lengthLeft()) |
| 144 | { |
| 145 | // We do not have enough bytes left in the message for this IE |
| 146 | errorStream.add((char *)"IE Length exceeds beyond message boundary\n"); |
| 147 | errorStream.add((char *)" Offending IE Type: "); |
| 148 | errorStream.add(ieHeader.ieType); |
| 149 | errorStream.add((char *)"\n Ie Length in Header: "); |
| 150 | errorStream.add(ieHeader.length); |
| 151 | errorStream.add((char *)"\n Bytes left in message: "); |
| 152 | errorStream.add(buffer.lengthLeft()); |
| 153 | errorStream.endOfLine(); |
| 154 | return false; |
| 155 | } |
| 156 | |
| 157 | switch (ieHeader.ieType){ |
| 158 | case SequenceNumberIeType: |
| 159 | { |
| 160 | SequenceNumberIe ieObject = |
| 161 | dynamic_cast< |
| 162 | SequenceNumberIe&>(GtpV2IeFactory::getInstance(). |
| 163 | getIeObject(SequenceNumberIeType)); |
| 164 | |
| 165 | |
| 166 | if(ieHeader.instance == 0) |
| 167 | { |
| 168 | |
| 169 | rc = ieObject.decodeSequenceNumberIe(buffer, data.loadControlSequenceNumber, ieHeader.length); |
| 170 | |
| 171 | if (!(rc)) |
| 172 | { |
| 173 | errorStream.add((char *)"Failed to decode IE: loadControlSequenceNumber\n"); |
| 174 | return false; |
| 175 | } |
| 176 | Uint16 mandIe = SequenceNumberIeType; |
| 177 | mandIe = (mandIe << 8) | 0; |
| 178 | mandatoryIeLocalList.erase(mandIe); |
| 179 | } |
| 180 | else |
| 181 | { |
| 182 | // Unknown IE instance print error TODO |
| 183 | errorStream.add((char *)"Unknown IE Type: "); |
| 184 | errorStream.add(ieHeader.ieType); |
| 185 | errorStream.endOfLine(); |
| 186 | buffer.skipBytes(ieHeader.length); |
| 187 | } |
| 188 | break; |
| 189 | } |
| 190 | case MetricIeType: |
| 191 | { |
| 192 | MetricIe ieObject = |
| 193 | dynamic_cast< |
| 194 | MetricIe&>(GtpV2IeFactory::getInstance(). |
| 195 | getIeObject(MetricIeType)); |
| 196 | |
| 197 | |
| 198 | if(ieHeader.instance == 0) |
| 199 | { |
| 200 | |
| 201 | rc = ieObject.decodeMetricIe(buffer, data.loadMetric, ieHeader.length); |
| 202 | |
| 203 | if (!(rc)) |
| 204 | { |
| 205 | errorStream.add((char *)"Failed to decode IE: loadMetric\n"); |
| 206 | return false; |
| 207 | } |
| 208 | Uint16 mandIe = MetricIeType; |
| 209 | mandIe = (mandIe << 8) | 0; |
| 210 | mandatoryIeLocalList.erase(mandIe); |
| 211 | } |
| 212 | else |
| 213 | { |
| 214 | // Unknown IE instance print error TODO |
| 215 | errorStream.add((char *)"Unknown IE Type: "); |
| 216 | errorStream.add(ieHeader.ieType); |
| 217 | errorStream.endOfLine(); |
| 218 | buffer.skipBytes(ieHeader.length); |
| 219 | } |
| 220 | break; |
| 221 | } |
| 222 | case ApnAndRelativeCapacityIeType: |
| 223 | { |
| 224 | ApnAndRelativeCapacityIe ieObject = |
| 225 | dynamic_cast< |
| 226 | ApnAndRelativeCapacityIe&>(GtpV2IeFactory::getInstance(). |
| 227 | getIeObject(ApnAndRelativeCapacityIeType)); |
| 228 | |
| 229 | |
| 230 | if(ieHeader.instance == 0) |
| 231 | { |
| 232 | |
| 233 | rc = ieObject.decodeApnAndRelativeCapacityIe(buffer, data.listOfApnAndRelativeCapacity, ieHeader.length); |
| 234 | |
| 235 | if (!(rc)) |
| 236 | { |
| 237 | errorStream.add((char *)"Failed to decode IE: listOfApnAndRelativeCapacity\n"); |
| 238 | return false; |
| 239 | } |
| 240 | Uint16 mandIe = ApnAndRelativeCapacityIeType; |
| 241 | mandIe = (mandIe << 8) | 0; |
| 242 | mandatoryIeLocalList.erase(mandIe); |
| 243 | } |
| 244 | else |
| 245 | { |
| 246 | // Unknown IE instance print error TODO |
| 247 | errorStream.add((char *)"Unknown IE Type: "); |
| 248 | errorStream.add(ieHeader.ieType); |
| 249 | errorStream.endOfLine(); |
| 250 | buffer.skipBytes(ieHeader.length); |
| 251 | } |
| 252 | break; |
| 253 | } |
| 254 | default: |
| 255 | { |
| 256 | // Unknown IE print error |
| 257 | errorStream.add((char *)"Unknown IE Type: "); |
| 258 | errorStream.add(ieHeader.ieType); |
| 259 | errorStream.endOfLine(); |
| 260 | buffer.skipBytes(ieHeader.length); |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | if (!mandatoryIeLocalList.empty()) |
| 265 | { |
| 266 | // some mandatory IEs are missing |
| 267 | errorStream.add((char *)"Missing Mandatory IEs:"); |
| 268 | errorStream.endOfLine(); |
| 269 | while (!mandatoryIeLocalList.empty()) |
| 270 | { |
| 271 | Uint16 missingMandIe = *mandatoryIeLocalList.begin (); |
| 272 | mandatoryIeLocalList.erase (mandatoryIeLocalList.begin ()); |
| 273 | Uint16 missingInstance = missingMandIe & 0x00FF; |
| 274 | Uint16 missingIeType = (missingMandIe >> 8); |
| 275 | errorStream.add ((char *)"Missing Ie type: "); |
| 276 | errorStream.add (missingIeType); |
| 277 | errorStream.add ((char *)" Instance: "); |
| 278 | errorStream.add (missingInstance); |
| 279 | errorStream.endOfLine(); |
| 280 | } |
| 281 | rc = false; |
| 282 | |
| 283 | } |
| 284 | return rc; |
| 285 | } |
| 286 | |
| 287 | void PgwsApnLevelLoadControlInformationInDeleteSessionResponse:: |
| 288 | displayPgwsApnLevelLoadControlInformationInDeleteSessionResponseData_v |
| 289 | (PgwsApnLevelLoadControlInformationInDeleteSessionResponseData const &data, Debug &stream) |
| 290 | { |
| 291 | stream.incrIndent(); |
| 292 | stream.add((char *)"PgwsApnLevelLoadControlInformationInDeleteSessionResponse:"); |
| 293 | stream.endOfLine(); |
| 294 | stream.incrIndent(); |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | stream.decrIndent(); |
| 300 | stream.decrIndent(); |
| 301 | } |
| 302 | |
| 303 | |
| 304 | |
| 305 | |
| 306 | |