Kea 2.7.5
|
Defines the pkt4_send and pkt6_send callout functions. More...
#include <config.h>
#include <asiolink/io_address.h>
#include <hooks/hooks.h>
#include <dhcp/dhcp4.h>
#include <dhcp/dhcp6.h>
#include <dhcp/option_string.h>
#include <dhcp/option_custom.h>
#include <dhcp/option6_ia.h>
#include <dhcp/option6_iaaddr.h>
#include <dhcp/option6_iaprefix.h>
#include <dhcp/docsis3_option_defs.h>
#include <dhcp/pkt4.h>
#include <dhcp/pkt6.h>
#include <user_chk.h>
Go to the source code of this file.
Functions | |
void | add4Option (Pkt4Ptr &response, uint8_t opt_code, std::string &opt_value) |
Adds/updates are specific IPv4 string option in response packet. | |
void | add4Options (Pkt4Ptr &response, const UserPtr &user) |
Adds IPv4 options to the response packet based on given user. | |
void | add6Option (OptionPtr &vendor, uint8_t opt_code, std::string &opt_value) |
Adds/updates a specific IPv6 string vendor option. | |
void | add6Options (Pkt6Ptr &response, const UserPtr &user) |
Adds IPv6 vendor options to the response packet based on given user. | |
bool | checkIAStatus (boost::shared_ptr< Option6IA > &ia) |
Tests given IA option set for successful status. | |
void | generate_output_record (const std::string &id_type_str, const std::string &id_val_str, const std::string &addr_str, const bool ®istered) |
Adds an entry to the end of the user check outcome file. | |
std::string | getAddrStrIA_NA (OptionPtr options) |
Stringify the lease address in an D6O_IA_NA option set. | |
std::string | getAddrStrIA_PD (OptionPtr options) |
Stringify the lease prefix in an D6O_IA_PD option set. | |
const UserPtr & | getDefaultUser4 () |
Fetches the default IPv4 user from the registry. | |
const UserPtr & | getDefaultUser6 () |
Fetches the default IPv6 user from the registry. | |
std::string | getV6AddrStr (Pkt6Ptr response) |
Stringify the lease address or prefix IPv6 response packet. | |
int | pkt4_send (CalloutHandle &handle) |
This callout is called at the "pkt4_send" hook. | |
int | pkt6_send (CalloutHandle &handle) |
This callout is called at the "pkt6_send" hook. | |
Defines the pkt4_send and pkt6_send callout functions.
Definition in file pkt_send_co.cc.
void add4Option | ( | Pkt4Ptr & | response, |
uint8_t | opt_code, | ||
std::string & | opt_value ) |
Adds/updates are specific IPv4 string option in response packet.
response | IPV4 response packet to update |
opt_code | DHCP standard numeric code of the option |
opt_value | String value of the option |
Definition at line 258 of file pkt_send_co.cc.
References isc::dhcp::Option::V4.
Referenced by add4Options().
Adds IPv4 options to the response packet based on given user.
Adds or replaces IPv4 options with values from the given user, if the user has corresponding properties defined. Currently it supports the following options:
response | IPv4 response packet |
user | User from whom properties are sourced |
Definition at line 221 of file pkt_send_co.cc.
References add4Option(), isc::dhcp::DHO_BOOT_FILE_NAME, and isc::dhcp::DHO_TFTP_SERVER_NAME.
Referenced by pkt4_send().
void add6Option | ( | OptionPtr & | vendor, |
uint8_t | opt_code, | ||
std::string & | opt_value ) |
Adds/updates a specific IPv6 string vendor option.
vendor | IPv6 vendor option set to update |
opt_code | DHCP standard numeric code of the option |
opt_value | String value of the option |
Definition at line 321 of file pkt_send_co.cc.
References isc::dhcp::Option::V6.
Referenced by add6Options().
Adds IPv6 vendor options to the response packet based on given user.
Adds or replaces IPv6 vendor options with values from the given user, if the user has the corresponding properties defined. Currently it supports the following options:
response | IPv5 response packet |
user | User from whom properties are sourced |
Definition at line 282 of file pkt_send_co.cc.
References add6Option(), D6O_VENDOR_OPTS, DOCSIS3_V6_CONFIG_FILE, and DOCSIS3_V6_TFTP_SERVERS.
Referenced by pkt6_send().
bool checkIAStatus | ( | boost::shared_ptr< Option6IA > & | ia | ) |
Tests given IA option set for successful status.
This function is used to determine if the given Option6IA represents a successful lease operation. If it contains no status option or a status option of 0 (which is defined to mean success), then the option represents success and should contain a lease value (address or prefix).
ia | pointer to the Option6IA to test |
Definition at line 515 of file pkt_send_co.cc.
References D6O_STATUS_CODE, and isc::dhcp::OptionCustom::readInteger().
Referenced by getAddrStrIA_NA(), and getAddrStrIA_PD().
void generate_output_record | ( | const std::string & | id_type_str, |
const std::string & | id_val_str, | ||
const std::string & | addr_str, | ||
const bool & | registered ) |
Adds an entry to the end of the user check outcome file.
Each user entry is written in an ini-like format, with one name-value pair per line as follows:
id_type=<id type>
client=<id str>
subnet=<addr str>
registered=<is registered>
where: <id type> text label of the id type: "HW_ADDR" or "DUID" <id str> user's id formatted as either isc::dhcp::Hwaddr.toText() or isc::dhcp::DUID.toText() <addr str> selected subnet formatted as isc::dhcp::Subnet4::toText() or isc::dhcp::Subnet6::toText() as appropriate. <is registered> "yes" or "no"
Sample IPv4 entry would like this:
Sample IPv4 entry would like this:
id_type_str | text label identify the id type |
id_val_str | text representation of the user id |
addr_str | text representation of the selected subnet |
registered | boolean indicating if the user is registered or not |
Definition at line 373 of file pkt_send_co.cc.
References user_chk_output.
Referenced by pkt4_send(), and pkt6_send().
std::string getAddrStrIA_NA | ( | OptionPtr | options | ) |
Stringify the lease address in an D6O_IA_NA option set.
Converts the IA_NA lease address into a string suitable for the user check outcome output.
options | pointer to the Option6IA instance from which to extract the lease address. |
isc::BadValue | if the lease address cannot be extracted from options. |
Definition at line 428 of file pkt_send_co.cc.
References checkIAStatus(), D6O_IAADDR, isc_throw, and isc::asiolink::IOAddress::toText().
Referenced by getV6AddrStr().
std::string getAddrStrIA_PD | ( | OptionPtr | options | ) |
Stringify the lease prefix in an D6O_IA_PD option set.
Converts the IA_PD lease prefix into a string suitable for the user check outcome output.
options | pointer to the Option6IA instance from which to extract the lease prefix. |
isc::BadValue | if the prefix cannot be extracted from options. |
Definition at line 467 of file pkt_send_co.cc.
References checkIAStatus(), D6O_IAPREFIX, isc_throw, and isc::asiolink::IOAddress::toText().
Referenced by getV6AddrStr().
const UserPtr & getDefaultUser4 | ( | ) |
Fetches the default IPv4 user from the registry.
The default user may be used to provide default property values.
Definition at line 538 of file pkt_send_co.cc.
References default_user4_id_str, user_chk::UserId::HW_ADDRESS, and user_registry.
Referenced by pkt4_send().
const UserPtr & getDefaultUser6 | ( | ) |
Fetches the default IPv6 user from the registry.
The default user may be used to provide default property values.
Definition at line 548 of file pkt_send_co.cc.
References default_user6_id_str, user_chk::UserId::DUID, and user_registry.
Referenced by pkt6_send().
std::string getV6AddrStr | ( | Pkt6Ptr | response | ) |
Stringify the lease address or prefix IPv6 response packet.
Converts the lease value, either an address or a prefix, into a string suitable for the user check outcome output. Note that this will use the first address or prefix in the response for responses with more than one value.
response | IPv6 response packet from which to extract the lease value. |
isc::BadValue | if the response contains neither an IA_NA nor IA_PD option. |
Definition at line 402 of file pkt_send_co.cc.
References D6O_IA_NA, D6O_IA_PD, getAddrStrIA_NA(), getAddrStrIA_PD(), and isc_throw.
Referenced by pkt6_send().
int pkt4_send | ( | CalloutHandle & | handle | ) |
This callout is called at the "pkt4_send" hook.
This function generates the user check outcome and modifies options to the IPv4 response packet based on whether the user is registered or not.
It retrieves a pointer to the registered user from the callout context. This value should have been set upstream. If the registered user pointer is non-null (i.e the user is registered), then a registered user outcome is recorded in the outcome output and the vendor properties are altered based upon this user's properties.
A null value means the user is not registered and a unregistered user outcome is recorded in the outcome output and the vendor properties are altered based upon the default IPv4 user in the registry (if defined).
handle | CalloutHandle which provides access to context. |
Definition at line 69 of file pkt_send_co.cc.
References add4Options(), isc::dhcp::DHCPNAK, generate_output_record(), isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getContext(), getDefaultUser4(), isc::hooks::CalloutHandle::getStatus(), user_chk::UserId::HW_ADDRESS_STR, isc_throw, isc::hooks::CalloutHandle::NEXT_STEP_DROP, isc::hooks::CalloutHandle::NEXT_STEP_SKIP, query_user_id_label, registered_user_label, and isc::asiolink::IOAddress::toText().
int pkt6_send | ( | CalloutHandle & | handle | ) |
This callout is called at the "pkt6_send" hook.
This function generates the user check outcome and modifies options to the IPv6 response packet based on whether the user is registered or not.
It retrieves a pointer to the registered user from the callout context. This value should have been set upstream. If the registered user pointer is non-null (i.e the user is registered), then a registered user outcome is recorded in the outcome output and the vendor properties are altered based upon this user's properties.
A null value means the user is not registered and a unregistered user outcome is recorded in the outcome output and the vendor properties are altered based upon the default IPv6 user in the registry (if defined).
handle | CalloutHandle which provides access to context. |
Definition at line 149 of file pkt_send_co.cc.
References add6Options(), user_chk::UserId::DUID_STR, generate_output_record(), isc::hooks::CalloutHandle::getArgument(), isc::hooks::CalloutHandle::getContext(), getDefaultUser6(), isc::hooks::CalloutHandle::getStatus(), getV6AddrStr(), isc_throw, isc::hooks::CalloutHandle::NEXT_STEP_DROP, isc::hooks::CalloutHandle::NEXT_STEP_SKIP, query_user_id_label, and registered_user_label.