Kea  2.1.2-git
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< void(int fd)> SocketCallback
 Defines callback used when data is received over external sockets. More...
 
typedef std::list< SocketCallbackInfoSocketCallbackInfoContainer
 Defines storage container for callbacks for external sockets. More...
 

Public Member Functions

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

Static Public Member Functions

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

Static Public Attributes

static const uint32_t RCVBUFSIZE = 1500
 Packet reception buffer size. More...
 

Protected Member Functions

 IfaceMgr ()
 Protected constructor. More...
 
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. More...
 
int openSocket6 (Iface &iface, const isc::asiolink::IOAddress &addr, uint16_t port, const bool join_multicast)
 Opens IPv6 socket. More...
 
Pkt4Ptr receive4Direct (uint32_t timeout_sec, uint32_t timeout_usec=0)
 Receive IPv4 packets directly or data from external sockets. More...
 
Pkt4Ptr receive4Indirect (uint32_t timeout_sec, uint32_t timeout_usec=0)
 Receive IPv4 packets indirectly or data from external sockets. More...
 
Pkt6Ptr receive6Direct (uint32_t timeout_sec, uint32_t timeout_usec=0)
 Receive IPv6 packets directly or data from external sockets. More...
 
Pkt6Ptr receive6Indirect (uint32_t timeout_sec, uint32_t timeout_usec=0)
 Receive IPv6 packets indirectly or data from external sockets. More...
 
void stubDetectIfaces ()
 Stub implementation of network interface detection. More...
 

Protected Attributes

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

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 632 of file iface_mgr.h.

Member Typedef Documentation

◆ 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 636 of file iface_mgr.h.

◆ SocketCallbackInfoContainer

Defines storage container for callbacks for external sockets.

Definition at line 648 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 186 of file iface_mgr.cc.

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

+ 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 324 of file iface_mgr.cc.

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

Referenced by isc::dhcp::Dhcp6to4Ipc::open(), isc::dhcp::Dhcp4to6Ipc::open(), isc::config::CommandMgrImpl::openCommandSocket(), and isc::dhcp::D2ClientMgr::startSender().

◆ 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 1390 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 771 of file iface_mgr.cc.

References ifaces_, and isc_throw.

◆ clearBoundAddresses()

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

Clears the addresses all sockets are bound to.

Definition at line 905 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 900 of file iface_mgr.cc.

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

Referenced by isc::dhcp::IfacesConfigParser::parse().

+ Here is the call graph for this function:

◆ clearUnicasts()

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

Clears unicast addresses on all interfaces.

Definition at line 925 of file iface_mgr.cc.

References ifaces_.

Referenced by isc::dhcp::CfgIface::openSockets().

◆ 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 isc::dhcp::CfgIface::closeSockets(), isc::dhcp::Dhcpv4Srv::~Dhcpv4Srv(), isc::dhcp::Dhcpv6Srv::~Dhcpv6Srv(), and ~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 910 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 queueuing has been enabled, false otherwise
Exceptions
InvalidOperationif the receiver thread is currently running.

Definition at line 1945 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 1081 of file iface_mgr.h.

◆ deleteAllExternalSockets()

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

Deletes all external sockets.

Definition at line 382 of file iface_mgr.cc.

◆ deleteExternalSocket()

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

Deletes external socket.

Parameters
socketfdsocket descriptor

Definition at line 347 of file iface_mgr.cc.

Referenced by isc::dhcp::Dhcp4o6IpcBase::close(), isc::config::CommandMgr::closeCommandSocket(), and isc::dhcp::D2ClientMgr::stopSender().

◆ detectIfaces()

void isc::dhcp::IfaceMgr::detectIfaces ( )

Detects network interfaces.

This method will eventually detect available interfaces. For now it offers stub implementation. First interface name and link-local IPv6 address is read from interfaces.txt file.

Referenced by IfaceMgr(), and isc::dhcp::IfacesConfigParser::parse().

◆ getIface() [1/3]

IfacePtr isc::dhcp::IfaceMgr::getIface ( 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 875 of file iface_mgr.cc.

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

Referenced by getIface(), isc::dhcp::Pkt::getMACFromIPv6(), isc::dhcp::Pkt6::getMACFromRemoteIdRelayOption(), getSocket(), isc::dhcp::Subnet4ConfigParser::initSubnet(), isc::dhcp::Subnet6ConfigParser::initSubnet(), openSocket(), isc::dhcp::CfgIface::openSockets(), isc::dhcp::SharedNetwork4Parser::parse(), isc::dhcp::SharedNetwork6Parser::parse(), send(), isc::dhcp::CfgIface::use(), and isc::perfdhcp::PerfSocket::~PerfSocket().

+ 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 883 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 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 891 of file iface_mgr.cc.

References getIface().

+ 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 757 of file iface_mgr.h.

◆ 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 1210 of file iface_mgr.h.

Referenced by receive4Indirect(), receive6Indirect(), 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 1227 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 1200 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 1217 of file iface_mgr.h.

◆ getSocket() [1/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 1855 of file iface_mgr.cc.

References getIface(), and isc_throw.

Referenced by isc::dhcp::Dhcpv4Srv::adjustIfaceData(), isc::dhcp::Dhcpv4Srv::appendServerID(), and send().

+ Here is the call graph for this function:

◆ getSocket() [2/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 1912 of file iface_mgr.cc.

References getIface(), and isc_throw.

+ Here is the call graph for this function:

◆ hasOpenSocket() [1/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 430 of file iface_mgr.cc.

References ifaces_.

Referenced by isc::dhcp::Dhcpv4Srv::acceptServerId(), and setPacketFilter().

◆ hasOpenSocket() [2/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.

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

Definition at line 446 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:

◆ 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 53 of file iface_mgr.cc.

Referenced by isc::dhcp::Dhcpv4Srv::acceptServerId(), isc::dhcp::Dhcpv4Srv::adjustIfaceData(), isc::dhcp::Dhcpv4Srv::adjustRemoteAddr(), isc::dhcp::Dhcpv4Srv::appendServerID(), isc::dhcp::Dhcp4o6IpcBase::close(), isc::config::CommandMgr::closeCommandSocket(), isc::dhcp::CfgIface::closeSockets(), isc::dhcp::DUIDFactory::createLL(), isc::dhcp::Dhcpv4Srv::Dhcpv4Srv(), isc::dhcp::Dhcpv6Srv::Dhcpv6Srv(), isc::dhcp::CfgIface::equals(), isc::perfdhcp::PerfSocket::getIface(), isc::dhcp::Pkt::getMACFromIPv6(), isc::dhcp::Pkt6::getMACFromRemoteIdRelayOption(), isc::perfdhcp::PerfSocket::initSocketData(), isc::dhcp::Subnet4ConfigParser::initSubnet(), isc::dhcp::Subnet6ConfigParser::initSubnet(), isc::dhcp::Dhcp6to4Ipc::open(), isc::dhcp::Dhcp4to6Ipc::open(), isc::config::CommandMgrImpl::openCommandSocket(), isc::dhcp::CfgIface::openSockets(), isc::dhcp::SharedNetwork4Parser::parse(), isc::dhcp::IfacesConfigParser::parse(), isc::dhcp::SharedNetwork6Parser::parse(), isc::perfdhcp::PerfSocket::receive4(), isc::perfdhcp::PerfSocket::receive6(), isc::dhcp::Dhcpv6Srv::receivePacket(), isc::dhcp::Dhcpv4Srv::receivePacket(), isc::dhcp::CfgIface::reset(), isc::perfdhcp::PerfSocket::send(), isc::dhcp::Dhcpv6Srv::sendPacket(), isc::dhcp::Dhcpv4Srv::sendPacket(), isc::dhcp::D2ClientMgr::startSender(), isc::dhcp::D2ClientMgr::stopSender(), isc::dhcp::CfgIface::use(), isc::dhcp::Dhcpv4Srv::~Dhcpv4Srv(), isc::dhcp::Dhcpv6Srv::~Dhcpv6Srv(), and isc::perfdhcp::PerfSocket::~PerfSocket().

◆ 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 58 of file iface_mgr.cc.

◆ 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 1251 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 isc::dhcp::Dhcpv4Srv::adjustRemoteAddr(), isc::dhcp::CfgIface::openSockets(), and openSockets4().

◆ 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 698 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 931 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 1088 of file iface_mgr.cc.

References isc::dhcp::Iface::addSocket(), isc::db::info, and isc::dhcp::SocketInfo::sockfd_.

Referenced by openSocket().

+ Here is the call graph for this function:

◆ 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 991 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 950 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 1014 of file iface_mgr.cc.

References isc::asiolink::IOEndpoint::create(), DHCP_IPV4_BROADCAST_ADDRESS, isc_throw, isc::asiolink::IOAddress::isV4(), 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 
)

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.
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 518 of file iface_mgr.cc.

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

Referenced by isc::dhcp::CfgIface::openSockets().

+ 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 
)

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.
Exceptions
SocketOpenFailureif tried and failed to open socket.
Returns
true if any sockets were open

Definition at line 650 of file iface_mgr.cc.

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

Referenced by isc::dhcp::CfgIface::openSockets().

+ 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 784 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 364 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 queuing 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 1126 of file iface_mgr.cc.

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

Referenced by isc::perfdhcp::PerfSocket::receive4().

+ 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 1256 of file iface_mgr.cc.

References addFDtoSet(), isc::dhcp::IfaceMgr::SocketCallbackInfo::callback_, ifaces_, isc_throw, purgeBadSockets(), and isc::dhcp::IfaceMgr::SocketCallbackInfo::socket_.

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 1134 of file iface_mgr.cc.

References addFDtoSet(), isc::dhcp::IfaceMgr::SocketCallbackInfo::callback_, isc::log::ERROR, getPacketQueue4(), isc_throw, purgeBadSockets(), and isc::dhcp::IfaceMgr::SocketCallbackInfo::socket_.

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 queuing 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 1381 of file iface_mgr.cc.

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

Referenced by isc::perfdhcp::PerfSocket::receive6().

+ 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 1402 of file iface_mgr.cc.

References addFDtoSet(), isc::dhcp::IfaceMgr::SocketCallbackInfo::callback_, ifaces_, isc_throw, purgeBadSockets(), and isc::dhcp::IfaceMgr::SocketCallbackInfo::socket_.

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 1524 of file iface_mgr.cc.

References addFDtoSet(), isc::dhcp::IfaceMgr::SocketCallbackInfo::callback_, isc::log::ERROR, FD_COPY, getPacketQueue4(), getPacketQueue6(), ifaces_, isc_throw, purgeBadSockets(), isc::dhcp::IfaceMgr::SocketCallbackInfo::socket_, and isc::dhcp::SocketInfo::sockfd_.

Referenced by receive6().

+ Here is the call graph for this function:

◆ send() [1/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 1101 of file iface_mgr.cc.

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

Referenced by isc::perfdhcp::PerfSocket::send(), isc::dhcp::Dhcpv6Srv::sendPacket(), and isc::dhcp::Dhcpv4Srv::sendPacket().

+ Here is the call graph for this function:

◆ send() [2/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 1114 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 707 of file iface_mgr.h.

Referenced by isc::dhcp::CfgIface::openSockets().

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

Referenced by isc::dhcp::Dhcpv4Srv::Dhcpv4Srv(), and isc::dhcp::CfgIface::openSockets().

◆ setPacketFilter() [1/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 388 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 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 412 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 691 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 738 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:

◆ stubDetectIfaces()

void isc::dhcp::IfaceMgr::stubDetectIfaces ( )
protected

Stub implementation of network interface detection.

This implementations reads a single line from interfaces.txt file and pretends to detect such interface. First interface name and link-local IPv6 address or IPv4 address is read from the interfaces.txt file.

Definition at line 479 of file iface_mgr.cc.

References isc_throw.

Member Data Documentation

◆ bound_address_

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

Unordered set of IPv4 bound addresses.

Definition at line 1424 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 657 of file iface_mgr.h.

Referenced by isc::dhcp::PktFilterLPF::receive().


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