Kea 2.7.5
isc::dhcp::Host Class Reference

Represents a device with IPv4 and/or IPv6 reservations. More...

#include <host.h>

+ Inheritance diagram for isc::dhcp::Host:

Public Types

enum  IdentifierType {
  IDENT_HWADDR , IDENT_DUID , IDENT_CIRCUIT_ID , IDENT_CLIENT_ID ,
  IDENT_FLEX
}
 Type of the host identifier. More...
 

Public Member Functions

 Host (const std::string &identifier, const std::string &identifier_name, const SubnetID ipv4_subnet_id, const SubnetID ipv6_subnet_id, const asiolink::IOAddress &ipv4_reservation, const std::string &hostname="", const std::string &dhcp4_client_classes="", const std::string &dhcp6_client_classes="", const asiolink::IOAddress &next_server=asiolink::IOAddress::IPV4_ZERO_ADDRESS(), const std::string &server_host_name="", const std::string &boot_file_name="", const AuthKey &auth_key=AuthKey(""))
 Constructor.
 
 Host (const uint8_t *identifier, const size_t identifier_len, const IdentifierType &identifier_type, const SubnetID ipv4_subnet_id, const SubnetID ipv6_subnet_id, const asiolink::IOAddress &ipv4_reservation, const std::string &hostname="", const std::string &dhcp4_client_classes="", const std::string &dhcp6_client_classes="", const asiolink::IOAddress &next_server=asiolink::IOAddress::IPV4_ZERO_ADDRESS(), const std::string &server_host_name="", const std::string &boot_file_name="", const AuthKey &auth_key=AuthKey(""))
 Constructor.
 
void addClientClass4 (const std::string &class_name)
 Adds new client class for DHCPv4.
 
void addClientClass6 (const std::string &class_name)
 Adds new client class for DHCPv6.
 
void addReservation (const IPv6Resrv &reservation)
 Adds new IPv6 reservation.
 
void encapsulateOptions () const
 Encapsulates host-specific options with their suboptions.
 
const std::string & getBootFileName () const
 Returns value of boot file name (file).
 
CfgOptionPtr getCfgOption4 ()
 Returns pointer to the DHCPv4 option data configuration for this host.
 
ConstCfgOptionPtr getCfgOption4 () const
 Returns const pointer to the DHCPv4 option data configuration for this host.
 
CfgOptionPtr getCfgOption6 ()
 Returns pointer to the DHCPv6 option data configuration for this host.
 
ConstCfgOptionPtr getCfgOption6 () const
 Returns const pointer to the DHCPv6 option data configuration for this host.
 
const ClientClassesgetClientClasses4 () const
 Returns classes which DHCPv4 client is associated with.
 
const ClientClassesgetClientClasses6 () const
 Returns classes which DHCPv6 client is associated with.
 
DuidPtr getDuid () const
 Returns DUID for which the reservations are made.
 
HostID getHostId () const
 Returns Host ID (primary key in MySQL and PostgreSQL backends)
 
const std::string & getHostname () const
 Returns reserved hostname.
 
HWAddrPtr getHWAddress () const
 Returns hardware address for which the reservations are made.
 
const std::vector< uint8_t > & getIdentifier () const
 Returns the identifier in a binary form.
 
std::string getIdentifierAsText () const
 Returns host identifier in a textual form.
 
IdentifierType getIdentifierType () const
 Returns the identifier type.
 
const asiolink::IOAddressgetIPv4Reservation () const
 Returns reserved IPv4 address.
 
SubnetID getIPv4SubnetID () const
 Returns subnet identifier for IPv4 reservation.
 
IPv6ResrvRange getIPv6Reservations () const
 Returns all IPv6 reservations.
 
IPv6ResrvRange getIPv6Reservations (const IPv6Resrv::Type &type) const
 Returns IPv6 reservations of a specified type.
 
SubnetID getIPv6SubnetID () const
 Returns subnet identifier for IPv6 reservations.
 
AuthKey getKey () const
 Returns the key.
 
std::string getLowerHostname () const
 Returns reserved hostname in lower case.
 
bool getNegative () const
 Return the negative cache flag value.
 
const asiolink::IOAddressgetNextServer () const
 Returns value of next server field (siaddr).
 
const std::string & getServerHostname () const
 Returns value of server hostname (sname).
 
bool hasIPv6Reservation () const
 Checks if there is at least one IPv6 reservation for this host.
 
bool hasReservation (const IPv6Resrv &reservation) const
 Checks if specified IPv6 reservation exists for the host.
 
void removeIPv4Reservation ()
 Removes the IPv4 reservation.
 
void setBootFileName (const std::string &boot_file_name)
 Sets new value for boot file name (file).
 
void setHostId (HostID id)
 Sets Host ID (primary key in MySQL and PostgreSQL backends)
 
void setHostname (const std::string &hostname)
 Sets new hostname.
 
void setIdentifier (const std::string &identifier, const std::string &name)
 Replaces currently used identifier with a new identifier.
 
void setIdentifier (const uint8_t *identifier, const size_t len, const IdentifierType &type)
 Replaces currently used identifier with a new identifier.
 
void setIPv4Reservation (const asiolink::IOAddress &address)
 Sets new IPv4 reservation.
 
void setIPv4SubnetID (const SubnetID ipv4_subnet_id)
 Sets new IPv4 subnet identifier.
 
void setIPv6SubnetID (const SubnetID ipv6_subnet_id)
 Sets new IPv6 subnet identifier.
 
void setKey (const AuthKey &key)
 sets key.
 
void setNegative (bool negative)
 Sets the negative cached flag.
 
void setNextServer (const asiolink::IOAddress &next_server)
 Sets new value for next server field (siaddr).
 
void setServerHostname (const std::string &server_host_name)
 Sets new value for server hostname (sname).
 
isc::data::ElementPtr toElement4 () const
 Unparses (converts to Element representation) IPv4 host.
 
isc::data::ElementPtr toElement6 () const
 Unparses (converts to Element representation) IPv6 host.
 
std::string toText () const
 Returns information about the host in the textual format.
 
- Public Member Functions inherited from isc::data::UserContext
void contextToElement (data::ElementPtr map) const
 Merge unparse a user_context object.
 
data::ConstElementPtr getContext () const
 Returns const pointer to the user context.
 
void setContext (const data::ConstElementPtr &ctx)
 Sets user context.
 

Static Public Member Functions

static std::string getIdentifierAsText (const IdentifierType &type, const uint8_t *value, const size_t length)
 Returns host identifier in textual form.
 
static size_t getIdentifierMaxLength (const IdentifierType &type)
 Get maximum identifier length.
 
static std::string getIdentifierName (const IdentifierType &type)
 Returns name of the identifier of a specified type.
 
static IdentifierType getIdentifierType (const std::string &identifier_name)
 Converts identifier name to identifier type.
 
- Static Public Member Functions inherited from isc::data::UserContext
static data::ElementPtr toElement (data::ConstElementPtr map)
 Copy an Element map.
 

Static Public Attributes

static const IdentifierType LAST_IDENTIFIER_TYPE = IDENT_FLEX
 Constant pointing to the last identifier of the IdentifierType enumeration.
 

Protected Member Functions

void setIdentifierType (const IdentifierType &type)
 Set the identifier type.
 

Additional Inherited Members

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

Detailed Description

Represents a device with IPv4 and/or IPv6 reservations.

This class represents a network device which can be identified by a unique property, such as MAC address on the interface or client identifier (DUID), and for which some resources are statically assigned:

  • IPv4 address which the device obtains when it contacts a DHCPv4 server
  • IPv6 address(es) which the device obtains when it contacts a DHCPv6 server
  • IPv6 prefix(es) obtained when the device contacts the DHCPv6 server and requests allocation of prefixes using prefix delegation mechanism
  • hostname which is used for dynamic DNS updates for both DHCPv4 and DHCPv6 exchanges.
  • client classes which the client is associated with
  • DHCP options specifically configured for the device

Note, that "host" in this context has a different meaning from host construed as device attached to a network with (possibly) multiple interfaces. For the MAC address based reservations, each interface on a network device maps to a single Host object as each Host object contains at most one MAC address. So, it is possible that a single device is associated with multiple distinct Host objects if the device has multiple interfaces. Under normal circumstances, a non-mobile dual stack device using one interface should be represented by a single Host object.

A DHCPv6 DUID is common for all interfaces on a device. Therefore, for DUID based reservations a Host object may represent a network device with multiple interfaces. However, since Host objects are grouped by subnets to which device's interfaces are connected a single instance of Host object usually defines reservations for a single interface.

The Host object combines reservations for both IPv4 and IPv6 resources to allow for correlation of the information about the dual stack devices using DHCPv4 and DHCPv6 respectively. For example: both the DHCPv4 and DHCPv6 servers may use the same database for storing host reservations, so the information about the DHCPv4 reservations are available for the DHCPv6 server and vice versa. Also, this approach allows for reserving common resources such as host name for DHCPv4 and DHCPv6 clients.

This class also holds pointers to specific DHCP options reserved for a host. Options instances are held in CfgOption objects. There are two CfgOption objects in this class, one holding DHCPv4 options, another one holding DHCPv6 options.

Todo
This class offers basic functionality for storing host information. It will need to be extended to allow for the following operations:
  • remove and replace IPv6 reservations
  • remove and replace client classes
  • disable IPv4 reservation without a need to set it to the 0.0.0.0 address Note that the last three operations are mainly required for managing host reservations which will be implemented later.

Definition at line 327 of file host.h.

Member Enumeration Documentation

◆ IdentifierType

Type of the host identifier.

Currently supported identifiers are:

  • hardware address (DHCPv4 and DHCPv6) (identifier name: "hw-address"),
  • DUID (DHCPv4 and DHCPv6) (identifier name: "duid"),
  • circuit identifier (DHCPv4) (identifier name: "circuit-id"),
  • client identifier (DHCPv4) (identifier name: "client-id")
Enumerator
IDENT_HWADDR 
IDENT_DUID 
IDENT_CIRCUIT_ID 
IDENT_CLIENT_ID 
IDENT_FLEX 

Flexible host identifier.

Definition at line 337 of file host.h.

Constructor & Destructor Documentation

◆ Host() [1/2]

isc::dhcp::Host::Host ( const uint8_t * identifier,
const size_t identifier_len,
const IdentifierType & identifier_type,
const SubnetID ipv4_subnet_id,
const SubnetID ipv6_subnet_id,
const asiolink::IOAddress & ipv4_reservation,
const std::string & hostname = "",
const std::string & dhcp4_client_classes = "",
const std::string & dhcp6_client_classes = "",
const asiolink::IOAddress & next_server = asiolink::IOAddress::IPV4_ZERO_ADDRESS(),
const std::string & server_host_name = "",
const std::string & boot_file_name = "",
const AuthKey & auth_key = AuthKey("") )

Constructor.

Creates a Host object using an identifier in a binary format. This is most useful in cases where the identifier is obtained from the database. The constructor will create an instance of the HWAddr or DUID object depending on the identifier type.

Parameters
identifierPointer to the binary value holding an identifier.
identifier_lenLength of the identifier.
identifier_typeType of the identifier (hardware address or DUID).
ipv4_subnet_idIdentifier of the IPv4 subnet to which the host is connected.
ipv6_subnet_idIdentifier of the IPv6 subnet to which the host is connected.
ipv4_reservationAn IPv4 address reserved for the client. If this address is set to 0, there is no reservation.
hostnameHostname to be allocated to both DHCPv4 and DHCPv6 clients. This is empty string if hostname is not allocated.
dhcp4_client_classesA string holding DHCPv4 client class names separated by commas. The names get trimmed by this constructor.
dhcp6_client_classesA string holding DHCPv6 client class names separated by commas. The names get trimmed by this constructor.
next_serverIPv4 address of next server (siaddr).
server_host_nameServer host name (a.k.a. sname).
boot_file_nameBoot file name (a.k.a. file).
auth_keyAuthentication key.
Exceptions
BadValueif the provided values are invalid. In particular, if the identifier is invalid.

Definition at line 177 of file host.cc.

References setIdentifier(), setIPv4Reservation(), and setNextServer().

+ Here is the call graph for this function:

◆ Host() [2/2]

isc::dhcp::Host::Host ( const std::string & identifier,
const std::string & identifier_name,
const SubnetID ipv4_subnet_id,
const SubnetID ipv6_subnet_id,
const asiolink::IOAddress & ipv4_reservation,
const std::string & hostname = "",
const std::string & dhcp4_client_classes = "",
const std::string & dhcp6_client_classes = "",
const asiolink::IOAddress & next_server = asiolink::IOAddress::IPV4_ZERO_ADDRESS(),
const std::string & server_host_name = "",
const std::string & boot_file_name = "",
const AuthKey & auth_key = AuthKey("") )

Constructor.

Creates Host object using an identifier in a textual format. This is useful in cases when the reservation is specified in the server configuration file. Identifiers can be specified in the following formats:

  • "yy:yy:yy:yy:yy:yy"
  • "yyyyyyyyyy",
  • "0xyyyyyyyyyy",
  • "'some identifier'". where y is a hexadecimal digit.

Note that it is possible to use textual representation, e.g. 'some identifier', which is converted to a vector of ASCII codes representing characters in a given string, excluding quotes. This is useful in cases when specific identifiers, e.g. circuit-id are manually assigned user friendly values.

Parameters
identifierIdentifier in the textual format. The expected formats for the hardware address and other identifiers are provided above.
identifier_nameOne of the supported identifiers in the text form as described for IdentifierType.
ipv4_subnet_idIdentifier of the IPv4 subnet to which the host is connected.
ipv6_subnet_idIdentifier of the IPv6 subnet to which the host is connected.
ipv4_reservationAn IPv4 address reserved for the client. If this address is set to 0, there is no reservation.
hostnameHostname to be allocated to both DHCPv4 and DHCPv6 clients. This is empty string if hostname is not allocated.
dhcp4_client_classesA string holding DHCPv4 client class names separated by commas. The names get trimmed by this constructor.
dhcp6_client_classesA string holding DHCPv6 client class names separated by commas. The names get trimmed by this constructor.
next_serverIPv4 address of next server (siaddr).
server_host_nameServer host name (a.k.a. sname).
boot_file_nameBoot file name (a.k.a. file).
auth_keyAuthentication key.
Exceptions
BadValueif the provided values are invalid. In particular, if the identifier is invalid.

Definition at line 215 of file host.cc.

References setIdentifier(), setIPv4Reservation(), and setNextServer().

+ Here is the call graph for this function:

Member Function Documentation

◆ addClientClass4()

void isc::dhcp::Host::addClientClass4 ( const std::string & class_name)

Adds new client class for DHCPv4.

Parameters
class_nameClass name.

Definition at line 501 of file host.cc.

◆ addClientClass6()

void isc::dhcp::Host::addClientClass6 ( const std::string & class_name)

Adds new client class for DHCPv6.

Parameters
class_nameClass name.

Definition at line 507 of file host.cc.

◆ addReservation()

void isc::dhcp::Host::addReservation ( const IPv6Resrv & reservation)

Adds new IPv6 reservation.

Parameters
reservationNew IPv6 reservation to be appended.

Definition at line 458 of file host.cc.

References hasReservation(), and isc_throw.

+ Here is the call graph for this function:

◆ encapsulateOptions()

void isc::dhcp::Host::encapsulateOptions ( ) const

Encapsulates host-specific options with their suboptions.

This function must be called before the server returns host-specific DHCP options to the client.

Definition at line 686 of file host.cc.

◆ getBootFileName()

const std::string & isc::dhcp::Host::getBootFileName ( ) const
inline

Returns value of boot file name (file).

Definition at line 668 of file host.h.

Referenced by toElement4().

◆ getCfgOption4() [1/2]

CfgOptionPtr isc::dhcp::Host::getCfgOption4 ( )
inline

Returns pointer to the DHCPv4 option data configuration for this host.

Returned pointer can be used to add, remove and update options reserved for a host.

Definition at line 677 of file host.h.

Referenced by toElement4().

◆ getCfgOption4() [2/2]

ConstCfgOptionPtr isc::dhcp::Host::getCfgOption4 ( ) const
inline

Returns const pointer to the DHCPv4 option data configuration for this host.

Definition at line 683 of file host.h.

◆ getCfgOption6() [1/2]

CfgOptionPtr isc::dhcp::Host::getCfgOption6 ( )
inline

Returns pointer to the DHCPv6 option data configuration for this host.

Returned pointer can be used to add, remove and update options reserved for a host.

Definition at line 692 of file host.h.

Referenced by toElement6().

◆ getCfgOption6() [2/2]

ConstCfgOptionPtr isc::dhcp::Host::getCfgOption6 ( ) const
inline

Returns const pointer to the DHCPv6 option data configuration for this host.

Definition at line 698 of file host.h.

◆ getClientClasses4()

const ClientClasses & isc::dhcp::Host::getClientClasses4 ( ) const
inline

Returns classes which DHCPv4 client is associated with.

Definition at line 621 of file host.h.

Referenced by toElement4().

◆ getClientClasses6()

const ClientClasses & isc::dhcp::Host::getClientClasses6 ( ) const
inline

Returns classes which DHCPv6 client is associated with.

Definition at line 631 of file host.h.

Referenced by toElement6().

◆ getDuid()

DuidPtr isc::dhcp::Host::getDuid ( ) const

Returns DUID for which the reservations are made.

Returns
Pointer to the DUID structure or null if the reservation is not associated with a DUID.

Definition at line 305 of file host.cc.

References IDENT_DUID.

Referenced by toElement4(), and toElement6().

◆ getHostId()

HostID isc::dhcp::Host::getHostId ( ) const
inline

Returns Host ID (primary key in MySQL and PostgreSQL backends)

Returns
id HostId value (or 0 if not set)

Definition at line 719 of file host.h.

◆ getHostname()

const std::string & isc::dhcp::Host::getHostname ( ) const
inline

Returns reserved hostname.

Definition at line 606 of file host.h.

Referenced by toElement4(), and toElement6().

◆ getHWAddress()

HWAddrPtr isc::dhcp::Host::getHWAddress ( ) const

Returns hardware address for which the reservations are made.

Returns
Pointer to the HWAddr structure or null if the reservation is not associated with a hardware address.

Definition at line 299 of file host.cc.

References isc::dhcp::HTYPE_ETHER, and IDENT_HWADDR.

Referenced by toElement4(), and toElement6().

◆ getIdentifier()

const std::vector< uint8_t > & isc::dhcp::Host::getIdentifier ( ) const

Returns the identifier in a binary form.

Returns
const reference to a vector<uint8_t> holding an identifier value.

Definition at line 268 of file host.cc.

Referenced by toElement4(), and toElement6().

◆ getIdentifierAsText() [1/2]

std::string isc::dhcp::Host::getIdentifierAsText ( ) const

Returns host identifier in a textual form.

Returns
Identifier in the form of type=value.

Definition at line 312 of file host.cc.

References getIdentifierAsText().

Referenced by isc::dhcp::CfgHosts::del4(), isc::dhcp::CfgHosts::del6(), isc::dhcp::HostMgr::get4Any(), isc::dhcp::HostMgr::get6Any(), getIdentifierAsText(), isc::dhcp::Dhcpv4Exchange::setHostIdentifiers(), isc::dhcp::Dhcpv6Srv::setHostIdentifiers(), and toText().

+ Here is the call graph for this function:

◆ getIdentifierAsText() [2/2]

std::string isc::dhcp::Host::getIdentifierAsText ( const IdentifierType & type,
const uint8_t * value,
const size_t length )
static

Returns host identifier in textual form.

Parameters
typeIdentifier type.
valuePointer to a buffer holding identifier.
lengthLength of the identifier.
Returns
Identifier in the form of type=value.

Definition at line 318 of file host.cc.

References isc::util::encode::encodeHex(), IDENT_CIRCUIT_ID, IDENT_CLIENT_ID, IDENT_DUID, IDENT_FLEX, and IDENT_HWADDR.

+ Here is the call graph for this function:

◆ getIdentifierMaxLength()

size_t isc::dhcp::Host::getIdentifierMaxLength ( const IdentifierType & type)
static

Get maximum identifier length.

This method returns the maximum identifier length.

Parameters
typeIdentifier type.

Definition at line 252 of file host.cc.

References IDENT_CLIENT_ID, IDENT_DUID, IDENT_HWADDR, isc::dhcp::ClientId::MAX_CLIENT_ID_LEN, isc::dhcp::DUID::MAX_DUID_LEN, and isc::dhcp::HWAddr::MAX_HWADDR_LEN.

Referenced by setIdentifier(), and setIdentifier().

◆ getIdentifierName()

std::string isc::dhcp::Host::getIdentifierName ( const IdentifierType & type)
static

Returns name of the identifier of a specified type.

Definition at line 349 of file host.cc.

References IDENT_CIRCUIT_ID, IDENT_CLIENT_ID, IDENT_DUID, IDENT_FLEX, and IDENT_HWADDR.

Referenced by isc::dhcp::HostReservationIdsParser::parseInternal(), setIdentifier(), and isc::dhcp::CfgHostOperations::toElement().

◆ getIdentifierType() [1/2]

Host::IdentifierType isc::dhcp::Host::getIdentifierType ( ) const

Returns the identifier type.

Definition at line 273 of file host.cc.

Referenced by isc::dhcp::CfgHostOperations::addIdentifierType(), setIdentifier(), toElement4(), and toElement6().

◆ getIdentifierType() [2/2]

Host::IdentifierType isc::dhcp::Host::getIdentifierType ( const std::string & identifier_name)
static

Converts identifier name to identifier type.

Parameters
identifier_nameIdentifier name.
Returns
Identifier type.

Definition at line 278 of file host.cc.

References IDENT_CIRCUIT_ID, IDENT_CLIENT_ID, IDENT_DUID, IDENT_FLEX, IDENT_HWADDR, and isc_throw.

◆ getIPv4Reservation()

const asiolink::IOAddress & isc::dhcp::Host::getIPv4Reservation ( ) const
inline

Returns reserved IPv4 address.

Returns
IPv4 address or 0.0.0.0 if no IPv4 reservation specified.

Definition at line 562 of file host.h.

Referenced by toElement4().

◆ getIPv4SubnetID()

SubnetID isc::dhcp::Host::getIPv4SubnetID ( ) const
inline

Returns subnet identifier for IPv4 reservation.

Definition at line 535 of file host.h.

◆ getIPv6Reservations() [1/2]

IPv6ResrvRange isc::dhcp::Host::getIPv6Reservations ( ) const

Returns all IPv6 reservations.

Returns
A range of iterators pointing to the reservations of the specified type.

Definition at line 475 of file host.cc.

Referenced by hasReservation(), and toElement6().

◆ getIPv6Reservations() [2/2]

IPv6ResrvRange isc::dhcp::Host::getIPv6Reservations ( const IPv6Resrv::Type & type) const

Returns IPv6 reservations of a specified type.

Parameters
typeType of the reservations to be returned (NA or PD).
Returns
A range of iterators pointing to the reservations of the specified type.

Definition at line 470 of file host.cc.

◆ getIPv6SubnetID()

SubnetID isc::dhcp::Host::getIPv6SubnetID ( ) const
inline

Returns subnet identifier for IPv6 reservations.

Definition at line 540 of file host.h.

◆ getKey()

AuthKey isc::dhcp::Host::getKey ( ) const
inline

Returns the key.

Keys are used for signing the Reconfigure Message.

Definition at line 758 of file host.h.

◆ getLowerHostname()

std::string isc::dhcp::Host::getLowerHostname ( ) const
inline

Returns reserved hostname in lower case.

Definition at line 611 of file host.h.

◆ getNegative()

bool isc::dhcp::Host::getNegative ( ) const
inline

Return the negative cache flag value.

When true standard lookup methods return null host pointer instead.

Definition at line 734 of file host.h.

◆ getNextServer()

const asiolink::IOAddress & isc::dhcp::Host::getNextServer ( ) const
inline

Returns value of next server field (siaddr).

Definition at line 644 of file host.h.

Referenced by toElement4().

◆ getServerHostname()

const std::string & isc::dhcp::Host::getServerHostname ( ) const
inline

Returns value of server hostname (sname).

Definition at line 656 of file host.h.

Referenced by toElement4().

◆ hasIPv6Reservation()

bool isc::dhcp::Host::hasIPv6Reservation ( ) const

Checks if there is at least one IPv6 reservation for this host.

Returns
true if there is a reservation for the host, false otherwise.

Definition at line 481 of file host.cc.

◆ hasReservation()

bool isc::dhcp::Host::hasReservation ( const IPv6Resrv & reservation) const

Checks if specified IPv6 reservation exists for the host.

Parameters
reservationA reservation to be checked for the host.
Returns
true if the reservation already exists for the host, false otherwise.

Definition at line 486 of file host.cc.

References getIPv6Reservations().

Referenced by addReservation().

+ Here is the call graph for this function:

◆ removeIPv4Reservation()

void isc::dhcp::Host::removeIPv4Reservation ( )

Removes the IPv4 reservation.

Sets the IPv4 reserved address to 0.

Definition at line 453 of file host.cc.

References isc::asiolink::IOAddress::IPV4_ZERO_ADDRESS().

+ Here is the call graph for this function:

◆ setBootFileName()

void isc::dhcp::Host::setBootFileName ( const std::string & boot_file_name)

Sets new value for boot file name (file).

Parameters
boot_file_nameNew value of boot file name.
Exceptions
BadValueif boot file name is longer than 128 bytes.

Definition at line 543 of file host.cc.

References isc_throw, and isc::dhcp::Pkt4::MAX_FILE_LEN.

◆ setHostId()

void isc::dhcp::Host::setHostId ( HostID id)
inline

Sets Host ID (primary key in MySQL and PostgreSQL backends)

Parameters
idHostId value

Definition at line 713 of file host.h.

◆ setHostname()

void isc::dhcp::Host::setHostname ( const std::string & hostname)
inline

Sets new hostname.

Parameters
hostnameNew hostname.

Definition at line 601 of file host.h.

◆ setIdentifier() [1/2]

void isc::dhcp::Host::setIdentifier ( const std::string & identifier,
const std::string & name )

Replaces currently used identifier with a new identifier.

This method sets a new identifier type and value for a host. This method is called by the Host constructor.

Parameters
identifierReference to a new identifier in the textual format.
nameOne of the supported identifiers in the text form as described for IdentifierType.
Exceptions
BadValueif the identifier is invalid.

Definition at line 389 of file host.cc.

References isc::util::str::decodeFormattedHexString(), getIdentifierMaxLength(), getIdentifierType(), isc_throw, and isc::util::str::quotedStringToBinary().

+ Here is the call graph for this function:

◆ setIdentifier() [2/2]

void isc::dhcp::Host::setIdentifier ( const uint8_t * identifier,
const size_t len,
const IdentifierType & type )

Replaces currently used identifier with a new identifier.

This method sets a new identifier type and value for a host. This method is called by the Host constructor.

Parameters
identifierPointer to a buffer holding an identifier.
lenLength of the identifier that the identifier points to.
typeIdentifier type.
Exceptions
BadValueif the identifier is invalid.

Definition at line 374 of file host.cc.

References getIdentifierMaxLength(), getIdentifierName(), and isc_throw.

Referenced by Host(), and Host().

+ Here is the call graph for this function:

◆ setIdentifierType()

void isc::dhcp::Host::setIdentifierType ( const IdentifierType & type)
protected

Set the identifier type.

Note
for test only!
Parameters
typeIdentifier type.

Definition at line 436 of file host.cc.

◆ setIPv4Reservation()

void isc::dhcp::Host::setIPv4Reservation ( const asiolink::IOAddress & address)

Sets new IPv4 reservation.

The new reservation removes a previous reservation.

Parameters
addressAddress to be reserved for the client.
Exceptions
isc::BadValueif the provided address is not an IPv4 address, is a 0 address or broadcast address.

Definition at line 441 of file host.cc.

References isc_throw.

Referenced by Host(), and Host().

◆ setIPv4SubnetID()

void isc::dhcp::Host::setIPv4SubnetID ( const SubnetID ipv4_subnet_id)
inline

Sets new IPv4 subnet identifier.

Parameters
ipv4_subnet_idNew subnet identifier.

Definition at line 523 of file host.h.

◆ setIPv6SubnetID()

void isc::dhcp::Host::setIPv6SubnetID ( const SubnetID ipv6_subnet_id)
inline

Sets new IPv6 subnet identifier.

Parameters
ipv6_subnet_idNew subnet identifier.

Definition at line 530 of file host.h.

◆ setKey()

void isc::dhcp::Host::setKey ( const AuthKey & key)
inline

sets key.

Keys are used for signing the Reconfigure Message.

Definition at line 751 of file host.h.

◆ setNegative()

void isc::dhcp::Host::setNegative ( bool negative)
inline

Sets the negative cached flag.

Parameters
negativesets whether this is a negative cached host, i.e. a fake host in the cache which indicates non-existence and avoids to lookup in a slow backend.

Definition at line 728 of file host.h.

◆ setNextServer()

void isc::dhcp::Host::setNextServer ( const asiolink::IOAddress & next_server)

Sets new value for next server field (siaddr).

Parameters
next_serverNew address of a next server.
Exceptions
isc::BadValueif the provided address is not an IPv4 address, is broadcast address.

Definition at line 521 of file host.cc.

References isc_throw.

Referenced by Host(), and Host().

◆ setServerHostname()

void isc::dhcp::Host::setServerHostname ( const std::string & server_host_name)

Sets new value for server hostname (sname).

Parameters
server_host_nameNew value for server hostname.
Exceptions
BadValueif hostname is longer than 63 bytes.

Definition at line 534 of file host.cc.

References isc_throw, and isc::dhcp::Pkt4::MAX_SNAME_LEN.

◆ toElement4()

ElementPtr isc::dhcp::Host::toElement4 ( ) const

Unparses (converts to Element representation) IPv4 host.

Returns
Element representation of the host

Definition at line 552 of file host.cc.

References isc::data::UserContext::contextToElement(), isc::data::Element::create(), isc::data::Element::createList(), isc::data::Element::createMap(), isc::util::encode::encodeHex(), getBootFileName(), getCfgOption4(), getClientClasses4(), getDuid(), getHostname(), getHWAddress(), getIdentifier(), getIdentifierType(), getIPv4Reservation(), getNextServer(), getServerHostname(), IDENT_CIRCUIT_ID, IDENT_CLIENT_ID, IDENT_DUID, IDENT_FLEX, IDENT_HWADDR, and isc_throw.

+ Here is the call graph for this function:

◆ toElement6()

ElementPtr isc::dhcp::Host::toElement6 ( ) const

Unparses (converts to Element representation) IPv6 host.

Returns
Element representation of the host

Definition at line 613 of file host.cc.

References isc::data::UserContext::contextToElement(), isc::data::Element::create(), isc::data::Element::createList(), isc::data::Element::createMap(), isc::util::encode::encodeHex(), getCfgOption6(), getClientClasses6(), getDuid(), getHostname(), getHWAddress(), getIdentifier(), getIdentifierType(), getIPv6Reservations(), IDENT_CIRCUIT_ID, IDENT_CLIENT_ID, IDENT_DUID, IDENT_FLEX, IDENT_HWADDR, isc_throw, isc::dhcp::IPv6Resrv::TYPE_NA, and isc::dhcp::IPv6Resrv::TYPE_PD.

+ Here is the call graph for this function:

◆ toText()

std::string isc::dhcp::Host::toText ( ) const

Returns information about the host in the textual format.

Definition at line 696 of file host.cc.

References getIdentifierAsText(), isc::asiolink::IOAddress::isV4Zero(), isc::asiolink::IOAddress::toText(), and isc::dhcp::AuthKey::toText().

+ Here is the call graph for this function:

Member Data Documentation

◆ LAST_IDENTIFIER_TYPE

const IdentifierType isc::dhcp::Host::LAST_IDENTIFIER_TYPE = IDENT_FLEX
static

Constant pointing to the last identifier of the IdentifierType enumeration.

Definition at line 347 of file host.h.

Referenced by isc::dhcp::HostReservationIdsParser::parseInternal().


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