raw_socket_layer.hh
Go to the documentation of this file.
#pragma once
#include <sys/types.h>
#include <sys/socket.h>
#if !defined(LINUX)
#include <netdb.h>
#else // LINUX
#include <netinet/ether.h> // Used for raw sockets
#include <net/ethernet.h> // Used for raw sockets
#include <linux/if_packet.h> // Used for raw sockets
#endif // LINUX
#include <netinet/in.h>
#include <netinet/udp.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <net/if.h> // Used for raw sockets
#include "t_layer.hh"
#include "Params.hh"
class OCTETSTRING;
class PORT;
class raw_socket_layer : public layer, public PORT {
Params _params;
int _socket;
std::string _time_key;
struct ifreq _if_interface;
struct ifreq _if_mac_addr;
std::vector<unsigned char> _mac_src;
std::vector<unsigned char> _mac_bc;
std::vector<unsigned char> _eth_type;
public:
raw_socket_layer(const std::string& p_type, const std::string& param);
virtual ~raw_socket_layer();
virtual void send_data(OCTETSTRING& data, Params& params);
virtual void receive_data(OCTETSTRING& data, Params& info);
void Handle_Fd_Event_Readable(int fd);
}; // End of class raw_socket_layer
raw_socket_layer::~raw_socket_layer
virtual ~raw_socket_layer()
Default destructor.
Definition: raw_socket_layer.cc:87
raw_socket_layer::Handle_Fd_Event_Readable
void Handle_Fd_Event_Readable(int fd)
Definition: raw_socket_layer.cc:133
layer
Forward declaration of TITAN class.
Definition: layer.hh:29
raw_socket_layer::_if_interface
struct ifreq _if_interface
Definition: raw_socket_layer.hh:42
raw_socket_layer::_mac_bc
std::vector< unsigned char > _mac_bc
MAC address.
Definition: raw_socket_layer.hh:45
raw_socket_layer
Definition: raw_socket_layer.hh:38
raw_socket_layer::_if_mac_addr
struct ifreq _if_mac_addr
NIC interface description.
Definition: raw_socket_layer.hh:43
raw_socket_layer::_eth_type
std::vector< unsigned char > _eth_type
MAC broadcast address.
Definition: raw_socket_layer.hh:46
raw_socket_layer::raw_socket_layer
raw_socket_layer(const std::string &p_type, const std::string &param)
Ethernet type.
Definition: raw_socket_layer.cc:15
raw_socket_layer::receive_data
virtual void receive_data(OCTETSTRING &data, Params &info)
Receive bytes formated data from the lower layers.
Definition: raw_socket_layer.cc:125
Params.hh
Header file for the parameter dictionary.
raw_socket_layer::send_data
virtual void send_data(OCTETSTRING &data, Params &params)
Send bytes formated data to the lower layers.
Definition: raw_socket_layer.cc:95
Params
This class provides basic functionalities for an ITS dictionary.
Definition: Params.hh:21
raw_socket_layer::_socket
int _socket
Layer parameters.
Definition: raw_socket_layer.hh:40
raw_socket_layer::_params
Params _params
Definition: raw_socket_layer.hh:39
raw_socket_layer::_mac_src
std::vector< unsigned char > _mac_src
NIC interface description.
Definition: raw_socket_layer.hh:44
raw_socket_layer::_time_key
std::string _time_key
Socket identifier.
Definition: raw_socket_layer.hh:41
t_layer.hh
Header file for ITS abstract protocol layer definition.