blob: 1991b0643b6337f2f6cf8345403ac7f921605e5d [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 "imsiIe.h"
15#include "dataTypeCodecUtils.h"
16
17ImsiIe::ImsiIe()
18{
19 ieType = 1;
20 // TODO
21
22}
23
24ImsiIe::~ImsiIe() {
25 // TODO Auto-generated destructor stub
26}
27
28bool ImsiIe::encodeImsiIe(MsgBuffer &buffer, ImsiIeData const &data)
29{
30 if (!(data.imsiValue.length>=9 && data.imsiValue.length <=15))
31 {
32 errorStream.add((char *)"Data validation failure: imsiValue\n");
33 return false;
34 }
35 if (!(DataTypeCodecUtils::encodeDigitRegister(buffer, data.imsiValue)))
36 {
37 errorStream.add((char *)"Encoding of imsiValue failed\n");
38 return false;
39 }
40
41 return true;
42}
43
44bool ImsiIe::decodeImsiIe(MsgBuffer &buffer, ImsiIeData &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.imsiValue, lengthLeft)))
53 {
54 errorStream.add((char *)"Failed to decode: imsiValue\n");
55 return false;
56 }
57 if (!(data.imsiValue.length>=9 && data.imsiValue.length <=15))
58 {
59 errorStream.add((char *)"Data validation failure : imsiValue\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 ImsiIe\n");
73 return false;
74 }
75}
76void ImsiIe::displayImsiIe_v(ImsiIeData const &data, Debug &stream)
77{
78 stream.incrIndent();
79 stream.add((char *)"ImsiIeData:");
80 stream.incrIndent();
81 stream.endOfLine();
82
83 stream.add((char *)"imsiValue:");
84 stream.endOfLine();
85 DataTypeCodecUtils::displayDigitRegister_v(data.imsiValue, stream);
86 stream.decrIndent();
87 stream.decrIndent();
88}