#pragma once

#include <sys/types.h>
#include <sys/socket.h>
#if (OSTYPE == linux)
#include <netinet/ether.h> // Used for raw sockets
#else
#endif
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <net/if.h> // Used for raw sockets
#if (OSTYPE == linux)
#include <net/ethernet.h> // Used for raw sockets
#include <linux/if_packet.h> // Used for raw sockets
#else
#endif

#include "TLayer.hh"
#include "Params.hh"

class OCTETSTRING;
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;
  OCTETSTRING _mac_src;
  OCTETSTRING _mac_bc;
  OCTETSTRING _eth_type;

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);
}; // End of class RawSocketLayer

