Kea  2.1.6-git
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. More...
 
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. More...
 
virtual Pkt4Ptr receive (Iface &iface, const SocketInfo &socket_info)
 Receive packet over specified socket. More...
 
virtual int send (const Iface &iface, uint16_t sockfd, const Pkt4Ptr &pkt)
 Send packet over specified socket. More...
 
- Public Member Functions inherited from isc::dhcp::PktFilter
virtual ~PktFilter ()
 Virtual Destructor. More...
 

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. More...
 

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.

References openSocket(), receive(), and send().

+ Here is the call graph for this function:

◆ 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 24 of file pkt_filter_inet.cc.

References isc::dhcp::Iface::flag_broadcast_, isc::dhcp::Iface::getName(), isc_throw, and isc::asiolink::IOAddress::toUint32().

Referenced by isDirectResponseSupported().

+ 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 107 of file pkt_filter_inet.cc.

References isc::dhcp::Iface::getIndex(), isc::dhcp::Iface::getName(), isc_throw, isc::dhcp::SocketInfo::port_, and isc::dhcp::SocketInfo::sockfd_.

Referenced by isDirectResponseSupported().

+ Here is the call graph for this function:

◆ 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 209 of file pkt_filter_inet.cc.

References isc_throw.

Referenced by isDirectResponseSupported().


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