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 "bearerContextsInDeleteBearerResponse.h" |
| 16 | #include "manual/gtpV2Ie.h" |
| 17 | #include "gtpV2IeFactory.h" |
| 18 | #include "ebiIe.h" |
| 19 | #include "causeIe.h" |
| 20 | #include "pcoIe.h" |
| 21 | #include "ranNasCauseIe.h" |
| 22 | #include "epcoIe.h" |
| 23 | |
| 24 | BearerContextsInDeleteBearerResponse:: |
| 25 | BearerContextsInDeleteBearerResponse() |
| 26 | { |
| 27 | Uint16 mandIe; |
| 28 | mandIe = EbiIeType; |
| 29 | mandIe = (mandIe << 8) | 0; // epsBearerId |
| 30 | mandatoryIeSet.insert(mandIe); |
| 31 | mandIe = CauseIeType; |
| 32 | mandIe = (mandIe << 8) | 0; // cause |
| 33 | mandatoryIeSet.insert(mandIe); |
| 34 | |
| 35 | } |
| 36 | |
| 37 | BearerContextsInDeleteBearerResponse:: |
| 38 | ~BearerContextsInDeleteBearerResponse() |
| 39 | { |
| 40 | |
| 41 | } |
| 42 | bool BearerContextsInDeleteBearerResponse:: |
| 43 | encodeBearerContextsInDeleteBearerResponse(MsgBuffer &buffer, |
| 44 | BearerContextsInDeleteBearerResponseData |
| 45 | const &data) |
| 46 | { |
| 47 | bool rc = false; |
| 48 | GtpV2IeHeader header; |
| 49 | Uint16 startIndex = 0; |
| 50 | Uint16 endIndex = 0; |
| 51 | Uint16 length = 0; |
| 52 | |
| 53 | |
| 54 | |
| 55 | // Encode the Ie Header |
| 56 | header.ieType = EbiIeType; |
| 57 | header.instance = 0; |
| 58 | header.length = 0; // We will encode the IE first and then update the length |
| 59 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 60 | startIndex = buffer.getCurrentIndex(); |
| 61 | EbiIe ebi= |
| 62 | dynamic_cast< |
| 63 | EbiIe&>(GtpV2IeFactory::getInstance().getIeObject(EbiIeType)); |
| 64 | rc = ebi.encodeEbiIe(buffer, data.epsBearerId); |
| 65 | endIndex = buffer.getCurrentIndex(); |
| 66 | length = endIndex - startIndex; |
| 67 | |
| 68 | // encode the length value now |
| 69 | buffer.goToIndex(startIndex - 3); |
| 70 | buffer.writeUint16(length, false); |
| 71 | buffer.goToIndex(endIndex); |
| 72 | if (!(rc)) |
| 73 | { |
| 74 | errorStream.add((char *)"Failed to encode IE: epsBearerId\n"); |
| 75 | return false; |
| 76 | } |
| 77 | |
| 78 | |
| 79 | |
| 80 | // Encode the Ie Header |
| 81 | header.ieType = CauseIeType; |
| 82 | header.instance = 0; |
| 83 | header.length = 0; // We will encode the IE first and then update the length |
| 84 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 85 | startIndex = buffer.getCurrentIndex(); |
| 86 | CauseIe cause= |
| 87 | dynamic_cast< |
| 88 | CauseIe&>(GtpV2IeFactory::getInstance().getIeObject(CauseIeType)); |
| 89 | rc = cause.encodeCauseIe(buffer, data.cause); |
| 90 | endIndex = buffer.getCurrentIndex(); |
| 91 | length = endIndex - startIndex; |
| 92 | |
| 93 | // encode the length value now |
| 94 | buffer.goToIndex(startIndex - 3); |
| 95 | buffer.writeUint16(length, false); |
| 96 | buffer.goToIndex(endIndex); |
| 97 | if (!(rc)) |
| 98 | { |
| 99 | errorStream.add((char *)"Failed to encode IE: cause\n"); |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | if (data.protocolConfigurationOptionsIePresent) |
| 104 | { |
| 105 | |
| 106 | // Encode the Ie Header |
| 107 | header.ieType = PcoIeType; |
| 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 | PcoIe pco= |
| 113 | dynamic_cast< |
| 114 | PcoIe&>(GtpV2IeFactory::getInstance().getIeObject(PcoIeType)); |
| 115 | rc = pco.encodePcoIe(buffer, data.protocolConfigurationOptions); |
| 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 | |
| 124 | if (!(rc)) |
| 125 | { |
| 126 | errorStream.add((char *)"Failed to encode IE: protocolConfigurationOptions\n"); |
| 127 | return false; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | if (data.ranNasCauseIePresent) |
| 132 | { |
| 133 | |
| 134 | // Encode the Ie Header |
| 135 | header.ieType = RanNasCauseIeType; |
| 136 | header.instance = 0; |
| 137 | header.length = 0; // We will encode the IE first and then update the length |
| 138 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 139 | startIndex = buffer.getCurrentIndex(); |
| 140 | RanNasCauseIe ranNasCause= |
| 141 | dynamic_cast< |
| 142 | RanNasCauseIe&>(GtpV2IeFactory::getInstance().getIeObject(RanNasCauseIeType)); |
| 143 | rc = ranNasCause.encodeRanNasCauseIe(buffer, data.ranNasCause); |
| 144 | endIndex = buffer.getCurrentIndex(); |
| 145 | length = endIndex - startIndex; |
| 146 | |
| 147 | // encode the length value now |
| 148 | buffer.goToIndex(startIndex - 3); |
| 149 | buffer.writeUint16(length, false); |
| 150 | buffer.goToIndex(endIndex); |
| 151 | |
| 152 | if (!(rc)) |
| 153 | { |
| 154 | errorStream.add((char *)"Failed to encode IE: ranNasCause\n"); |
| 155 | return false; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | if (data.extendedProtocolConfigurationOptionsIePresent) |
| 160 | { |
| 161 | |
| 162 | // Encode the Ie Header |
| 163 | header.ieType = EpcoIeType; |
| 164 | header.instance = 0; |
| 165 | header.length = 0; // We will encode the IE first and then update the length |
| 166 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 167 | startIndex = buffer.getCurrentIndex(); |
| 168 | EpcoIe epco= |
| 169 | dynamic_cast< |
| 170 | EpcoIe&>(GtpV2IeFactory::getInstance().getIeObject(EpcoIeType)); |
| 171 | rc = epco.encodeEpcoIe(buffer, data.extendedProtocolConfigurationOptions); |
| 172 | endIndex = buffer.getCurrentIndex(); |
| 173 | length = endIndex - startIndex; |
| 174 | |
| 175 | // encode the length value now |
| 176 | buffer.goToIndex(startIndex - 3); |
| 177 | buffer.writeUint16(length, false); |
| 178 | buffer.goToIndex(endIndex); |
| 179 | |
| 180 | if (!(rc)) |
| 181 | { |
| 182 | errorStream.add((char *)"Failed to encode IE: extendedProtocolConfigurationOptions\n"); |
| 183 | return false; |
| 184 | } |
| 185 | } |
| 186 | return rc; |
| 187 | } |
| 188 | |
| 189 | bool BearerContextsInDeleteBearerResponse:: |
| 190 | decodeBearerContextsInDeleteBearerResponse(MsgBuffer &buffer, |
| 191 | BearerContextsInDeleteBearerResponseData |
| 192 | &data, Uint16 length) |
| 193 | { |
| 194 | |
| 195 | bool rc = false; |
| 196 | GtpV2IeHeader ieHeader; |
| 197 | set<Uint16> mandatoryIeLocalList = mandatoryIeSet; |
| 198 | while (buffer.lengthLeft() > IE_HEADER_SIZE) |
| 199 | { |
| 200 | GtpV2Ie::decodeGtpV2IeHeader(buffer, ieHeader); |
| 201 | if (ieHeader.length > buffer.lengthLeft()) |
| 202 | { |
| 203 | // We do not have enough bytes left in the message for this IE |
| 204 | errorStream.add((char *)"IE Length exceeds beyond message boundary\n"); |
| 205 | errorStream.add((char *)" Offending IE Type: "); |
| 206 | errorStream.add(ieHeader.ieType); |
| 207 | errorStream.add((char *)"\n Ie Length in Header: "); |
| 208 | errorStream.add(ieHeader.length); |
| 209 | errorStream.add((char *)"\n Bytes left in message: "); |
| 210 | errorStream.add(buffer.lengthLeft()); |
| 211 | errorStream.endOfLine(); |
| 212 | return false; |
| 213 | } |
| 214 | |
| 215 | switch (ieHeader.ieType){ |
| 216 | case EbiIeType: |
| 217 | { |
| 218 | EbiIe ieObject = |
| 219 | dynamic_cast< |
| 220 | EbiIe&>(GtpV2IeFactory::getInstance(). |
| 221 | getIeObject(EbiIeType)); |
| 222 | |
| 223 | |
| 224 | if(ieHeader.instance == 0) |
| 225 | { |
| 226 | |
| 227 | rc = ieObject.decodeEbiIe(buffer, data.epsBearerId, ieHeader.length); |
| 228 | |
| 229 | if (!(rc)) |
| 230 | { |
| 231 | errorStream.add((char *)"Failed to decode IE: epsBearerId\n"); |
| 232 | return false; |
| 233 | } |
| 234 | Uint16 mandIe = EbiIeType; |
| 235 | mandIe = (mandIe << 8) | 0; |
| 236 | mandatoryIeLocalList.erase(mandIe); |
| 237 | } |
| 238 | else |
| 239 | { |
| 240 | // Unknown IE instance print error TODO |
| 241 | errorStream.add((char *)"Unknown IE Type: "); |
| 242 | errorStream.add(ieHeader.ieType); |
| 243 | errorStream.endOfLine(); |
| 244 | buffer.skipBytes(ieHeader.length); |
| 245 | } |
| 246 | break; |
| 247 | } |
| 248 | case CauseIeType: |
| 249 | { |
| 250 | CauseIe ieObject = |
| 251 | dynamic_cast< |
| 252 | CauseIe&>(GtpV2IeFactory::getInstance(). |
| 253 | getIeObject(CauseIeType)); |
| 254 | |
| 255 | |
| 256 | if(ieHeader.instance == 0) |
| 257 | { |
| 258 | |
| 259 | rc = ieObject.decodeCauseIe(buffer, data.cause, ieHeader.length); |
| 260 | |
| 261 | if (!(rc)) |
| 262 | { |
| 263 | errorStream.add((char *)"Failed to decode IE: cause\n"); |
| 264 | return false; |
| 265 | } |
| 266 | Uint16 mandIe = CauseIeType; |
| 267 | mandIe = (mandIe << 8) | 0; |
| 268 | mandatoryIeLocalList.erase(mandIe); |
| 269 | } |
| 270 | else |
| 271 | { |
| 272 | // Unknown IE instance print error TODO |
| 273 | errorStream.add((char *)"Unknown IE Type: "); |
| 274 | errorStream.add(ieHeader.ieType); |
| 275 | errorStream.endOfLine(); |
| 276 | buffer.skipBytes(ieHeader.length); |
| 277 | } |
| 278 | break; |
| 279 | } |
| 280 | case PcoIeType: |
| 281 | { |
| 282 | PcoIe ieObject = |
| 283 | dynamic_cast< |
| 284 | PcoIe&>(GtpV2IeFactory::getInstance(). |
| 285 | getIeObject(PcoIeType)); |
| 286 | |
| 287 | |
| 288 | if(ieHeader.instance == 0) |
| 289 | { |
| 290 | |
| 291 | rc = ieObject.decodePcoIe(buffer, data.protocolConfigurationOptions, ieHeader.length); |
| 292 | |
| 293 | data.protocolConfigurationOptionsIePresent = true; |
| 294 | if (!(rc)) |
| 295 | { |
| 296 | errorStream.add((char *)"Failed to decode IE: protocolConfigurationOptions\n"); |
| 297 | return false; |
| 298 | } |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | // Unknown IE instance print error TODO |
| 303 | errorStream.add((char *)"Unknown IE Type: "); |
| 304 | errorStream.add(ieHeader.ieType); |
| 305 | errorStream.endOfLine(); |
| 306 | buffer.skipBytes(ieHeader.length); |
| 307 | } |
| 308 | break; |
| 309 | } |
| 310 | case RanNasCauseIeType: |
| 311 | { |
| 312 | RanNasCauseIe ieObject = |
| 313 | dynamic_cast< |
| 314 | RanNasCauseIe&>(GtpV2IeFactory::getInstance(). |
| 315 | getIeObject(RanNasCauseIeType)); |
| 316 | |
| 317 | |
| 318 | if(ieHeader.instance == 0) |
| 319 | { |
| 320 | |
| 321 | rc = ieObject.decodeRanNasCauseIe(buffer, data.ranNasCause, ieHeader.length); |
| 322 | |
| 323 | data.ranNasCauseIePresent = true; |
| 324 | if (!(rc)) |
| 325 | { |
| 326 | errorStream.add((char *)"Failed to decode IE: ranNasCause\n"); |
| 327 | return false; |
| 328 | } |
| 329 | } |
| 330 | else |
| 331 | { |
| 332 | // Unknown IE instance print error TODO |
| 333 | errorStream.add((char *)"Unknown IE Type: "); |
| 334 | errorStream.add(ieHeader.ieType); |
| 335 | errorStream.endOfLine(); |
| 336 | buffer.skipBytes(ieHeader.length); |
| 337 | } |
| 338 | break; |
| 339 | } |
| 340 | case EpcoIeType: |
| 341 | { |
| 342 | EpcoIe ieObject = |
| 343 | dynamic_cast< |
| 344 | EpcoIe&>(GtpV2IeFactory::getInstance(). |
| 345 | getIeObject(EpcoIeType)); |
| 346 | |
| 347 | |
| 348 | if(ieHeader.instance == 0) |
| 349 | { |
| 350 | |
| 351 | rc = ieObject.decodeEpcoIe(buffer, data.extendedProtocolConfigurationOptions, ieHeader.length); |
| 352 | |
| 353 | data.extendedProtocolConfigurationOptionsIePresent = true; |
| 354 | if (!(rc)) |
| 355 | { |
| 356 | errorStream.add((char *)"Failed to decode IE: extendedProtocolConfigurationOptions\n"); |
| 357 | return false; |
| 358 | } |
| 359 | } |
| 360 | else |
| 361 | { |
| 362 | // Unknown IE instance print error TODO |
| 363 | errorStream.add((char *)"Unknown IE Type: "); |
| 364 | errorStream.add(ieHeader.ieType); |
| 365 | errorStream.endOfLine(); |
| 366 | buffer.skipBytes(ieHeader.length); |
| 367 | } |
| 368 | break; |
| 369 | } |
| 370 | default: |
| 371 | { |
| 372 | // Unknown IE print error |
| 373 | errorStream.add((char *)"Unknown IE Type: "); |
| 374 | errorStream.add(ieHeader.ieType); |
| 375 | errorStream.endOfLine(); |
| 376 | buffer.skipBytes(ieHeader.length); |
| 377 | } |
| 378 | } |
| 379 | } |
| 380 | if (!mandatoryIeLocalList.empty()) |
| 381 | { |
| 382 | // some mandatory IEs are missing |
| 383 | errorStream.add((char *)"Missing Mandatory IEs:"); |
| 384 | errorStream.endOfLine(); |
| 385 | while (!mandatoryIeLocalList.empty()) |
| 386 | { |
| 387 | Uint16 missingMandIe = *mandatoryIeLocalList.begin (); |
| 388 | mandatoryIeLocalList.erase (mandatoryIeLocalList.begin ()); |
| 389 | Uint16 missingInstance = missingMandIe & 0x00FF; |
| 390 | Uint16 missingIeType = (missingMandIe >> 8); |
| 391 | errorStream.add ((char *)"Missing Ie type: "); |
| 392 | errorStream.add (missingIeType); |
| 393 | errorStream.add ((char *)" Instance: "); |
| 394 | errorStream.add (missingInstance); |
| 395 | errorStream.endOfLine(); |
| 396 | } |
| 397 | rc = false; |
| 398 | |
| 399 | } |
| 400 | return rc; |
| 401 | } |
| 402 | |
| 403 | void BearerContextsInDeleteBearerResponse:: |
| 404 | displayBearerContextsInDeleteBearerResponseData_v |
| 405 | (BearerContextsInDeleteBearerResponseData const &data, Debug &stream) |
| 406 | { |
| 407 | stream.incrIndent(); |
| 408 | stream.add((char *)"BearerContextsInDeleteBearerResponse:"); |
| 409 | stream.endOfLine(); |
| 410 | stream.incrIndent(); |
| 411 | |
| 412 | |
| 413 | |
| 414 | if (data.protocolConfigurationOptionsIePresent) |
| 415 | { |
| 416 | |
| 417 | stream.add((char *)"protocolConfigurationOptions:"); |
| 418 | stream.endOfLine(); |
| 419 | PcoIe pco= |
| 420 | dynamic_cast< |
| 421 | PcoIe&>(GtpV2IeFactory::getInstance().getIeObject(PcoIeType)); |
| 422 | pco.displayPcoIe_v(data.protocolConfigurationOptions, stream); |
| 423 | |
| 424 | } |
| 425 | |
| 426 | if (data.ranNasCauseIePresent) |
| 427 | { |
| 428 | |
| 429 | stream.add((char *)"ranNasCause:"); |
| 430 | stream.endOfLine(); |
| 431 | RanNasCauseIe ranNasCause= |
| 432 | dynamic_cast< |
| 433 | RanNasCauseIe&>(GtpV2IeFactory::getInstance().getIeObject(RanNasCauseIeType)); |
| 434 | ranNasCause.displayRanNasCauseIe_v(data.ranNasCause, stream); |
| 435 | |
| 436 | } |
| 437 | |
| 438 | if (data.extendedProtocolConfigurationOptionsIePresent) |
| 439 | { |
| 440 | |
| 441 | stream.add((char *)"extendedProtocolConfigurationOptions:"); |
| 442 | stream.endOfLine(); |
| 443 | EpcoIe epco= |
| 444 | dynamic_cast< |
| 445 | EpcoIe&>(GtpV2IeFactory::getInstance().getIeObject(EpcoIeType)); |
| 446 | epco.displayEpcoIe_v(data.extendedProtocolConfigurationOptions, stream); |
| 447 | |
| 448 | } |
| 449 | |
| 450 | stream.decrIndent(); |
| 451 | stream.decrIndent(); |
| 452 | } |
| 453 | |
| 454 | |
| 455 | |
| 456 | |
| 457 | |