Raw Packet-Socket access (Linux) More...

#include <senf/Socket/Protocols/Raw/PacketSocketHandle.hh>

Inheritance diagram for senf::PacketSocketProtocol:

Constructors

void init_client (SocketType type=RawSocket, int protocol=-1) const
 Create packet socket. More...
 

Additional Inherited Members

- Public Types inherited from senf::ConcreteSocketProtocol< Packet_Policy, PacketSocketProtocol >
typedef Packet_Policy Policy
 The protocols policy. More...
 
- Public Types inherited from senf::LinuxPacketSocketProtocol
enum  SocketType { RawSocket, DatagramSocket }
 
- Public Member Functions inherited from senf::ConcreteSocketProtocol< Packet_Policy, PacketSocketProtocol >
Policy const & policy () const
 Access the policy instance. More...
 
 ~ConcreteSocketProtocol ()=0
 
- Public Member Functions inherited from senf::SocketProtocol
virtual void close ()
 Close socket. More...
 
virtual void terminate () const
 Forcibly close socket. More...
 
virtual void state (SocketStateMap &map, unsigned lod) const
 Return socket state information. More...
 
int fd () const
 Get file descriptor. More...
 
 SocketProtocol ()
 
virtual ~SocketProtocol ()=0
 
- Public Member Functions inherited from senf::DatagramSocketProtocol
void timestamp (struct timespec *spec) const
 Return packet timestamp of last packet. More...
 
ClockService::clock_type timestamp () const
 Return packet timestamp of last packet. More...
 
- Public Member Functions inherited from senf::BSDSocketProtocol
std::pair< bool, unsigned > linger () const
 Return current linger status. More...
 
void linger (bool enable, unsigned timeout=0) const
 Change linger status. More...
 
boost::uint8_t priority () const
 Get packet priority assigned to outgoing packets. More...
 
void priority (boost::uint8_t value) const
 Set packet priority (e.g. TOS) More...
 
int error () const
 Get and clear pending socket error. More...
 
unsigned rcvbuf () const
 Check receive buffer size. More...
 
void rcvbuf (unsigned size) const
 Change receive buffer size. More...
 
unsigned sndbuf () const
 Check send buffer size. More...
 
void sndbuf (unsigned size) const
 Change size of send buffer. More...
 
template<unsigned short N>
void attachSocketFilter (::sock_filter(&filter)[N])
 
void detachSocketFilter ()
 
void mtuDiscovery (int mode) const
 
void rcvLowat (unsigned lowWat) const
 
void sndLowat (unsigned lowWat) const
 
- Public Member Functions inherited from senf::LinuxPacketSocketProtocol
void mcAdd (std::string const &interface, MACAddress const &address) const
 Enable reception of a multicast group. More...
 
void mcDrop (std::string const &interface, MACAddress const &address) const
 Disable reception of a multicast group. More...
 
void promisc (std::string const &interface, bool mode) const
 enable/disable promiscuous mode More...
 
unsigned rxQueueDropped () const
 packets dropped by kernel since last call More...
 
unsigned txWrongFormat () const
 packets dropped by kernel due to wrong format (too large) since last call More...
 
bool eof () const
 Check for end-of-file condition. More...
 
- Public Member Functions inherited from senf::ReadableLinuxPacketProtocol
unsigned available () const
 Return (maximum) number of bytes available for reading without < blocking. More...
 
- Protected Member Functions inherited from senf::ConcreteSocketProtocol< Packet_Policy, PacketSocketProtocol >
ClientSocketHandle< PolicyclientHandle () const
 Get client handle for associated socket. More...
 
ServerSocketHandle< PolicyserverHandle () const
 Get server handle for associated socket. More...
 
- Protected Member Functions inherited from senf::SocketProtocol
FileHandle fh () const
 Get a FileHandle for this instance. More...
 
void fd (int) const
 Initialize file descriptor. More...
 
- Protected Member Functions inherited from senf::LinuxPacketSocketProtocol
void init_packetSocket (SocketType type, int protocol) const
 

Detailed Description

Raw Packet-Socket access (Linux)

Socket Handle typedefs:
PacketSocketHandle (ProtocolClientSocketHandle)
Policy Interface:
ClientSocketHandle::read(), ClientSocketHandle::readfrom(), ClientSocketHandle::writeto(), ClientSocketHandle::bind(), ClientSocketHandle::local()
Address Type:
LLSocketAddress

The PacketSocketProtocol provides access to the linux packet socket API. This API gives access to the low level network packets. The packet socket allows read() and write() operations. The PacketSocketProtocol has no concept of a server socket.

This class is utilized as the protocol class of the ProtocolClientSocketHandle via the Socket Handle typedefs above.

Definition at line 69 of file PacketSocketHandle.hh.

Member Function Documentation

◆ init_client()

void senf::PacketSocketProtocol::init_client ( SocketType  type = RawSocket,
int  protocol = -1 
) const

Create packet socket.

The new socket will receive all packets of the given IEEE 802.3 protocol. The socket will receive all packets, if protocol is -1.

If type is RawSocket, the packet will include the link-level header (the Ethernet header). Sent packets must already include a well formed ll header.

If type is DatagramSocket, the link level header will not be part of the packet data. The ll header will be removed from received packets and a correct ll header will be created on sent packets.

Parameters
[in]typesocket type
[in]protocolIEEE 802.3 protocol number
Note
This member is implicitly called from the ProtocolClientSocketHandle::ProtocolClientSocketHandle() constructor

Definition at line 34 of file PacketSocketHandle.cc.


The documentation for this class was generated from the following files: