ETSI STF525 / Internal Testing test suite This project provides an internal testing test suite and its associated Test Adapter/Codec

geonetworking_layer.hh
Go to the documentation of this file.
1
11 #pragma once
12
13 #include <unistd.h>
14 #include <signal.h>
15 #include <time.h>
16
17 #include <mutex>
18
19 #include "t_layer.hh"
20 #include "GeoNetworkingCodec.hh"
21 #include "location_table.hh"
22
23 class INTEGER;
24 class OCTETSTRING;
25
26 namespace LibItsGeoNetworking__TestSystem {
27 class GeoNetworkingPort;
28 class GeoNetworkingReq;
29 class GeoNetworkingInd;
30 }
31
32 namespace LibItsGeoNetworking__TypesAndValues {
33 class GeoNetworkingPdu;
34 class BeaconHeader;
35 class LongPosVector;
36 class GN__Address;
37 }
38
39 // TODO Change pointers into smart pointers
44 class geonetworking_layer : public t_layer<LibItsGeoNetworking__TestSystem::GeoNetworkingPort> {
45 Params _params;
46 GeoNetworkingCodec _codec;
47 LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu* _beacon;
48 LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu* _gbc_packet;
49 LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu* _shb_packet;
50 LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu* _tsb_packet;
51 LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu* _ls_reply;
52 location_table _location_table;
53 location_table _pass_beacon_table;
54 bool _device_mode;
55 bool _secured_mode;
56 bool _encrypted_mode;
57 bool _enable_security_checks;
58 std::mutex _sendData; // FIXME To be removed, useless
59 timer_t _timerid;
60 struct sigevent _sev;
61 struct itimerspec _its;
62 long long _freq_nanosecs;
63 sigset_t _mask;
64 struct sigaction _sa;
65 unsigned int _sequence_number;
66 int _latitude;
67 int _longitude;
68
76 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);
84 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);
92 void fill_shb_packet(const OCTETSTRING& p_ll_address);
102 void fill_tsb_packet(const OCTETSTRING& p_ll_address, const int p_hop_number = 3, const int p_max_hop_limit = 5);
110 void fill_ls_reply(const OCTETSTRING& p_ll_address);
111
112 static void timer_irq_sigalrm_handler(int p_signal, siginfo_t *p_signal_info, void *p_uc);
113
114 const int _signal_id = SIGTERM;
115
116 public:
117 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} { };
118 geonetworking_layer(const std::string& p_type, const std::string& param);
119 virtual ~geonetworking_layer();
120
127 void sendMsg(const LibItsGeoNetworking__TestSystem::GeoNetworkingReq& p_gn_req, Params& p_param);
128
136 virtual void send_data(OCTETSTRING& data, Params& params);
144 virtual void receive_data(OCTETSTRING& data, Params& info);
145
153 virtual OCTETSTRING trigger_ac_event(OCTETSTRING& data, Params& params);
154
155 const LibItsGeoNetworking__TypesAndValues::LongPosVector* get_lpv(const LibItsGeoNetworking__TypesAndValues::GN__Address& p_gn_address);
156 void start_beaconing();
157 void start_beaconing(const LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu& p_beacon);
158 void stop_beaconing();
159 void start_pass_beaconing(const LibItsGeoNetworking__TypesAndValues::BeaconHeader& p_beacon);
160 void stop_pass_beaconing();
161
162 int enable_secured_mode(const std::string& p_certificate_id, const boolean p_enforce_security = false);
163 int disable_secured_mode();
164
165 private:
166 void send_beacon();
167 int build_geonetworking_pdu(OCTETSTRING& data, Params& params);
168 int build_secured_pdu(OCTETSTRING& data, Params& params);
169 int decode_basic_header(const OCTETSTRING& p_data, LibItsGeoNetworking__TypesAndValues::BasicHeader& p_basic_header);
170 int setup_secured_mode();
171
172 }; // End of class geonetworking_layer
173
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.