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 "bearerContextsToBeRemovedInCreateSessionRequest.h" |
| 16 | #include "manual/gtpV2Ie.h" |
| 17 | #include "gtpV2IeFactory.h" |
| 18 | #include "ebiIe.h" |
| 19 | #include "fTeidIe.h" |
| 20 | |
| 21 | BearerContextsToBeRemovedInCreateSessionRequest:: |
| 22 | BearerContextsToBeRemovedInCreateSessionRequest() |
| 23 | { |
| 24 | Uint16 mandIe; |
| 25 | mandIe = EbiIeType; |
| 26 | mandIe = (mandIe << 8) | 0; // epsBearerId |
| 27 | mandatoryIeSet.insert(mandIe); |
| 28 | |
| 29 | } |
| 30 | |
| 31 | BearerContextsToBeRemovedInCreateSessionRequest:: |
| 32 | ~BearerContextsToBeRemovedInCreateSessionRequest() |
| 33 | { |
| 34 | |
| 35 | } |
| 36 | bool BearerContextsToBeRemovedInCreateSessionRequest:: |
| 37 | encodeBearerContextsToBeRemovedInCreateSessionRequest(MsgBuffer &buffer, |
| 38 | BearerContextsToBeRemovedInCreateSessionRequestData |
| 39 | const &data) |
| 40 | { |
| 41 | bool rc = false; |
| 42 | GtpV2IeHeader header; |
| 43 | Uint16 startIndex = 0; |
| 44 | Uint16 endIndex = 0; |
| 45 | Uint16 length = 0; |
| 46 | |
| 47 | |
| 48 | |
| 49 | // Encode the Ie Header |
| 50 | header.ieType = EbiIeType; |
| 51 | header.instance = 0; |
| 52 | header.length = 0; // We will encode the IE first and then update the length |
| 53 | GtpV2Ie::encodeGtpV2IeHeader(buffer, header); |
| 54 | startIndex = buffer.getCurrentIndex(); |
| 55 | EbiIe ebi= |
| 56 | dynamic_cast< |
| 57 | EbiIe&>(GtpV2IeFactory::getInstance().getIeObject(EbiIeType)); |
| 58 | rc = ebi.encodeEbiIe(buffer, data.epsBearerId); |
| 59 | endIndex = buffer.getCurrentIndex(); |
| 60 | length = endIndex - startIndex; |
| 61 | |
| 62 | // encode the length value now |
| 63 | buffer.goToIndex(startIndex - 3); |
| 64 | buffer.writeUint16(length, false); |
| 65 | buffer.goToIndex(endIndex); |
| 66 | if (!(rc)) |
| 67 | { |
| 68 | errorStream.add((char *)"Failed to encode IE: epsBearerId\n"); |
| 69 | return false; |
| 70 | } |
| 71 | |
| 72 | if (data.s4USgsnFTeidIePresent) |
| 73 | { |
| 74 | |
| 75 | // Encode the Ie Header |
| 76 | header.ieType = FTeidIeType; |
| 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 | FTeidIe fTeid= |
| 82 | dynamic_cast< |
| 83 | FTeidIe&>(GtpV2IeFactory::getInstance().getIeObject(FTeidIeType)); |
| 84 | rc = fTeid.encodeFTeidIe(buffer, data.s4USgsnFTeid); |
| 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: s4USgsnFTeid\n"); |
| 96 | return false; |
| 97 | } |
| 98 | } |
| 99 | return rc; |
| 100 | } |
| 101 | |
| 102 | bool BearerContextsToBeRemovedInCreateSessionRequest:: |
| 103 | decodeBearerContextsToBeRemovedInCreateSessionRequest(MsgBuffer &buffer, |
| 104 | BearerContextsToBeRemovedInCreateSessionRequestData |
| 105 | &data, Uint16 length) |
| 106 | { |
| 107 | |
| 108 | bool rc = false; |
| 109 | GtpV2IeHeader ieHeader; |
| 110 | set<Uint16> mandatoryIeLocalList = mandatoryIeSet; |
| 111 | while (buffer.lengthLeft() > IE_HEADER_SIZE) |
| 112 | { |
| 113 | GtpV2Ie::decodeGtpV2IeHeader(buffer, ieHeader); |
| 114 | if (ieHeader.length > buffer.lengthLeft()) |
| 115 | { |
| 116 | // We do not have enough bytes left in the message for this IE |
| 117 | errorStream.add((char *)"IE Length exceeds beyond message boundary\n"); |
| 118 | errorStream.add((char *)" Offending IE Type: "); |
| 119 | errorStream.add(ieHeader.ieType); |
| 120 | errorStream.add((char *)"\n Ie Length in Header: "); |
| 121 | errorStream.add(ieHeader.length); |
| 122 | errorStream.add((char *)"\n Bytes left in message: "); |
| 123 | errorStream.add(buffer.lengthLeft()); |
| 124 | errorStream.endOfLine(); |
| 125 | return false; |
| 126 | } |
| 127 | |
| 128 | switch (ieHeader.ieType){ |
| 129 | case EbiIeType: |
| 130 | { |
| 131 | EbiIe ieObject = |
| 132 | dynamic_cast< |
| 133 | EbiIe&>(GtpV2IeFactory::getInstance(). |
| 134 | getIeObject(EbiIeType)); |
| 135 | |
| 136 | |
| 137 | if(ieHeader.instance == 0) |
| 138 | { |
| 139 | |
| 140 | rc = ieObject.decodeEbiIe(buffer, data.epsBearerId, ieHeader.length); |
| 141 | |
| 142 | if (!(rc)) |
| 143 | { |
| 144 | errorStream.add((char *)"Failed to decode IE: epsBearerId\n"); |
| 145 | return false; |
| 146 | } |
| 147 | Uint16 mandIe = EbiIeType; |
| 148 | mandIe = (mandIe << 8) | 0; |
| 149 | mandatoryIeLocalList.erase(mandIe); |
| 150 | } |
| 151 | else |
| 152 | { |
| 153 | // Unknown IE instance print error TODO |
| 154 | errorStream.add((char *)"Unknown IE Type: "); |
| 155 | errorStream.add(ieHeader.ieType); |
| 156 | errorStream.endOfLine(); |
| 157 | buffer.skipBytes(ieHeader.length); |
| 158 | } |
| 159 | break; |
| 160 | } |
| 161 | case FTeidIeType: |
| 162 | { |
| 163 | FTeidIe ieObject = |
| 164 | dynamic_cast< |
| 165 | FTeidIe&>(GtpV2IeFactory::getInstance(). |
| 166 | getIeObject(FTeidIeType)); |
| 167 | |
| 168 | |
| 169 | if(ieHeader.instance == 0) |
| 170 | { |
| 171 | |
| 172 | rc = ieObject.decodeFTeidIe(buffer, data.s4USgsnFTeid, ieHeader.length); |
| 173 | |
| 174 | data.s4USgsnFTeidIePresent = true; |
| 175 | if (!(rc)) |
| 176 | { |
| 177 | errorStream.add((char *)"Failed to decode IE: s4USgsnFTeid\n"); |
| 178 | return false; |
| 179 | } |
| 180 | } |
| 181 | else |
| 182 | { |
| 183 | // Unknown IE instance print error TODO |
| 184 | errorStream.add((char *)"Unknown IE Type: "); |
| 185 | errorStream.add(ieHeader.ieType); |
| 186 | errorStream.endOfLine(); |
| 187 | buffer.skipBytes(ieHeader.length); |
| 188 | } |
| 189 | break; |
| 190 | } |
| 191 | default: |
| 192 | { |
| 193 | // Unknown IE print error |
| 194 | errorStream.add((char *)"Unknown IE Type: "); |
| 195 | errorStream.add(ieHeader.ieType); |
| 196 | errorStream.endOfLine(); |
| 197 | buffer.skipBytes(ieHeader.length); |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | if (!mandatoryIeLocalList.empty()) |
| 202 | { |
| 203 | // some mandatory IEs are missing |
| 204 | errorStream.add((char *)"Missing Mandatory IEs:"); |
| 205 | errorStream.endOfLine(); |
| 206 | while (!mandatoryIeLocalList.empty()) |
| 207 | { |
| 208 | Uint16 missingMandIe = *mandatoryIeLocalList.begin (); |
| 209 | mandatoryIeLocalList.erase (mandatoryIeLocalList.begin ()); |
| 210 | Uint16 missingInstance = missingMandIe & 0x00FF; |
| 211 | Uint16 missingIeType = (missingMandIe >> 8); |
| 212 | errorStream.add ((char *)"Missing Ie type: "); |
| 213 | errorStream.add (missingIeType); |
| 214 | errorStream.add ((char *)" Instance: "); |
| 215 | errorStream.add (missingInstance); |
| 216 | errorStream.endOfLine(); |
| 217 | } |
| 218 | rc = false; |
| 219 | |
| 220 | } |
| 221 | return rc; |
| 222 | } |
| 223 | |
| 224 | void BearerContextsToBeRemovedInCreateSessionRequest:: |
| 225 | displayBearerContextsToBeRemovedInCreateSessionRequestData_v |
| 226 | (BearerContextsToBeRemovedInCreateSessionRequestData const &data, Debug &stream) |
| 227 | { |
| 228 | stream.incrIndent(); |
| 229 | stream.add((char *)"BearerContextsToBeRemovedInCreateSessionRequest:"); |
| 230 | stream.endOfLine(); |
| 231 | stream.incrIndent(); |
| 232 | |
| 233 | |
| 234 | if (data.s4USgsnFTeidIePresent) |
| 235 | { |
| 236 | |
| 237 | stream.add((char *)"s4USgsnFTeid:"); |
| 238 | stream.endOfLine(); |
| 239 | FTeidIe fTeid= |
| 240 | dynamic_cast< |
| 241 | FTeidIe&>(GtpV2IeFactory::getInstance().getIeObject(FTeidIeType)); |
| 242 | fTeid.displayFTeidIe_v(data.s4USgsnFTeid, stream); |
| 243 | |
| 244 | } |
| 245 | |
| 246 | stream.decrIndent(); |
| 247 | stream.decrIndent(); |
| 248 | } |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |