geonetworking_layer.hh
Go to the documentation of this file.
#pragma once
#include <unistd.h>
#include <signal.h>
#include <time.h>
#include <mutex>
#include "t_layer.hh"
#include "GeoNetworkingCodec.hh"
#include "location_table.hh"
class INTEGER;
class OCTETSTRING;
namespace LibItsGeoNetworking__TestSystem {
class GeoNetworkingPort;
class GeoNetworkingReq;
class GeoNetworkingInd;
}
namespace LibItsGeoNetworking__TypesAndValues {
class GeoNetworkingPdu;
class BeaconHeader;
class LongPosVector;
class GN__Address;
}
// TODO Change pointers into smart pointers
class geonetworking_layer : public t_layer<LibItsGeoNetworking__TestSystem::GeoNetworkingPort> {
Params _params;
GeoNetworkingCodec _codec;
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu* _beacon;
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu* _gbc_packet;
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu* _shb_packet;
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu* _tsb_packet;
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu* _ls_reply;
location_table _location_table;
location_table _pass_beacon_table;
bool _device_mode;
bool _secured_mode;
bool _encrypted_mode;
bool _enable_security_checks;
std::mutex _sendData; // FIXME To be removed, useless
timer_t _timerid;
struct sigevent _sev;
struct itimerspec _its;
long long _freq_nanosecs;
sigset_t _mask;
struct sigaction _sa;
unsigned int _sequence_number;
int _latitude;
int _longitude;
void fill_beacon(const OCTETSTRING& p_ll_address, const INTEGER p_station_type = 5, const INTEGER p_country = 0, const INTEGER type_of_address = 1);
void fill_gbc_packet(const OCTETSTRING& p_ll_address, const INTEGER& p_geoAreaPosLatitude, const INTEGER& p_geoAreaPosLongitude, const INTEGER& p_distanceA, const INTEGER& p_distanceB, const INTEGER& p_angle);
void fill_shb_packet(const OCTETSTRING& p_ll_address);
void fill_tsb_packet(const OCTETSTRING& p_ll_address, const int p_hop_number = 3, const int p_max_hop_limit = 5);
void fill_ls_reply(const OCTETSTRING& p_ll_address);
static void timer_irq_sigalrm_handler(int p_signal, siginfo_t *p_signal_info, void *p_uc);
const int _signal_id = SIGTERM;
public:
explicit geonetworking_layer() : t_layer<LibItsGeoNetworking__TestSystem::GeoNetworkingPort>(), _params(), _codec(), _beacon(NULL), _gbc_packet(NULL), _shb_packet(nullptr), _ls_reply(nullptr), _location_table(), _pass_beacon_table(), _device_mode{false}, _sendData(), _timerid{0}, _sev{0}, _its{0}, _freq_nanosecs(0), _mask{0}, _sa{0}, _sequence_number{0} { };
geonetworking_layer(const std::string& p_type, const std::string& param);
virtual ~geonetworking_layer();
void sendMsg(const LibItsGeoNetworking__TestSystem::GeoNetworkingReq& p_gn_req, Params& p_param);
virtual void send_data(OCTETSTRING& data, Params& params);
virtual void receive_data(OCTETSTRING& data, Params& info);
virtual OCTETSTRING trigger_ac_event(OCTETSTRING& data, Params& params);
const LibItsGeoNetworking__TypesAndValues::LongPosVector* get_lpv(const LibItsGeoNetworking__TypesAndValues::GN__Address& p_gn_address);
void start_beaconing();
void start_beaconing(const LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu& p_beacon);
void stop_beaconing();
void start_pass_beaconing(const LibItsGeoNetworking__TypesAndValues::BeaconHeader& p_beacon);
void stop_pass_beaconing();
int enable_secured_mode(const std::string& p_certificate_id, const boolean p_enforce_security = false);
int disable_secured_mode();
private:
void send_beacon();
int build_geonetworking_pdu(OCTETSTRING& data, Params& params);
int build_secured_pdu(OCTETSTRING& data, Params& params);
int decode_basic_header(const OCTETSTRING& p_data, LibItsGeoNetworking__TypesAndValues::BasicHeader& p_basic_header);
int setup_secured_mode();
}; // End of class geonetworking_layer
geonetworking_layer::_timerid
timer_t _timerid
Definition: geonetworking_layer.hh:59
t_layer
This class provides basic description of an ITS port protocol layer. A port protocol layer is the fin...
Definition: t_layer.hh:21
geonetworking_layer::_enable_security_checks
bool _enable_security_checks
Definition: geonetworking_layer.hh:57
geonetworking_layer::_beacon
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu * _beacon
Definition: geonetworking_layer.hh:47
LibItsGeoNetworking__TypesAndValues
Definition: geonetworking_layer.hh:32
location_table
This class provides description of GeoNetworking table.
Definition: location_table.hh:28
geonetworking_layer::_encrypted_mode
bool _encrypted_mode
Definition: geonetworking_layer.hh:56
geonetworking_layer::_gbc_packet
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu * _gbc_packet
Definition: geonetworking_layer.hh:48
geonetworking_layer::_codec
GeoNetworkingCodec _codec
Definition: geonetworking_layer.hh:46
geonetworking_layer::_secured_mode
bool _secured_mode
Definition: geonetworking_layer.hh:55
geonetworking_layer::_sequence_number
unsigned int _sequence_number
Definition: geonetworking_layer.hh:65
geonetworking_layer::_location_table
location_table _location_table
Definition: geonetworking_layer.hh:52
geonetworking_layer::_mask
sigset_t _mask
Definition: geonetworking_layer.hh:63
geonetworking_layer::_freq_nanosecs
long long _freq_nanosecs
Definition: geonetworking_layer.hh:62
Params
This class provides basic functionalities for an ITS dictionary.
Definition: Params.hh:21
geonetworking_layer::_sendData
std::mutex _sendData
Definition: geonetworking_layer.hh:58
geonetworking_layer::_device_mode
bool _device_mode
Definition: geonetworking_layer.hh:54
GeoNetworkingCodec.hh
geonetworking_layer
This class provides description of ITS GeoNetworking protocol layer.
Definition: geonetworking_layer.hh:44
LibItsGeoNetworking__TestSystem
Forward declaration of TITAN class.
Definition: GeoNetworkingPort.cc:14
GeoNetworkingCodec
Definition: GeoNetworkingCodec.hh:46
location_table.hh
Header file for GeoNetworking location table definition.
geonetworking_layer::_ls_reply
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu * _ls_reply
Definition: geonetworking_layer.hh:51
geonetworking_layer::geonetworking_layer
geonetworking_layer()
Definition: geonetworking_layer.hh:117
geonetworking_layer::_longitude
int _longitude
Definition: geonetworking_layer.hh:67
geonetworking_layer::_latitude
int _latitude
Definition: geonetworking_layer.hh:66
geonetworking_layer::_tsb_packet
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu * _tsb_packet
Definition: geonetworking_layer.hh:50
geonetworking_layer::_shb_packet
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu * _shb_packet
Definition: geonetworking_layer.hh:49
geonetworking_layer::_params
Params _params
Definition: geonetworking_layer.hh:45
geonetworking_layer::_pass_beacon_table
location_table _pass_beacon_table
Definition: geonetworking_layer.hh:53
t_layer.hh
Header file for ITS abstract protocol layer definition.