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 {
29 Params _params;
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
pcap_layer
Forward declaration of TITAN class.
Definition: pcap_layer.hh:28
pcap_layer::_thread
std::thread * _thread
PCAP instance handle.
Definition: pcap_layer.hh:32
pcap_layer::_fd
int _fd[2]
Definition: pcap_layer.hh:37
pcap_layer::_params
Params _params
Definition: pcap_layer.hh:29
layer
Forward declaration of TITAN class.
Definition: layer.hh:29
pcap_layer::run
static void * run(void *p_this)
Definition: pcap_layer.cc:158
Params.hh
Header file for the parameter dictionary.
pcap_layer::send_data
virtual void send_data(OCTETSTRING &data, Params &params)
Send bytes formated data to the lower layers.
Definition: pcap_layer.cc:196
pcap_layer::_device
pcap_t * _device
Layer parameters.
Definition: pcap_layer.hh:30
pcap_layer::~pcap_layer
virtual ~pcap_layer()
Default destructor.
Definition: pcap_layer.cc:137
pcap_layer::receive_data
virtual void receive_data(OCTETSTRING &data, Params &info)
Receive bytes formated data from the lower layers.
Definition: pcap_layer.cc:217
pcap_layer::_resume
std::mutex _resume
Set to true when the thread is running, used in file mode.
Definition: pcap_layer.hh:34
Params
This class provides basic functionalities for an ITS dictionary.
Definition: Params.hh:21
pcap_layer::pcap_layer
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
pcap_layer::_running
bool _running
Thread handle, used to read PCAP file instead of NIC, used in file mode.
Definition: pcap_layer.hh:33
pcap_layer::_time_key
std::string _time_key
Write file handle to save sent packet, used in file mode.
Definition: pcap_layer.hh:36
pcap_layer::Handle_Fd_Event_Readable
void Handle_Fd_Event_Readable(int fd)
Definition: pcap_layer.cc:225
pcap_layer::_pcap_h
int _pcap_h
Device handle.
Definition: pcap_layer.hh:31
t_layer.hh
Header file for ITS abstract protocol layer definition.
pcap_layer::_sent_file
pcap_dumper_t * _sent_file
Definition: pcap_layer.hh:35