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 "twanIdentifierIe.h" |
| 15 | #include "dataTypeCodecUtils.h" |
| 16 | |
| 17 | TwanIdentifierIe::TwanIdentifierIe() |
| 18 | { |
| 19 | ieType = 169; |
| 20 | // TODO |
| 21 | |
| 22 | } |
| 23 | |
| 24 | TwanIdentifierIe::~TwanIdentifierIe() { |
| 25 | // TODO Auto-generated destructor stub |
| 26 | } |
| 27 | |
| 28 | bool TwanIdentifierIe::encodeTwanIdentifierIe(MsgBuffer &buffer, TwanIdentifierIeData const &data) |
| 29 | { |
| 30 | buffer.skipBits(2); |
| 31 | |
| 32 | if(!(buffer.writeBits(data.laiipresent, 1))) |
| 33 | { |
| 34 | errorStream.add((char *)"Encoding of laiipresent failed\n"); |
| 35 | return false; |
| 36 | } |
| 37 | if(!(buffer.writeBits(data.opnaipresent, 1))) |
| 38 | { |
| 39 | errorStream.add((char *)"Encoding of opnaipresent failed\n"); |
| 40 | return false; |
| 41 | } |
| 42 | if(!(buffer.writeBits(data.plmnipresent, 1))) |
| 43 | { |
| 44 | errorStream.add((char *)"Encoding of plmnipresent failed\n"); |
| 45 | return false; |
| 46 | } |
| 47 | if(!(buffer.writeBits(data.civaipresent, 1))) |
| 48 | { |
| 49 | errorStream.add((char *)"Encoding of civaipresent failed\n"); |
| 50 | return false; |
| 51 | } |
| 52 | if(!(buffer.writeBits(data.bssidipresent, 2))) |
| 53 | { |
| 54 | errorStream.add((char *)"Encoding of bssidipresent failed\n"); |
| 55 | return false; |
| 56 | } |
| 57 | if (!(buffer.writeUint64(data.ssidLength))) |
| 58 | { |
| 59 | errorStream.add((char *)"Encoding of ssidLength failed\n"); |
| 60 | return false; |
| 61 | } |
| 62 | if ( data.ssidLength <=32) |
| 63 | { |
| 64 | if (!(buffer.writeUint8(data.ssid))) |
| 65 | { |
| 66 | errorStream.add((char *)"Encoding of ssid failed\n"); |
| 67 | return false; |
| 68 | } |
| 69 | } |
| 70 | if (data.bssidipresent) |
| 71 | { |
| 72 | if (!(buffer.writeUint8(data.bssid))) |
| 73 | { |
| 74 | errorStream.add((char *)"Encoding of bssid failed\n"); |
| 75 | return false; |
| 76 | } |
| 77 | } |
| 78 | if (data.civaipresent) |
| 79 | { |
| 80 | if (!(buffer.writeUint8(data.civicAddressLength))) |
| 81 | { |
| 82 | errorStream.add((char *)"Encoding of civicAddressLength failed\n"); |
| 83 | return false; |
| 84 | } |
| 85 | } |
| 86 | if (data.civaipresent) |
| 87 | { |
| 88 | if (!(buffer.writeUint8(data.civicAddressInformation))) |
| 89 | { |
| 90 | errorStream.add((char *)"Encoding of civicAddressInformation failed\n"); |
| 91 | return false; |
| 92 | } |
| 93 | } |
| 94 | if (data.plmnipresent) |
| 95 | { |
| 96 | if (!(buffer.writeUint8(data.twanplmnid))) |
| 97 | { |
| 98 | errorStream.add((char *)"Encoding of twanplmnid failed\n"); |
| 99 | return false; |
| 100 | } |
| 101 | } |
| 102 | if (data.opnaipresent) |
| 103 | { |
| 104 | if (!(buffer.writeUint8(data.twanOperatorNameLength))) |
| 105 | { |
| 106 | errorStream.add((char *)"Encoding of twanOperatorNameLength failed\n"); |
| 107 | return false; |
| 108 | } |
| 109 | } |
| 110 | if (data.opnaipresent) |
| 111 | { |
| 112 | if (!(buffer.writeUint8(data.twanOperatorName))) |
| 113 | { |
| 114 | errorStream.add((char *)"Encoding of twanOperatorName failed\n"); |
| 115 | return false; |
| 116 | } |
| 117 | } |
| 118 | if (data.laiipresent) |
| 119 | { |
| 120 | if (!(buffer.writeUint8(data.relayIdentityType))) |
| 121 | { |
| 122 | errorStream.add((char *)"Encoding of relayIdentityType failed\n"); |
| 123 | return false; |
| 124 | } |
| 125 | } |
| 126 | if (data.laiipresent) |
| 127 | { |
| 128 | if (!(buffer.writeUint8(data.relayIdentityLength))) |
| 129 | { |
| 130 | errorStream.add((char *)"Encoding of relayIdentityLength failed\n"); |
| 131 | return false; |
| 132 | } |
| 133 | } |
| 134 | if (data.laiipresent) |
| 135 | { |
| 136 | if (!(buffer.writeUint8(data.relayIdentity))) |
| 137 | { |
| 138 | errorStream.add((char *)"Encoding of relayIdentity failed\n"); |
| 139 | return false; |
| 140 | } |
| 141 | } |
| 142 | if (data.laiipresent) |
| 143 | { |
| 144 | if (!(buffer.writeUint8(data.circuitIDLength))) |
| 145 | { |
| 146 | errorStream.add((char *)"Encoding of circuitIDLength failed\n"); |
| 147 | return false; |
| 148 | } |
| 149 | } |
| 150 | if (data.laiipresent) |
| 151 | { |
| 152 | if (!(buffer.writeUint8(data.circuitID))) |
| 153 | { |
| 154 | errorStream.add((char *)"Encoding of circuitID failed\n"); |
| 155 | return false; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | return true; |
| 160 | } |
| 161 | |
| 162 | bool TwanIdentifierIe::decodeTwanIdentifierIe(MsgBuffer &buffer, TwanIdentifierIeData &data, Uint16 length) |
| 163 | { |
| 164 | // TODO optimize the length checks |
| 165 | |
| 166 | Uint16 ieBoundary = buffer.getCurrentIndex() + length; |
| 167 | buffer.skipBits(2); |
| 168 | if (buffer.getCurrentIndex() > ieBoundary) |
| 169 | { |
| 170 | errorStream.add((char *)"Attempt to read beyond IE boundary: \n"); |
| 171 | return false; |
| 172 | } |
| 173 | |
| 174 | data.laiipresent = 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: laiipresent\n"); |
| 179 | return false; |
| 180 | } |
| 181 | data.opnaipresent = 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: opnaipresent\n"); |
| 186 | return false; |
| 187 | } |
| 188 | data.plmnipresent = buffer.readBits(1); |
| 189 | // confirm that we are not reading beyond the IE boundary |
| 190 | if (buffer.getCurrentIndex() > ieBoundary) |
| 191 | { |
| 192 | errorStream.add((char *)"Attempt to read beyond IE boundary: plmnipresent\n"); |
| 193 | return false; |
| 194 | } |
| 195 | data.civaipresent = buffer.readBits(1); |
| 196 | // confirm that we are not reading beyond the IE boundary |
| 197 | if (buffer.getCurrentIndex() > ieBoundary) |
| 198 | { |
| 199 | errorStream.add((char *)"Attempt to read beyond IE boundary: civaipresent\n"); |
| 200 | return false; |
| 201 | } |
| 202 | data.bssidipresent = buffer.readBits(2); |
| 203 | // confirm that we are not reading beyond the IE boundary |
| 204 | if (buffer.getCurrentIndex() > ieBoundary) |
| 205 | { |
| 206 | errorStream.add((char *)"Attempt to read beyond IE boundary: bssidipresent\n"); |
| 207 | return false; |
| 208 | } |
| 209 | |
| 210 | buffer.readUint64(data.ssidLength); |
| 211 | if (buffer.getCurrentIndex() > ieBoundary) |
| 212 | { |
| 213 | errorStream.add((char *)"Attempt to read beyond IE boundary: ssidLength\n"); |
| 214 | return false; |
| 215 | } |
| 216 | |
| 217 | if ( data.ssidLength <=32) |
| 218 | { |
| 219 | |
| 220 | buffer.readUint8(data.ssid); |
| 221 | if (buffer.getCurrentIndex() > ieBoundary) |
| 222 | { |
| 223 | errorStream.add((char *)"Attempt to read beyond IE boundary: ssid\n"); |
| 224 | return false; |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | if (data.bssidipresent) |
| 229 | { |
| 230 | |
| 231 | buffer.readUint8(data.bssid); |
| 232 | if (buffer.getCurrentIndex() > ieBoundary) |
| 233 | { |
| 234 | errorStream.add((char *)"Attempt to read beyond IE boundary: bssid\n"); |
| 235 | return false; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | if (data.civaipresent) |
| 240 | { |
| 241 | |
| 242 | buffer.readUint8(data.civicAddressLength); |
| 243 | if (buffer.getCurrentIndex() > ieBoundary) |
| 244 | { |
| 245 | errorStream.add((char *)"Attempt to read beyond IE boundary: civicAddressLength\n"); |
| 246 | return false; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | if (data.civaipresent) |
| 251 | { |
| 252 | |
| 253 | buffer.readUint8(data.civicAddressInformation); |
| 254 | if (buffer.getCurrentIndex() > ieBoundary) |
| 255 | { |
| 256 | errorStream.add((char *)"Attempt to read beyond IE boundary: civicAddressInformation\n"); |
| 257 | return false; |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | if (data.plmnipresent) |
| 262 | { |
| 263 | |
| 264 | buffer.readUint8(data.twanplmnid); |
| 265 | if (buffer.getCurrentIndex() > ieBoundary) |
| 266 | { |
| 267 | errorStream.add((char *)"Attempt to read beyond IE boundary: twanplmnid\n"); |
| 268 | return false; |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | if (data.opnaipresent) |
| 273 | { |
| 274 | |
| 275 | buffer.readUint8(data.twanOperatorNameLength); |
| 276 | if (buffer.getCurrentIndex() > ieBoundary) |
| 277 | { |
| 278 | errorStream.add((char *)"Attempt to read beyond IE boundary: twanOperatorNameLength\n"); |
| 279 | return false; |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | if (data.opnaipresent) |
| 284 | { |
| 285 | |
| 286 | buffer.readUint8(data.twanOperatorName); |
| 287 | if (buffer.getCurrentIndex() > ieBoundary) |
| 288 | { |
| 289 | errorStream.add((char *)"Attempt to read beyond IE boundary: twanOperatorName\n"); |
| 290 | return false; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | if (data.laiipresent) |
| 295 | { |
| 296 | |
| 297 | buffer.readUint8(data.relayIdentityType); |
| 298 | if (buffer.getCurrentIndex() > ieBoundary) |
| 299 | { |
| 300 | errorStream.add((char *)"Attempt to read beyond IE boundary: relayIdentityType\n"); |
| 301 | return false; |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | if (data.laiipresent) |
| 306 | { |
| 307 | |
| 308 | buffer.readUint8(data.relayIdentityLength); |
| 309 | if (buffer.getCurrentIndex() > ieBoundary) |
| 310 | { |
| 311 | errorStream.add((char *)"Attempt to read beyond IE boundary: relayIdentityLength\n"); |
| 312 | return false; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | if (data.laiipresent) |
| 317 | { |
| 318 | |
| 319 | buffer.readUint8(data.relayIdentity); |
| 320 | if (buffer.getCurrentIndex() > ieBoundary) |
| 321 | { |
| 322 | errorStream.add((char *)"Attempt to read beyond IE boundary: relayIdentity\n"); |
| 323 | return false; |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | if (data.laiipresent) |
| 328 | { |
| 329 | |
| 330 | buffer.readUint8(data.circuitIDLength); |
| 331 | if (buffer.getCurrentIndex() > ieBoundary) |
| 332 | { |
| 333 | errorStream.add((char *)"Attempt to read beyond IE boundary: circuitIDLength\n"); |
| 334 | return false; |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | if (data.laiipresent) |
| 339 | { |
| 340 | |
| 341 | buffer.readUint8(data.circuitID); |
| 342 | if (buffer.getCurrentIndex() > ieBoundary) |
| 343 | { |
| 344 | errorStream.add((char *)"Attempt to read beyond IE boundary: circuitID\n"); |
| 345 | return false; |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | // The IE is decoded now. The buffer index should be pointing to the |
| 350 | // IE Boundary. If not, we have some more data left for the IE which we don't know |
| 351 | // how to decode |
| 352 | if (ieBoundary == buffer.getCurrentIndex()) |
| 353 | { |
| 354 | return true; |
| 355 | } |
| 356 | else |
| 357 | { |
| 358 | errorStream.add((char *)"Unable to decode IE TwanIdentifierIe\n"); |
| 359 | return false; |
| 360 | } |
| 361 | } |
| 362 | void TwanIdentifierIe::displayTwanIdentifierIe_v(TwanIdentifierIeData const &data, Debug &stream) |
| 363 | { |
| 364 | stream.incrIndent(); |
| 365 | stream.add((char *)"TwanIdentifierIeData:"); |
| 366 | stream.incrIndent(); |
| 367 | stream.endOfLine(); |
| 368 | |
| 369 | stream.add( (char *)"laiipresent: "); |
| 370 | stream.add((Uint8)data.laiipresent); |
| 371 | stream.endOfLine(); |
| 372 | |
| 373 | stream.add( (char *)"opnaipresent: "); |
| 374 | stream.add((Uint8)data.opnaipresent); |
| 375 | stream.endOfLine(); |
| 376 | |
| 377 | stream.add( (char *)"plmnipresent: "); |
| 378 | stream.add((Uint8)data.plmnipresent); |
| 379 | stream.endOfLine(); |
| 380 | |
| 381 | stream.add( (char *)"civaipresent: "); |
| 382 | stream.add((Uint8)data.civaipresent); |
| 383 | stream.endOfLine(); |
| 384 | |
| 385 | stream.add( (char *)"bssidipresent: "); |
| 386 | stream.add((Uint8)data.bssidipresent); |
| 387 | stream.endOfLine(); |
| 388 | |
| 389 | stream.add((char *)"ssidLength: "); |
| 390 | stream.add(data.ssidLength); |
| 391 | stream.endOfLine(); |
| 392 | |
| 393 | if ( data.ssidLength <=32) |
| 394 | { |
| 395 | stream.add((char *)"ssid: "); |
| 396 | stream.add(data.ssid); |
| 397 | stream.endOfLine(); |
| 398 | } |
| 399 | |
| 400 | if (data.bssidipresent) |
| 401 | { |
| 402 | stream.add((char *)"bssid: "); |
| 403 | stream.add(data.bssid); |
| 404 | stream.endOfLine(); |
| 405 | } |
| 406 | |
| 407 | if (data.civaipresent) |
| 408 | { |
| 409 | stream.add((char *)"civicAddressLength: "); |
| 410 | stream.add(data.civicAddressLength); |
| 411 | stream.endOfLine(); |
| 412 | } |
| 413 | |
| 414 | if (data.civaipresent) |
| 415 | { |
| 416 | stream.add((char *)"civicAddressInformation: "); |
| 417 | stream.add(data.civicAddressInformation); |
| 418 | stream.endOfLine(); |
| 419 | } |
| 420 | |
| 421 | if (data.plmnipresent) |
| 422 | { |
| 423 | stream.add((char *)"twanplmnid: "); |
| 424 | stream.add(data.twanplmnid); |
| 425 | stream.endOfLine(); |
| 426 | } |
| 427 | |
| 428 | if (data.opnaipresent) |
| 429 | { |
| 430 | stream.add((char *)"twanOperatorNameLength: "); |
| 431 | stream.add(data.twanOperatorNameLength); |
| 432 | stream.endOfLine(); |
| 433 | } |
| 434 | |
| 435 | if (data.opnaipresent) |
| 436 | { |
| 437 | stream.add((char *)"twanOperatorName: "); |
| 438 | stream.add(data.twanOperatorName); |
| 439 | stream.endOfLine(); |
| 440 | } |
| 441 | |
| 442 | if (data.laiipresent) |
| 443 | { |
| 444 | stream.add((char *)"relayIdentityType: "); |
| 445 | stream.add(data.relayIdentityType); |
| 446 | stream.endOfLine(); |
| 447 | } |
| 448 | |
| 449 | if (data.laiipresent) |
| 450 | { |
| 451 | stream.add((char *)"relayIdentityLength: "); |
| 452 | stream.add(data.relayIdentityLength); |
| 453 | stream.endOfLine(); |
| 454 | } |
| 455 | |
| 456 | if (data.laiipresent) |
| 457 | { |
| 458 | stream.add((char *)"relayIdentity: "); |
| 459 | stream.add(data.relayIdentity); |
| 460 | stream.endOfLine(); |
| 461 | } |
| 462 | |
| 463 | if (data.laiipresent) |
| 464 | { |
| 465 | stream.add((char *)"circuitIDLength: "); |
| 466 | stream.add(data.circuitIDLength); |
| 467 | stream.endOfLine(); |
| 468 | } |
| 469 | |
| 470 | if (data.laiipresent) |
| 471 | { |
| 472 | stream.add((char *)"circuitID: "); |
| 473 | stream.add(data.circuitID); |
| 474 | stream.endOfLine(); |
| 475 | } |
| 476 | stream.decrIndent(); |
| 477 | stream.decrIndent(); |
| 478 | } |