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 "downlinkDataNotificationFailureIndicationMsg.h" |
| 16 | #include "../ieClasses/manual/gtpV2Ie.h" |
| 17 | #include "../ieClasses/gtpV2IeFactory.h" |
| 18 | #include "../ieClasses/causeIe.h" |
| 19 | #include "../ieClasses/nodeTypeIe.h" |
| 20 | #include "../ieClasses/imsiIe.h" |
| 21 | |
| 22 | DownlinkDataNotificationFailureIndicationMsg::DownlinkDataNotificationFailureIndicationMsg() |
| 23 | { |
| 24 | msgType = DownlinkDataNotificationFailureIndicationMsgType; |
| 25 | Uint16 mandIe; |
| 26 | mandIe = CauseIeType; |
| 27 | mandIe = (mandIe << 8) | 0; // cause |
| 28 | mandatoryIeSet.insert(mandIe); |
| 29 | } |
| 30 | |
| 31 | DownlinkDataNotificationFailureIndicationMsg::~DownlinkDataNotificationFailureIndicationMsg() |
| 32 | { |
| 33 | |
| 34 | } |
| 35 | |
| 36 | bool DownlinkDataNotificationFailureIndicationMsg::encodeDownlinkDataNotificationFailureIndicationMsg(MsgBuffer &buffer, |
| 37 | DownlinkDataNotificationFailureIndicationMsgData |
| 38 | const &data) |
| 39 | { |
| 40 | bool rc = false; |
| 41 | GtpV2IeHeader header; |
| 42 | Uint16 startIndex = 0; |
| 43 | Uint16 endIndex = 0; |
| 44 | Uint16 length = 0; |
| 45 | |
| 46 | |
| 47 | // Encode the Ie Header |
| 48 | header.ieType = CauseIeType; |
| 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 | CauseIe cause= |
| 54 | dynamic_cast< |
| 55 | CauseIe&>(GtpV2IeFactory::getInstance().getIeObject(CauseIeType)); |
| 56 | rc = cause.encodeCauseIe(buffer, data.cause); |
| 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: cause\n"); |
| 68 | return false; |
| 69 | } |
| 70 | |
| 71 | if (data.originatingNodeIePresent) |
| 72 | { |
| 73 | |
| 74 | // Encode the Ie Header |
| 75 | header.ieType = NodeTypeIeType; |
| 76 | header.instance = 0; |
| 77 | header.length = 0; // We will encode the IE first and then update the length |
| 78 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 79 | startIndex = buffer.getCurrentIndex(); |
| 80 | NodeTypeIe nodeType= |
| 81 | dynamic_cast< |
| 82 | NodeTypeIe&>(GtpV2IeFactory::getInstance().getIeObject(NodeTypeIeType)); |
| 83 | rc = nodeType.encodeNodeTypeIe(buffer, data.originatingNode); |
| 84 | endIndex = buffer.getCurrentIndex(); |
| 85 | length = endIndex - startIndex; |
| 86 | |
| 87 | // encode the length value now |
| 88 | buffer.goToIndex(startIndex - 3); |
| 89 | buffer.writeUint16(length, false); |
| 90 | buffer.goToIndex(endIndex); |
| 91 | |
| 92 | if (!(rc)) |
| 93 | { |
| 94 | errorStream.add((char *)"Failed to encode IE: originatingNode\n"); |
| 95 | return false; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | if (data.imsiIePresent) |
| 100 | { |
| 101 | |
| 102 | // Encode the Ie Header |
| 103 | header.ieType = ImsiIeType; |
| 104 | header.instance = 0; |
| 105 | header.length = 0; // We will encode the IE first and then update the length |
| 106 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 107 | startIndex = buffer.getCurrentIndex(); |
| 108 | ImsiIe imsi= |
| 109 | dynamic_cast< |
| 110 | ImsiIe&>(GtpV2IeFactory::getInstance().getIeObject(ImsiIeType)); |
| 111 | rc = imsi.encodeImsiIe(buffer, data.imsi); |
| 112 | endIndex = buffer.getCurrentIndex(); |
| 113 | length = endIndex - startIndex; |
| 114 | |
| 115 | // encode the length value now |
| 116 | buffer.goToIndex(startIndex - 3); |
| 117 | buffer.writeUint16(length, false); |
| 118 | buffer.goToIndex(endIndex); |
| 119 | |
| 120 | if (!(rc)) |
| 121 | { |
| 122 | errorStream.add((char *)"Failed to encode IE: imsi\n"); |
| 123 | return false; |
| 124 | } |
| 125 | } |
| 126 | return rc; |
| 127 | |
| 128 | } |
| 129 | |
| 130 | bool DownlinkDataNotificationFailureIndicationMsg::decodeDownlinkDataNotificationFailureIndicationMsg(MsgBuffer &buffer, |
| 131 | DownlinkDataNotificationFailureIndicationMsgData |
| 132 | &data, Uint16 length) |
| 133 | { |
| 134 | |
| 135 | bool rc = false; |
| 136 | GtpV2IeHeader ieHeader; |
| 137 | |
| 138 | set<Uint16> mandatoryIeLocalList = mandatoryIeSet; |
| 139 | while (buffer.lengthLeft() > IE_HEADER_SIZE) |
| 140 | { |
| 141 | GtpV2Ie::decodeGtpV2IeHeader(buffer, ieHeader); |
| 142 | if (ieHeader.length > buffer.lengthLeft()) |
| 143 | { |
| 144 | // We do not have enough bytes left in the message for this IE |
| 145 | errorStream.add((char *)"IE Length exceeds beyond message boundary\n"); |
| 146 | errorStream.add((char *)" Offending IE Type: "); |
| 147 | errorStream.add(ieHeader.ieType); |
| 148 | errorStream.add((char *)"\n Ie Length in Header: "); |
| 149 | errorStream.add(ieHeader.length); |
| 150 | errorStream.add((char *)"\n Bytes left in message: "); |
| 151 | errorStream.add(buffer.lengthLeft()); |
| 152 | errorStream.endOfLine(); |
| 153 | return false; |
| 154 | } |
| 155 | |
| 156 | switch (ieHeader.ieType){ |
| 157 | |
| 158 | case CauseIeType: |
| 159 | { |
| 160 | CauseIe ieObject = |
| 161 | dynamic_cast< |
| 162 | CauseIe&>(GtpV2IeFactory::getInstance().getIeObject(CauseIeType)); |
| 163 | |
| 164 | if(ieHeader.instance == 0) |
| 165 | { |
| 166 | rc = ieObject.decodeCauseIe(buffer, data.cause, ieHeader.length); |
| 167 | |
| 168 | if (!(rc)) |
| 169 | { |
| 170 | errorStream.add((char *)"Failed to decode IE: cause\n"); |
| 171 | return false; |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | else |
| 176 | { |
| 177 | // Unknown IE instance print error |
| 178 | errorStream.add((char *)"Unknown IE Type: "); |
| 179 | errorStream.add(ieHeader.ieType); |
| 180 | errorStream.endOfLine(); |
| 181 | buffer.skipBytes(ieHeader.length); |
| 182 | } |
| 183 | break; |
| 184 | } |
| 185 | |
| 186 | case NodeTypeIeType: |
| 187 | { |
| 188 | NodeTypeIe ieObject = |
| 189 | dynamic_cast< |
| 190 | NodeTypeIe&>(GtpV2IeFactory::getInstance().getIeObject(NodeTypeIeType)); |
| 191 | |
| 192 | if(ieHeader.instance == 0) |
| 193 | { |
| 194 | rc = ieObject.decodeNodeTypeIe(buffer, data.originatingNode, ieHeader.length); |
| 195 | |
| 196 | data.originatingNodeIePresent = true; |
| 197 | if (!(rc)) |
| 198 | { |
| 199 | errorStream.add((char *)"Failed to decode IE: originatingNode\n"); |
| 200 | return false; |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | else |
| 205 | { |
| 206 | // Unknown IE instance print error |
| 207 | errorStream.add((char *)"Unknown IE Type: "); |
| 208 | errorStream.add(ieHeader.ieType); |
| 209 | errorStream.endOfLine(); |
| 210 | buffer.skipBytes(ieHeader.length); |
| 211 | } |
| 212 | break; |
| 213 | } |
| 214 | |
| 215 | case ImsiIeType: |
| 216 | { |
| 217 | ImsiIe ieObject = |
| 218 | dynamic_cast< |
| 219 | ImsiIe&>(GtpV2IeFactory::getInstance().getIeObject(ImsiIeType)); |
| 220 | |
| 221 | if(ieHeader.instance == 0) |
| 222 | { |
| 223 | rc = ieObject.decodeImsiIe(buffer, data.imsi, ieHeader.length); |
| 224 | |
| 225 | data.imsiIePresent = true; |
| 226 | if (!(rc)) |
| 227 | { |
| 228 | errorStream.add((char *)"Failed to decode IE: imsi\n"); |
| 229 | return false; |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | else |
| 234 | { |
| 235 | // Unknown IE instance print error |
| 236 | errorStream.add((char *)"Unknown IE Type: "); |
| 237 | errorStream.add(ieHeader.ieType); |
| 238 | errorStream.endOfLine(); |
| 239 | buffer.skipBytes(ieHeader.length); |
| 240 | } |
| 241 | break; |
| 242 | } |
| 243 | |
| 244 | default: |
| 245 | { |
| 246 | // Unknown IE print error |
| 247 | errorStream.add((char *)"Unknown IE Type: "); |
| 248 | errorStream.add(ieHeader.ieType); |
| 249 | errorStream.endOfLine(); |
| 250 | buffer.skipBytes(ieHeader.length); |
| 251 | } |
| 252 | } |
| 253 | } |
| 254 | return rc; // TODO validations |
| 255 | } |
| 256 | |
| 257 | void DownlinkDataNotificationFailureIndicationMsg:: |
| 258 | displayDownlinkDataNotificationFailureIndicationMsgData_v(DownlinkDataNotificationFailureIndicationMsgData const &data, Debug &stream) |
| 259 | { |
| 260 | stream.incrIndent(); |
| 261 | stream.add((char *)"DownlinkDataNotificationFailureIndicationMsg:"); |
| 262 | stream.endOfLine(); |
| 263 | stream.incrIndent(); |
| 264 | |
| 265 | |
| 266 | stream.add((char *)"IE - cause:"); |
| 267 | stream.endOfLine(); |
| 268 | CauseIe cause= |
| 269 | dynamic_cast< |
| 270 | CauseIe&>(GtpV2IeFactory::getInstance().getIeObject(CauseIeType)); |
| 271 | cause.displayCauseIe_v(data.cause, stream); |
| 272 | |
| 273 | if (data.originatingNodeIePresent) |
| 274 | { |
| 275 | |
| 276 | |
| 277 | stream.add((char *)"IE - originatingNode:"); |
| 278 | stream.endOfLine(); |
| 279 | NodeTypeIe nodeType= |
| 280 | dynamic_cast< |
| 281 | NodeTypeIe&>(GtpV2IeFactory::getInstance().getIeObject(NodeTypeIeType)); |
| 282 | nodeType.displayNodeTypeIe_v(data.originatingNode, stream); |
| 283 | |
| 284 | } |
| 285 | if (data.imsiIePresent) |
| 286 | { |
| 287 | |
| 288 | |
| 289 | stream.add((char *)"IE - imsi:"); |
| 290 | stream.endOfLine(); |
| 291 | ImsiIe imsi= |
| 292 | dynamic_cast< |
| 293 | ImsiIe&>(GtpV2IeFactory::getInstance().getIeObject(ImsiIeType)); |
| 294 | imsi.displayImsiIe_v(data.imsi, stream); |
| 295 | |
| 296 | } |
| 297 | |
| 298 | stream.decrIndent(); |
| 299 | stream.decrIndent(); |
| 300 | } |
| 301 | |
| 302 | |