Kea 2.7.5
isc::dhcp::IfaceMgr Class Reference

Handles network interfaces, transmission and reception. More...

#include <iface_mgr.h>

+ Inheritance diagram for isc::dhcp::IfaceMgr:

Classes

struct  SocketCallbackInfo
 Keeps callback information for external sockets. More...
 

Public Types

typedef std::function< bool(bool)> DetectCallback
 Defines callback used when detecting interfaces.
 
typedef std::function< void(int fd)> SocketCallback
 Defines callback used when data is received over external sockets.
 
typedef std::list< SocketCallbackInfoSocketCallbackInfoContainer
 Defines storage container for callbacks for external sockets.
 

Public Member Functions

virtual ~IfaceMgr ()
 Destructor.
 
void addExternalSocket (int socketfd, SocketCallback callback)
 Adds external socket and a callback.
 
void addInterface (const IfacePtr &iface)
 Adds an interface to list of known interfaces.
 
bool checkDetectIfaces (bool update_only)
 Check if the specific system calls used to detect interfaces should be executed.
 
void clearBoundAddresses ()
 Clears the addresses all sockets are bound to.
 
void clearIfaces ()
 Removes detected interfaces.
 
void clearUnicasts ()
 Clears unicast addresses on all interfaces.
 
void closeSockets ()
 Closes all open sockets.
 
void collectBoundAddresses ()
 Collect the addresses all sockets are bound to.
 
bool configureDHCPPacketQueue (const uint16_t family, data::ConstElementPtr queue_control)
 Configures DHCP packet queue.
 
uint16_t countIfaces ()
 Returns number of detected interfaces.
 
void deleteAllExternalSockets ()
 Deletes all external sockets.
 
void deleteExternalSocket (int socketfd)
 Deletes external socket.
 
void detectIfaces (bool update_only=false)
 Detects network interfaces.
 
IfacePtr getIface (const PktPtr &pkt)
 Returns interface with specified packet.
 
IfacePtr getIface (const std::string &ifname)
 Returns interface with specified interface name.
 
IfacePtr getIface (const unsigned int ifindex)
 Returns interface specified interface index.
 
const IfaceCollectiongetIfaces ()
 Returns container with all interfaces.
 
PacketQueue4Ptr getPacketQueue4 ()
 Fetches the DHCPv4 receiver packet queue.
 
PacketQueue6Ptr getPacketQueue6 ()
 Fetches the DHCPv6 receiver packet queue.
 
PacketQueueMgr4Ptr getPacketQueueMgr4 ()
 Fetches the DHCPv4 packet queue manager.
 
PacketQueueMgr6Ptr getPacketQueueMgr6 ()
 Fetches the DHCPv6 packet queue manager.
 
SocketInfo getSocket (const isc::dhcp::Pkt4Ptr &pkt)
 Return most suitable socket for transmitting specified IPv4 packet.
 
uint16_t getSocket (const isc::dhcp::Pkt6Ptr &pkt)
 Return most suitable socket for transmitting specified IPv6 packet.
 
bool hasOpenSocket (const isc::asiolink::IOAddress &addr) const
 Checks if there is a socket open and bound to an address.
 
bool hasOpenSocket (const uint16_t family) const
 Checks if there is at least one socket of the specified family open.
 
bool isDHCPReceiverRunning () const
 Returns true if there is a receiver exists and its thread is currently running.
 
bool isDirectResponseSupported () const
 Check if packet be sent directly to the client having no address.
 
bool isExternalSocket (int fd)
 Checks if socket's file description is registered.
 
virtual bool isSocketReceivedTimeSupported () const
 Check if the socket received time is supported.
 
bool isTestMode () const
 Checks if the IfaceMgr is in the test mode.
 
int openSocket (const std::string &ifname, const isc::asiolink::IOAddress &addr, const uint16_t port, const bool receive_bcast=false, const bool send_bcast=false)
 Opens UDP/IP socket and binds it to address, interface and port.
 
int openSocketFromAddress (const isc::asiolink::IOAddress &addr, const uint16_t port)
 Opens UDP/IP socket and binds to address specified.
 
int openSocketFromIface (const std::string &ifname, const uint16_t port, const uint8_t family)
 Opens UDP/IP socket and binds it to interface specified.
 
int openSocketFromRemoteAddress (const isc::asiolink::IOAddress &remote_addr, const uint16_t port)
 Opens UDP/IP socket to be used to connect to remote address.
 
bool openSockets4 (const uint16_t port=DHCP4_SERVER_PORT, const bool use_bcast=true, IfaceMgrErrorMsgCallback error_handler=0, const bool skip_opened=false)
 Opens IPv4 sockets on detected interfaces.
 
bool openSockets6 (const uint16_t port=DHCP6_SERVER_PORT, IfaceMgrErrorMsgCallback error_handler=0, const bool skip_opened=false)
 Opens IPv6 sockets on detected interfaces.
 
void printIfaces (std::ostream &out=std::cout)
 Debugging method that prints out all available interfaces.
 
int purgeBadSockets ()
 Scans registered socket set and removes any that are invalid.
 
Pkt4Ptr receive4 (uint32_t timeout_sec, uint32_t timeout_usec=0)
 Receive IPv4 packets or data from external sockets.
 
Pkt6Ptr receive6 (uint32_t timeout_sec, uint32_t timeout_usec=0)
 Receive IPv4 packets or data from external sockets.
 
bool send (const Pkt4Ptr &pkt)
 Sends an IPv4 packet.
 
bool send (const Pkt6Ptr &pkt)
 Sends an IPv6 packet.
 
void setAllowLoopBack (const bool allow_loopback)
 Allows or disallows the loopback interface.
 
void setDetectCallback (const DetectCallback &cb)
 Set a callback to perform operations before executing specific system calls.
 
void setMatchingPacketFilter (const bool direct_response_desired=false)
 Set Packet Filter object to handle send/receive packets.
 
void setPacketFilter (const PktFilter6Ptr &packet_filter)
 Set packet filter object to handle sending and receiving DHCPv6 messages.
 
void setPacketFilter (const PktFilterPtr &packet_filter)
 Set packet filter object to handle sending and receiving DHCPv4 messages.
 
void setTestMode (const bool test_mode)
 Sets or clears the test mode for IfaceMgr.
 
void startDHCPReceiver (const uint16_t family)
 Starts DHCP packet receiver.
 
void stopDHCPReceiver ()
 Stops the DHCP packet receiver.
 

Static Public Member Functions

static void addFDtoSet (int fd, int &maxfd, fd_set *sockets)
 Convenience method for adding an descriptor to a set.
 
static IfaceMgrinstance ()
 IfaceMgr is a singleton class.
 
static const IfaceMgrPtrinstancePtr ()
 Returns pointer to the sole instance of the interface manager.
 

Static Public Attributes

static const uint32_t RCVBUFSIZE = 1500
 Packet reception buffer size.
 

Protected Member Functions

 IfaceMgr ()
 Protected constructor.
 
int openSocket4 (Iface &iface, const isc::asiolink::IOAddress &addr, const uint16_t port, const bool receive_bcast=false, const bool send_bcast=false)
 Opens IPv4 socket.
 
int openSocket6 (Iface &iface, const isc::asiolink::IOAddress &addr, uint16_t port, const bool join_multicast)
 Opens IPv6 socket.
 
Pkt4Ptr receive4Direct (uint32_t timeout_sec, uint32_t timeout_usec=0)
 Receive IPv4 packets directly or data from external sockets.
 
Pkt4Ptr receive4Indirect (uint32_t timeout_sec, uint32_t timeout_usec=0)
 Receive IPv4 packets indirectly or data from external sockets.
 
Pkt6Ptr receive6Direct (uint32_t timeout_sec, uint32_t timeout_usec=0)
 Receive IPv6 packets directly or data from external sockets.
 
Pkt6Ptr receive6Indirect (uint32_t timeout_sec, uint32_t timeout_usec=0)
 Receive IPv6 packets indirectly or data from external sockets.
 

Protected Attributes

BoundAddresses bound_address_
 Unordered set of IPv4 bound addresses.
 
IfaceCollection ifaces_
 List of available interfaces.
 

Detailed Description

Handles network interfaces, transmission and reception.

IfaceMgr is an interface manager class that detects available network interfaces, configured addresses, link-local addresses, and provides API for using sockets.

Definition at line 656 of file iface_mgr.h.

Member Typedef Documentation

◆ DetectCallback

typedef std::function<bool (bool)> isc::dhcp::IfaceMgr::DetectCallback

Defines callback used when detecting interfaces.

Parameters
update_onlyOnly add interfaces that do not exist and update existing interfaces.
Returns
true if callback exited with no issue and detectIfaces should continue with specific system calls, false otherwise.

Definition at line 670 of file iface_mgr.h.

◆ SocketCallback

typedef std::function<void (int fd)> isc::dhcp::IfaceMgr::SocketCallback

Defines callback used when data is received over external sockets.

Parameters
fdsocket descriptor of the ready socket

Definition at line 661 of file iface_mgr.h.

◆ SocketCallbackInfoContainer

Defines storage container for callbacks for external sockets.

Definition at line 682 of file iface_mgr.h.

Constructor & Destructor Documentation

◆ ~IfaceMgr()

isc::dhcp::IfaceMgr::~IfaceMgr ( )
virtual

Destructor.

Closes open sockets.

Definition at line 314 of file iface_mgr.cc.

References closeSockets().

+ Here is the call graph for this function:

◆ IfaceMgr()

isc::dhcp::IfaceMgr::IfaceMgr ( )
protected

Protected constructor.

Protected constructor. This is a singleton class. We don't want anyone to create instances of IfaceMgr. Use instance() method instead.

Definition at line 185 of file iface_mgr.cc.

References checkDetectIfaces(), detectIfaces(), isc_throw, and isc::Exception::what().

Referenced by instancePtr().

+ Here is the call graph for this function:

Member Function Documentation

◆ addExternalSocket()

void isc::dhcp::IfaceMgr::addExternalSocket ( int socketfd,
SocketCallback callback )

Adds external socket and a callback.

Specifies external socket and a callback that will be called when data will be received over that socket.

Parameters
socketfdsocket descriptor
callbackcallback function

Definition at line 329 of file iface_mgr.cc.

References isc_throw, and isc::dhcp::IfaceMgr::SocketCallbackInfo::socket_.

◆ addFDtoSet()

void isc::dhcp::IfaceMgr::addFDtoSet ( int fd,
int & maxfd,
fd_set * sockets )
static

Convenience method for adding an descriptor to a set.

Parameters
fddescriptor to add
[out]maxfdmaximum fd value in the set. If the new fd is larger than it's current value, it will be updated to new fd value
socketspointer to the set of sockets
Exceptions
BadValueif sockets is null

Definition at line 1389 of file iface_mgr.cc.

References isc_throw.

Referenced by receive4Direct(), receive4Indirect(), receive6Direct(), and receive6Indirect().

◆ addInterface()

void isc::dhcp::IfaceMgr::addInterface ( const IfacePtr & iface)

Adds an interface to list of known interfaces.

Parameters
ifacereference to Iface object.
Note
This function must be public because it has to be callable from unit tests.
Exceptions
Unexpectedwhen name or index already exists.

Definition at line 775 of file iface_mgr.cc.

References ifaces_, isc_throw, and isc::dhcp::IfaceCollection::push_back().

+ Here is the call graph for this function:

◆ checkDetectIfaces()

bool isc::dhcp::IfaceMgr::checkDetectIfaces ( bool update_only)

Check if the specific system calls used to detect interfaces should be executed.

Parameters
update_onlyOnly add interfaces that do not exist and update existing interfaces.
Returns
true if the specific system calls should be executed, false otherwise causing the detectIfaces to return immediately.

Definition at line 1994 of file iface_mgr.cc.

Referenced by IfaceMgr().

◆ clearBoundAddresses()

void isc::dhcp::IfaceMgr::clearBoundAddresses ( )

Clears the addresses all sockets are bound to.

Definition at line 906 of file iface_mgr.cc.

References bound_address_.

Referenced by closeSockets().

◆ clearIfaces()

void isc::dhcp::IfaceMgr::clearIfaces ( )

Removes detected interfaces.

This method removes all detected interfaces. This method should be used by unit tests to supply a custom set of interfaces. For example: a unit test may create a pool of fake interfaces and use the custom PktFilter class to mimic socket operation on these interfaces.

Definition at line 901 of file iface_mgr.cc.

References isc::dhcp::IfaceCollection::clear(), and ifaces_.

+ Here is the call graph for this function:

◆ clearUnicasts()

void isc::dhcp::IfaceMgr::clearUnicasts ( )

Clears unicast addresses on all interfaces.

Definition at line 926 of file iface_mgr.cc.

References ifaces_.

◆ closeSockets()

void isc::dhcp::IfaceMgr::closeSockets ( )

Closes all open sockets.

It calls stopDHCPReceiver to stop the receiver thread and then it closes all open interface sockets.

Is used in destructor, but also from Dhcpv4Srv and Dhcpv6Srv classes.

Definition at line 286 of file iface_mgr.cc.

References clearBoundAddresses(), ifaces_, and stopDHCPReceiver().

Referenced by ~IfaceMgr().

+ Here is the call graph for this function:

◆ collectBoundAddresses()

void isc::dhcp::IfaceMgr::collectBoundAddresses ( )

Collect the addresses all sockets are bound to.

Definition at line 911 of file iface_mgr.cc.

References bound_address_, ifaces_, isc::asiolink::IOAddress::isV4(), and isc::asiolink::IOAddress::toUint32().

Referenced by openSockets4().

+ Here is the call graph for this function:

◆ configureDHCPPacketQueue()

bool isc::dhcp::IfaceMgr::configureDHCPPacketQueue ( const uint16_t family,
data::ConstElementPtr queue_control )

Configures DHCP packet queue.

If the given configuration enables packet queueing, then the appropriate queue is created. Otherwise, the existing queue is destroyed. If the receiver thread is running when this function is invoked, it will throw.

Parameters
familyindicates which receiver to start, (AF_INET or AF_INET6)
queue_controlconfiguration containing "dhcp-queue-control" content
Returns
true if packet queueing has been enabled, false otherwise
Exceptions
InvalidOperationif the receiver thread is currently running.

Definition at line 1943 of file iface_mgr.cc.

References isc::data::SimpleParser::getBoolean(), isc_throw, and isDHCPReceiverRunning().

+ Here is the call graph for this function:

◆ countIfaces()

uint16_t isc::dhcp::IfaceMgr::countIfaces ( )
inline

Returns number of detected interfaces.

Returns
number of detected interfaces

Definition at line 1146 of file iface_mgr.h.

References ifaces_, and isc::dhcp::IfaceCollection::size().

+ Here is the call graph for this function:

◆ deleteAllExternalSockets()

void isc::dhcp::IfaceMgr::deleteAllExternalSockets ( )

Deletes all external sockets.

Definition at line 399 of file iface_mgr.cc.

◆ deleteExternalSocket()

void isc::dhcp::IfaceMgr::deleteExternalSocket ( int socketfd)

Deletes external socket.

Parameters
socketfdsocket descriptor

Definition at line 352 of file iface_mgr.cc.

◆ detectIfaces()

void isc::dhcp::IfaceMgr::detectIfaces ( bool update_only = false)

Detects network interfaces.

If the detect callback returns true, the specific system calls are executed, otherwise the detectIfaces will return immediately.

Parameters
update_onlyOnly add interfaces that do not exist and update existing interfaces.

Referenced by IfaceMgr().

◆ getIface() [1/3]

IfacePtr isc::dhcp::IfaceMgr::getIface ( const PktPtr & pkt)

Returns interface with specified packet.

Note
When the interface index is set (Pkt::indexSet returns true) it is searched for, if it is not set the name instead is searched for.
Parameters
pktpacket with interface index and name
Returns
interface with packet interface index or name (or null if no such interface is present)

Definition at line 892 of file iface_mgr.cc.

References getIface().

+ Here is the call graph for this function:

◆ getIface() [2/3]

IfacePtr isc::dhcp::IfaceMgr::getIface ( const std::string & ifname)

Returns interface with specified interface name.

Parameters
ifnamename of searched interface
Returns
interface with requested name (or null if no such interface is present)

Definition at line 884 of file iface_mgr.cc.

References isc::dhcp::IfaceCollection::getIface(), and ifaces_.

+ Here is the call graph for this function:

◆ getIface() [3/3]

IfacePtr isc::dhcp::IfaceMgr::getIface ( const unsigned int ifindex)

Returns interface specified interface index.

Parameters
ifindexindex of searched interface
Returns
interface with requested index (or null if no such interface is present)

Definition at line 879 of file iface_mgr.cc.

References isc::dhcp::IfaceCollection::getIface(), and ifaces_.

Referenced by getIface(), getSocket(), getSocket(), openSocket(), send(), and send().

+ Here is the call graph for this function:

◆ getIfaces()

const IfaceCollection & isc::dhcp::IfaceMgr::getIfaces ( )
inline

Returns container with all interfaces.

This reference is only valid as long as IfaceMgr is valid. However, since IfaceMgr is a singleton and is expected to be destroyed after main() function completes, you should not worry much about this.

Returns
container with all interfaces.

Definition at line 799 of file iface_mgr.h.

References ifaces_.

◆ getPacketQueue4()

PacketQueue4Ptr isc::dhcp::IfaceMgr::getPacketQueue4 ( )
inline

Fetches the DHCPv4 receiver packet queue.

Incoming packets are read by the receiver thread and added to this queue. receive4() dequeues and returns them.

Returns
pointer to the packet queue

Definition at line 1285 of file iface_mgr.h.

Referenced by receive4Indirect(), startDHCPReceiver(), and stopDHCPReceiver().

◆ getPacketQueue6()

PacketQueue6Ptr isc::dhcp::IfaceMgr::getPacketQueue6 ( )
inline

Fetches the DHCPv6 receiver packet queue.

Incoming packets are read by the receiver thread and added to this queue. receive6() dequeues and returns them.

Returns
pointer to the packet queue

Definition at line 1302 of file iface_mgr.h.

Referenced by receive6Indirect(), startDHCPReceiver(), and stopDHCPReceiver().

◆ getPacketQueueMgr4()

PacketQueueMgr4Ptr isc::dhcp::IfaceMgr::getPacketQueueMgr4 ( )
inline

Fetches the DHCPv4 packet queue manager.

Returns
pointer to the packet queue mgr

Definition at line 1275 of file iface_mgr.h.

◆ getPacketQueueMgr6()

PacketQueueMgr6Ptr isc::dhcp::IfaceMgr::getPacketQueueMgr6 ( )
inline

Fetches the DHCPv6 packet queue manager.

Returns
pointer to the packet queue mgr

Definition at line 1292 of file iface_mgr.h.

◆ getSocket() [1/2]

SocketInfo isc::dhcp::IfaceMgr::getSocket ( const isc::dhcp::Pkt4Ptr & pkt)

Return most suitable socket for transmitting specified IPv4 packet.

This method uses the local address assigned to the packet and tries to match it with addresses to which sockets are bound for the particular interface. If the match is not found, the method returns the first IPv4 socket found for the particular interface. In case, there are no IPv4 sockets assigned to the interface the exception is thrown.

Parameters
pktA packet to be transmitted. It must hold a local address and a valid pointer to the interface.
Returns
A structure describing a socket.
Exceptions
SocketNotFoundif no suitable socket found.

Definition at line 1910 of file iface_mgr.cc.

References getIface(), and isc_throw.

+ Here is the call graph for this function:

◆ getSocket() [2/2]

uint16_t isc::dhcp::IfaceMgr::getSocket ( const isc::dhcp::Pkt6Ptr & pkt)

Return most suitable socket for transmitting specified IPv6 packet.

This method takes Pkt6Ptr (see overloaded implementation that takes Pkt4Ptr) and chooses appropriate socket to send it. This method may throw if specified packet does not have outbound interface specified, no such interface exists, or specified interface does not have any appropriate sockets open.

Parameters
pkta packet to be transmitted
Returns
a socket descriptor
Exceptions
SocketNotFoundIf no suitable socket found.
IfaceNotFoundIf interface is not set for the packet.

Definition at line 1854 of file iface_mgr.cc.

References getIface(), and isc_throw.

Referenced by send(), and send().

+ Here is the call graph for this function:

◆ hasOpenSocket() [1/2]

bool isc::dhcp::IfaceMgr::hasOpenSocket ( const isc::asiolink::IOAddress & addr) const

Checks if there is a socket open and bound to an address.

This function checks if one of the sockets opened by the IfaceMgr is bound to the IP address specified as the method parameter. If the socket is bound to the port (and address is unspecified), the method will check if the address passed in the argument is configured on an interface. Note: On BSD and Solaris the socket is opened for "::" address instead of the link-local address or the "ff02::1:2" address. If there are multiple interfaces joining the multicast group, this function matches the "::" address bound by any interface, not necessary the one with the specified link-local address and returns true.

Parameters
addrAddress of the socket being searched.
Returns
true if there is a socket bound to the specified address.

Definition at line 463 of file iface_mgr.cc.

References bound_address_, ifaces_, isc::asiolink::IOAddress::isV4(), and isc::asiolink::IOAddress::toUint32().

+ Here is the call graph for this function:

◆ hasOpenSocket() [2/2]

bool isc::dhcp::IfaceMgr::hasOpenSocket ( const uint16_t family) const

Checks if there is at least one socket of the specified family open.

Parameters
familyA socket family.
Returns
true if there is at least one socket open, false otherwise.

Definition at line 447 of file iface_mgr.cc.

References ifaces_.

Referenced by openSockets4(), openSockets6(), setPacketFilter(), and setPacketFilter().

◆ instance()

IfaceMgr & isc::dhcp::IfaceMgr::instance ( )
static

IfaceMgr is a singleton class.

This method returns reference to its sole instance.

Returns
the only existing instance of interface manager

Definition at line 54 of file iface_mgr.cc.

References instancePtr().

Referenced by isc::dhcp::Dhcpv4Srv::Dhcpv4Srv(), isc::dhcp::Dhcpv6Srv::Dhcpv6Srv(), isc::perfdhcp::TestControl::TestControl(), isc::dhcp::Dhcpv4Srv::~Dhcpv4Srv(), isc::dhcp::Dhcpv6Srv::~Dhcpv6Srv(), isc::perfdhcp::PerfSocket::~PerfSocket(), isc::http::HttpConnection::acceptorCallback(), isc::dhcp::Dhcpv4Srv::acceptServerId(), isc::dhcp::Dhcpv4Srv::adjustIfaceData(), isc::dhcp::Dhcpv4Srv::adjustRemoteAddr(), isc::dhcp::Dhcpv4Srv::appendServerID(), isc::ha::HAService::clientCloseHandler(), isc::ha::HAService::clientConnectHandler(), isc::dhcp::Dhcp4o6IpcBase::close(), isc::http::HttpConnection::close(), isc::config::UnixCommandMgrImpl::closeCommandSocket(), isc::dhcp::CfgIface::closeSockets(), isc::http::HttpConnection::closeWatchSocket(), isc::dhcp::configureDhcp4Server(), isc::dhcp::configureDhcp6Server(), dhcp4_srv_configured(), dhcp6_srv_configured(), isc::perfdhcp::PerfSocket::getIface(), isc::dhcp::Pkt::getMACFromIPv6(), isc::dhcp::Pkt6::getMACFromRemoteIdRelayOption(), isc::dhcp::Dhcp6to4Ipc::handler(), isc::perfdhcp::PerfSocket::initSocketData(), isc::dhcp::Subnet4ConfigParser::initSubnet(), isc::dhcp::Subnet6ConfigParser::initSubnet(), isc::dhcp::Dhcp4to6Ipc::open(), isc::dhcp::Dhcp6to4Ipc::open(), isc::config::UnixCommandMgrImpl::openCommandSocket(), isc::perfdhcp::PerfSocket::openSocket(), isc::dhcp::CfgIface::openSockets(), isc::dhcp::IfacesConfigParser::parse(), isc::dhcp::SharedNetwork4Parser::parse(), isc::dhcp::SharedNetwork6Parser::parse(), isc::dhcp::ControlledDhcpv4Srv::processConfig(), isc::dhcp::ControlledDhcpv6Srv::processConfig(), isc::dhcp::Dhcp4o6IpcBase::receive(), isc::perfdhcp::PerfSocket::receive4(), isc::perfdhcp::PerfSocket::receive6(), isc::dhcp::Dhcpv4Srv::receivePacket(), isc::dhcp::Dhcpv6Srv::receivePacket(), isc::dhcp::CfgSubnets4::selectSubnet(), isc::perfdhcp::PerfSocket::send(), isc::perfdhcp::PerfSocket::send(), isc::dhcp::Dhcpv4Srv::sendPacket(), isc::dhcp::Dhcpv6Srv::sendPacket(), isc::http::HttpConnection::shutdown(), isc::http::HttpConnection::shutdownCallback(), isc::http::HttpListenerImpl::start(), isc::dhcp::D2ClientMgr::startSender(), isc::http::HttpListenerImpl::stop(), isc::dhcp::D2ClientMgr::stopSender(), and isc::dhcp::CfgIface::use().

+ Here is the call graph for this function:

◆ instancePtr()

const IfaceMgrPtr & isc::dhcp::IfaceMgr::instancePtr ( )
static

Returns pointer to the sole instance of the interface manager.

This method returns the pointer to the instance of the interface manager which can be held in singleton objects that depend on it. This will eliminate issues with the static deinitialization fiasco between this object and dependent singleton objects.

The IfaceMgr::instance method should be considered deprecated.

Returns
Shared pointer to the IfaceMgr instance.

Definition at line 59 of file iface_mgr.cc.

References IfaceMgr().

Referenced by instance().

+ Here is the call graph for this function:

◆ isDHCPReceiverRunning()

bool isc::dhcp::IfaceMgr::isDHCPReceiverRunning ( ) const
inline

Returns true if there is a receiver exists and its thread is currently running.

Definition at line 1326 of file iface_mgr.h.

Referenced by configureDHCPPacketQueue(), receive4(), receive6(), startDHCPReceiver(), and stopDHCPReceiver().

◆ isDirectResponseSupported()

bool isc::dhcp::IfaceMgr::isDirectResponseSupported ( ) const

Check if packet be sent directly to the client having no address.

Checks if IfaceMgr can send DHCPv4 packet to the client who hasn't got address assigned. If this is not supported broadcast address should be used to send response to the client.

Returns
true if direct response is supported.

Definition at line 319 of file iface_mgr.cc.

Referenced by openSockets4().

◆ isExternalSocket()

bool isc::dhcp::IfaceMgr::isExternalSocket ( int fd)

Checks if socket's file description is registered.

Returns
True if the fd is in the list of registered sockets.

Definition at line 369 of file iface_mgr.cc.

◆ isSocketReceivedTimeSupported()

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

Check if the socket received time is supported.

If true, then received packets will include a SOCKET_RECEIVED event in their event stack.

Returns
True if it is supported.

Definition at line 324 of file iface_mgr.cc.

◆ isTestMode()

bool isc::dhcp::IfaceMgr::isTestMode ( ) const
inline

Checks if the IfaceMgr is in the test mode.

Returns
true if the IfaceMgr is in the test mode, false otherwise.

Definition at line 732 of file iface_mgr.h.

◆ openSocket()

int isc::dhcp::IfaceMgr::openSocket ( const std::string & ifname,
const isc::asiolink::IOAddress & addr,
const uint16_t port,
const bool receive_bcast = false,
const bool send_bcast = false )

Opens UDP/IP socket and binds it to address, interface and port.

Specific type of socket (UDP/IPv4 or UDP/IPv6) depends on passed addr family.

Parameters
ifnamename of the interface
addraddress to be bound.
portUDP port.
receive_bcastconfigure IPv4 socket to receive broadcast messages or IPv6 socket to join multicast group.
send_bcastconfigure IPv4 socket to send broadcast messages. This parameter is ignored for IPv6 sockets.

Method will throw if socket creation, socket binding or multicast join fails.

Returns
socket descriptor, if socket creation, binding and multicast group join were all successful.

Definition at line 932 of file iface_mgr.cc.

References getIface(), isc_throw, isc::asiolink::IOAddress::isV4(), isc::asiolink::IOAddress::isV6(), openSocket4(), and openSocket6().

Referenced by openSocketFromAddress(), openSocketFromIface(), openSockets4(), and openSockets6().

+ Here is the call graph for this function:

◆ openSocket4()

int isc::dhcp::IfaceMgr::openSocket4 ( Iface & iface,
const isc::asiolink::IOAddress & addr,
const uint16_t port,
const bool receive_bcast = false,
const bool send_bcast = false )
protected

Opens IPv4 socket.

Please do not use this method directly. Use openSocket instead.

This method may throw exception if socket creation fails.

Parameters
ifacereference to interface structure.
addran address the created socket should be bound to
porta port that created socket should be bound to
receive_bcastconfigure socket to receive broadcast messages
send_bcastconfigure socket to send broadcast messages.
Returns
socket descriptor

Definition at line 1089 of file iface_mgr.cc.

References isc::db::info.

Referenced by openSocket().

◆ openSocket6()

int isc::dhcp::IfaceMgr::openSocket6 ( Iface & iface,
const isc::asiolink::IOAddress & addr,
uint16_t port,
const bool join_multicast )
protected

Opens IPv6 socket.

Please do not use this method directly. Use openSocket instead.

This method may throw exception if socket creation fails.

Parameters
ifacereference to interface structure.
addran address the created socket should be bound to
porta port that created socket should be bound to
join_multicastA boolean parameter which indicates whether socket should join All_DHCP_Relay_Agents_and_servers multicast group.
Returns
socket descriptor

Referenced by openSocket().

◆ openSocketFromAddress()

int isc::dhcp::IfaceMgr::openSocketFromAddress ( const isc::asiolink::IOAddress & addr,
const uint16_t port )

Opens UDP/IP socket and binds to address specified.

This methods differs from openSocket in that it does not require the specification of the interface to which the socket will be bound.

Note
This method does not join the socket to the multicast group.
Parameters
addraddress to be bound
portUDP port
Returns
socket descriptor, if socket creation and binding was successful.
Exceptions
isc::Unexpectedif failed to create and bind socket
isc::BadValueif specified address is not available on any interface

Definition at line 992 of file iface_mgr.cc.

References ifaces_, isc_throw, and openSocket().

Referenced by openSocketFromRemoteAddress().

+ Here is the call graph for this function:

◆ openSocketFromIface()

int isc::dhcp::IfaceMgr::openSocketFromIface ( const std::string & ifname,
const uint16_t port,
const uint8_t family )

Opens UDP/IP socket and binds it to interface specified.

This method differs from openSocket in that it does not require the specification of a local address to which socket will be bound. Instead, the method searches through the addresses on the specified interface and selects one that matches the address family.

Note
This method does not join the socket to the multicast group.
Parameters
ifnamename of the interface
portUDP port
familyaddress family (AF_INET or AF_INET6)
Returns
socket descriptor, if socket creation and binding was successful.
Exceptions
isc::Unexpectedif failed to create and bind socket.
isc::BadValueif there is no address on specified interface that belongs to given family.

Definition at line 951 of file iface_mgr.cc.

References ifaces_, isc_throw, and openSocket().

+ Here is the call graph for this function:

◆ openSocketFromRemoteAddress()

int isc::dhcp::IfaceMgr::openSocketFromRemoteAddress ( const isc::asiolink::IOAddress & remote_addr,
const uint16_t port )

Opens UDP/IP socket to be used to connect to remote address.

This method identifies the local address to be used to connect to the remote address specified as argument. Once the local address is identified, openSocket is called to open a socket and bind it to the interface, address and port.

Note
This method does not join the socket to a multicast group.
Parameters
remote_addrremote address to connect to
portUDP port
Returns
socket descriptor, if socket creation and binding was successful.
Exceptions
isc::Unexpectedif failed to create and bind socket

Definition at line 1015 of file iface_mgr.cc.

References isc_throw, openSocketFromAddress(), and isc::Exception::what().

+ Here is the call graph for this function:

◆ openSockets4()

bool isc::dhcp::IfaceMgr::openSockets4 ( const uint16_t port = DHCP4_SERVER_PORT,
const bool use_bcast = true,
IfaceMgrErrorMsgCallback error_handler = 0,
const bool skip_opened = false )

Opens IPv4 sockets on detected interfaces.

This method opens sockets only on interfaces which have the inactive4_ field set to false (are active). If the interface is active but it is not running, it is down, or is a loopback interface when loopback is not allowed, an error is reported.

The type of the socket being open depends on the selected Packet Filter represented by a class derived from isc::dhcp::PktFilter abstract class.

If sockets were successfully opened, it calls @ startDHCPReceiver to start the receiver thread (if packet queueing is enabled).

It is possible to specify whether sockets should be broadcast capable. In most of the cases, the sockets should support broadcast traffic, e.g. DHCPv4 server and relay need to listen to broadcast messages sent by clients. If the socket has to be open on the particular interface, this interface must have broadcast flag set. If this condition is not met, the socket will be created in the unicast-only mode. If there are multiple broadcast-capable interfaces present, they may be all open in a broadcast mode only if the OS supports SO_BINDTODEVICE (bind socket to a device) socket option. If this option is not supported, only the first broadcast-capable socket will be opened in the broadcast mode. The error will be reported for sockets being opened on other interfaces. If the socket is bound to a device (interface), the broadcast traffic sent to this interface will be received on this interface only. This allows the DHCPv4 server or relay to detect the interface on which the broadcast message has been received. This interface is later used to send a response.

On the systems with multiple interfaces, it is often desired that the failure to open a socket on a particular interface doesn't cause a fatal error and sockets should be opened on remaining interfaces. However, the warning about the failure for the particular socket should be communicated to the caller. The libdhcp++ is a common library with no logger associated with it. Most of the functions in this library communicate errors via exceptions. In case of openSockets4 function exception must not be thrown if the function is supposed to continue opening sockets, despite an error. Therefore, if such a behavior is desired, the error handler function can be passed as a parameter. This error handler is called (if present) with an error string. Typically, error handler will simply log an error using an application logger, but it can do more sophisticated error handling too.

Todo
It is possible that additional parameters will have to be added to the error handler, e.g. Iface if it was really supposed to do some more sophisticated error handling.

If the error handler is not installed (is null), the exception is thrown for each failure (default behavior).

Warning
This function does not check if there has been any sockets already open by the IfaceMgr. Therefore a caller should call IfaceMgr::closeSockets() before calling this function. If there are any sockets open, the function may either throw an exception or invoke an error handler on attempt to bind the new socket to the same address and port.
Parameters
portspecifies port number (usually DHCP4_SERVER_PORT)
use_bcastconfigure sockets to support broadcast messages.
error_handlera pointer to an error handler function which is called by the openSockets4 when it fails to open a socket. This parameter can be null to indicate that the callback should not be used.
skip_openedskip the addresses that already have the opened port
Exceptions
SocketOpenFailureif tried and failed to open socket and callback function hasn't been specified.
Returns
true if any sockets were open

Definition at line 497 of file iface_mgr.cc.

References collectBoundAddresses(), hasOpenSocket(), IFACEMGR_ERROR, ifaces_, isDirectResponseSupported(), openSocket(), startDHCPReceiver(), and isc::Exception::what().

+ Here is the call graph for this function:

◆ openSockets6()

bool isc::dhcp::IfaceMgr::openSockets6 ( const uint16_t port = DHCP6_SERVER_PORT,
IfaceMgrErrorMsgCallback error_handler = 0,
const bool skip_opened = false )

Opens IPv6 sockets on detected interfaces.

This method opens sockets only on interfaces which have the inactive6_ field set to false (are active). If the interface is active but it is not running, it is down, or is a loopback interface when loopback is not allowed, an error is reported.

If sockets were successfully opened, it calls @ startDHCPReceiver to start the receiver thread (if packet queueing is enabled).

On the systems with multiple interfaces, it is often desired that the failure to open a socket on a particular interface doesn't cause a fatal error and sockets should be opened on remaining interfaces. However, the warning about the failure for the particular socket should be communicated to the caller. The libdhcp++ is a common library with no logger associated with it. Most of the functions in this library communicate errors via exceptions. In case of openSockets6 function exception must not be thrown if the function is supposed to continue opening sockets, despite an error. Therefore, if such a behavior is desired, the error handler function can be passed as a parameter. This error handler is called (if present) with an error string. Typically, error handler will simply log an error using an application logger, but it can do more sophisticated error handling too.

Todo
It is possible that additional parameters will have to be added to the error handler, e.g. Iface if it was really supposed to do some more sophisticated error handling.

If the error handler is not installed (is null), the exception is thrown for each failure (default behavior).

Warning
This function does not check if there has been any sockets already open by the IfaceMgr. Therefore a caller should call IfaceMgr::closeSockets() before calling this function. If there are any sockets open, the function may either throw an exception or invoke an error handler on attempt to bind the new socket to the same address and port.
Parameters
portspecifies port number (usually DHCP6_SERVER_PORT)
error_handlera pointer to an error handler function which is called by the openSockets6 when it fails to open a socket. This parameter can be null to indicate that the callback should not be used.
skip_openedskip the addresses that already have the opened port
Exceptions
SocketOpenFailureif tried and failed to open socket.
Returns
true if any sockets were open

Definition at line 627 of file iface_mgr.cc.

References hasOpenSocket(), IFACEMGR_ERROR, ifaces_, openSocket(), startDHCPReceiver(), and isc::Exception::what().

+ Here is the call graph for this function:

◆ printIfaces()

void isc::dhcp::IfaceMgr::printIfaces ( std::ostream & out = std::cout)

Debugging method that prints out all available interfaces.

Parameters
outspecifies stream to print list of interfaces to

Definition at line 788 of file iface_mgr.cc.

References ifaces_.

◆ purgeBadSockets()

int isc::dhcp::IfaceMgr::purgeBadSockets ( )

Scans registered socket set and removes any that are invalid.

Walks the list of registered external sockets and tests each for validity. If any are found to be invalid they are removed. This is primarily a self-defense mechanism against hook libs or other users of external sockets that may leave a closed socket registered by mistake.

Returns
A count of the sockets purged.

Definition at line 381 of file iface_mgr.cc.

Referenced by receive4Direct(), receive4Indirect(), receive6Direct(), and receive6Indirect().

◆ receive4()

Pkt4Ptr isc::dhcp::IfaceMgr::receive4 ( uint32_t timeout_sec,
uint32_t timeout_usec = 0 )

Receive IPv4 packets or data from external sockets.

Wrapper around calls to either receive4Direct or receive4Indirect. The former is called when packet queueing is disabled, the latter when it is enabled.

Parameters
timeout_secspecifies integral part of the timeout (in seconds)
timeout_usecspecifies fractional part of the timeout (in microseconds)
Returns
Pkt4 object representing received packet (or null)

Definition at line 1125 of file iface_mgr.cc.

References isDHCPReceiverRunning(), receive4Direct(), and receive4Indirect().

+ Here is the call graph for this function:

◆ receive4Direct()

Pkt4Ptr isc::dhcp::IfaceMgr::receive4Direct ( uint32_t timeout_sec,
uint32_t timeout_usec = 0 )
protected

Receive IPv4 packets directly or data from external sockets.

Attempts to receive a single DHCPv4 message over any of the open IPv4 sockets. If reception is successful and all information about its sender is obtained, an Pkt4 object is created and returned.

This method also checks if data arrived over registered external socket. This data may be of a different protocol family than AF_INET.

Parameters
timeout_secspecifies integral part of the timeout (in seconds)
timeout_usecspecifies fractional part of the timeout (in microseconds)
Exceptions
isc::BadValueif timeout_usec is greater than one million
isc::dhcp::SocketReadErrorif error occurred when receiving a packet.
isc::dhcp::SignalInterruptOnSelectwhen a call to select() is interrupted by a signal.
Returns
Pkt4 object representing received packet (or null)
Todo
: marginal performance optimization. We could create the set once and then use its copy for select(). Please note that select() modifies provided set to indicated which sockets have something to read.

Definition at line 1255 of file iface_mgr.cc.

References addFDtoSet(), ifaces_, isc_throw, and purgeBadSockets().

Referenced by receive4().

+ Here is the call graph for this function:

◆ receive4Indirect()

Pkt4Ptr isc::dhcp::IfaceMgr::receive4Indirect ( uint32_t timeout_sec,
uint32_t timeout_usec = 0 )
protected

Receive IPv4 packets indirectly or data from external sockets.

Attempts to receive a single DHCPv4 message from the packet queue. The queue is populated by the receiver thread. If a packet is waiting in the queue, a Pkt4 returned.

This method also checks if data arrived over registered external socket. This data may be of a different protocol family than AF_INET.

Parameters
timeout_secspecifies integral part of the timeout (in seconds)
timeout_usecspecifies fractional part of the timeout (in microseconds)
Exceptions
isc::BadValueif timeout_usec is greater than one million
isc::dhcp::SocketReadErrorif error occurred when receiving a packet.
isc::dhcp::SignalInterruptOnSelectwhen a call to select() is interrupted by a signal.
Returns
Pkt4 object representing received packet (or null)

Definition at line 1133 of file iface_mgr.cc.

References addFDtoSet(), isc::util::WatchedThread::ERROR, getPacketQueue4(), isc_throw, purgeBadSockets(), and isc::util::WatchedThread::READY.

Referenced by receive4().

+ Here is the call graph for this function:

◆ receive6()

Pkt6Ptr isc::dhcp::IfaceMgr::receive6 ( uint32_t timeout_sec,
uint32_t timeout_usec = 0 )

Receive IPv4 packets or data from external sockets.

Wrapper around calls to either receive4Direct or receive4Indirect. The former is called when packet queueing is disabled, the latter when it is enabled.

Parameters
timeout_secspecifies integral part of the timeout (in seconds)
timeout_usecspecifies fractional part of the timeout (in microseconds)
Returns
Pkt4 object representing received packet (or null)

Definition at line 1380 of file iface_mgr.cc.

References isDHCPReceiverRunning(), receive6Direct(), and receive6Indirect().

+ Here is the call graph for this function:

◆ receive6Direct()

Pkt6Ptr isc::dhcp::IfaceMgr::receive6Direct ( uint32_t timeout_sec,
uint32_t timeout_usec = 0 )
protected

Receive IPv6 packets directly or data from external sockets.

Attempts to receive a single DHCPv6 message over any of the open IPv6 sockets. If reception is successful and all information about its sender is obtained, an Pkt6 object is created and returned.

This method also checks if data arrived over registered external socket. This data may be of a different protocol family than AF_INET.

Parameters
timeout_secspecifies integral part of the timeout (in seconds)
timeout_usecspecifies fractional part of the timeout (in microseconds)
Exceptions
isc::BadValueif timeout_usec is greater than one million
isc::dhcp::SocketReadErrorif error occurred when receiving a packet.
isc::dhcp::SignalInterruptOnSelectwhen a call to select() is interrupted by a signal.
Returns
Pkt6 object representing received packet (or null)
Todo
: marginal performance optimization. We could create the set once and then use its copy for select(). Please note that select() modifies provided set to indicated which sockets have something to read.

Definition at line 1401 of file iface_mgr.cc.

References addFDtoSet(), ifaces_, isc_throw, and purgeBadSockets().

Referenced by receive6().

+ Here is the call graph for this function:

◆ receive6Indirect()

Pkt6Ptr isc::dhcp::IfaceMgr::receive6Indirect ( uint32_t timeout_sec,
uint32_t timeout_usec = 0 )
protected

Receive IPv6 packets indirectly or data from external sockets.

Attempts to receive a single DHCPv6 message from the packet queue. The queue is populated by the receiver thread. If a packet is waiting in the queue, a Pkt6 returned.

This method also checks if data arrived over registered external socket. This data may be of a different protocol family than AF_INET.

Parameters
timeout_secspecifies integral part of the timeout (in seconds)
timeout_usecspecifies fractional part of the timeout (in microseconds)
Exceptions
isc::BadValueif timeout_usec is greater than one million
isc::dhcp::SocketReadErrorif error occurred when receiving a packet.
isc::dhcp::SignalInterruptOnSelectwhen a call to select() is interrupted by a signal.
Returns
Pkt6 object representing received packet (or null)

Definition at line 1523 of file iface_mgr.cc.

References addFDtoSet(), isc::util::WatchedThread::ERROR, getPacketQueue6(), isc_throw, purgeBadSockets(), and isc::util::WatchedThread::READY.

Referenced by receive6().

+ Here is the call graph for this function:

◆ send() [1/2]

bool isc::dhcp::IfaceMgr::send ( const Pkt4Ptr & pkt)

Sends an IPv4 packet.

Sends an IPv4 packet. All parameters for actual transmission are specified in Pkt4 structure itself. That includes destination address, src/dst port and interface over which data will be sent.

Parameters
pkta packet to be sent
Exceptions
isc::BadValueif invalid interface specified in the packet.
isc::dhcp::SocketWriteErrorif sendmsg() failed to send packet.
Returns
true if sending was successful

Definition at line 1113 of file iface_mgr.cc.

References getIface(), getSocket(), and isc_throw.

+ Here is the call graph for this function:

◆ send() [2/2]

bool isc::dhcp::IfaceMgr::send ( const Pkt6Ptr & pkt)

Sends an IPv6 packet.

Sends an IPv6 packet. All parameters for actual transmission are specified in Pkt6 structure itself. That includes destination address, src/dst port and interface over which data will be sent.

Parameters
pktpacket to be sent
Exceptions
isc::BadValueif invalid interface specified in the packet.
isc::dhcp::SocketWriteErrorif sendmsg() failed to send packet.
Returns
true if sending was successful

Definition at line 1100 of file iface_mgr.cc.

References getIface(), getSocket(), and isc_throw.

+ Here is the call graph for this function:

◆ setAllowLoopBack()

void isc::dhcp::IfaceMgr::setAllowLoopBack ( const bool allow_loopback)
inline

Allows or disallows the loopback interface.

By default the loopback interface is not considered when opening sockets. This flag provides a way to relax this constraint.

Definition at line 741 of file iface_mgr.h.

◆ setDetectCallback()

void isc::dhcp::IfaceMgr::setDetectCallback ( const DetectCallback & cb)
inline

Set a callback to perform operations before executing specific system calls.

Parameters
cbThe callback used before executing specific system calls.

Definition at line 813 of file iface_mgr.h.

◆ setMatchingPacketFilter()

void isc::dhcp::IfaceMgr::setMatchingPacketFilter ( const bool direct_response_desired = false)

Set Packet Filter object to handle send/receive packets.

This function sets Packet Filter object to be used by IfaceMgr, appropriate for the current OS. Setting the argument to 'true' indicates that function should set a packet filter class which supports direct responses to clients having no address assigned yet. Filters picked by this function will vary, depending on the OS being used. There is no guarantee that there is an implementation that supports this feature on a particular OS. If there isn't, the PktFilterInet object will be set. If the argument is set to 'false', PktFilterInet object instance will be set as the Packet Filter regardless of the OS type.

Parameters
direct_response_desiredspecifies whether the Packet Filter object being set should support direct traffic to the host not having address assigned.

◆ setPacketFilter() [1/2]

void isc::dhcp::IfaceMgr::setPacketFilter ( const PktFilter6Ptr & packet_filter)

Set packet filter object to handle sending and receiving DHCPv6 messages.

Packet filter objects provide means for the IfaceMgr to open sockets for IPv6 packets reception and sending. This function sets the new instance of the packet filter which will be used by IfaceMgr to send and receive DHCPv6 messages, until replaced by another packet filter.

It is required that DHCPv6 messages are send and received using methods of the same object that was used to open socket. Therefore, it is required that all IPv6 sockets are closed prior to calling this function. Call closeSockets(AF_INET6) to close all hanging IPv6 sockets opened by the current packet filter object.

Parameters
packet_filtera pointer to the new packet filter object to be used by IfaceMgr.
Exceptions
isc::dhcp::InvalidPacketFilterif specified object is null.
isc::dhcp::PacketFilterChangeDeniedif there are open IPv6 sockets.

Definition at line 429 of file iface_mgr.cc.

References hasOpenSocket(), and isc_throw.

+ Here is the call graph for this function:

◆ setPacketFilter() [2/2]

void isc::dhcp::IfaceMgr::setPacketFilter ( const PktFilterPtr & packet_filter)

Set packet filter object to handle sending and receiving DHCPv4 messages.

Packet filter objects provide means for the IfaceMgr to open sockets for IPv4 packets reception and sending. This function sets custom packet filter (represented by a class derived from PktFilter) to be used by IfaceMgr. Note that there must be no IPv4 sockets open when this function is called. Call closeSockets(AF_INET) to close all hanging IPv4 sockets opened by the current packet filter object.

Parameters
packet_filtera pointer to the new packet filter object to be used by IfaceMgr.
Exceptions
InvalidPacketFilterif provided packet filter object is null.
PacketFilterChangeDeniedif there are open IPv4 sockets.

Definition at line 405 of file iface_mgr.cc.

References hasOpenSocket(), and isc_throw.

+ Here is the call graph for this function:

◆ setTestMode()

void isc::dhcp::IfaceMgr::setTestMode ( const bool test_mode)
inline

Sets or clears the test mode for IfaceMgr.

Various unit test may set this flag to true, to indicate that the IfaceMgr is in the test mode. There are places in the code that modify the behavior depending if the IfaceMgr is in the test mode or not.

Parameters
test_modeA flag which indicates that the IfaceMgr is in the test mode (if true), or not (if false).

Definition at line 725 of file iface_mgr.h.

◆ startDHCPReceiver()

void isc::dhcp::IfaceMgr::startDHCPReceiver ( const uint16_t family)

Starts DHCP packet receiver.

Starts the DHCP packet receiver thread for the given. protocol, AF_NET or AF_INET6, if the packet queue exists, otherwise it simply returns.

Parameters
familyindicates which receiver to start, (AF_INET or AF_INET6)
Exceptions
Unexpectedif the thread already exists.

Definition at line 742 of file iface_mgr.cc.

References getPacketQueue4(), getPacketQueue6(), isc_throw, and isDHCPReceiverRunning().

Referenced by openSockets4(), and openSockets6().

+ Here is the call graph for this function:

◆ stopDHCPReceiver()

void isc::dhcp::IfaceMgr::stopDHCPReceiver ( )

Stops the DHCP packet receiver.

If the thread exists, it is stopped, deleted, and the packet queue is flushed.

Definition at line 298 of file iface_mgr.cc.

References getPacketQueue4(), getPacketQueue6(), and isDHCPReceiverRunning().

Referenced by closeSockets().

+ Here is the call graph for this function:

Member Data Documentation

◆ bound_address_

BoundAddresses isc::dhcp::IfaceMgr::bound_address_
protected

Unordered set of IPv4 bound addresses.

Definition at line 1490 of file iface_mgr.h.

Referenced by clearBoundAddresses(), collectBoundAddresses(), and hasOpenSocket().

◆ ifaces_

◆ RCVBUFSIZE

const uint32_t isc::dhcp::IfaceMgr::RCVBUFSIZE = 1500
static

Packet reception buffer size.

RFC 8415 states that server responses may be fragmented if they are over MTU. There is no text whether client's packets may be larger than 1500. For now, we can assume that we don't support packets larger than 1500.

Definition at line 691 of file iface_mgr.h.

Referenced by isc::dhcp::PktFilterInet6::receive(), isc::dhcp::PktFilterInet::receive(), and isc::dhcp::PktFilterLPF::receive().


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