Commit 51bab01d authored by garciay's avatar garciay
Browse files

Simplify Payload for GeoNetworking & BTP

==> Check TODO in Security ATS
parent cdf1455a
......@@ -5,27 +5,6 @@
namespace LibItsBtp__EncdecDeclarations {
/****************************************************
* @desc External function to encode a BtpPayload type
* @param value to encode
* @return encoded value
****************************************************/
BITSTRING fx__enc__BtpPayload(const LibItsBtp__TypesAndValues::BtpPayload& p)
{
return int2bit(0,8);
}
/****************************************************
* @desc External function to decode a BtpPayload type
* @param value to encode
* @return encoded value
****************************************************/
/* TODO RGy function not implemented! (decvalue() not used by test suite @29-06-2016)
INTEGER fx__dec__BtpPayload(BITSTRING& b, LibItsBtp__TypesAndValues::BtpPayload& p)
{
return -1;
}
*/
/****************************************************
* @desc External function to encode a BtpReq type
* @param value to encode
......
......@@ -205,28 +205,6 @@ namespace LibItsGeoNetworking__EncdecDeclarations {
return 0;
}
/****************************************************
* @desc External function to encode a Payload type
* @param value to encode
* @return encoded value
****************************************************/
BITSTRING fx__enc__Payload(const LibItsGeoNetworking__TypesAndValues::Payload& p)
{
loggers::get_instance().log("fx__enc__Payload");
return int2bit(0,8);
}
/****************************************************
* @desc External function to decode a Payload type
* @param value to encode
* @return encoded value
****************************************************/
INTEGER fx__dec__Payload(BITSTRING& b, LibItsGeoNetworking__TypesAndValues::Payload& p)
{
return -1;
}
/****************************************************
* @desc External function to encode a GnNonSecuredPacket type
* @param value to encode
......
#include "LibItsIpv6OverGeoNetworking_EncdecDeclarations.hh"
namespace LibItsIpv6OverGeoNetworking__EncdecDeclarations {
/****************************************************
* @desc External function to encode a Ipv6Packet type
* @param value to encode
* @return encoded value
****************************************************/
BITSTRING fx__enc__Ipv6Packet(const LibItsIpv6OverGeoNetworking__TypesAndValues::Ipv6Packet& p)
{
return int2bit(0,8);
}
/****************************************************
* @desc External function to decode a Ipv6Packet type
* @param value to encode
* @return encoded value
****************************************************/
INTEGER fx__dec__Ipv6Packet(BITSTRING& b, LibItsIpv6OverGeoNetworking__TypesAndValues::Ipv6Packet& p)
{
return -1;
}
} //end namespace
......@@ -42,30 +42,25 @@ public:
protected:
inline void toAllLayers(std::vector<Layer*>&layers, OCTETSTRING& data, Params& params) {
//loggers::get_instance().log_msg(">>> Layer::toAllLayer: ", data);
loggers::get_instance().log(">>> Layer::toAllLayer: %d", layers.size());
//loggers::get_instance().log(">>> Layer::toAllLayer: %d", layers.size());
for (std::vector<Layer*>::const_iterator it = layers.cbegin(); it != layers.cend(); ++it) {
Layer * p = *it;
p->receiveData(data, params); // FIXME BUG I
} // End of 'for' statement
};
//inline void toAllUpperLayers(OCTETSTRING& data, Params& params) { toAllLayers(upperLayers, data, params); } // TODO Useless??
//inline void toAllLowerLayers(OCTETSTRING& data, Params& params) { toAllLayers(lowerLayers, data, params); } // TODO Useless??
inline void receiveToAllLayers(OCTETSTRING& data, Params& params) {
//loggers::get_instance().log_msg(">>> Layer::receiveToAllLayers: ", data);
loggers::get_instance().log(">>> Layer::receiveToAllLayers: %d", upperLayers.size());
//loggers::get_instance().log(">>> Layer::receiveToAllLayers: %d", upperLayers.size());
for (std::vector<Layer*>::const_iterator it = upperLayers.cbegin(); it != upperLayers.cend(); ++it) {
Layer * p = *it;
loggers::get_instance().log("Layer::receiveToAllLayers: call Layer::receiveData for %s", p->to_string().c_str());
//loggers::get_instance().log("Layer::receiveToAllLayers: call Layer::receiveData for %s", p->to_string().c_str());
p->receiveData(data, params);
} // End of 'for' statement
};
inline void sendToAllLayers(OCTETSTRING& data, Params& params) {
//loggers::get_instance().log_msg(">>> Layer::sendToAllLayers: ", data);
loggers::get_instance().log(">>> Layer::sendToAllLayers: %d", lowerLayers.size());
//loggers::get_instance().log(">>> Layer::sendToAllLayers: %d", lowerLayers.size());
for (std::vector<Layer*>::const_iterator it = lowerLayers.cbegin(); it != lowerLayers.cend(); ++it) {
Layer * p = *it;
loggers::get_instance().log("Layer::sendToAllLayers: call Layer::sendData for %s", p->to_string().c_str());
//loggers::get_instance().log("Layer::sendToAllLayers: call Layer::sendData for %s", p->to_string().c_str());
p->sendData(data, params);
} // End of 'for' statement
};
......@@ -87,7 +82,7 @@ public:
protected:
template <typename TMessage>
inline void toAllUpperPorts(const TMessage& m, const Params& param) {
loggers::get_instance().log(">>> TLayer::toAllUpperPorts: %d", upperPorts.size());
//loggers::get_instance().log(">>> TLayer::toAllUpperPorts: %d", upperPorts.size());
for(TPortListIterator it=upperPorts.begin(); it<upperPorts.end(); ++it){
(*it)->receiveMsg(m, param);
}
......
......@@ -19,6 +19,13 @@ public:
static const std::string& btp_payload;
static const std::string& btp_destination_port;
static const std::string& btp_info;
static const std::string& nic;
static const std::string& ll_address;
static const std::string& latitude;
static const std::string& longitude;
static const std::string& expiry;
Params() : std::map<std::string, std::string>() {};
Params(const Params& p_params) : std::map<std::string, std::string>(p_params.begin(), p_params.end()) {};
......
......@@ -19,6 +19,13 @@ const std::string& Params::btp_payload = std::string("btp_payload");
const std::string& Params::btp_destination_port = std::string("btpDestinationPort");
const std::string& Params::btp_info = std::string("btpInfo");
const std::string& Params::nic = std::string("nic");
const std::string& Params::latitude = std::string("latitude");
const std::string& Params::longitude = std::string("longitude");
const std::string& Params::ll_address = std::string("ll_address");
const std::string& Params::expiry = std::string("expiry");
void Params::convert(Params& p_param, const std::string p_parameters) {
//loggers::get_instance().log(">>> Params::convert: '%s'", p_parameters.c_str());
// Sanity checks
......
......@@ -39,21 +39,15 @@ int BTPCodec::encode_ (const Base_Type& type, const TTCN_Typedescriptor_t& field
}
}
} // End of 'for' statement
} else if (std::string(type.get_descriptor()->name).compare("@LibItsBtp_TypesAndValues.BtpPayload") == 0) {
const OPTIONAL<LibItsBtp__TypesAndValues::BtpPayload> &v = dynamic_cast<const OPTIONAL<LibItsBtp__TypesAndValues::BtpPayload> &>(type);
loggers::get_instance().log("BTPCodec::encode_: Payload present: %d", v.is_present());
} else if (std::string(field_descriptor.name).compare("@LibItsBtp_TypesAndValues.BtpPacket.payload") == 0) {
const OPTIONAL<LibItsBtp__TypesAndValues::BtpRawPayload> &v = dynamic_cast<const OPTIONAL<LibItsBtp__TypesAndValues::BtpRawPayload> &>(type);
loggers::get_instance().log("BTPCodec::encode_: BtpRawPayload present: %d", v.is_present());
if (v.is_present()) {
if (encode_(static_cast<const LibItsBtp__TypesAndValues::BtpPayload &>(*v.get_opt_value()), LibItsBtp__TypesAndValues::BtpPayload_descr_, encoding_buffer) == -1) {
if (encode_(static_cast<const LibItsBtp__TypesAndValues::BtpRawPayload &>(*v.get_opt_value()), LibItsBtp__TypesAndValues::BtpRawPayload_descr_, encoding_buffer) == -1) {
loggers::get_instance().warning("BTPCodec::encode_: -1 result code returned");
return -1;
}
}
} else if (std::string(type.get_descriptor()->name).compare("@LibItsBtp_TypesAndValues.DecodedBtpPayload") == 0) {
const OPTIONAL<LibItsBtp__TypesAndValues::DecodedBtpPayload> &v = dynamic_cast<const OPTIONAL<LibItsBtp__TypesAndValues::DecodedBtpPayload> &>(type);
loggers::get_instance().log("BTPCodec::encode_: DecodedBtpPayload present: %d", v.is_present());
if (v.is_present()) {
loggers::get_instance().error("BTPCodec::encode_ DecodedBtpPayload shall not be present");
}
} else {
loggers::get_instance().log("BTPCodec::encode_ (else): processing type %s/%s", type.get_descriptor()->name, field_descriptor.name);
type.encode(field_descriptor, encoding_buffer, TTCN_EncDec::CT_RAW);
......@@ -111,32 +105,25 @@ int BTPCodec::decode_ (Base_Type& type, const TTCN_Typedescriptor_t& field_descr
loggers::get_instance().error("BTPCodec::decode_: Invalid BTP type"); // Cannot be reached
}
loggers::get_instance().log_msg("BTPCodec::decode_: BtpHeader: ", type);
} else if (std::string(field_descriptor.name).compare("@LibItsBtp_TypesAndValues.BtpPayload") == 0) {
} else if (std::string(field_descriptor.name).compare("@LibItsBtp_TypesAndValues.BtpPacket.payload") == 0) {
if (decoding_buffer.get_len() == decoding_buffer.get_pos()) { // No payload, set it to omit
loggers::get_instance().log("BTPCodec::decode_: Set OPTIONAL<BtpPayload> to omit");
dynamic_cast<OPTIONAL<LibItsBtp__TypesAndValues::BtpPayload> &>(type).set_to_omit();
loggers::get_instance().log("BTPCodec::decode_: Set OPTIONAL<BtpRawPayload> to omit");
dynamic_cast<OPTIONAL<LibItsBtp__TypesAndValues::BtpRawPayload> &>(type).set_to_omit();
} else {
LibItsBtp__TypesAndValues::BtpPayload p;
decode_(p, LibItsBtp__TypesAndValues::BtpPayload_descr_, decoding_buffer);
loggers::get_instance().log_msg("BTPCodec::decode_: payload= ", p);
if (p.is_bound()) {
dynamic_cast<OPTIONAL<LibItsBtp__TypesAndValues::BtpPayload> &>(type) = OPTIONAL<LibItsBtp__TypesAndValues::BtpPayload>(p);
// Decode BtpRawPayload data structure
OCTETSTRING os(decoding_buffer.get_len() - decoding_buffer.get_pos(), decoding_buffer.get_data() + decoding_buffer.get_pos());
loggers::get_instance().log_msg("BTPCodec::decode_: s=", os);
if (_params != NULL) {
(*_params)[Params::btp_payload] = std::string(static_cast<const char *>(oct2str(os)));
}
if (os.lengthof() != 0) {
dynamic_cast<OPTIONAL<LibItsBtp__TypesAndValues::BtpRawPayload> &>(type) = OPTIONAL<LibItsBtp__TypesAndValues::BtpRawPayload>(os);
loggers::get_instance().log_msg("BTPCodec::decode_: Set OPTIONAL to ", type);
} else {
loggers::get_instance().log("BTPCodec::decode_: Set OPTIONAL to omit");
dynamic_cast<OPTIONAL<LibItsBtp__TypesAndValues::BtpPayload> &>(type).set_to_omit();
dynamic_cast<OPTIONAL<LibItsBtp__TypesAndValues::BtpRawPayload> &>(type).set_to_omit();
}
}
} else if (std::string(field_descriptor.name).compare("@LibItsBtp_TypesAndValues.DecodedBtpPayload") == 0) {
dynamic_cast<OPTIONAL<LibItsBtp__TypesAndValues::DecodedBtpPayload> &>(type).set_to_omit();
} else if (std::string(field_descriptor.name).compare("@LibItsBtp_TypesAndValues.BtpRawPayload") == 0) {
// Decode BtpRawPayload data structure
OCTETSTRING os(decoding_buffer.get_len() - decoding_buffer.get_pos(), decoding_buffer.get_data() + decoding_buffer.get_pos());
loggers::get_instance().log_msg("BTPCodec::decode_: s=", os);
if (_params != NULL) {
(*_params)[Params::btp_payload] = std::string(static_cast<const char *>(oct2str(os)));
}
dynamic_cast<OCTETSTRING &>(type) = os;
} else {
type.decode(field_descriptor, decoding_buffer, TTCN_EncDec::CT_RAW);
}
......
#include "CAMLayer.hh"
#include "CAMTypes.hh"
#include "loggers.hh"
CAMLayer::CAMLayer(const std::string & p_type, const std::string & param) : TLayer<LibItsCam__TestSystem::CamPort>(p_type), _params(), _codec() {
loggers::get_instance().log(">>> CAMLayer::CAMLayer: %s, %s", to_string().c_str(), param.c_str());
// Setup parameters
Params::convert(_params, param);
}
void CAMLayer::sendMsg(const LibItsCam__TestSystem::CamReq& p, Params& params){
loggers::get_instance().log(">>> CAMLayer::sendMsg");
// Encode CAM PDU
OCTETSTRING data;
_codec.encode(p.msgOut(), data);
// Update parameters
// Params par(params); // FIXME Review all const Param& in method declarations
sendData(data, params);
}
void CAMLayer::sendData(OCTETSTRING& data, Params& params) {
loggers::get_instance().log_msg(">>> CAMLayer::sendData: ", data);
params.log();
sendToAllLayers(data, params);
}
void CAMLayer::receiveData(OCTETSTRING& data, Params& params)
{
loggers::get_instance().log_msg(">>> CAMLayer::receiveData: ", data);
// Decode the payload
LibItsCam__TestSystem::CamInd p;
_codec.decode(data, p.msgIn());
// Add lower layers parameters
// const OPTIONAL<INTEGER>& par_gnNextHeader,
// const OPTIONAL<INTEGER>& par_gnHeaderType,
// const OPTIONAL<INTEGER>& par_gnHeaderSubtype,
// const OPTIONAL<INTEGER>& par_gnLifetime,
// const OPTIONAL<INTEGER>& par_gnTrafficClass,
// const OPTIONAL<INTEGER>& par_btpDestinationPort,
// const OPTIONAL<INTEGER>& par_btpInfo,
// const OPTIONAL<BITSTRING>& par_ssp,
// const OPTIONAL<INTEGER>& par_its__aid);
// Pass it to the ports if amy
toAllUpperPorts(p, params);
}
class CAMFactory : public LayerFactory {
static CAMFactory _f;
public:
CAMFactory();
virtual Layer * createLayer(const std::string & type, const std::string & param);
};
CAMFactory::CAMFactory(){
// Register factory
loggers::get_instance().log(">>> CAMFactory::CAMFactory");
LayerStackBuilder::RegisterLayerFactory("CAM", this);
}
Layer * CAMFactory::createLayer(const std::string & p_type, const std::string & param){
return new CAMLayer(p_type, param);
}
CAMFactory CAMFactory::_f;
#ifndef CAM_LAYER_H
#define CAM_LAYER_H
#include "Layer.hh"
#include "CAMCodec.hh"
namespace LibItsCam__TestSystem {
class CamPort;
class CamReq;
class CamInd;
}
class CAMLayer : public TLayer<LibItsCam__TestSystem::CamPort> {
Params _params;
CAMCodec _codec;
public:
CAMLayer() : TLayer<LibItsCam__TestSystem::CamPort>(), _params(), _codec() {};
CAMLayer(const std::string & p_type, const std::string & param);
virtual ~CAMLayer() {};
void sendMsg(const LibItsCam__TestSystem::CamReq&, Params& params);
virtual void sendData(OCTETSTRING& data, Params& params);
virtual void receiveData(OCTETSTRING& data, Params& info);
};
#endif
#include "DENMLayer.hh"
#include "DENMTypes.hh"
#include "loggers.hh"
DENMLayer::DENMLayer(const std::string & p_type, const std::string & param) : TLayer<LibItsDenm__TestSystem::DenmPort>(p_type), _params(), _codec() {
loggers::get_instance().log(">>> DENMLayer::DENMLayer: %s, %s", to_string().c_str(), param.c_str());
// Setup parameters
Params::convert(_params, param);
}
void DENMLayer::sendMsg(const LibItsDenm__TestSystem::DenmReq& p, Params& params){
loggers::get_instance().log(">>> DENMLayer::sendMsg");
// Encode DENM PDU
OCTETSTRING data;
_codec.encode(p.msgOut(), data);
// Update parameters
// Params par(params); // FIXME Review all const Param& in method declarations
sendData(data, params);
}
void DENMLayer::sendData(OCTETSTRING& data, Params& params) {
loggers::get_instance().log_msg(">>> DENMLayer::sendData: ", data);
params.log();
sendToAllLayers(data, params);
}
void DENMLayer::receiveData(OCTETSTRING& data, Params& params)
{
loggers::get_instance().log_msg(">>> DENMLayer::receiveData: ", data);
// Decode the payload
LibItsDenm__TestSystem::DenmInd p;
_codec.decode(data, p.msgIn());
// Add lower layers parameters
// const OPTIONAL<INTEGER>& par_gnNextHeader,
// const OPTIONAL<INTEGER>& par_gnHeaderType,
// const OPTIONAL<INTEGER>& par_gnHeaderSubtype,
// const OPTIONAL<INTEGER>& par_gnLifetime,
// const OPTIONAL<INTEGER>& par_gnTrafficClass,
// const OPTIONAL<INTEGER>& par_btpDestinationPort,
// const OPTIONAL<INTEGER>& par_btpInfo,
// const OPTIONAL<BITSTRING>& par_ssp,
// const OPTIONAL<INTEGER>& par_its__aid);
// Pass it to the ports if amy
toAllUpperPorts(p, params);
}
class DENMFactory : public LayerFactory {
static DENMFactory _f;
public:
DENMFactory();
virtual Layer * createLayer(const std::string & type, const std::string & param);
};
DENMFactory::DENMFactory(){
// Register factory
loggers::get_instance().log(">>> DENMFactory::DENMFactory");
LayerStackBuilder::RegisterLayerFactory("DENM", this);
}
Layer * DENMFactory::createLayer(const std::string & p_type, const std::string & param){
return new DENMLayer(p_type, param);
}
DENMFactory DENMFactory::_f;
#ifndef DENM_LAYER_H
#define DENM_LAYER_H
#include "Layer.hh"
#include "DENMCodec.hh"
namespace LibItsDenm__TestSystem {
class DenmPort;
class DenmReq;
class DenmInd;
}
class DENMLayer : public TLayer<LibItsDenm__TestSystem::DenmPort> {
Params _params;
DENMCodec _codec;
public:
DENMLayer() : TLayer<LibItsDenm__TestSystem::DenmPort>(), _params(), _codec() {};
DENMLayer(const std::string & p_type, const std::string & param);
virtual ~DENMLayer() {};
void sendMsg(const LibItsDenm__TestSystem::DenmReq&, Params& params);
virtual void sendData(OCTETSTRING& data, Params& params);
virtual void receiveData(OCTETSTRING& data, Params& info);
};
#endif
......@@ -56,23 +56,17 @@ int GeoNetworkingCodec::encode_ (const Base_Type& type, const TTCN_Typedescripto
return -1;
}
}
} else if (std::string(type.get_descriptor()->name).compare("@LibItsGeoNetworking_TypesAndValues.Payload") == 0) {
const OPTIONAL<LibItsGeoNetworking__TypesAndValues::Payload> &v = dynamic_cast<const OPTIONAL<LibItsGeoNetworking__TypesAndValues::Payload> &>(type);
loggers::get_instance().log("GeoNetworkingCodec::encode_: Payload present: %d", v.is_present());
} else if (std::string(field_descriptor.name).compare("@LibItsGeoNetworking_TypesAndValues.GnNonSecuredPacket.payload") == 0) {
const OPTIONAL<LibItsGeoNetworking__TypesAndValues::GnRawPayload> &v = dynamic_cast<const OPTIONAL<LibItsGeoNetworking__TypesAndValues::GnRawPayload> &>(type);
loggers::get_instance().log("GeoNetworkingCodec::encode_: GnRawPayload present: %d", v.is_present());
if (v.is_present()) {
if (encode_(static_cast<const LibItsGeoNetworking__TypesAndValues::Payload &>(*v.get_opt_value()), LibItsGeoNetworking__TypesAndValues::Payload_descr_, encoding_buffer) == -1) {
loggers::get_instance().warning("GeoNetworkingCodec::encode_: -1 result code returned");
return -1;
}
}
} else if (std::string(type.get_descriptor()->name).compare("@LibItsGeoNetworking_TypesAndValues.DecodedPayload") == 0) {
const OPTIONAL<LibItsGeoNetworking__TypesAndValues::DecodedPayload> &v = dynamic_cast<const OPTIONAL<LibItsGeoNetworking__TypesAndValues::DecodedPayload> &>(type);
loggers::get_instance().log("GeoNetworkingCodec::encode_: DecodedPayload present: %d", v.is_present());
if (v.is_present()) {
if (encode_decodedPayload(static_cast<const LibItsGeoNetworking__TypesAndValues::DecodedPayload &>(*v.get_opt_value()), encoding_buffer) == -1) {
if (encode_(static_cast<const LibItsGeoNetworking__TypesAndValues::GnRawPayload &>(*v.get_opt_value()), LibItsGeoNetworking__TypesAndValues::GnRawPayload_descr_, encoding_buffer) == -1) {
loggers::get_instance().warning("GeoNetworkingCodec::encode_: -1 result code returned");
return -1;
}
// Store playload length and continue encoding
_ec.length = dynamic_cast<const OCTETSTRING *>(v.get_opt_value())->lengthof();
loggers::get_instance().log("GeoNetworkingCodec::encode_: Storing payload length %d for %s", _ec.length, field_descriptor.name);
}
} else {
loggers::get_instance().log("GeoNetworkingCodec::encode_ (else): processing type %s/%s", type.get_descriptor()->name, field_descriptor.name);
......@@ -88,14 +82,10 @@ int GeoNetworkingCodec::encode_ (const Base_Type& type, const TTCN_Typedescripto
// Store TTCN_Buffer position and continue encoding
_ec.length_position = encoding_buffer.get_len();
loggers::get_instance().log("GeoNetworkingCodec::encode_: Storing position %d for %s", _ec.length_position, field_descriptor.name);
} else if (std::string(field_descriptor.name).compare("@LibItsGeoNetworking_TypesAndValues.Payload.rawPayload") == 0) {
// Store playload length and continue encoding
_ec.length = dynamic_cast<const OCTETSTRING &>(type).lengthof();
loggers::get_instance().log("GeoNetworkingCodec::encode_: Storing payload length %d for %s", _ec.length, field_descriptor.name);
}
type.encode(field_descriptor, encoding_buffer, TTCN_EncDec::CT_RAW);
}
loggers::get_instance().log_to_hexa("<<<GeoNetworkingCodec::encode_: encoding_buffer=", encoding_buffer);
return 0;
}
......@@ -108,7 +98,7 @@ int GeoNetworkingCodec::decode (const OCTETSTRING& data, LibItsGeoNetworking__Ty
loggers::get_instance().log_to_hexa(">>> GeoNetworkingCodec::decode: decoding_buffer=", decoding_buffer);
decode_(msg, *msg.get_descriptor(), decoding_buffer);
loggers::get_instance().log("GeoNetworkingCodec::decode: After decoding, , payload: plLength=%d", _dc.length);
loggers::get_instance().log("GeoNetworkingCodec::decode: After decoding, payload: plLength=%d", _dc.length);
// Set layer parameters
if (_params != NULL) {
(*_params)[Params::gn_next_header] = _dc.next_header;
......@@ -160,20 +150,7 @@ int GeoNetworkingCodec::decode_ (Base_Type& type, const TTCN_Typedescriptor_t& f
dynamic_cast<OPTIONAL<LibItsGeoNetworking__TypesAndValues::ExtendedHeader> &>(type).set_to_omit();
}
} else if (std::string(field_descriptor.name).compare("@LibItsGeoNetworking_TypesAndValues.GnNonSecuredPacket.payload") == 0) {
LibItsGeoNetworking__TypesAndValues::Payload p;
decode_(p, *p.get_descriptor(), decoding_buffer);
loggers::get_instance().log_msg("GeoNetworkingCodec::decode_: payload= ", p);
if (p.is_bound() && (p.rawPayload().lengthof() != 0)) {
dynamic_cast<OPTIONAL<LibItsGeoNetworking__TypesAndValues::Payload> &>(type) = OPTIONAL<LibItsGeoNetworking__TypesAndValues::Payload>(p);
loggers::get_instance().log_msg("GeoNetworkingCodec::decode_: Set OPTIONAL<Payload> to ", type);
} else {
loggers::get_instance().log("GeoNetworkingCodec::decode_: Set OPTIONAL<Payload> to omit");
dynamic_cast<OPTIONAL<LibItsGeoNetworking__TypesAndValues::Payload> &>(type).set_to_omit();
}
} else if (std::string(field_descriptor.name).compare("@LibItsGeoNetworking_TypesAndValues.Payload.decodedPayload") == 0) {
dynamic_cast<OPTIONAL<LibItsGeoNetworking__TypesAndValues::DecodedPayload> &>(type).set_to_omit();
} else if (std::string(field_descriptor.name).compare("@LibItsGeoNetworking_TypesAndValues.Payload.rawPayload") == 0) {
// Decode RawPayload data structure
// Decode raw payload data structure
OCTETSTRING s(decoding_buffer.get_len() - decoding_buffer.get_pos(), decoding_buffer.get_data() + decoding_buffer.get_pos());
loggers::get_instance().log_msg("GeoNetworkingCodec::decode_: s=", s);
const unsigned char * p = static_cast<const unsigned char *>(s);
......@@ -198,7 +175,13 @@ int GeoNetworkingCodec::decode_ (Base_Type& type, const TTCN_Typedescriptor_t& f
_dc.payload.clear();
}
loggers::get_instance().log("GeoNetworkingCodec::decode_: Payload: '%s'", _dc.payload.c_str());
dynamic_cast<OCTETSTRING &>(type) = os;
if (os.lengthof() != 0) {
dynamic_cast<OPTIONAL<LibItsGeoNetworking__TypesAndValues::GnRawPayload> &>(type) = OPTIONAL<LibItsGeoNetworking__TypesAndValues::GnRawPayload>(os);
loggers::get_instance().log_msg("GeoNetworkingCodec::decode_: Set OPTIONAL<GnRawPayload> to ", type);
} else {
loggers::get_instance().log("GeoNetworkingCodec::decode_: Set OPTIONAL<GnRawPayload> to omit");
dynamic_cast<OPTIONAL<LibItsGeoNetworking__TypesAndValues::GnRawPayload> &>(type).set_to_omit();
}
} else if (std::string(field_descriptor.name).compare("@LibItsGeoNetworking_TypesAndValues.CommonHeader.plLength") == 0) {
// Decode plLength data structure
type.decode(field_descriptor, decoding_buffer, TTCN_EncDec::CT_RAW);
......@@ -265,28 +248,6 @@ int GeoNetworkingCodec::encode_extendedHeader(const LibItsGeoNetworking__TypesAn
return result;
}
int GeoNetworkingCodec::encode_decodedPayload(const LibItsGeoNetworking__TypesAndValues::DecodedPayload& u, TTCN_Buffer& encoding_buffer) {
loggers::get_instance().log(">>> GeoNetworkingCodec::encode_decodedPayload: processing %s", u.get_descriptor()->name);
int result = -1;
switch (u.get_selection()) {
case LibItsGeoNetworking__TypesAndValues::DecodedPayload::UNBOUND_VALUE:
TTCN_error("GeoNetworkingCodec::encode_decodedPayload: Invalid selection in unbound union");
break;
case LibItsGeoNetworking__TypesAndValues::DecodedPayload::ALT_ipv6Packet:
loggers::get_instance().log("GeoNetworkingCodec::encode_decodedPayload: processing type %s", u.ipv6Packet().get_descriptor()->name);
//result = encode_(u.geoUnicastHeader(), LibItsGeoNetworking__TypesAndValues::DecodedPayload_ipv6Packet_descr_, encoding_buffer);
break;
case LibItsGeoNetworking__TypesAndValues::DecodedPayload::ALT_btpPacket:
loggers::get_instance().log("GeoNetworkingCodec::encode_decodedPayload: processing type %s", u.btpPacket().get_descriptor()->name);
//result = encode_(u.geoUnicastHeader(), LibItsGeoNetworking__TypesAndValues::DecodedPayload_btpPacket_descr_, encoding_buffer);
break;
default: TTCN_error("GeoNetworkingCodec::encode_decodedPayload: Invalid selection in union is_bound");
} // End of 'switch' statement
return result;
}
int GeoNetworkingCodec::decode_headerTST(LibItsGeoNetworking__TypesAndValues::HeaderTST& u, TTCN_Buffer& decoding_buffer) {
loggers::get_instance().log(">>> GeoNetworkingCodec::decode_headerTST: processing %s", u.get_descriptor()->name);
......
......@@ -49,7 +49,6 @@ class GeoNetworkingCodec : public Codec<LibItsGeoNetworking__TypesAndValues::Geo
int encode_ (const Base_Type& type, const TTCN_Typedescriptor_t& field_descriptor, TTCN_Buffer& encoding_buffer);
int encode_extendedHeader(const LibItsGeoNetworking__TypesAndValues::ExtendedHeader& u, TTCN_Buffer& encoding_buffer);
int encode_decodedPayload(const LibItsGeoNetworking__TypesAndValues::DecodedPayload& u, TTCN_Buffer& encoding_buffer);
int decode_ (Base_Type& type, const TTCN_Typedescriptor_t& field_descriptor, TTCN_Buffer& decoding_buffer);
int decode_headerTST(LibItsGeoNetworking__TypesAndValues::HeaderTST& u, TTCN_Buffer& decoding_buffer);
......
......@@ -7,11 +7,28 @@
using namespace LibItsGeoNetworking__TypesAndValues;
GeoNetworkingLayer::GeoNetworkingLayer(const std::string & p_type, const std::string & param) : TLayer<LibItsGeoNetworking__TestSystem::GeoNetworkingPort>(p_type), _params(), _codec(), _beacon(NULL), _thread(NULL), _running(FALSE) {
GeoNetworkingLayer::GeoNetworkingLayer(const std::string & p_type, const std::string & param) : TLayer<LibItsGeoNetworking__TestSystem::GeoNetworkingPort>(p_type), _params(), _codec(), _beacon(NULL), _thread(NULL), _sendData(), _running(FALSE) {
loggers::get_instance().log(">>> GeoNetworkingLayer::GeoNetworkingLayer: %s, %s", to_string().c_str(), param.c_str());
// Setup parameters
Params::convert(_params, param);
Params::const_iterator it = _params.find("mac_bc");
// Sanity checks
INTEGER latitude;
Params::const_iterator it = _params.find(Params::latitude);
if (it != _params.cend()) {
latitude = str2int(CHARSTRING(it->second.c_str()));
}
INTEGER longitude;
it = _params.find(Params::longitude);
if (it != _params.cend()) {
longitude = str2int(CHARSTRING(it->second.c_str()));
}