blob: 9fb328a65f9628061f1216c640c09be8365aebf7 [file] [log] [blame]
anjana_sreekumar@infosys.com991c2062020-01-08 11:42:57 +05301/*
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 "meiIe.h"
15#include "dataTypeCodecUtils.h"
16
17MeiIe::MeiIe()
18{
19 ieType = 75;
20 // TODO
21
22}
23
24MeiIe::~MeiIe() {
25 // TODO Auto-generated destructor stub
26}
27
28bool MeiIe::encodeMeiIe(MsgBuffer &buffer, MeiIeData const &data)
29{
30 if (!(data.imeiSvValue.length ==15 || data.imeiSvValue.length == 16))
31 {
32 errorStream.add((char *)"Data validation failure: imeiSvValue\n");
33 return false;
34 }
35 if (!(DataTypeCodecUtils::encodeDigitRegister(buffer, data.imeiSvValue)))
36 {
37 errorStream.add((char *)"Encoding of imeiSvValue failed\n");
38 return false;
39 }
40
41 return true;
42}
43
44bool MeiIe::decodeMeiIe(MsgBuffer &buffer, MeiIeData &data, Uint16 length)
45{
46 // TODO optimize the length checks
47
48 Uint16 ieBoundary = buffer.getCurrentIndex() + length;
49
50 Uint16 lengthLeft = length;
51 lengthLeft = ieBoundary - buffer.getCurrentIndex();
52 if (!(DataTypeCodecUtils::decodeDigitRegister(buffer, data.imeiSvValue, lengthLeft)))
53 {
54 errorStream.add((char *)"Failed to decode: imeiSvValue\n");
55 return false;
56 }
57 if (!(data.imeiSvValue.length ==15 || data.imeiSvValue.length == 16))
58 {
59 errorStream.add((char *)"Data validation failure : imeiSvValue\n");
60 return false; //TODO need to add validations
61 }
62
63 // The IE is decoded now. The buffer index should be pointing to the
64 // IE Boundary. If not, we have some more data left for the IE which we don't know
65 // how to decode
66 if (ieBoundary == buffer.getCurrentIndex())
67 {
68 return true;
69 }
70 else
71 {
72 errorStream.add((char *)"Unable to decode IE MeiIe\n");
73 return false;
74 }
75}
76void MeiIe::displayMeiIe_v(MeiIeData const &data, Debug &stream)
77{
78 stream.incrIndent();
79 stream.add((char *)"MeiIeData:");
80 stream.incrIndent();
81 stream.endOfLine();
82
83 stream.add((char *)"imeiSvValue:");
84 stream.endOfLine();
85 DataTypeCodecUtils::displayDigitRegister_v(data.imeiSvValue, stream);
86 stream.decrIndent();
87 stream.decrIndent();
88}