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/msgtemplate.cpp.tt> |
| 13 | ******************************************************************************/ |
| 14 | |
| 15 | #include "releaseAccessBearersRequestMsg.h" |
| 16 | #include "../ieClasses/manual/gtpV2Ie.h" |
| 17 | #include "../ieClasses/gtpV2IeFactory.h" |
| 18 | #include "../ieClasses/ebiIe.h" |
| 19 | #include "../ieClasses/nodeTypeIe.h" |
| 20 | #include "../ieClasses/indicationIe.h" |
| 21 | #include "../ieClasses/secondaryRatUsageDataReportIe.h" |
| 22 | |
| 23 | ReleaseAccessBearersRequestMsg::ReleaseAccessBearersRequestMsg() |
| 24 | { |
| 25 | msgType = ReleaseAccessBearersRequestMsgType; |
| 26 | |
| 27 | } |
| 28 | |
| 29 | ReleaseAccessBearersRequestMsg::~ReleaseAccessBearersRequestMsg() |
| 30 | { |
| 31 | |
| 32 | } |
| 33 | |
| 34 | bool ReleaseAccessBearersRequestMsg::encodeReleaseAccessBearersRequestMsg(MsgBuffer &buffer, |
| 35 | ReleaseAccessBearersRequestMsgData |
| 36 | const &data) |
| 37 | { |
| 38 | bool rc = false; |
| 39 | GtpV2IeHeader header; |
| 40 | Uint16 startIndex = 0; |
| 41 | Uint16 endIndex = 0; |
| 42 | Uint16 length = 0; |
| 43 | |
| 44 | if (data.listOfRabsIePresent) |
| 45 | { |
| 46 | |
| 47 | // Encode the Ie Header |
| 48 | header.ieType = EbiIeType; |
| 49 | header.instance = 0; |
| 50 | header.length = 0; // We will encode the IE first and then update the length |
| 51 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 52 | startIndex = buffer.getCurrentIndex(); |
| 53 | EbiIe ebi= |
| 54 | dynamic_cast< |
| 55 | EbiIe&>(GtpV2IeFactory::getInstance().getIeObject(EbiIeType)); |
| 56 | rc = ebi.encodeEbiIe(buffer, data.listOfRabs); |
| 57 | endIndex = buffer.getCurrentIndex(); |
| 58 | length = endIndex - startIndex; |
| 59 | |
| 60 | // encode the length value now |
| 61 | buffer.goToIndex(startIndex - 3); |
| 62 | buffer.writeUint16(length, false); |
| 63 | buffer.goToIndex(endIndex); |
| 64 | |
| 65 | if (!(rc)) |
| 66 | { |
| 67 | errorStream.add((char *)"Failed to encode IE: listOfRabs\n"); |
| 68 | return false; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | if (data.originatingNodeIePresent) |
| 73 | { |
| 74 | |
| 75 | // Encode the Ie Header |
| 76 | header.ieType = NodeTypeIeType; |
| 77 | header.instance = 0; |
| 78 | header.length = 0; // We will encode the IE first and then update the length |
| 79 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 80 | startIndex = buffer.getCurrentIndex(); |
| 81 | NodeTypeIe nodeType= |
| 82 | dynamic_cast< |
| 83 | NodeTypeIe&>(GtpV2IeFactory::getInstance().getIeObject(NodeTypeIeType)); |
| 84 | rc = nodeType.encodeNodeTypeIe(buffer, data.originatingNode); |
| 85 | endIndex = buffer.getCurrentIndex(); |
| 86 | length = endIndex - startIndex; |
| 87 | |
| 88 | // encode the length value now |
| 89 | buffer.goToIndex(startIndex - 3); |
| 90 | buffer.writeUint16(length, false); |
| 91 | buffer.goToIndex(endIndex); |
| 92 | |
| 93 | if (!(rc)) |
| 94 | { |
| 95 | errorStream.add((char *)"Failed to encode IE: originatingNode\n"); |
| 96 | return false; |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | if (data.indicationFlagsIePresent) |
| 101 | { |
| 102 | |
| 103 | // Encode the Ie Header |
| 104 | header.ieType = IndicationIeType; |
| 105 | header.instance = 0; |
| 106 | header.length = 0; // We will encode the IE first and then update the length |
| 107 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 108 | startIndex = buffer.getCurrentIndex(); |
| 109 | IndicationIe indication= |
| 110 | dynamic_cast< |
| 111 | IndicationIe&>(GtpV2IeFactory::getInstance().getIeObject(IndicationIeType)); |
| 112 | rc = indication.encodeIndicationIe(buffer, data.indicationFlags); |
| 113 | endIndex = buffer.getCurrentIndex(); |
| 114 | length = endIndex - startIndex; |
| 115 | |
| 116 | // encode the length value now |
| 117 | buffer.goToIndex(startIndex - 3); |
| 118 | buffer.writeUint16(length, false); |
| 119 | buffer.goToIndex(endIndex); |
| 120 | |
| 121 | if (!(rc)) |
| 122 | { |
| 123 | errorStream.add((char *)"Failed to encode IE: indicationFlags\n"); |
| 124 | return false; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | if (data.secondaryRatUsageDataReportIePresent) |
| 129 | { |
| 130 | |
| 131 | // Encode the Ie Header |
| 132 | header.ieType = SecondaryRatUsageDataReportIeType; |
| 133 | header.instance = 0; |
| 134 | header.length = 0; // We will encode the IE first and then update the length |
| 135 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 136 | startIndex = buffer.getCurrentIndex(); |
| 137 | SecondaryRatUsageDataReportIe secondaryRatUsageDataReport= |
| 138 | dynamic_cast< |
| 139 | SecondaryRatUsageDataReportIe&>(GtpV2IeFactory::getInstance().getIeObject(SecondaryRatUsageDataReportIeType)); |
| 140 | rc = secondaryRatUsageDataReport.encodeSecondaryRatUsageDataReportIe(buffer, data.secondaryRatUsageDataReport); |
| 141 | endIndex = buffer.getCurrentIndex(); |
| 142 | length = endIndex - startIndex; |
| 143 | |
| 144 | // encode the length value now |
| 145 | buffer.goToIndex(startIndex - 3); |
| 146 | buffer.writeUint16(length, false); |
| 147 | buffer.goToIndex(endIndex); |
| 148 | |
| 149 | if (!(rc)) |
| 150 | { |
| 151 | errorStream.add((char *)"Failed to encode IE: secondaryRatUsageDataReport\n"); |
| 152 | return false; |
| 153 | } |
| 154 | } |
| 155 | return rc; |
| 156 | |
| 157 | } |
| 158 | |
| 159 | bool ReleaseAccessBearersRequestMsg::decodeReleaseAccessBearersRequestMsg(MsgBuffer &buffer, |
| 160 | ReleaseAccessBearersRequestMsgData |
| 161 | &data, Uint16 length) |
| 162 | { |
| 163 | |
| 164 | bool rc = false; |
| 165 | GtpV2IeHeader ieHeader; |
| 166 | |
| 167 | set<Uint16> mandatoryIeLocalList = mandatoryIeSet; |
| 168 | while (buffer.lengthLeft() > IE_HEADER_SIZE) |
| 169 | { |
| 170 | GtpV2Ie::decodeGtpV2IeHeader(buffer, ieHeader); |
| 171 | if (ieHeader.length > buffer.lengthLeft()) |
| 172 | { |
| 173 | // We do not have enough bytes left in the message for this IE |
| 174 | errorStream.add((char *)"IE Length exceeds beyond message boundary\n"); |
| 175 | errorStream.add((char *)" Offending IE Type: "); |
| 176 | errorStream.add(ieHeader.ieType); |
| 177 | errorStream.add((char *)"\n Ie Length in Header: "); |
| 178 | errorStream.add(ieHeader.length); |
| 179 | errorStream.add((char *)"\n Bytes left in message: "); |
| 180 | errorStream.add(buffer.lengthLeft()); |
| 181 | errorStream.endOfLine(); |
| 182 | return false; |
| 183 | } |
| 184 | |
| 185 | switch (ieHeader.ieType){ |
| 186 | |
| 187 | case EbiIeType: |
| 188 | { |
| 189 | EbiIe ieObject = |
| 190 | dynamic_cast< |
| 191 | EbiIe&>(GtpV2IeFactory::getInstance().getIeObject(EbiIeType)); |
| 192 | |
| 193 | if(ieHeader.instance == 0) |
| 194 | { |
| 195 | rc = ieObject.decodeEbiIe(buffer, data.listOfRabs, ieHeader.length); |
| 196 | |
| 197 | data.listOfRabsIePresent = true; |
| 198 | if (!(rc)) |
| 199 | { |
| 200 | errorStream.add((char *)"Failed to decode IE: listOfRabs\n"); |
| 201 | return false; |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | else |
| 206 | { |
| 207 | // Unknown IE instance print error |
| 208 | errorStream.add((char *)"Unknown IE Type: "); |
| 209 | errorStream.add(ieHeader.ieType); |
| 210 | errorStream.endOfLine(); |
| 211 | buffer.skipBytes(ieHeader.length); |
| 212 | } |
| 213 | break; |
| 214 | } |
| 215 | |
| 216 | case NodeTypeIeType: |
| 217 | { |
| 218 | NodeTypeIe ieObject = |
| 219 | dynamic_cast< |
| 220 | NodeTypeIe&>(GtpV2IeFactory::getInstance().getIeObject(NodeTypeIeType)); |
| 221 | |
| 222 | if(ieHeader.instance == 0) |
| 223 | { |
| 224 | rc = ieObject.decodeNodeTypeIe(buffer, data.originatingNode, ieHeader.length); |
| 225 | |
| 226 | data.originatingNodeIePresent = true; |
| 227 | if (!(rc)) |
| 228 | { |
| 229 | errorStream.add((char *)"Failed to decode IE: originatingNode\n"); |
| 230 | return false; |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | else |
| 235 | { |
| 236 | // Unknown IE instance print error |
| 237 | errorStream.add((char *)"Unknown IE Type: "); |
| 238 | errorStream.add(ieHeader.ieType); |
| 239 | errorStream.endOfLine(); |
| 240 | buffer.skipBytes(ieHeader.length); |
| 241 | } |
| 242 | break; |
| 243 | } |
| 244 | |
| 245 | case IndicationIeType: |
| 246 | { |
| 247 | IndicationIe ieObject = |
| 248 | dynamic_cast< |
| 249 | IndicationIe&>(GtpV2IeFactory::getInstance().getIeObject(IndicationIeType)); |
| 250 | |
| 251 | if(ieHeader.instance == 0) |
| 252 | { |
| 253 | rc = ieObject.decodeIndicationIe(buffer, data.indicationFlags, ieHeader.length); |
| 254 | |
| 255 | data.indicationFlagsIePresent = true; |
| 256 | if (!(rc)) |
| 257 | { |
| 258 | errorStream.add((char *)"Failed to decode IE: indicationFlags\n"); |
| 259 | return false; |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | else |
| 264 | { |
| 265 | // Unknown IE instance print error |
| 266 | errorStream.add((char *)"Unknown IE Type: "); |
| 267 | errorStream.add(ieHeader.ieType); |
| 268 | errorStream.endOfLine(); |
| 269 | buffer.skipBytes(ieHeader.length); |
| 270 | } |
| 271 | break; |
| 272 | } |
| 273 | |
| 274 | case SecondaryRatUsageDataReportIeType: |
| 275 | { |
| 276 | SecondaryRatUsageDataReportIe ieObject = |
| 277 | dynamic_cast< |
| 278 | SecondaryRatUsageDataReportIe&>(GtpV2IeFactory::getInstance().getIeObject(SecondaryRatUsageDataReportIeType)); |
| 279 | |
| 280 | if(ieHeader.instance == 0) |
| 281 | { |
| 282 | rc = ieObject.decodeSecondaryRatUsageDataReportIe(buffer, data.secondaryRatUsageDataReport, ieHeader.length); |
| 283 | |
| 284 | data.secondaryRatUsageDataReportIePresent = true; |
| 285 | if (!(rc)) |
| 286 | { |
| 287 | errorStream.add((char *)"Failed to decode IE: secondaryRatUsageDataReport\n"); |
| 288 | return false; |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | else |
| 293 | { |
| 294 | // Unknown IE instance print error |
| 295 | errorStream.add((char *)"Unknown IE Type: "); |
| 296 | errorStream.add(ieHeader.ieType); |
| 297 | errorStream.endOfLine(); |
| 298 | buffer.skipBytes(ieHeader.length); |
| 299 | } |
| 300 | break; |
| 301 | } |
| 302 | |
| 303 | default: |
| 304 | { |
| 305 | // Unknown IE print error |
| 306 | errorStream.add((char *)"Unknown IE Type: "); |
| 307 | errorStream.add(ieHeader.ieType); |
| 308 | errorStream.endOfLine(); |
| 309 | buffer.skipBytes(ieHeader.length); |
| 310 | } |
| 311 | } |
| 312 | } |
| 313 | return rc; // TODO validations |
| 314 | } |
| 315 | |
| 316 | void ReleaseAccessBearersRequestMsg:: |
| 317 | displayReleaseAccessBearersRequestMsgData_v(ReleaseAccessBearersRequestMsgData const &data, Debug &stream) |
| 318 | { |
| 319 | stream.incrIndent(); |
| 320 | stream.add((char *)"ReleaseAccessBearersRequestMsg:"); |
| 321 | stream.endOfLine(); |
| 322 | stream.incrIndent(); |
| 323 | |
| 324 | |
| 325 | if (data.listOfRabsIePresent) |
| 326 | { |
| 327 | |
| 328 | |
| 329 | stream.add((char *)"IE - listOfRabs:"); |
| 330 | stream.endOfLine(); |
| 331 | EbiIe ebi= |
| 332 | dynamic_cast< |
| 333 | EbiIe&>(GtpV2IeFactory::getInstance().getIeObject(EbiIeType)); |
| 334 | ebi.displayEbiIe_v(data.listOfRabs, stream); |
| 335 | |
| 336 | } |
| 337 | if (data.originatingNodeIePresent) |
| 338 | { |
| 339 | |
| 340 | |
| 341 | stream.add((char *)"IE - originatingNode:"); |
| 342 | stream.endOfLine(); |
| 343 | NodeTypeIe nodeType= |
| 344 | dynamic_cast< |
| 345 | NodeTypeIe&>(GtpV2IeFactory::getInstance().getIeObject(NodeTypeIeType)); |
| 346 | nodeType.displayNodeTypeIe_v(data.originatingNode, stream); |
| 347 | |
| 348 | } |
| 349 | if (data.indicationFlagsIePresent) |
| 350 | { |
| 351 | |
| 352 | |
| 353 | stream.add((char *)"IE - indicationFlags:"); |
| 354 | stream.endOfLine(); |
| 355 | IndicationIe indication= |
| 356 | dynamic_cast< |
| 357 | IndicationIe&>(GtpV2IeFactory::getInstance().getIeObject(IndicationIeType)); |
| 358 | indication.displayIndicationIe_v(data.indicationFlags, stream); |
| 359 | |
| 360 | } |
| 361 | if (data.secondaryRatUsageDataReportIePresent) |
| 362 | { |
| 363 | |
| 364 | |
| 365 | stream.add((char *)"IE - secondaryRatUsageDataReport:"); |
| 366 | stream.endOfLine(); |
| 367 | SecondaryRatUsageDataReportIe secondaryRatUsageDataReport= |
| 368 | dynamic_cast< |
| 369 | SecondaryRatUsageDataReportIe&>(GtpV2IeFactory::getInstance().getIeObject(SecondaryRatUsageDataReportIeType)); |
| 370 | secondaryRatUsageDataReport.displaySecondaryRatUsageDataReportIe_v(data.secondaryRatUsageDataReport, stream); |
| 371 | |
| 372 | } |
| 373 | |
| 374 | stream.decrIndent(); |
| 375 | stream.decrIndent(); |
| 376 | } |
| 377 | |
| 378 | |