blob: 87d30286e4827bd833f5c1d29635ffd21d1c4814 [file] [log] [blame]
/*
* Copyright 2019-present Infosys Limited  
*   
* SPDX-License-Identifier: Apache-2.0    
*/
/******************************************************************************
*
* This is an auto generated file.
* Please do not edit this file.
* All edits to be made through template source file
* <TOP-DIR/scripts/GtpV2StackCodeGen/tts/grpieinsttemplate.cpp.tt>
******************************************************************************/
#include "bearerContextsInDeleteBearerResponse.h"
#include "manual/gtpV2Ie.h"
#include "gtpV2IeFactory.h"
#include "ebiIe.h"
#include "causeIe.h"
#include "pcoIe.h"
#include "ranNasCauseIe.h"
#include "epcoIe.h"
BearerContextsInDeleteBearerResponse::
BearerContextsInDeleteBearerResponse()
{
Uint16 mandIe;
mandIe = EbiIeType;
mandIe = (mandIe << 8) | 0; // epsBearerId
mandatoryIeSet.insert(mandIe);
mandIe = CauseIeType;
mandIe = (mandIe << 8) | 0; // cause
mandatoryIeSet.insert(mandIe);
}
BearerContextsInDeleteBearerResponse::
~BearerContextsInDeleteBearerResponse()
{
}
bool BearerContextsInDeleteBearerResponse::
encodeBearerContextsInDeleteBearerResponse(MsgBuffer &buffer,
BearerContextsInDeleteBearerResponseData
const &data)
{
bool rc = false;
GtpV2IeHeader header;
Uint16 startIndex = 0;
Uint16 endIndex = 0;
Uint16 length = 0;
// Encode the Ie Header
header.ieType = EbiIeType;
header.instance = 0;
header.length = 0; // We will encode the IE first and then update the length
GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
startIndex = buffer.getCurrentIndex();
EbiIe ebi=
dynamic_cast<
EbiIe&>(GtpV2IeFactory::getInstance().getIeObject(EbiIeType));
rc = ebi.encodeEbiIe(buffer, data.epsBearerId);
endIndex = buffer.getCurrentIndex();
length = endIndex - startIndex;
// encode the length value now
buffer.goToIndex(startIndex - 3);
buffer.writeUint16(length, false);
buffer.goToIndex(endIndex);
if (!(rc))
{
errorStream.add((char *)"Failed to encode IE: epsBearerId\n");
return false;
}
// Encode the Ie Header
header.ieType = CauseIeType;
header.instance = 0;
header.length = 0; // We will encode the IE first and then update the length
GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
startIndex = buffer.getCurrentIndex();
CauseIe cause=
dynamic_cast<
CauseIe&>(GtpV2IeFactory::getInstance().getIeObject(CauseIeType));
rc = cause.encodeCauseIe(buffer, data.cause);
endIndex = buffer.getCurrentIndex();
length = endIndex - startIndex;
// encode the length value now
buffer.goToIndex(startIndex - 3);
buffer.writeUint16(length, false);
buffer.goToIndex(endIndex);
if (!(rc))
{
errorStream.add((char *)"Failed to encode IE: cause\n");
return false;
}
if (data.protocolConfigurationOptionsIePresent)
{
// Encode the Ie Header
header.ieType = PcoIeType;
header.instance = 0;
header.length = 0; // We will encode the IE first and then update the length
GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
startIndex = buffer.getCurrentIndex();
PcoIe pco=
dynamic_cast<
PcoIe&>(GtpV2IeFactory::getInstance().getIeObject(PcoIeType));
rc = pco.encodePcoIe(buffer, data.protocolConfigurationOptions);
endIndex = buffer.getCurrentIndex();
length = endIndex - startIndex;
// encode the length value now
buffer.goToIndex(startIndex - 3);
buffer.writeUint16(length, false);
buffer.goToIndex(endIndex);
if (!(rc))
{
errorStream.add((char *)"Failed to encode IE: protocolConfigurationOptions\n");
return false;
}
}
if (data.ranNasCauseIePresent)
{
// Encode the Ie Header
header.ieType = RanNasCauseIeType;
header.instance = 0;
header.length = 0; // We will encode the IE first and then update the length
GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
startIndex = buffer.getCurrentIndex();
RanNasCauseIe ranNasCause=
dynamic_cast<
RanNasCauseIe&>(GtpV2IeFactory::getInstance().getIeObject(RanNasCauseIeType));
rc = ranNasCause.encodeRanNasCauseIe(buffer, data.ranNasCause);
endIndex = buffer.getCurrentIndex();
length = endIndex - startIndex;
// encode the length value now
buffer.goToIndex(startIndex - 3);
buffer.writeUint16(length, false);
buffer.goToIndex(endIndex);
if (!(rc))
{
errorStream.add((char *)"Failed to encode IE: ranNasCause\n");
return false;
}
}
if (data.extendedProtocolConfigurationOptionsIePresent)
{
// Encode the Ie Header
header.ieType = EpcoIeType;
header.instance = 0;
header.length = 0; // We will encode the IE first and then update the length
GtpV2Ie::encodeGtpV2IeHeader(buffer, header);
startIndex = buffer.getCurrentIndex();
EpcoIe epco=
dynamic_cast<
EpcoIe&>(GtpV2IeFactory::getInstance().getIeObject(EpcoIeType));
rc = epco.encodeEpcoIe(buffer, data.extendedProtocolConfigurationOptions);
endIndex = buffer.getCurrentIndex();
length = endIndex - startIndex;
// encode the length value now
buffer.goToIndex(startIndex - 3);
buffer.writeUint16(length, false);
buffer.goToIndex(endIndex);
if (!(rc))
{
errorStream.add((char *)"Failed to encode IE: extendedProtocolConfigurationOptions\n");
return false;
}
}
return rc;
}
bool BearerContextsInDeleteBearerResponse::
decodeBearerContextsInDeleteBearerResponse(MsgBuffer &buffer,
BearerContextsInDeleteBearerResponseData
&data, Uint16 length)
{
bool rc = false;
GtpV2IeHeader ieHeader;
set<Uint16> mandatoryIeLocalList = mandatoryIeSet;
while (buffer.lengthLeft() > IE_HEADER_SIZE)
{
GtpV2Ie::decodeGtpV2IeHeader(buffer, ieHeader);
if (ieHeader.length > buffer.lengthLeft())
{
// We do not have enough bytes left in the message for this IE
errorStream.add((char *)"IE Length exceeds beyond message boundary\n");
errorStream.add((char *)" Offending IE Type: ");
errorStream.add(ieHeader.ieType);
errorStream.add((char *)"\n Ie Length in Header: ");
errorStream.add(ieHeader.length);
errorStream.add((char *)"\n Bytes left in message: ");
errorStream.add(buffer.lengthLeft());
errorStream.endOfLine();
return false;
}
switch (ieHeader.ieType){
case EbiIeType:
{
EbiIe ieObject =
dynamic_cast<
EbiIe&>(GtpV2IeFactory::getInstance().
getIeObject(EbiIeType));
if(ieHeader.instance == 0)
{
rc = ieObject.decodeEbiIe(buffer, data.epsBearerId, ieHeader.length);
if (!(rc))
{
errorStream.add((char *)"Failed to decode IE: epsBearerId\n");
return false;
}
Uint16 mandIe = EbiIeType;
mandIe = (mandIe << 8) | 0;
mandatoryIeLocalList.erase(mandIe);
}
else
{
// Unknown IE instance print error TODO
errorStream.add((char *)"Unknown IE Type: ");
errorStream.add(ieHeader.ieType);
errorStream.endOfLine();
buffer.skipBytes(ieHeader.length);
}
break;
}
case CauseIeType:
{
CauseIe ieObject =
dynamic_cast<
CauseIe&>(GtpV2IeFactory::getInstance().
getIeObject(CauseIeType));
if(ieHeader.instance == 0)
{
rc = ieObject.decodeCauseIe(buffer, data.cause, ieHeader.length);
if (!(rc))
{
errorStream.add((char *)"Failed to decode IE: cause\n");
return false;
}
Uint16 mandIe = CauseIeType;
mandIe = (mandIe << 8) | 0;
mandatoryIeLocalList.erase(mandIe);
}
else
{
// Unknown IE instance print error TODO
errorStream.add((char *)"Unknown IE Type: ");
errorStream.add(ieHeader.ieType);
errorStream.endOfLine();
buffer.skipBytes(ieHeader.length);
}
break;
}
case PcoIeType:
{
PcoIe ieObject =
dynamic_cast<
PcoIe&>(GtpV2IeFactory::getInstance().
getIeObject(PcoIeType));
if(ieHeader.instance == 0)
{
rc = ieObject.decodePcoIe(buffer, data.protocolConfigurationOptions, ieHeader.length);
data.protocolConfigurationOptionsIePresent = true;
if (!(rc))
{
errorStream.add((char *)"Failed to decode IE: protocolConfigurationOptions\n");
return false;
}
}
else
{
// Unknown IE instance print error TODO
errorStream.add((char *)"Unknown IE Type: ");
errorStream.add(ieHeader.ieType);
errorStream.endOfLine();
buffer.skipBytes(ieHeader.length);
}
break;
}
case RanNasCauseIeType:
{
RanNasCauseIe ieObject =
dynamic_cast<
RanNasCauseIe&>(GtpV2IeFactory::getInstance().
getIeObject(RanNasCauseIeType));
if(ieHeader.instance == 0)
{
rc = ieObject.decodeRanNasCauseIe(buffer, data.ranNasCause, ieHeader.length);
data.ranNasCauseIePresent = true;
if (!(rc))
{
errorStream.add((char *)"Failed to decode IE: ranNasCause\n");
return false;
}
}
else
{
// Unknown IE instance print error TODO
errorStream.add((char *)"Unknown IE Type: ");
errorStream.add(ieHeader.ieType);
errorStream.endOfLine();
buffer.skipBytes(ieHeader.length);
}
break;
}
case EpcoIeType:
{
EpcoIe ieObject =
dynamic_cast<
EpcoIe&>(GtpV2IeFactory::getInstance().
getIeObject(EpcoIeType));
if(ieHeader.instance == 0)
{
rc = ieObject.decodeEpcoIe(buffer, data.extendedProtocolConfigurationOptions, ieHeader.length);
data.extendedProtocolConfigurationOptionsIePresent = true;
if (!(rc))
{
errorStream.add((char *)"Failed to decode IE: extendedProtocolConfigurationOptions\n");
return false;
}
}
else
{
// Unknown IE instance print error TODO
errorStream.add((char *)"Unknown IE Type: ");
errorStream.add(ieHeader.ieType);
errorStream.endOfLine();
buffer.skipBytes(ieHeader.length);
}
break;
}
default:
{
// Unknown IE print error
errorStream.add((char *)"Unknown IE Type: ");
errorStream.add(ieHeader.ieType);
errorStream.endOfLine();
buffer.skipBytes(ieHeader.length);
}
}
}
if (!mandatoryIeLocalList.empty())
{
// some mandatory IEs are missing
errorStream.add((char *)"Missing Mandatory IEs:");
errorStream.endOfLine();
while (!mandatoryIeLocalList.empty())
{
Uint16 missingMandIe = *mandatoryIeLocalList.begin ();
mandatoryIeLocalList.erase (mandatoryIeLocalList.begin ());
Uint16 missingInstance = missingMandIe & 0x00FF;
Uint16 missingIeType = (missingMandIe >> 8);
errorStream.add ((char *)"Missing Ie type: ");
errorStream.add (missingIeType);
errorStream.add ((char *)" Instance: ");
errorStream.add (missingInstance);
errorStream.endOfLine();
}
rc = false;
}
return rc;
}
void BearerContextsInDeleteBearerResponse::
displayBearerContextsInDeleteBearerResponseData_v
(BearerContextsInDeleteBearerResponseData const &data, Debug &stream)
{
stream.incrIndent();
stream.add((char *)"BearerContextsInDeleteBearerResponse:");
stream.endOfLine();
stream.incrIndent();
if (data.protocolConfigurationOptionsIePresent)
{
stream.add((char *)"protocolConfigurationOptions:");
stream.endOfLine();
PcoIe pco=
dynamic_cast<
PcoIe&>(GtpV2IeFactory::getInstance().getIeObject(PcoIeType));
pco.displayPcoIe_v(data.protocolConfigurationOptions, stream);
}
if (data.ranNasCauseIePresent)
{
stream.add((char *)"ranNasCause:");
stream.endOfLine();
RanNasCauseIe ranNasCause=
dynamic_cast<
RanNasCauseIe&>(GtpV2IeFactory::getInstance().getIeObject(RanNasCauseIeType));
ranNasCause.displayRanNasCauseIe_v(data.ranNasCause, stream);
}
if (data.extendedProtocolConfigurationOptionsIePresent)
{
stream.add((char *)"extendedProtocolConfigurationOptions:");
stream.endOfLine();
EpcoIe epco=
dynamic_cast<
EpcoIe&>(GtpV2IeFactory::getInstance().getIeObject(EpcoIeType));
epco.displayEpcoIe_v(data.extendedProtocolConfigurationOptions, stream);
}
stream.decrIndent();
stream.decrIndent();
}