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 "uciIe.h" |
| 15 | #include "dataTypeCodecUtils.h" |
| 16 | |
| 17 | UciIe::UciIe() |
| 18 | { |
| 19 | ieType = 145; |
| 20 | // TODO |
| 21 | |
| 22 | } |
| 23 | |
| 24 | UciIe::~UciIe() { |
| 25 | // TODO Auto-generated destructor stub |
| 26 | } |
| 27 | |
| 28 | bool UciIe::encodeUciIe(MsgBuffer &buffer, UciIeData 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 (!(data.csgId<= 0x07FFFFFF)) |
| 61 | { |
| 62 | errorStream.add((char *)"Data validation failure: csgId\n"); |
| 63 | return false; |
| 64 | } |
| 65 | if (!(buffer.writeUint32(data.csgId))) |
| 66 | { |
| 67 | errorStream.add((char *)"Encoding of csgId failed\n"); |
| 68 | return false; |
| 69 | } |
| 70 | if (!(data.accessMode<= 1)) |
| 71 | { |
| 72 | errorStream.add((char *)"Data validation failure: accessMode\n"); |
| 73 | return false; |
| 74 | } |
| 75 | if(!(buffer.writeBits(data.accessMode, 2))) |
| 76 | { |
| 77 | errorStream.add((char *)"Encoding of accessMode failed\n"); |
| 78 | return false; |
| 79 | } |
| 80 | buffer.skipBits(4); |
| 81 | |
| 82 | if(!(buffer.writeBits(data.lcsg, 1))) |
| 83 | { |
| 84 | errorStream.add((char *)"Encoding of lcsg failed\n"); |
| 85 | return false; |
| 86 | } |
| 87 | if(!(buffer.writeBits(data.cmi, 1))) |
| 88 | { |
| 89 | errorStream.add((char *)"Encoding of cmi failed\n"); |
| 90 | return false; |
| 91 | } |
| 92 | |
| 93 | return true; |
| 94 | } |
| 95 | |
| 96 | bool UciIe::decodeUciIe(MsgBuffer &buffer, UciIeData &data, Uint16 length) |
| 97 | { |
| 98 | // TODO optimize the length checks |
| 99 | |
| 100 | Uint16 ieBoundary = buffer.getCurrentIndex() + length; |
| 101 | data.mccDigit2 = buffer.readBits(4); |
| 102 | // confirm that we are not reading beyond the IE boundary |
| 103 | if (buffer.getCurrentIndex() > ieBoundary) |
| 104 | { |
| 105 | errorStream.add((char *)"Attempt to read beyond IE boundary: mccDigit2\n"); |
| 106 | return false; |
| 107 | } |
| 108 | data.mccDigit1 = buffer.readBits(4); |
| 109 | // confirm that we are not reading beyond the IE boundary |
| 110 | if (buffer.getCurrentIndex() > ieBoundary) |
| 111 | { |
| 112 | errorStream.add((char *)"Attempt to read beyond IE boundary: mccDigit1\n"); |
| 113 | return false; |
| 114 | } |
| 115 | data.mncDigit3 = buffer.readBits(4); |
| 116 | // confirm that we are not reading beyond the IE boundary |
| 117 | if (buffer.getCurrentIndex() > ieBoundary) |
| 118 | { |
| 119 | errorStream.add((char *)"Attempt to read beyond IE boundary: mncDigit3\n"); |
| 120 | return false; |
| 121 | } |
| 122 | data.mccDigit3 = buffer.readBits(4); |
| 123 | // confirm that we are not reading beyond the IE boundary |
| 124 | if (buffer.getCurrentIndex() > ieBoundary) |
| 125 | { |
| 126 | errorStream.add((char *)"Attempt to read beyond IE boundary: mccDigit3\n"); |
| 127 | return false; |
| 128 | } |
| 129 | data.mncDigit2 = buffer.readBits(4); |
| 130 | // confirm that we are not reading beyond the IE boundary |
| 131 | if (buffer.getCurrentIndex() > ieBoundary) |
| 132 | { |
| 133 | errorStream.add((char *)"Attempt to read beyond IE boundary: mncDigit2\n"); |
| 134 | return false; |
| 135 | } |
| 136 | data.mncDigit1 = buffer.readBits(4); |
| 137 | // confirm that we are not reading beyond the IE boundary |
| 138 | if (buffer.getCurrentIndex() > ieBoundary) |
| 139 | { |
| 140 | errorStream.add((char *)"Attempt to read beyond IE boundary: mncDigit1\n"); |
| 141 | return false; |
| 142 | } |
| 143 | |
| 144 | buffer.readUint32(data.csgId); |
| 145 | if (buffer.getCurrentIndex() > ieBoundary) |
| 146 | { |
| 147 | errorStream.add((char *)"Attempt to read beyond IE boundary: csgId\n"); |
| 148 | return false; |
| 149 | } |
| 150 | if (!(data.csgId<= 0x07FFFFFF)) |
| 151 | { |
| 152 | errorStream.add((char *)"Data validation failure : csgId\n"); |
| 153 | return false; //TODO need to add validations |
| 154 | } |
| 155 | data.accessMode = buffer.readBits(2); |
| 156 | // confirm that we are not reading beyond the IE boundary |
| 157 | if (buffer.getCurrentIndex() > ieBoundary) |
| 158 | { |
| 159 | errorStream.add((char *)"Attempt to read beyond IE boundary: accessMode\n"); |
| 160 | return false; |
| 161 | } |
| 162 | if (!(data.accessMode<= 1)) |
| 163 | { |
| 164 | errorStream.add((char *)"Data validation failure : accessMode\n"); |
| 165 | return false; //TODO need to add validations |
| 166 | } |
| 167 | buffer.skipBits(4); |
| 168 | if (buffer.getCurrentIndex() > ieBoundary) |
| 169 | { |
| 170 | errorStream.add((char *)"Attempt to read beyond IE boundary: \n"); |
| 171 | return false; |
| 172 | } |
| 173 | |
| 174 | data.lcsg = buffer.readBits(1); |
| 175 | // confirm that we are not reading beyond the IE boundary |
| 176 | if (buffer.getCurrentIndex() > ieBoundary) |
| 177 | { |
| 178 | errorStream.add((char *)"Attempt to read beyond IE boundary: lcsg\n"); |
| 179 | return false; |
| 180 | } |
| 181 | data.cmi = buffer.readBits(1); |
| 182 | // confirm that we are not reading beyond the IE boundary |
| 183 | if (buffer.getCurrentIndex() > ieBoundary) |
| 184 | { |
| 185 | errorStream.add((char *)"Attempt to read beyond IE boundary: cmi\n"); |
| 186 | return false; |
| 187 | } |
| 188 | |
| 189 | // The IE is decoded now. The buffer index should be pointing to the |
| 190 | // IE Boundary. If not, we have some more data left for the IE which we don't know |
| 191 | // how to decode |
| 192 | if (ieBoundary == buffer.getCurrentIndex()) |
| 193 | { |
| 194 | return true; |
| 195 | } |
| 196 | else |
| 197 | { |
| 198 | errorStream.add((char *)"Unable to decode IE UciIe\n"); |
| 199 | return false; |
| 200 | } |
| 201 | } |
| 202 | void UciIe::displayUciIe_v(UciIeData const &data, Debug &stream) |
| 203 | { |
| 204 | stream.incrIndent(); |
| 205 | stream.add((char *)"UciIeData:"); |
| 206 | stream.incrIndent(); |
| 207 | stream.endOfLine(); |
| 208 | |
| 209 | stream.add( (char *)"mccDigit2: "); |
| 210 | stream.add((Uint8)data.mccDigit2); |
| 211 | stream.endOfLine(); |
| 212 | |
| 213 | stream.add( (char *)"mccDigit1: "); |
| 214 | stream.add((Uint8)data.mccDigit1); |
| 215 | stream.endOfLine(); |
| 216 | |
| 217 | stream.add( (char *)"mncDigit3: "); |
| 218 | stream.add((Uint8)data.mncDigit3); |
| 219 | stream.endOfLine(); |
| 220 | |
| 221 | stream.add( (char *)"mccDigit3: "); |
| 222 | stream.add((Uint8)data.mccDigit3); |
| 223 | stream.endOfLine(); |
| 224 | |
| 225 | stream.add( (char *)"mncDigit2: "); |
| 226 | stream.add((Uint8)data.mncDigit2); |
| 227 | stream.endOfLine(); |
| 228 | |
| 229 | stream.add( (char *)"mncDigit1: "); |
| 230 | stream.add((Uint8)data.mncDigit1); |
| 231 | stream.endOfLine(); |
| 232 | |
| 233 | stream.add((char *)"csgId: "); |
| 234 | stream.add(data.csgId); |
| 235 | stream.endOfLine(); |
| 236 | |
| 237 | stream.add( (char *)"accessMode: "); |
| 238 | stream.add((Uint8)data.accessMode); |
| 239 | stream.endOfLine(); |
| 240 | |
| 241 | stream.add( (char *)"lcsg: "); |
| 242 | stream.add((Uint8)data.lcsg); |
| 243 | stream.endOfLine(); |
| 244 | |
| 245 | stream.add( (char *)"cmi: "); |
| 246 | stream.add((Uint8)data.cmi); |
| 247 | stream.endOfLine(); |
| 248 | stream.decrIndent(); |
| 249 | stream.decrIndent(); |
| 250 | } |