Commit cf2b30d8 authored by garciay's avatar garciay
Browse files

STF525: Doxygen help support

parent 06343993
......@@ -270,19 +270,12 @@ namespace LibItsSecurity__Functions
p__tag = OCTETSTRING(ec.tag().size(), ec.tag().data());
loggers::get_instance().log_to_hexa("fx__encryptWithEciesNistp256WithSha256: p__tag: ", p__tag);
// Encrypt symmetric key
// Encrypt the symmetric key
OCTETSTRING encSymKey = OCTETSTRING(ec.nonce().size(), ec.symmetric_encryption_key().data());
loggers::get_instance().log_to_hexa("fx__encryptWithEciesNistp256WithSha256: p__encSymKey: ", encSymKey);
// Create new instance of ECC
// 1. Create new instance of ECC
security_ecc ec_ecies(ec_elliptic_curves::nist_p_256);
// Generate (Private,Public) keys
// 2. Generate (Private,Public) keys
ec_ecies.generate();
// Generate ephemeral key and derive it
std::vector<unsigned char> peer_public_key_x(static_cast<const unsigned char *>(p__peerPublicKeyX), p__peerPublicKeyX.lengthof() + static_cast<const unsigned char *>(p__peerPublicKeyX));
......@@ -294,7 +287,7 @@ namespace LibItsSecurity__Functions
loggers::get_instance().warning("fx__encryptWithEciesNistp256WithSha256: Failed to generate and derive sender's ephemeral key");
return OCTETSTRING();
}
// Encrypt the symmetric encryption key using existing nonce and symmetric encryption key
// 3. Encrypt the symmetric encryption key using existing nonce and symmetric encryption key
std::vector<unsigned char> enc_eph_key;
if (ec.encrypt(encryption_algotithm::aes_128_ccm, ec_ecies.ephemeral_key(), ec.nonce(), ec.symmetric_encryption_key(), enc_eph_key) == -1) {
loggers::get_instance().warning("fx__encryptWithEciesNistp256WithSha256: Failed to encrypt message");
......@@ -312,7 +305,9 @@ namespace LibItsSecurity__Functions
}
OCTETSTRING fx__decryptWithEciesNistp256WithSha256(const OCTETSTRING& p__encryptedSecuredMessage, const OCTETSTRING& p__publicKeyX, const OCTETSTRING& p__publicKeyY, const OCTETSTRING& p__nonce, const OCTETSTRING& p__tag) {
OCTETSTRING os;
OCTETSTRING os;
os = OCTETSTRING();
......
/*!
* \file t_layer.hh
* \brief Header file for ITS abstract protocol layer definition.
* \author ETSI STF525
* \copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
* The copyright and the foregoing restriction extend to reproduction in all media.
* All rights reserved.
* \version 0.1
*/
#pragma once
#include "Layer.hh"
template <typename TPort> class TLayer : public Layer {
typedef std::vector<TPort*> TPortList;
typedef typename std::vector<TPort*>::iterator TPortListIterator;
TPortList upperPorts;
public:
explicit TLayer() : Layer(), upperPorts() { };
explicit TLayer(const std::string& p_type) : Layer(p_type), upperPorts() { };
void addUpperPort(TPort * p_port) { upperPorts.push_back(p_port); };
void removeUpperPort(TPort*);
protected:
template <typename TMessage>
inline void toAllUpperPorts(const TMessage& m, const Params& param) {
for(TPortListIterator it=upperPorts.begin(); it<upperPorts.end(); ++it){
(*it)->receiveMsg(m, param);
}
}
}; // End of class TLayer
......@@ -23,12 +23,12 @@ class CHARSTRING; //! Forward declaration of TITAN class
class INTEGER; //! Forward declaration of TITAN class
/*!
* \class Layer
* \class layer
* \brief This class provides basic description of an ITS protocol layer
*/
class Layer {
std::vector<Layer*> upperLayers; //! List of the upper protocol layers
std::vector<Layer*> lowerLayers; //! List of the lower protocol layers
class layer {
std::vector<layer*> upperLayers; //! List of the upper protocol layers
std::vector<layer*> lowerLayers; //! List of the lower protocol layers
protected:
std::string type; //! Type description, it indicates the protocol type (e.g. CAM, DENM, GN, ETH, PCAP...)
......@@ -36,47 +36,45 @@ protected:
public: //! \publicsection
/*!
* \brief Default constructor
* Create a new instance of the Layer class
* \todo Remove logs
* Create a new instance of the layer class
*/
explicit Layer() : upperLayers(), lowerLayers(), type(std::string("")) { };
explicit layer() : upperLayers(), lowerLayers(), type(std::string("")) { };
/*!
* \brief Specialized constructor
* Create a new instance of the Layer class with its type description
* \remark This constructor is called by the Layer factory
* Create a new instance of the layer class with its type description
* \param[in] p_type The port type name (e.g. GN for the GeoNetworking layer)
* \remark This constructor is called by the layer factory
* \see layer_factory
* \todo Remove logs
*/
explicit Layer(const std::string& p_type) : upperLayers(), lowerLayers(), type(std::string(p_type.begin(), p_type.end())) { };
explicit layer(const std::string& p_type) : upperLayers(), lowerLayers(), type(std::string(p_type.begin(), p_type.end())) { };
/*!
* \brief Default destructor
* \todo Remove logs
*/
virtual ~Layer() {
virtual ~layer() {
// Double linked list, only remove layers in lowerLayers from the lowest one
std::for_each(lowerLayers.rbegin(), lowerLayers.rend(), [](Layer* it) { delete it; } );
std::for_each(lowerLayers.rbegin(), lowerLayers.rend(), [](layer* it) { delete it; } );
lowerLayers.clear();
upperLayers.clear();
};
/*!
* \fn void deleteLayer();
* \fn void delete_layer();
* \brief Delete this layer
* \todo To be done
* \todo To be implemented
*/
void deleteLayer() { };
void delete_layer() { };
public: //! \publicsection
/*!
* \inline
* \fn void addUpperLayer(Layer* p_layer);
* \fn void add_upper_layer(layer* p_layer);
* \brief Add a new layer in the list of the upper layer
* \param[in] p_layer The layer protocol to be removed
* \todo Remove logs
*/
inline void addUpperLayer(Layer* p_layer) {
inline void add_upper_layer(layer* p_layer) {
if (p_layer != NULL) {
upperLayers.push_back(p_layer);
p_layer->lowerLayers.push_back(this);
......@@ -84,34 +82,34 @@ public: //! \publicsection
};
/*!
* \fn void removeUpperLayer(Layer* p_layer);
* \fn void remove_upper_layer(layer* p_layer);
* \brief Remove the specified upper layer protocol from the list of the upper layer
* \param[in] p_layer The layer protocol to be removed
* \todo To be implemented
*/
void removeUpperLayer(Layer* p_layer) { };
void remove_upper_layer(layer* p_layer) { };
/*!
* \virtual
* \fn void sendData(OCTETSTRING& data, Params& params);
* \fn void send_data(OCTETSTRING& data, Params& params);
* \brief Send bytes formated data to the lower layers
* \param[in] p_data The data to be sent
* \param[in] p_params Some parameters to overwrite default value of the lower layers parameters
* \todo Remove the logs
* \virtual
*/
virtual void sendData(OCTETSTRING& p_data, Params& p_params) { };
virtual void send_data(OCTETSTRING& p_data, Params& p_params) { };
/*!
* \virtual
* \fn void receiveData(OCTETSTRING& data, Params& params);
* \fn void receive_data(OCTETSTRING& data, Params& params);
* \brief Receive bytes formated data from the lower layers
* \param[in] p_data The bytes formated data received
* \param[in] p_params Some lower layers parameters values when data was received
* \todo Remove the logs
* \virtual
*/
virtual void receiveData(OCTETSTRING& p_data, Params& p_params) { }
virtual void receive_data(OCTETSTRING& p_data, Params& p_params) { }
/*!
* \inline
......@@ -122,25 +120,25 @@ public: //! \publicsection
inline const std::string& to_string() const { return type; };
protected: //! \protectedsection
inline void toAllLayers(std::vector<Layer*>&layers, OCTETSTRING& data, Params& params) {
for (std::vector<Layer*>::const_iterator it = layers.cbegin(); it != layers.cend(); ++it) {
Layer * p = *it;
p->receiveData(data, params); // FIXME BUG I
inline void to_all_layers(std::vector<layer*>&layers, OCTETSTRING& data, Params& params) {
for (std::vector<layer*>::const_iterator it = layers.cbegin(); it != layers.cend(); ++it) {
layer* p = *it;
p->receive_data(data, params); // FIXME BUG I
} // End of 'for' statement
};
inline void receiveToAllLayers(OCTETSTRING& data, Params& params) {
for (std::vector<Layer*>::const_iterator it = upperLayers.cbegin(); it != upperLayers.cend(); ++it) {
Layer * p = *it;
p->receiveData(data, params);
inline void receive_to_all_layers(OCTETSTRING& data, Params& params) {
for (std::vector<layer*>::const_iterator it = upperLayers.cbegin(); it != upperLayers.cend(); ++it) {
layer* p = *it;
p->receive_data(data, params);
} // End of 'for' statement
};
inline void sendToAllLayers(OCTETSTRING& data, Params& params) {
for (std::vector<Layer*>::const_iterator it = lowerLayers.cbegin(); it != lowerLayers.cend(); ++it) {
Layer * p = *it;
p->sendData(data, params);
inline void send_to_all_layers(OCTETSTRING& data, Params& params) {
for (std::vector<layer*>::const_iterator it = lowerLayers.cbegin(); it != lowerLayers.cend(); ++it) {
layer* p = *it;
p->send_data(data, params);
} // End of 'for' statement
};
}; // End of class Layer
}; // End of class layer
......@@ -15,11 +15,11 @@
#include <vector>
#include <algorithm>
#include "Layer.hh"
#include "layer.hh"
/*!
* \class layer_factory
* \brief This class provides a factory class to create Layer class instances
* \brief This class provides a factory class to create layer class instances
* \abstract
*/
class layer_factory {
......@@ -30,25 +30,25 @@ public: //! \publicsection
*/
layer_factory() {};
/*!
* \fn Layer * create_layer(const std::string & type, const std::string & param);
* \fn layer* create_layer(const std::string & type, const std::string & param);
* \brief Create the layers stack based on the provided layers stack description (cf. remark)
* \param[in] p_type The provided layers stack description
* \param[in] p_params Optional parameters
* \return 0 on success, -1 otherwise
* \remark The description below introduces layers stack in case of ITS project:
* CAM Layer
* CAM layer
* next_header : btpA|btpB (overwrite BTP.type)
* header_type : tsb|gbc
* header_sub_type : sh (single hop)
* DENM Layer
* DENM layer
* next_header : btpA|btpB (overwrite BTP.type)
* header_type : tsb|gbc
* BTP Layer
* BTP layer
* type : btpA|btpB
* destination port: dst_port
* source port : src_port
* device_mode : Set to 1 if the layer shall encapsulate upper layer PDU
* GN Layer
* GN layer
* its_aid : ITS AID as defined by ETSI TS 102 965 V1.2.1. Default: 141
* ll_address : GeoNetworking address of the Test System
* latitude : latitude of the Test System
......@@ -109,6 +109,6 @@ NodeC.geoNetworkingPort.params := "GN(ll_address=70b3d5791b48,latitude=43551050,
* system.utPort.params := "UT_GN/UDP(dst_ip=192.168.1.1,dst_port=12346,src_ip=192.168.156.4,src_port=12345)/ETH(mac_src=026f8338c1e5,mac_dst=0A0027000011,eth_type=0800)/PCAP(mac_src=0800275c4959,nic=enp0s8,filter=and udp port 12346)"
* \pure
*/
virtual Layer* create_layer(const std::string & p_type, const std::string & p_params) = 0;
virtual layer* create_layer(const std::string & p_type, const std::string & p_params) = 0;
}; // End of class layer_factory
......@@ -21,7 +21,7 @@ private: //! \privatesection
typedef std::map<std::string, layer_factory*> LayerFactoryMap;
static layer_stack_builder * _instance; //! Smart pointer to the unique instance of the logger framework
std::map<std::string, layer_factory*> _layer_factories; //! The list of the registered \see TLayer factories
std::map<std::string, layer_factory*> _layer_factories; //! The list of the registered \see t_layer factories
/*!
* \brief Default constructor
......@@ -57,11 +57,11 @@ private: //! \privatesection
public: //! \publicsection
/*!
* \fn Layer* create_layer_stack(const char* p_layer_stack_description);
* \fn layer* create_layer_stack(const char* p_layer_stack_description);
* \brief Add a new layer factory
* \param[in] p_layer_stack_description A textual description of the layer to create
* \return The created layer object on success, nullptr otherwise
*/
Layer* create_layer_stack(const char* p_layer_stack_description);
layer* create_layer_stack(const char* p_layer_stack_description);
}; // End of class layer_stack_builder
......@@ -28,12 +28,12 @@ void layer_stack_builder::_register_layer_factory(const std::string & p_type, la
_layer_factories[p_type] = p_layer_factory;
}
Layer* layer_stack_builder::create_layer_stack(const char* p_layer_stack_description)
layer* layer_stack_builder::create_layer_stack(const char* p_layer_stack_description)
{
loggers::get_instance().log(">>> layer_stack_builder::create_layer_stack: %s", p_layer_stack_description);
Layer * entry = NULL; // Initial layer (the first declared)
Layer * up = NULL; // Upper layer
layer* entry = NULL; // Initial layer (the first declared)
layer* up = NULL; // Upper layer
// Parse the layer description
try {
std::regex rgx ("(\\w+)(\\((.*?)\\))?(\\/|$)");
......@@ -48,13 +48,13 @@ Layer* layer_stack_builder::create_layer_stack(const char* p_layer_stack_descrip
loggers::get_instance().error("layer_stack_builder::create_layer_stack: %s: Unknown layer type", m[1].str().c_str());
}
loggers::get_instance().log("layer_stack_builder::create_layer_stack: Create layer %s, %s", m[1].str().c_str(), m[3].str().c_str());
Layer * l = i->second->create_layer(m[1].str(), m[3].str());
layer* l = i->second->create_layer(m[1].str(), m[3].str());
if (NULL == l) {
loggers::get_instance().error("layer_stack_builder::create_layer_stack: %s: Layer creation error", m[1].str().c_str());
}
loggers::get_instance().log("layer_stack_builder::create_layer_stack: Setup layers for %s", l->to_string().c_str());
l->addUpperLayer(up);
l->add_upper_layer(up);
if (entry == NULL) { // Set the first declared layer
entry = l;
}
......@@ -63,7 +63,7 @@ Layer* layer_stack_builder::create_layer_stack(const char* p_layer_stack_descrip
}
catch(const std::logic_error& e){
if(up){ // FIXME To be reviewed
up->deleteLayer();
up->delete_layer();
up = NULL;
}
}
......
/*!
* \file t_layer.hh
* \brief Header file for ITS abstract protocol layer definition.
* \author ETSI STF525
* \copyright ETSI Copyright Notification
* No part may be reproduced except as authorized by written permission.
* The copyright and the foregoing restriction extend to reproduction in all media.
* All rights reserved.
* \version 0.1
*/
#pragma once
#include "layer.hh"
/*!
* \class t_layer
* \brief This class provides basic description of an ITS port protocol layer.
* A port protocol layer is the final layer which provides the access to the physical communication channel
* A port protocol layer derives from both a layer class and a template port class
*/
template <typename TPort> class t_layer : public layer {
typedef std::vector<TPort*> TPortList;
typedef typename std::vector<TPort*>::iterator TPortListIterator;
TPortList upperPorts; //! The list of the upper ports
public: //! \publicsection
/*!
* \brief Default constructor
* Create a new instance of the t_layer class
* \todo Remove logs
*/
explicit t_layer() : layer(), upperPorts() { };
/*!
* \brief Specialized constructor
* Create a new instance of the layer class with its type description
* \param[in] p_type The port type name (e.g. TCP for the TCP sockect based layer)
* \remark This constructor is called by the layer factory
* \see layer_factory
*/
explicit t_layer(const std::string& p_type) : layer(p_type), upperPorts() { };
/*!
* \inline
* \fn void add_upper_port(TPort * p_port);
* \brief Add a new upper port layer
* \todo To be done
*/
inline void add_upper_port(TPort * p_port) { upperPorts.push_back(p_port); };
/*!
* \fn void remove_upper_port(TPort*);
* \brief Remove the specified upper layer port protocol from the list of the upper layers
* \param[in] p_layer The layer protocol to be removed
*/
void remove_upper_port(TPort*);
protected: //! \protectedsection
/*!
* \inline
* \fn void to_all_upper_ports(const TMessage& m, const Params& param);
* \brief Forward the message to all available upper port layers
* \param[in] p_message The message to be forwarded
* \param[in] p_params Some lower layers parameters values when data was received
*/
template <typename TMessage>
inline void to_all_upper_ports(const TMessage& p_message, const Params& p_params) {
for(TPortListIterator it=upperPorts.begin(); it<upperPorts.end(); ++it){
(*it)->receiveMsg(p_message, p_params);
}
}
}; // End of class t_layer
......@@ -59,7 +59,7 @@ namespace LibItsBtp__TestSystem {
if (static_cast<btp_layer *>(_layer) == NULL) {
loggers::get_instance().error("BtpPort::user_map: Invalid stack configuration: %s", it->second.c_str());
}
static_cast<btp_layer *>(_layer)->addUpperPort(this);
static_cast<btp_layer *>(_layer)->add_upper_port(this);
} else {
loggers::get_instance().error("BtpPort::user_map: No layers defined in configuration file");
}
......
......@@ -12,7 +12,7 @@
#include "LibItsBtp_TestSystem.hh"
#include "Layer.hh"
#include "layer.hh"
#include "Params.hh"
namespace LibItsBtp__TestSystem {
......@@ -20,7 +20,7 @@ namespace LibItsBtp__TestSystem {
class BtpPort : public BtpPort_BASE {
Params _cfg_params;
Params _layer_params;
Layer * _layer;
layer* _layer;
std::string _time_key;
public:
BtpPort(const char *par_port_name = NULL);
......
......@@ -64,7 +64,7 @@ namespace LibItsCam__TestSystem {
if (static_cast<cam_layer *>(_layer) == NULL) {
loggers::get_instance().error("CamPort::user_map: Invalid stack configuration: %s", it->second.c_str());
}
static_cast<cam_layer *>(_layer)->addUpperPort(this);
static_cast<cam_layer *>(_layer)->add_upper_port(this);
} else {
loggers::get_instance().error("CamPort::user_map: No layers defined in configuration file");
}
......
......@@ -12,7 +12,7 @@
#include "LibItsCam_TestSystem.hh"
#include "Layer.hh"
#include "layer.hh"
#include "Params.hh"
namespace LibItsCam__TestSystem {
......@@ -20,7 +20,7 @@ namespace LibItsCam__TestSystem {
class CamPort : public CamPort_BASE {
Params _cfg_params;
Params _layer_params;
Layer * _layer;
layer* _layer;
std::string _time_key;
public:
CamPort(const char *par_port_name = NULL);
......
......@@ -56,7 +56,7 @@ namespace LibItsCam__TestSystem {
if (static_cast<UpperTesterCamLayer *>(_layer) == NULL) {
loggers::get_instance().error("UpperTesterPort_Cam::user_map: Invalid stack configuration: %s", it->second.c_str());
}
static_cast<UpperTesterCamLayer *>(_layer)->addUpperPort(this);
static_cast<UpperTesterCamLayer *>(_layer)->add_upper_port(this);
} else {
loggers::get_instance().error("UpperTesterPort_Cam::user_map: No layers defined in configuration file");
}
......
#include "Layer.hh"
#include "layer.hh"
#include "Params.hh"
//=============================================================================
......@@ -8,7 +8,7 @@ namespace LibItsCam__TestSystem {
class UpperTesterPort : public UpperTesterPort_BASE {
Params _cfg_params;
Params _layer_params;
Layer * _layer;
layer* _layer;
std::string _time_key;
public:
......
......@@ -64,7 +64,7 @@ namespace LibItsDenm__TestSystem {
if (static_cast<denm_layer *>(_layer) == NULL) {
loggers::get_instance().error("DenmPort::user_map: Invalid stack configuration: %s", it->second.c_str());
}
static_cast<denm_layer *>(_layer)->addUpperPort(this);
static_cast<denm_layer *>(_layer)->add_upper_port(this);
} else {
loggers::get_instance().error("DenmPort::user_map: No layers defined in configuration file");
}
......
......@@ -12,7 +12,7 @@
#include "LibItsDenm_TestSystem.hh"
#include "Layer.hh"
#include "layer.hh"
#include "Params.hh"
namespace LibItsDenm__TestSystem {
......@@ -20,7 +20,7 @@ namespace LibItsDenm__TestSystem {
class DenmPort : public DenmPort_BASE {
Params _cfg_params;
Params _layer_params;
Layer * _layer;
layer* _layer;
std::string _time_key;
public:
DenmPort(const char *par_port_name = NULL);
......
......@@ -56,7 +56,7 @@ namespace LibItsDenm__TestSystem {
if (static_cast<UpperTesterDenmLayer *>(_layer) == NULL) {
loggers::get_instance().error("UpperTesterPort_Denm::user_map: Invalid stack configuration: %s", it->second.c_str());
}
static_cast<UpperTesterDenmLayer *>(_layer)->addUpperPort(this);
static_cast<UpperTesterDenmLayer *>(_layer)->add_upper_port(this);
} else {
loggers::get_instance().error("UpperTesterPort_Denm::user_map: No layers defined in configuration file");
}
......
#include "Layer.hh"
#include "layer.hh"
#include "Params.hh"
//=============================================================================
......@@ -8,7 +8,7 @@ namespace LibItsDenm__TestSystem {
class UpperTesterPort : public UpperTesterPort_BASE {
Params _cfg_params;
Params _layer_params;
Layer * _layer;
layer* _layer;
std::string _time_key;
public:
......
......@@ -67,7 +67,7 @@ namespace LibItsGeoNetworking__TestSystem {
if (static_cast<geonetworking_layer *>(_layer) == nullptr) {
loggers::get_instance().error("GeoNetworkingPort::user_map: Invalid stack configuration: %s", it->second.c_str());
}
static_cast<geonetworking_layer *>(_layer)->addUpperPort(this);
static_cast<geonetworking_layer *>(_layer)->add_upper_port(this);
} else {
loggers::get_instance().error("GeoNetworkingPort::user_map: No layers defined in configuration file");
......
......@@ -12,7 +12,7 @@
#include "LibItsGeoNetworking_TestSystem.hh"
#include "Layer.hh"
#include "layer.hh"
#include "Params.hh"
namespace LibItsGeoNetworking__TestSystem {
......@@ -20,7 +20,7 @@ namespace LibItsGeoNetworking__TestSystem {
class GeoNetworkingPort : public GeoNetworkingPort_BASE {
Params _cfg_params;
Params _layer_params;
Layer * _layer;
layer* _layer;
std::string _time_key;
public:
......
......@@ -57,7 +57,7 @@ namespace LibItsGeoNetworking__TestSystem {
if (static_cast<UpperTesterGnLayer *>(_layer) == NULL) {
loggers::get_instance().error("UpperTesterPort_Gn::user_map: Invalid stack configuration: %s", it->second.c_str());
}
static_cast<UpperTesterGnLayer *>(_layer)->addUpperPort(this);
static_cast<UpperTesterGnLayer *>(_layer)->add_upper_port(this);
} else {
loggers::get_instance().error("UpperTesterPort_Gn::user_map: No layers defined in configuration file");
}
......