ETSI STF525 / Internal Testing test suite
This project provides an internal testing test suite and its associated Test Adapter/Codec
pcap_layer.hh
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #if (OSTYPE == linux)
14 
15 #include <thread>
16 #include <mutex>
17 #include <pcap/pcap.h>
18 
19 #include "t_layer.hh"
20 #include "Params.hh"
21 
22 class PORT;
23 
28 class pcap_layer : public layer, public PORT {
30  pcap_t* _device;
31  int _pcap_h;
32  std::thread* _thread;
33  bool _running;
34  std::mutex _resume;
35  pcap_dumper_t* _sent_file;
36  std::string _time_key;
37  int _fd[2];
38 
39  static void* run(void* p_this);
40 public:
41 
47  pcap_layer(const std::string& p_type, const std::string& param);
51  virtual ~pcap_layer();
52 
60  virtual void send_data(OCTETSTRING& data, Params& params);
68  virtual void receive_data(OCTETSTRING& data, Params& info);
69 
70  void Handle_Fd_Event_Readable(int fd);
71 };
72 
73 #endif
Forward declaration of TITAN class.
Definition: pcap_layer.hh:28
std::thread * _thread
PCAP instance handle.
Definition: pcap_layer.hh:32
int _fd[2]
Definition: pcap_layer.hh:37
Params _params
Definition: pcap_layer.hh:29
Forward declaration of TITAN class.
Definition: layer.hh:29
static void * run(void *p_this)
Definition: pcap_layer.cc:158
Header file for the parameter dictionary.
virtual void send_data(OCTETSTRING &data, Params &params)
Send bytes formated data to the lower layers.
Definition: pcap_layer.cc:196
pcap_t * _device
Layer parameters.
Definition: pcap_layer.hh:30
virtual ~pcap_layer()
Default destructor.
Definition: pcap_layer.cc:137
virtual void receive_data(OCTETSTRING &data, Params &info)
Receive bytes formated data from the lower layers.
Definition: pcap_layer.cc:217
std::mutex _resume
Set to true when the thread is running, used in file mode.
Definition: pcap_layer.hh:34
This class provides basic functionalities for an ITS dictionary.
Definition: Params.hh:21
pcap_layer(const std::string &p_type, const std::string &param)
Specialised constructor Create a new instance of the pcap_layer class.
Definition: pcap_layer.cc:15
bool _running
Thread handle, used to read PCAP file instead of NIC, used in file mode.
Definition: pcap_layer.hh:33
std::string _time_key
Write file handle to save sent packet, used in file mode.
Definition: pcap_layer.hh:36
void Handle_Fd_Event_Readable(int fd)
Definition: pcap_layer.cc:225
int _pcap_h
Device handle.
Definition: pcap_layer.hh:31
Header file for ITS abstract protocol layer definition.
pcap_dumper_t * _sent_file
Definition: pcap_layer.hh:35