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 
27  class GeoNetworkingPort;
28  class GeoNetworkingReq;
29  class GeoNetworkingInd;
30 }
31 
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> {
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;
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;
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 
timer_t _timerid
Definition: geonetworking_layer.hh:59
This class provides basic description of an ITS port protocol layer. A port protocol layer is the fin...
Definition: t_layer.hh:21
bool _enable_security_checks
Definition: geonetworking_layer.hh:57
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu * _beacon
Definition: geonetworking_layer.hh:47
Definition: geonetworking_layer.hh:32
This class provides description of GeoNetworking table.
Definition: location_table.hh:28
bool _encrypted_mode
Definition: geonetworking_layer.hh:56
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu * _gbc_packet
Definition: geonetworking_layer.hh:48
GeoNetworkingCodec _codec
Definition: geonetworking_layer.hh:46
bool _secured_mode
Definition: geonetworking_layer.hh:55
unsigned int _sequence_number
Definition: geonetworking_layer.hh:65
location_table _location_table
Definition: geonetworking_layer.hh:52
sigset_t _mask
Definition: geonetworking_layer.hh:63
long long _freq_nanosecs
Definition: geonetworking_layer.hh:62
This class provides basic functionalities for an ITS dictionary.
Definition: Params.hh:21
std::mutex _sendData
Definition: geonetworking_layer.hh:58
bool _device_mode
Definition: geonetworking_layer.hh:54
This class provides description of ITS GeoNetworking protocol layer.
Definition: geonetworking_layer.hh:44
Forward declaration of TITAN class.
Definition: GeoNetworkingPort.cc:14
Definition: GeoNetworkingCodec.hh:46
Header file for GeoNetworking location table definition.
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu * _ls_reply
Definition: geonetworking_layer.hh:51
geonetworking_layer()
Definition: geonetworking_layer.hh:117
int _longitude
Definition: geonetworking_layer.hh:67
int _latitude
Definition: geonetworking_layer.hh:66
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu * _tsb_packet
Definition: geonetworking_layer.hh:50
LibItsGeoNetworking__TypesAndValues::GeoNetworkingPdu * _shb_packet
Definition: geonetworking_layer.hh:49
Params _params
Definition: geonetworking_layer.hh:45
location_table _pass_beacon_table
Definition: geonetworking_layer.hh:53
Header file for ITS abstract protocol layer definition.