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 | * This is an auto generated file. |
| 9 | * Please do not edit this file. |
| 10 | * All edits to be made through template source file |
| 11 | * <TOP-DIR/scripts/GtpV2StackCodeGen/tts/ietemplate.cpp.tt> |
| 12 | ******************************************************************************/ |
| 13 | |
| 14 | #include "traceInformationIe.h" |
| 15 | #include "dataTypeCodecUtils.h" |
| 16 | |
| 17 | TraceInformationIe::TraceInformationIe() |
| 18 | { |
| 19 | ieType = 96; |
| 20 | // TODO |
| 21 | |
| 22 | } |
| 23 | |
| 24 | TraceInformationIe::~TraceInformationIe() { |
| 25 | // TODO Auto-generated destructor stub |
| 26 | } |
| 27 | |
| 28 | bool TraceInformationIe::encodeTraceInformationIe(MsgBuffer &buffer, TraceInformationIeData const &data) |
| 29 | { |
| 30 | if(!(buffer.writeBits(data.mccDigit2, 4))) |
| 31 | { |
| 32 | errorStream.add((char *)"Encoding of mccDigit2 failed\n"); |
| 33 | return false; |
| 34 | } |
| 35 | if(!(buffer.writeBits(data.mccDigit1, 4))) |
| 36 | { |
| 37 | errorStream.add((char *)"Encoding of mccDigit1 failed\n"); |
| 38 | return false; |
| 39 | } |
| 40 | if(!(buffer.writeBits(data.mncDigit3, 4))) |
| 41 | { |
| 42 | errorStream.add((char *)"Encoding of mncDigit3 failed\n"); |
| 43 | return false; |
| 44 | } |
| 45 | if(!(buffer.writeBits(data.mccDigit3, 4))) |
| 46 | { |
| 47 | errorStream.add((char *)"Encoding of mccDigit3 failed\n"); |
| 48 | return false; |
| 49 | } |
| 50 | if(!(buffer.writeBits(data.mncDigit2, 4))) |
| 51 | { |
| 52 | errorStream.add((char *)"Encoding of mncDigit2 failed\n"); |
| 53 | return false; |
| 54 | } |
| 55 | if(!(buffer.writeBits(data.mncDigit1, 4))) |
| 56 | { |
| 57 | errorStream.add((char *)"Encoding of mncDigit1 failed\n"); |
| 58 | return false; |
| 59 | } |
| 60 | if (!(DataTypeCodecUtils::encodeUint8Array4(buffer, data.traceId))) |
| 61 | { |
| 62 | errorStream.add((char *)"Encoding of traceId failed\n"); |
| 63 | return false; |
| 64 | } |
| 65 | if (!(DataTypeCodecUtils::encodeUint8Array16(buffer, data.triggeringEvents))) |
| 66 | { |
| 67 | errorStream.add((char *)"Encoding of triggeringEvents failed\n"); |
| 68 | return false; |
| 69 | } |
| 70 | if (!(buffer.writeUint16(data.listOfNeTypes))) |
| 71 | { |
| 72 | errorStream.add((char *)"Encoding of listOfNeTypes failed\n"); |
| 73 | return false; |
| 74 | } |
| 75 | if (!(buffer.writeUint8(data.sessionTraceDepth))) |
| 76 | { |
| 77 | errorStream.add((char *)"Encoding of sessionTraceDepth failed\n"); |
| 78 | return false; |
| 79 | } |
| 80 | if (!(DataTypeCodecUtils::encodeUint8Array16(buffer, data.listOfInterfaces))) |
| 81 | { |
| 82 | errorStream.add((char *)"Encoding of listOfInterfaces failed\n"); |
| 83 | return false; |
| 84 | } |
| 85 | if (!(DataTypeCodecUtils::encodeIpAddressV4(buffer, data.ipAddressOfTce))) |
| 86 | { |
| 87 | errorStream.add((char *)"Encoding of ipAddressOfTce failed\n"); |
| 88 | return false; |
| 89 | } |
| 90 | |
| 91 | return true; |
| 92 | } |
| 93 | |
| 94 | bool TraceInformationIe::decodeTraceInformationIe(MsgBuffer &buffer, TraceInformationIeData &data, Uint16 length) |
| 95 | { |
| 96 | // TODO optimize the length checks |
| 97 | |
| 98 | Uint16 ieBoundary = buffer.getCurrentIndex() + length; |
| 99 | data.mccDigit2 = buffer.readBits(4); |
| 100 | // confirm that we are not reading beyond the IE boundary |
| 101 | if (buffer.getCurrentIndex() > ieBoundary) |
| 102 | { |
| 103 | errorStream.add((char *)"Attempt to read beyond IE boundary: mccDigit2\n"); |
| 104 | return false; |
| 105 | } |
| 106 | data.mccDigit1 = buffer.readBits(4); |
| 107 | // confirm that we are not reading beyond the IE boundary |
| 108 | if (buffer.getCurrentIndex() > ieBoundary) |
| 109 | { |
| 110 | errorStream.add((char *)"Attempt to read beyond IE boundary: mccDigit1\n"); |
| 111 | return false; |
| 112 | } |
| 113 | data.mncDigit3 = buffer.readBits(4); |
| 114 | // confirm that we are not reading beyond the IE boundary |
| 115 | if (buffer.getCurrentIndex() > ieBoundary) |
| 116 | { |
| 117 | errorStream.add((char *)"Attempt to read beyond IE boundary: mncDigit3\n"); |
| 118 | return false; |
| 119 | } |
| 120 | data.mccDigit3 = buffer.readBits(4); |
| 121 | // confirm that we are not reading beyond the IE boundary |
| 122 | if (buffer.getCurrentIndex() > ieBoundary) |
| 123 | { |
| 124 | errorStream.add((char *)"Attempt to read beyond IE boundary: mccDigit3\n"); |
| 125 | return false; |
| 126 | } |
| 127 | data.mncDigit2 = buffer.readBits(4); |
| 128 | // confirm that we are not reading beyond the IE boundary |
| 129 | if (buffer.getCurrentIndex() > ieBoundary) |
| 130 | { |
| 131 | errorStream.add((char *)"Attempt to read beyond IE boundary: mncDigit2\n"); |
| 132 | return false; |
| 133 | } |
| 134 | data.mncDigit1 = buffer.readBits(4); |
| 135 | // confirm that we are not reading beyond the IE boundary |
| 136 | if (buffer.getCurrentIndex() > ieBoundary) |
| 137 | { |
| 138 | errorStream.add((char *)"Attempt to read beyond IE boundary: mncDigit1\n"); |
| 139 | return false; |
| 140 | } |
| 141 | |
| 142 | Uint16 lengthLeft = length; |
| 143 | lengthLeft = ieBoundary - buffer.getCurrentIndex(); |
| 144 | if (!(DataTypeCodecUtils::decodeUint8Array4(buffer, data.traceId, lengthLeft, 3))) |
| 145 | { |
| 146 | errorStream.add((char *)"Failed to decode: traceId\n"); |
| 147 | return false; |
| 148 | } |
| 149 | lengthLeft = ieBoundary - buffer.getCurrentIndex(); |
| 150 | if (!(DataTypeCodecUtils::decodeUint8Array16(buffer, data.triggeringEvents, lengthLeft, 0))) |
| 151 | { |
| 152 | errorStream.add((char *)"Failed to decode: triggeringEvents\n"); |
| 153 | return false; |
| 154 | } |
| 155 | |
| 156 | buffer.readUint16(data.listOfNeTypes); |
| 157 | if (buffer.getCurrentIndex() > ieBoundary) |
| 158 | { |
| 159 | errorStream.add((char *)"Attempt to read beyond IE boundary: listOfNeTypes\n"); |
| 160 | return false; |
| 161 | } |
| 162 | |
| 163 | buffer.readUint8(data.sessionTraceDepth); |
| 164 | if (buffer.getCurrentIndex() > ieBoundary) |
| 165 | { |
| 166 | errorStream.add((char *)"Attempt to read beyond IE boundary: sessionTraceDepth\n"); |
| 167 | return false; |
| 168 | } |
| 169 | lengthLeft = ieBoundary - buffer.getCurrentIndex(); |
| 170 | if (!(DataTypeCodecUtils::decodeUint8Array16(buffer, data.listOfInterfaces, lengthLeft, 0))) |
| 171 | { |
| 172 | errorStream.add((char *)"Failed to decode: listOfInterfaces\n"); |
| 173 | return false; |
| 174 | } |
| 175 | lengthLeft = ieBoundary - buffer.getCurrentIndex(); |
| 176 | if (!(DataTypeCodecUtils::decodeIpAddressV4(buffer, data.ipAddressOfTce, lengthLeft))) |
| 177 | { |
| 178 | errorStream.add((char *)"Failed to decode: ipAddressOfTce\n"); |
| 179 | return false; |
| 180 | } |
| 181 | |
| 182 | // The IE is decoded now. The buffer index should be pointing to the |
| 183 | // IE Boundary. If not, we have some more data left for the IE which we don't know |
| 184 | // how to decode |
| 185 | if (ieBoundary == buffer.getCurrentIndex()) |
| 186 | { |
| 187 | return true; |
| 188 | } |
| 189 | else |
| 190 | { |
| 191 | errorStream.add((char *)"Unable to decode IE TraceInformationIe\n"); |
| 192 | return false; |
| 193 | } |
| 194 | } |
| 195 | void TraceInformationIe::displayTraceInformationIe_v(TraceInformationIeData const &data, Debug &stream) |
| 196 | { |
| 197 | stream.incrIndent(); |
| 198 | stream.add((char *)"TraceInformationIeData:"); |
| 199 | stream.incrIndent(); |
| 200 | stream.endOfLine(); |
| 201 | |
| 202 | stream.add( (char *)"mccDigit2: "); |
| 203 | stream.add((Uint8)data.mccDigit2); |
| 204 | stream.endOfLine(); |
| 205 | |
| 206 | stream.add( (char *)"mccDigit1: "); |
| 207 | stream.add((Uint8)data.mccDigit1); |
| 208 | stream.endOfLine(); |
| 209 | |
| 210 | stream.add( (char *)"mncDigit3: "); |
| 211 | stream.add((Uint8)data.mncDigit3); |
| 212 | stream.endOfLine(); |
| 213 | |
| 214 | stream.add( (char *)"mccDigit3: "); |
| 215 | stream.add((Uint8)data.mccDigit3); |
| 216 | stream.endOfLine(); |
| 217 | |
| 218 | stream.add( (char *)"mncDigit2: "); |
| 219 | stream.add((Uint8)data.mncDigit2); |
| 220 | stream.endOfLine(); |
| 221 | |
| 222 | stream.add( (char *)"mncDigit1: "); |
| 223 | stream.add((Uint8)data.mncDigit1); |
| 224 | stream.endOfLine(); |
| 225 | |
| 226 | stream.add((char *)"traceId:"); |
| 227 | stream.endOfLine(); |
| 228 | DataTypeCodecUtils::displayUint8Array4_v(data.traceId, stream); |
| 229 | |
| 230 | stream.add((char *)"triggeringEvents:"); |
| 231 | stream.endOfLine(); |
| 232 | DataTypeCodecUtils::displayUint8Array16_v(data.triggeringEvents, stream); |
| 233 | |
| 234 | stream.add((char *)"listOfNeTypes: "); |
| 235 | stream.add(data.listOfNeTypes); |
| 236 | stream.endOfLine(); |
| 237 | |
| 238 | stream.add((char *)"sessionTraceDepth: "); |
| 239 | stream.add(data.sessionTraceDepth); |
| 240 | stream.endOfLine(); |
| 241 | |
| 242 | stream.add((char *)"listOfInterfaces:"); |
| 243 | stream.endOfLine(); |
| 244 | DataTypeCodecUtils::displayUint8Array16_v(data.listOfInterfaces, stream); |
| 245 | |
| 246 | stream.add((char *)"ipAddressOfTce:"); |
| 247 | stream.endOfLine(); |
| 248 | DataTypeCodecUtils::displayIpAddressV4_v(data.ipAddressOfTce, stream); |
| 249 | stream.decrIndent(); |
| 250 | stream.decrIndent(); |
| 251 | } |