Kea  1.5.0
isc::dhcp::Network Class Reference

Common interface representing a network to which the DHCP clients are connected. More...

#include <network.h>

+ Inheritance diagram for isc::dhcp::Network:

Classes

class  RelayInfo
 Holds optional information about relay. More...
 

Public Types

enum  HRMode { HR_DISABLED, HR_OUT_OF_POOL, HR_GLOBAL, HR_ALL }
 Specifies allowed host reservation mode. More...
 
typedef boost::shared_ptr< Network::RelayInfoRelayInfoPtr
 Pointer to the RelayInfo structure. More...
 

Public Member Functions

 Network ()
 Constructor. More...
 
virtual ~Network ()
 Virtual destructor. More...
 
void addRelayAddress (const asiolink::IOAddress &addr)
 Adds an address to the list addresses in the network's relay info. More...
 
void allowClientClass (const isc::dhcp::ClientClass &class_name)
 Sets the supported class to class class_name. More...
 
virtual bool clientSupported (const isc::dhcp::ClientClasses &client_classes) const
 Checks whether this network supports client that belongs to specified classes. More...
 
CfgOptionPtr getCfgOption ()
 Returns pointer to the option data configuration for this subnet. More...
 
ConstCfgOptionPtr getCfgOption () const
 Returns const pointer to the option data configuration for this subnet. More...
 
const isc::dhcp::ClientClassgetClientClass () const
 returns the client class More...
 
HRMode getHostReservationMode () const
 Specifies what type of Host Reservations are supported. More...
 
std::string getIface () const
 Returns name of the local interface for which this network is selected. More...
 
const IOAddressListgetRelayAddresses () const
 Returns the list of relay addresses from the network's relay info. More...
 
const RelayInfogetRelayInfo () const
 Returns const reference to relay information. More...
 
const isc::dhcp::ClientClassesgetRequiredClasses () const
 Returns classes which are required to be evaluated. More...
 
Triplet< uint32_t > getT1 () const
 Returns T1 (renew timer), expressed in seconds. More...
 
Triplet< uint32_t > getT2 () const
 Returns T2 (rebind timer), expressed in seconds. More...
 
Triplet< uint32_t > getValid () const
 Return valid-lifetime for addresses in that prefix. More...
 
bool hasRelayAddress (const asiolink::IOAddress &address) const
 Tests if the network's relay info contains the given address. More...
 
bool hasRelays () const
 Indicates if network's relay info has relay addresses. More...
 
void requireClientClass (const isc::dhcp::ClientClass &class_name)
 Adds class class_name to classes required to be evaluated. More...
 
void setHostReservationMode (HRMode mode)
 Sets host reservation mode. More...
 
void setIface (const std::string &iface_name)
 Sets local name of the interface for which this network is selected. More...
 
void setRelayInfo (const RelayInfo &relay)
 Sets information about relay. More...
 
void setT1 (const Triplet< uint32_t > &t1)
 Sets new renew timer for a network. More...
 
void setT2 (const Triplet< uint32_t > &t2)
 Sets new rebind timer for a network. More...
 
void setValid (const Triplet< uint32_t > &valid)
 Sets new valid lifetime for a network. More...
 
virtual data::ElementPtr toElement () const
 Unparses network object. More...
 
- Public Member Functions inherited from isc::data::StampedElement
 StampedElement ()
 Constructor. More...
 
boost::posix_time::ptime getModificationTime () const
 Returns timestamp. More...
 
void setModificationTime (const boost::posix_time::ptime &timestamp)
 Sets timestamp to the explicitly provided value. More...
 
void updateModificationTime ()
 Sets timestmp to the current time. 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...
 

Protected Attributes

CfgOptionPtr cfg_option_
 Pointer to the option data configuration for this subnet. More...
 
ClientClass client_class_
 Optional definition of a client class. More...
 
HRMode host_reservation_mode_
 Specifies host reservation mode. More...
 
std::string iface_name_
 Holds interface name for which this network is selected. More...
 
RelayInfo relay_
 Relay information. More...
 
ClientClasses required_classes_
 Required classes. More...
 
Triplet< uint32_t > t1_
 a Triplet (min/default/max) holding allowed renew timer values More...
 
Triplet< uint32_t > t2_
 a Triplet (min/default/max) holding allowed rebind timer values More...
 
Triplet< uint32_t > valid_
 a Triplet (min/default/max) holding allowed valid lifetime values More...
 
- Protected Attributes inherited from isc::data::UserContext
data::ConstElementPtr user_context_
 Pointer to the user context (may be NULL) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from isc::data::UserContext
static data::ElementPtr toElement (data::ConstElementPtr map)
 Copy extracting comments an Element map. More...
 

Detailed Description

Common interface representing a network to which the DHCP clients are connected.

The most common type of network, in Kea's terminology, is a subnet. The Subnet implements this interface. Another types of objects implementing this interface are SharedNetwork4 and SharedNetwork6 objects. They group multiple subnets together to provide means for extending available address pools (a single client may obtain IP address from any of the pools belonging to subnets in the shared network), or for selecting a subnet on a given link, depending on the class of the client (e.g. cable network case: different subnet is selected for cable modems, different one for routers).

The subnets and shared networks share many data structures, e.g. DHCP options, local interface name, address manipulation methods, thus this class provides an abstract interface that must be implemented by derived classes and, where appropriate, implements common methods used by the derived classes.

Definition at line 49 of file network.h.

Member Typedef Documentation

◆ RelayInfoPtr

Pointer to the RelayInfo structure.

Definition at line 116 of file network.h.

Member Enumeration Documentation

◆ HRMode

Specifies allowed host reservation mode.

Enumerator
HR_DISABLED 

None - host reservation is disabled.

No reservation types are allowed.

HR_OUT_OF_POOL 

Only out-of-pool reservations is allowed.

This mode allows AllocEngine to skip reservation checks when dealing with with addresses that are in pool.

HR_GLOBAL 

Only global reservations are allowed.

This mode instructs AllocEngine to only look at global reservations.

HR_ALL 

Both out-of-pool and in-pool reservations are allowed.

This is the most flexible mode, where sysadmin have biggest liberty. However, there is a non-trivial performance penalty for it, as the AllocEngine code has to check whether there are reservations, even when dealing with reservations from within the dynamic pools.

Todo:
  • should ALL include global?

Definition at line 91 of file network.h.

Constructor & Destructor Documentation

◆ Network()

isc::dhcp::Network::Network ( )
inline

Constructor.

Definition at line 119 of file network.h.

◆ ~Network()

virtual isc::dhcp::Network::~Network ( )
inlinevirtual

Virtual destructor.

Does nothing at the moment.

Definition at line 127 of file network.h.

Member Function Documentation

◆ addRelayAddress()

void isc::dhcp::Network::addRelayAddress ( const asiolink::IOAddress addr)

Adds an address to the list addresses in the network's relay info.

Parameters
addraddress of the relay
Exceptions
BadValueif the address is already in the list

Definition at line 54 of file network.cc.

◆ allowClientClass()

void isc::dhcp::Network::allowClientClass ( const isc::dhcp::ClientClass class_name)

Sets the supported class to class class_name.

Parameters
class_nameclient class to be supported by this network

Definition at line 85 of file network.cc.

Referenced by isc::dhcp::Subnet6ConfigParser::initSubnet().

◆ clientSupported()

bool isc::dhcp::Network::clientSupported ( const isc::dhcp::ClientClasses client_classes) const
virtual

Checks whether this network supports client that belongs to specified classes.

This method checks whether a client that belongs to given classes can use this network. For example, if this class is reserved for client class "foo" and the client belongs to classes "foo", "bar" and "baz", it is supported. On the other hand, client belonging to classes "foobar" and "zyxxy" is not supported.

Note
: changed the planned white and black lists idea to a simple client class name.
Parameters
client_classeslist of all classes the client belongs to
Returns
true if client can be supported, false otherwise

Reimplemented in isc::dhcp::Subnet6, and isc::dhcp::Subnet4.

Definition at line 74 of file network.cc.

References isc::dhcp::ClientClasses::contains().

Referenced by isc::dhcp::Subnet4::clientSupported(), and isc::dhcp::Subnet6::clientSupported().

+ Here is the call graph for this function:

◆ getCfgOption() [1/2]

CfgOptionPtr isc::dhcp::Network::getCfgOption ( )
inline

Returns pointer to the option data configuration for this subnet.

Definition at line 303 of file network.h.

References cfg_option_.

Referenced by isc::dhcp::Subnet6ConfigParser::initSubnet().

◆ getCfgOption() [2/2]

ConstCfgOptionPtr isc::dhcp::Network::getCfgOption ( ) const
inline

Returns const pointer to the option data configuration for this subnet.

Definition at line 309 of file network.h.

References cfg_option_.

◆ getClientClass()

const isc::dhcp::ClientClass& isc::dhcp::Network::getClientClass ( ) const
inline

returns the client class

Note
The returned reference is only valid as long as the object returned it is valid.
Returns
client class client_class_

Definition at line 240 of file network.h.

References client_class_.

◆ getHostReservationMode()

HRMode isc::dhcp::Network::getHostReservationMode ( ) const
inline

Specifies what type of Host Reservations are supported.

Host reservations may be either in-pool (they reserve an address that is in the dynamic pool) or out-of-pool (they reserve an address that is not in the dynamic pool). HR may also be completely disabled for performance reasons.

Returns
whether in-pool host reservations are allowed.

Definition at line 289 of file network.h.

References host_reservation_mode_.

◆ getIface()

std::string isc::dhcp::Network::getIface ( ) const
inline

Returns name of the local interface for which this network is selected.

Returns
Interface name as text.

Definition at line 145 of file network.h.

References iface_name_.

◆ getRelayAddresses()

const IOAddressList & isc::dhcp::Network::getRelayAddresses ( ) const

Returns the list of relay addresses from the network's relay info.

Returns
const reference to the list of addresses

Definition at line 69 of file network.cc.

◆ getRelayInfo()

const RelayInfo& isc::dhcp::Network::getRelayInfo ( ) const
inline

Returns const reference to relay information.

Note
The returned reference is only valid as long as the object returned it is valid.
Returns
const reference to the relay information

Definition at line 178 of file network.h.

References relay_.

◆ getRequiredClasses()

const ClientClasses & isc::dhcp::Network::getRequiredClasses ( ) const

Returns classes which are required to be evaluated.

Definition at line 97 of file network.cc.

◆ getT1()

Triplet<uint32_t> isc::dhcp::Network::getT1 ( ) const
inline

Returns T1 (renew timer), expressed in seconds.

Definition at line 257 of file network.h.

References t1_.

◆ getT2()

Triplet<uint32_t> isc::dhcp::Network::getT2 ( ) const
inline

Returns T2 (rebind timer), expressed in seconds.

Definition at line 269 of file network.h.

References t2_.

◆ getValid()

Triplet<uint32_t> isc::dhcp::Network::getValid ( ) const
inline

Return valid-lifetime for addresses in that prefix.

Definition at line 245 of file network.h.

References valid_.

◆ hasRelayAddress()

bool isc::dhcp::Network::hasRelayAddress ( const asiolink::IOAddress address) const

Tests if the network's relay info contains the given address.

Parameters
addressaddress to search for in the relay list
Returns
True if a relay with the given address is found, false otherwise

Definition at line 64 of file network.cc.

◆ hasRelays()

bool isc::dhcp::Network::hasRelays ( ) const

Indicates if network's relay info has relay addresses.

Returns
True the relay list is not empty, false otherwise

Definition at line 59 of file network.cc.

◆ requireClientClass()

void isc::dhcp::Network::requireClientClass ( const isc::dhcp::ClientClass class_name)

Adds class class_name to classes required to be evaluated.

Parameters
class_nameclient class required to be evaluated

Definition at line 90 of file network.cc.

Referenced by isc::dhcp::Subnet6ConfigParser::initSubnet().

◆ setHostReservationMode()

void isc::dhcp::Network::setHostReservationMode ( HRMode  mode)
inline

Sets host reservation mode.

See getHostReservationMode for details.

Parameters
modemode to be set

Definition at line 298 of file network.h.

References host_reservation_mode_.

Referenced by isc::dhcp::Subnet6ConfigParser::initSubnet().

◆ setIface()

void isc::dhcp::Network::setIface ( const std::string &  iface_name)
inline

Sets local name of the interface for which this network is selected.

If the interface is specified, the server will use the network associated with this local interface to allocate IP addresses and other resources to a client.

Parameters
iface_nameInterface name.

Definition at line 137 of file network.h.

References iface_name_.

Referenced by isc::dhcp::Subnet6ConfigParser::initSubnet().

◆ setRelayInfo()

void isc::dhcp::Network::setRelayInfo ( const RelayInfo relay)
inline

Sets information about relay.

In some situations where there are shared subnets (i.e. two different subnets are available on the same physical link), there is only one relay that handles incoming requests from clients. In such a case, the usual subnet selection criteria based on relay belonging to the subnet being selected are no longer sufficient and we need to explicitly specify a relay. One notable example of such uncommon, but valid scenario is a cable network, where there is only one CMTS (one relay), but there are 2 distinct subnets behind it: one for cable modems and another one for CPEs and other user equipment behind modems. From manageability perspective, it is essential that modems get addresses from different subnet, so users won't tinker with their modems.

Setting this parameter is not needed in most deployments. This structure holds IP address only for now, but it is expected to be extended in the future.

Parameters
relaystructure that contains relay information

Definition at line 168 of file network.h.

References relay_.

◆ setT1()

void isc::dhcp::Network::setT1 ( const Triplet< uint32_t > &  t1)
inline

Sets new renew timer for a network.

Parameters
t1New renew timer value in seconds.

Definition at line 264 of file network.h.

References t1_.

Referenced by isc::dhcp::Subnet4::Subnet4(), and isc::dhcp::Subnet6::Subnet6().

◆ setT2()

void isc::dhcp::Network::setT2 ( const Triplet< uint32_t > &  t2)
inline

Sets new rebind timer for a network.

Parameters
t2New rebind timer value in seconds.

Definition at line 276 of file network.h.

References t2_.

Referenced by isc::dhcp::Subnet4::Subnet4(), and isc::dhcp::Subnet6::Subnet6().

◆ setValid()

void isc::dhcp::Network::setValid ( const Triplet< uint32_t > &  valid)
inline

Sets new valid lifetime for a network.

Parameters
validNew valid lifetime in seconds.

Definition at line 252 of file network.h.

References valid_.

Referenced by isc::dhcp::Subnet4::Subnet4(), and isc::dhcp::Subnet6::Subnet6().

◆ toElement()

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

Unparses network object.

Returns
A pointer to unparsed network configuration.

Implements isc::data::CfgToElement.

Reimplemented in isc::dhcp::Subnet6, isc::dhcp::Subnet4, isc::dhcp::Network6, isc::dhcp::Network4, isc::dhcp::SharedNetwork6, and isc::dhcp::SharedNetwork4.

Definition at line 102 of file network.cc.

References isc::dhcp::ClientClasses::cbegin(), isc::dhcp::ClientClasses::cend(), isc::dhcp::ClientClasses::empty(), and isc_throw.

+ Here is the call graph for this function:

Member Data Documentation

◆ cfg_option_

CfgOptionPtr isc::dhcp::Network::cfg_option_
protected

Pointer to the option data configuration for this subnet.

Definition at line 356 of file network.h.

Referenced by getCfgOption().

◆ client_class_

ClientClass isc::dhcp::Network::client_class_
protected

Optional definition of a client class.

If defined, only clients belonging to that class will be allowed to use this particular network. The default value for this is an empty string, which means that any client is allowed, regardless of its class.

Definition at line 333 of file network.h.

Referenced by getClientClass().

◆ host_reservation_mode_

HRMode isc::dhcp::Network::host_reservation_mode_
protected

Specifies host reservation mode.

See HRMode type for details.

Definition at line 353 of file network.h.

Referenced by getHostReservationMode(), and setHostReservationMode().

◆ iface_name_

std::string isc::dhcp::Network::iface_name_
protected

Holds interface name for which this network is selected.

Definition at line 321 of file network.h.

Referenced by getIface(), and setIface().

◆ relay_

RelayInfo isc::dhcp::Network::relay_
protected

Relay information.

See RelayInfo for detailed description.

Definition at line 326 of file network.h.

Referenced by getRelayInfo(), and setRelayInfo().

◆ required_classes_

ClientClasses isc::dhcp::Network::required_classes_
protected

Required classes.

If the network is selected these classes will be added to the incoming packet and their evaluation will be required.

Definition at line 339 of file network.h.

◆ t1_

Triplet<uint32_t> isc::dhcp::Network::t1_
protected

a Triplet (min/default/max) holding allowed renew timer values

Definition at line 342 of file network.h.

Referenced by getT1(), and setT1().

◆ t2_

Triplet<uint32_t> isc::dhcp::Network::t2_
protected

a Triplet (min/default/max) holding allowed rebind timer values

Definition at line 345 of file network.h.

Referenced by getT2(), and setT2().

◆ valid_

Triplet<uint32_t> isc::dhcp::Network::valid_
protected

a Triplet (min/default/max) holding allowed valid lifetime values

Definition at line 348 of file network.h.

Referenced by getValid(), and setValid().


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