Kea  1.9.9-git
isc::dhcp::CfgIface Class Reference

#include <cfg_iface.h>

+ Inheritance diagram for isc::dhcp::CfgIface:

Public Types

enum  OutboundIface { SAME_AS_INBOUND, USE_ROUTING }
 Indicates how outbound interface is selected for relayed traffic. More...
 
enum  SocketType { SOCKET_RAW, SOCKET_UDP }
 Socket type used by the DHCPv4 server. More...
 

Public Member Functions

 CfgIface ()
 Constructor. More...
 
void closeSockets () const
 Convenience function which closes all open sockets. More...
 
bool equals (const CfgIface &other) const
 Compares two CfgIface objects for equality. More...
 
OutboundIface getOutboundIface () const
 Returns outbound interface selection mode. More...
 
SocketType getSocketType () const
 Returns DHCP socket type used by the server. More...
 
void openSockets (const uint16_t family, const uint16_t port, const bool use_bcast=true) const
 Tries to open sockets on selected interfaces. More...
 
bool operator!= (const CfgIface &other) const
 Inequality operator. More...
 
bool operator== (const CfgIface &other) const
 Equality operator. More...
 
std::string outboundTypeToText () const
 Returns outbound interface selection mode as string. More...
 
void reset ()
 Puts the interface configuration into default state. More...
 
void setOutboundIface (const OutboundIface &outbound_iface)
 Sets outbound interface selection mode. More...
 
void setReDetect (bool re_detect)
 Set the re-detect flag. More...
 
std::string socketTypeToText () const
 Returns the socket type in the textual format. More...
 
SocketType textToSocketType (const std::string &socket_type_name) const
 Converts the socket type in the textual format to the type represented by the SocketType. More...
 
virtual isc::data::ElementPtr toElement () const
 Unparse a configuration object. More...
 
void use (const uint16_t family, const std::string &iface_name)
 Select interface to be used to receive DHCP traffic. More...
 
void useSocketType (const uint16_t family, const SocketType &socket_type)
 Sets the specified socket type to be used by the server. More...
 
void useSocketType (const uint16_t family, const std::string &socket_type_name)
 Sets the specified socket type specified in textual format. More...
 
- Public Member Functions inherited from isc::data::UserContext
void contextToElement (data::ElementPtr map) const
 Merge unparse a user_context object. More...
 
data::ConstElementPtr getContext () const
 Returns const pointer to the user context. More...
 
void setContext (const data::ConstElementPtr &ctx)
 Sets user context. More...
 
- Public Member Functions inherited from isc::data::CfgToElement
virtual ~CfgToElement ()
 Destructor. More...
 

Static Public Member Functions

static OutboundIface textToOutboundIface (const std::string &txt)
 Converts text to outbound interface selection mode. More...
 
- Static Public Member Functions inherited from isc::data::UserContext
static data::ElementPtr toElement (data::ConstElementPtr map)
 Copy an Element map. More...
 

Static Public Attributes

static const char * ALL_IFACES_KEYWORD = "*"
 Keyword used to enable all interfaces. More...
 

Additional Inherited Members

- Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr user_context_
 Pointer to the user context (may be NULL) More...
 

Detailed Description

Definition at line 130 of file cfg_iface.h.

Member Enumeration Documentation

Indicates how outbound interface is selected for relayed traffic.

Enumerator
SAME_AS_INBOUND 

Server sends responses over the same interface on which queries are received.

USE_ROUTING 

Server uses routing to determine the right interface to send response.

Definition at line 142 of file cfg_iface.h.

Socket type used by the DHCPv4 server.

Enumerator
SOCKET_RAW 

Raw socket, used for direct DHCPv4 traffic.

SOCKET_UDP 

Datagram socket, i.e. IP/UDP socket.

Definition at line 134 of file cfg_iface.h.

Constructor & Destructor Documentation

isc::dhcp::CfgIface::CfgIface ( )

Constructor.

Definition at line 24 of file cfg_iface.cc.

Member Function Documentation

void isc::dhcp::CfgIface::closeSockets ( ) const

Convenience function which closes all open sockets.

It stops the receiver thread too.

Definition at line 30 of file cfg_iface.cc.

References isc::dhcp::IfaceMgr::closeSockets(), and isc::dhcp::IfaceMgr::instance().

Referenced by openSockets().

+ Here is the call graph for this function:

bool isc::dhcp::CfgIface::equals ( const CfgIface other) const

Compares two CfgIface objects for equality.

Parameters
otherAn object to be compared with this object.
Returns
true if objects are equal, false otherwise.

Definition at line 35 of file cfg_iface.cc.

Referenced by operator!=(), and operator==().

CfgIface::OutboundIface isc::dhcp::CfgIface::getOutboundIface ( ) const

Returns outbound interface selection mode.

Returns
Outbound interface selection mode.

Definition at line 253 of file cfg_iface.cc.

SocketType isc::dhcp::CfgIface::getSocketType ( ) const
inline

Returns DHCP socket type used by the server.

Definition at line 240 of file cfg_iface.h.

void isc::dhcp::CfgIface::openSockets ( const uint16_t  family,
const uint16_t  port,
const bool  use_bcast = true 
) const

Tries to open sockets on selected interfaces.

This function opens sockets bound to link-local address as well as sockets bound to unicast address. See CfgIface::use function documentation for details how to specify interfaces and unicast addresses to bind the sockets to. This function starts the family receiver.

Parameters
familyAddress family (AF_INET or AF_INET6).
portPort number to be used to bind sockets to.
use_bcastA boolean flag which indicates if the broadcast traffic should be received through the socket. This parameter is ignored for IPv6.

Definition at line 53 of file cfg_iface.cc.

References isc::dhcp::IfaceMgr::clearUnicasts(), closeSockets(), isc::dhcp::DHCPSRV_CFGMGR_SOCKET_RAW_UNSUPPORTED, isc::dhcp::dhcpsrv_logger, isc::dhcp::DHCPSRV_MULTIPLE_RAW_SOCKETS_PER_IFACE, isc::dhcp::DHCPSRV_NO_SOCKETS_OPEN, isc::dhcp::IfaceMgr::getIface(), isc::dhcp::IfaceMgr::instance(), isc_throw, isc::dhcp::IfaceMgr::isDirectResponseSupported(), LOG_WARN, isc::dhcp::IfaceMgr::openSockets4(), isc::dhcp::IfaceMgr::openSockets6(), isc::dhcp::IfaceMgr::setAllowLoopBack(), isc::dhcp::IfaceMgr::setMatchingPacketFilter(), SOCKET_RAW, and SOCKET_UDP.

+ Here is the call graph for this function:

bool isc::dhcp::CfgIface::operator!= ( const CfgIface other) const
inline

Inequality operator.

Parameters
otherObject to be compared with this object.
Returns
true if objects are not equal, false otherwise.

Definition at line 289 of file cfg_iface.h.

References equals().

+ Here is the call graph for this function:

bool isc::dhcp::CfgIface::operator== ( const CfgIface other) const
inline

Equality operator.

Parameters
otherObject to be compared with this object.
Returns
true if objects are equal, false otherwise.

Definition at line 280 of file cfg_iface.h.

References equals().

+ Here is the call graph for this function:

std::string isc::dhcp::CfgIface::outboundTypeToText ( ) const

Returns outbound interface selection mode as string.

Returns
text representation of the outbound interface selection mode.

Definition at line 258 of file cfg_iface.cc.

References isc_throw, SAME_AS_INBOUND, and USE_ROUTING.

Referenced by toElement().

void isc::dhcp::CfgIface::reset ( )

Puts the interface configuration into default state.

This function removes interface names from the set.

Definition at line 183 of file cfg_iface.cc.

References SOCKET_RAW, and useSocketType().

+ Here is the call graph for this function:

void isc::dhcp::CfgIface::setOutboundIface ( const OutboundIface outbound_iface)

Sets outbound interface selection mode.

Parameters
outbound_ifaceNew outbound interface selection mode setting.

Definition at line 285 of file cfg_iface.cc.

void isc::dhcp::CfgIface::setReDetect ( bool  re_detect)
inline

Set the re-detect flag.

Parameters
re_detectthe new value of the flag

Definition at line 301 of file cfg_iface.h.

std::string isc::dhcp::CfgIface::socketTypeToText ( ) const

Returns the socket type in the textual format.

Definition at line 223 of file cfg_iface.cc.

References isc_throw, SOCKET_RAW, and SOCKET_UDP.

Referenced by useSocketType().

CfgIface::OutboundIface isc::dhcp::CfgIface::textToOutboundIface ( const std::string &  txt)
static

Converts text to outbound interface selection mode.

Parameters
txteither 'same-as-inbound' or 'use-routing'
Returns
Outbound interface selection mode.

Definition at line 271 of file cfg_iface.cc.

References isc_throw, SAME_AS_INBOUND, and USE_ROUTING.

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

CfgIface::SocketType isc::dhcp::CfgIface::textToSocketType ( const std::string &  socket_type_name) const

Converts the socket type in the textual format to the type represented by the SocketType.

Exceptions
InvalidSocketTypeif the specified value of the socket_type_name is invalid.

Definition at line 239 of file cfg_iface.cc.

References isc_throw, SOCKET_RAW, and SOCKET_UDP.

Referenced by useSocketType().

ElementPtr isc::dhcp::CfgIface::toElement ( ) const
virtual

Unparse a configuration object.

Returns
a pointer to unparsed configuration

Implements isc::data::CfgToElement.

Definition at line 463 of file cfg_iface.cc.

References ALL_IFACES_KEYWORD, isc::data::UserContext::contextToElement(), outboundTypeToText(), SAME_AS_INBOUND, and SOCKET_RAW.

+ Here is the call graph for this function:

void isc::dhcp::CfgIface::use ( const uint16_t  family,
const std::string &  iface_name 
)

Select interface to be used to receive DHCP traffic.

CfgIface for a detail explanation of the interface name argument.

Parameters
familyAddress family (AF_INET or AF_INET6).
iface_nameExplicit interface name, a wildcard name (*) of the interface(s) or the pair of interface/unicast-address to be used to receive DHCP traffic.
Exceptions
InvalidIfaceNameIf the interface name is incorrect, e.g. empty.
NoSuchIfaceIf the specified interface is not present.
NoSuchAddressIf the specified unicast address is not assigned to the interface.
DuplicateIfaceNameIf the interface is already selected, i.e.
IOErrorwhen specified unicast address is invalid. CfgIface::use has been already called for this interface.

Definition at line 290 of file cfg_iface.cc.

References ALL_IFACES_KEYWORD, isc::dhcp::DHCPSRV_CFGMGR_ADD_IFACE, isc::dhcp::DHCPSRV_CFGMGR_ALL_IFACES_ACTIVE, isc::dhcp::DHCPSRV_CFGMGR_UNICAST_LINK_LOCAL, isc::dhcp::DHCPSRV_CFGMGR_USE_ADDRESS, isc::dhcp::DHCPSRV_CFGMGR_USE_UNICAST, isc::dhcp::DHCPSRV_DBG_TRACE, isc::dhcp::dhcpsrv_logger, isc::dhcp::IfaceMgr::getIface(), isc::dhcp::IfaceMgr::instance(), isc_throw, isc::asiolink::IOAddress::isV4(), isc::asiolink::IOAddress::isV6(), isc::asiolink::IOAddress::isV6LinkLocal(), isc::asiolink::IOAddress::isV6Multicast(), LOG_DEBUG, LOG_INFO, LOG_WARN, isc::asiolink::IOAddress::toText(), and isc::util::str::trim().

+ Here is the call graph for this function:

void isc::dhcp::CfgIface::useSocketType ( const uint16_t  family,
const SocketType socket_type 
)

Sets the specified socket type to be used by the server.

Supported socket types for DHCPv4 are:

  • SOCKET_RAW
  • SOCKET_UDP
Parameters
familyAddress family (AF_INET or AF_INET6).
socket_typeSocket type.
Exceptions
InvalidSocketTypeif the unsupported socket type has been specified for the address family. Currently, the socket type can only be selected for the AF_INET family.

Definition at line 445 of file cfg_iface.cc.

References isc::dhcp::DHCPSRV_CFGMGR_SOCKET_TYPE_SELECT, isc::dhcp::dhcpsrv_logger, isc_throw, LOG_INFO, and socketTypeToText().

Referenced by reset(), and useSocketType().

+ Here is the call graph for this function:

void isc::dhcp::CfgIface::useSocketType ( const uint16_t  family,
const std::string &  socket_type_name 
)

Sets the specified socket type specified in textual format.

The following names of the socket types are currently supported, and can be passed in the socket_type parameter:

  • raw - for raw sockets,
  • udp - for the IP/UDP datagram sockets,
Parameters
familyAddress family (AF_INET or AF_INET6)
socket_type_nameSocket type in the textual format.
Exceptions
InvalidSocketTypeif the unsupported socket type has been specified for the address family. Currently, the socket type can only be selected for the AF_INET family.

Definition at line 457 of file cfg_iface.cc.

References textToSocketType(), and useSocketType().

+ Here is the call graph for this function:

Member Data Documentation

const char * isc::dhcp::CfgIface::ALL_IFACES_KEYWORD = "*"
static

Keyword used to enable all interfaces.

This keyword can be used instead of the interface name to specify that DHCP server should listen on all interfaces.

Definition at line 154 of file cfg_iface.h.

Referenced by toElement(), and use().


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