31 const std::string& id_val_str,
32 const std::string& addr_str,
33 const bool& registered);
71 if (status == CalloutHandle::NEXT_STEP_DROP) {
75 if (status == CalloutHandle::NEXT_STEP_SKIP) {
83 uint8_t packet_type = response->getType();
85 std::cout <<
"DHCP UserCheckHook : pkt4_send"
86 <<
"skipping packet type: "
87 <<
static_cast<int>(packet_type) << std::endl;
102 if (registered_user) {
105 std::cout <<
"DHCP UserCheckHook : pkt4_send registered_user is: "
106 << registered_user->getUserId() << std::endl;
115 std::cout <<
"DHCP UserCheckHook : pkt4_send no registered_user"
123 }
catch (
const std::exception& ex) {
124 std::cout <<
"DHCP UserCheckHook : pkt4_send unexpected error: "
125 << ex.what() << std::endl;
151 if (status == CalloutHandle::NEXT_STEP_DROP) {
155 if (status == CalloutHandle::NEXT_STEP_SKIP) {
165 if (addr_str.empty()) {
167 std::cout <<
"pkt6_send: Skipping packet address is blank"
180 if (registered_user) {
183 std::cout <<
"DHCP UserCheckHook : pkt6_send registered_user is: "
184 << registered_user->getUserId() << std::endl;
192 std::cout <<
"DHCP UserCheckHook : pkt6_send no registered_user"
199 }
catch (
const std::exception& ex) {
200 std::cout <<
"DHCP UserCheckHook : pkt6_send unexpected error: "
201 << ex.what() << std::endl;
228 std::string opt_value = user->getProperty(
"bootfile");
229 if (!opt_value.empty()) {
230 std::cout <<
"DHCP UserCheckHook : add4Options "
231 <<
"adding boot file:" << opt_value << std::endl;
237 response->setFile((
const uint8_t*)(opt_value.c_str()),
242 opt_value = user->getProperty(
"tftp_server");
243 if (!opt_value.empty()) {
244 std::cout <<
"DHCP UserCheckHook : add4Options "
245 <<
"adding TFTP server:" << opt_value << std::endl;
260 OptionPtr opt = response->getOption(opt_code);
262 response->delOption(opt_code);
267 response->addOption(opt);
291 std::cout <<
"DHCP UserCheckHook : add6Options "
292 <<
"response has no vendor option to update" << std::endl;
297 std::string opt_value = user->getProperty(
"bootfile");
298 if (!opt_value.empty()) {
299 std::cout <<
"DHCP UserCheckHook : add6Options "
300 <<
"adding boot file:" << opt_value << std::endl;
305 opt_value = user->getProperty(
"tftp_server");
306 if (!opt_value.empty()) {
307 std::cout <<
"DHCP UserCheckHook : add6Options "
308 <<
"adding tftp server:" << opt_value << std::endl;
322 vendor->delOption(opt_code);
324 vendor->addOption(option);
374 const std::string& id_val_str,
375 const std::string& addr_str,
376 const bool& registered)
379 <<
"client=" << id_val_str << std::endl
380 <<
"addr=" << addr_str << std::endl
381 <<
"registered=" << (registered ?
"yes" :
"no")
429 boost::shared_ptr<Option6IA> ia =
430 boost::dynamic_pointer_cast<
Option6IA>(options);
438 return (std::string(
""));
446 boost::shared_ptr<Option6IAAddr> addr_option;
447 addr_option = boost::dynamic_pointer_cast<
Option6IAAddr>(options);
468 boost::shared_ptr<Option6IA> ia =
469 boost::dynamic_pointer_cast<
Option6IA>(options);
480 return (std::string(
""));
489 boost::shared_ptr<Option6IAPrefix> addr_option;
497 uint8_t prefix_len = addr_option->getLength();
501 buf << addr.
toText() <<
"/" <<
static_cast<int>(prefix_len);
517 boost::dynamic_pointer_cast
523 if (status_val != 0) {
524 std::cout <<
"SKIPPING PACKET STATUS is not success:"
525 << status_val << std::endl;
void add6Options(Pkt6Ptr &response, const UserPtr &user)
Adds IPv6 vendor options to the response packet based on given user.
boost::shared_ptr< DUID > DuidPtr
const char * query_user_id_label
Text label of user id in the inbound query in callout context.
boost::shared_ptr< OptionCustom > OptionCustomPtr
A pointer to the OptionCustom object.
std::string getAddrStrIA_PD(OptionPtr options)
Stringify the lease prefix in an D6O_IA_PD option set.
boost::shared_ptr< HWAddr > HWAddrPtr
Shared pointer to a hardware address structure.
const UserPtr & getDefaultUser6()
Fetches the default IPv6 user from the registry.
std::string getAddrStrIA_NA(OptionPtr options)
Stringify the lease address in an D6O_IA_NA option set.
const char * default_user6_id_str
Text id used to identify the default IPv6 user in the registry The format is a string containing an e...
Encapsulates a unique identifier for a DHCP client.
boost::shared_ptr< Option > OptionPtr
const UserPtr & getDefaultUser4()
Fetches the default IPv4 user from the registry.
void add6Option(OptionPtr &vendor, uint8_t opt_code, std::string &opt_value)
Adds/updates a specific IPv6 string vendor option.
boost::shared_ptr< User > UserPtr
Defines a smart pointer to a User.
const char * registered_user_label
Text label of registered user pointer in callout context.
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 logger used by the user check hooks library.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
A generic exception that is thrown if a parameter given to a method is considered invalid in that con...
boost::shared_ptr< Pkt6 > Pkt6Ptr
A pointer to Pkt6 packet.
std::fstream user_chk_output
Output filestream for recording user check outcomes.
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.
void add4Option(Pkt4Ptr &response, uint8_t opt_code, std::string &opt_value)
Adds/updates are specific IPv4 string option in response packet.
Per-packet callout handle.
void add4Options(Pkt4Ptr &response, const UserPtr &user)
Adds IPv4 options to the response packet based on given user.
#define DOCSIS3_V6_CONFIG_FILE
boost::shared_ptr< Pkt4 > Pkt4Ptr
A pointer to Pkt4 object.
CalloutNextStep
Specifies allowed next steps.
T readInteger(const uint32_t index=0) const
Read a buffer as integer value.
std::string getV6AddrStr(Pkt6Ptr response)
Stringify the lease address or prefix IPv6 response packet.
A generic exception that is thrown if a function is called in a prohibited way.
std::string toText() const
Convert the address to a string.
#define DOCSIS3_V6_TFTP_SERVERS
void getArgument(const std::string &name, T &value) const
Get argument.
bool checkIAStatus(boost::shared_ptr< Option6IA > &ia_opt)
Tests given IA option set for successful status.
UserRegistryPtr user_registry
Pointer to the registry instance.
The IOAddress class represents an IP addresses (version agnostic)
Class that represents IAPREFIX option in DHCPv6.
Option with defined data fields represented as buffers that can be accessed using data field index...
const char * default_user4_id_str
Text id used to identify the default IPv4 user in the registry The format is a string containing an e...
Class which represents an option carrying a single string value.
void getContext(const std::string &name, T &value) const
Get context.
CalloutNextStep getStatus() const
Returns the next processing step.