pcap_layer.hh
Go to the documentation of this file.
#pragma once
#if (OSTYPE == linux)
#include <thread>
#include <mutex>
#include <pcap/pcap.h>
#include "t_layer.hh"
#include "Params.hh"
class PORT;
class pcap_layer : public layer, public PORT {
Params _params;
pcap_t* _device;
int _pcap_h;
std::thread* _thread;
bool _running;
std::mutex _resume;
pcap_dumper_t* _sent_file;
std::string _time_key;
int _fd[2];
static void* run(void* p_this);
public:
pcap_layer(const std::string& p_type, const std::string& param);
virtual ~pcap_layer();
virtual void send_data(OCTETSTRING& data, Params& params);
virtual void receive_data(OCTETSTRING& data, Params& info);
void Handle_Fd_Event_Readable(int fd);
};
#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