#include <RawSocket.hpp>
Public Member Functions | |
RawSocket (std::string iface, bool isWrite=false) | |
RawSocket (const RawSocket &)=delete | |
Copy constructor. | |
RawSocket (RawSocket &&)=delete | |
Move constructor. | |
RawSocket & | operator= (RawSocket)=delete |
Copy assignment operator. | |
RawSocket & | operator= (RawSocket &&)=delete |
Move assignment operator. | |
const std::string & | getInterfaceName () const |
int | writeData (const unsigned char *data, size_t dataLen) |
int | readData (unsigned char *data, size_t dataLen) |
RawSocketStats | getStats (bool resetInternalStats=false) |
~RawSocket () | |
Private Member Functions | |
void | init (int domain, int type, int protocol) |
Private Attributes | |
bool | _isReady {false} |
Ready flag. | |
bool | _writeMode {false} |
Mode indicator. True = Write, False = Read. | |
int | _sockFd {-1} |
Socket descriptor. | |
std::string | _iFace |
Currently used ethernet interface. | |
sockaddr_ll | _addr {} |
Socket structure. | |
RawSocketStats | _stats {} |
Internal structure for statistics. | |
Raw socket reads and writes binary data to the provided interface. Write operations do not modify any field (MAC, IP, etc.). They only write the full data directly, similar to file write operations.
Definition at line 23 of file RawSocket.hpp.
|
explicit |
Construct a new RawSocket object
[in] | iface | Ethernet interface |
[in] | isWrite | True if write mode, false if read mode is requested |
Definition at line 30 of file RawSocket.cpp.
|
delete |
Copy constructor.
|
delete |
Move constructor.
RawSocket::~RawSocket | ( | ) |
|
inlinenodiscard |
Returns the binded ethernet interface
Definition at line 64 of file RawSocket.hpp.
RawSocketStats RawSocket::getStats | ( | bool | resetInternalStats = false | ) |
Get the statistics of the class
[in] | resetInternalStats | Whether the internal statistics structure should be reset after being returned |
Definition at line 100 of file RawSocket.cpp.
|
private |
Definition at line 17 of file RawSocket.cpp.
int RawSocket::readData | ( | unsigned char * | data, |
size_t | dataLen ) |
Reads data from the interface
[out] | data | User-allocated data |
[out] | dataLen | Length of the data |
Definition at line 80 of file RawSocket.cpp.
int RawSocket::writeData | ( | const unsigned char * | data, |
size_t | dataLen ) |
Writes data to the interface
[in] | data | Full payload data to write |
[in] | dataLen | Length of the data |
Definition at line 63 of file RawSocket.cpp.
|
private |
|
private |
Currently used ethernet interface.
Definition at line 32 of file RawSocket.hpp.
|
private |
|
private |
|
private |
|
private |