RawSocketLayer.hh 870 Bytes
Newer Older
#pragma once

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/ether.h> // Used for raw sockets
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <net/if.h> // Used for raw sockets
#include <net/ethernet.h> // Used for raw sockets

#include <linux/if_packet.h> // Used for raw sockets

#include "Layer.hh"
#include "Params.hh"

class PORT;

class RawSocketLayer : public Layer, public PORT {
  Params _params;
  int _socket;
  std::string _time_key;
  struct ifreq _if_interface;
  struct ifreq _if_mac_addr;

public:
  RawSocketLayer(const std::string& p_type, const std::string& param);
  virtual ~RawSocketLayer();

  virtual void sendData(OCTETSTRING& data, Params& params);
  virtual void receiveData(OCTETSTRING& data, Params& info);
  
  void Handle_Fd_Event_Readable(int fd);
};