Kea 2.7.4
isc::dhcp::PktFilterInet Class Reference

Packet handling class using AF_INET socket family. More...

#include <pkt_filter_inet.h>

+ Inheritance diagram for isc::dhcp::PktFilterInet:

Public Member Functions

virtual bool isDirectResponseSupported () const
 Check if packet can be sent to the host without address directly.
 
virtual bool isSocketReceivedTimeSupported () const
 Check if the socket received time is supported.
 
virtual SocketInfo openSocket (Iface &iface, const isc::asiolink::IOAddress &addr, const uint16_t port, const bool receive_bcast, const bool send_bcast)
 Open primary and fallback socket.
 
virtual Pkt4Ptr receive (Iface &iface, const SocketInfo &socket_info)
 Receive packet over specified socket.
 
virtual int send (const Iface &iface, uint16_t sockfd, const Pkt4Ptr &pkt)
 Send packet over specified socket.
 
- Public Member Functions inherited from isc::dhcp::PktFilter
virtual ~PktFilter ()
 Virtual Destructor.
 

Additional Inherited Members

- Protected Member Functions inherited from isc::dhcp::PktFilter
virtual int openFallbackSocket (const isc::asiolink::IOAddress &addr, const uint16_t port)
 Default implementation to open a fallback socket.
 

Detailed Description

Packet handling class using AF_INET socket family.

This class provides methods to send and receive packet via socket using AF_INET family and SOCK_DGRAM type.

Definition at line 20 of file pkt_filter_inet.h.

Member Function Documentation

◆ isDirectResponseSupported()

virtual bool isc::dhcp::PktFilterInet::isDirectResponseSupported ( ) const
inlinevirtual

Check if packet can be sent to the host without address directly.

This Packet Filter sends packets through AF_INET datagram sockets, so it can't inject the HW address of the destination host into the packet. Therefore this class does not support direct responses.

Returns
false always.

Implements isc::dhcp::PktFilter.

Definition at line 30 of file pkt_filter_inet.h.

◆ isSocketReceivedTimeSupported()

bool isc::dhcp::PktFilterInet::isSocketReceivedTimeSupported ( ) const
virtual

Check if the socket received time is supported.

If true, then packets received through this filter will include a SOCKET_RECEIVED event in its event stack.

Returns
True if SO_TIMESTAMP is defined.

Implements isc::dhcp::PktFilter.

Definition at line 23 of file pkt_filter_inet.cc.

◆ openSocket()

SocketInfo isc::dhcp::PktFilterInet::openSocket ( Iface & iface,
const isc::asiolink::IOAddress & addr,
const uint16_t port,
const bool receive_bcast,
const bool send_bcast )
virtual

Open primary and fallback socket.

Parameters
ifaceInterface descriptor.
addrAddress on the interface to be used to send packets.
portPort number.
receive_bcastConfigure socket to receive broadcast messages
send_bcastConfigure socket to send broadcast messages.
Returns
A structure describing a primary and fallback socket.
Exceptions
isc::dhcp::SocketConfigErrorif error occurs when opening, binding or configuring the socket.

Implements isc::dhcp::PktFilter.

Definition at line 32 of file pkt_filter_inet.cc.

References isc_throw, isc::asiolink::IOAddress::toText(), and isc::asiolink::IOAddress::toUint32().

+ Here is the call graph for this function:

◆ receive()

Pkt4Ptr isc::dhcp::PktFilterInet::receive ( Iface & iface,
const SocketInfo & socket_info )
virtual

Receive packet over specified socket.

Parameters
ifaceinterface
socket_infostructure holding socket information
Returns
Received packet
Exceptions
isc::dhcp::SocketReadErrorif an error occurs during reception of the packet.
Anexception thrown by the isc::dhcp::Pkt4 object if DHCPv4 message parsing fails.

Implements isc::dhcp::PktFilter.

Definition at line 124 of file pkt_filter_inet.cc.

References isc_throw, isc::dhcp::IfaceMgr::RCVBUFSIZE, and isc::dhcp::PktEvent::SOCKET_RECEIVED.

◆ send()

int isc::dhcp::PktFilterInet::send ( const Iface & iface,
uint16_t sockfd,
const Pkt4Ptr & pkt )
virtual

Send packet over specified socket.

This function will use local address specified in the pkt as a source address for the packet and the interface index to select the index through which the packet will be sent. However, if these values are not specified for the packet (zero IP address and negative interface index), this function will rely on the routing information to determine the right outbound interface and source address.

Parameters
ifaceinterface to be used to send packet
sockfdsocket descriptor
pktpacket to be sent
Returns
result of sending a packet. It is 0 if successful.
Exceptions
isc::dhcp::SocketWriteErrorif an error occurs during sending a DHCP message through the socket.

Implements isc::dhcp::PktFilter.

Definition at line 248 of file pkt_filter_inet.cc.

References isc_throw.


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