31 const std::string& id_val_str,
32 const std::string& addr_str,
33 const bool& registered);
74 uint8_t packet_type = response->getType();
76 std::cout <<
"DHCP UserCheckHook : pkt4_send" 77 <<
"skipping packet type: " 78 << static_cast<int>(packet_type) << std::endl;
93 if (registered_user) {
96 std::cout <<
"DHCP UserCheckHook : pkt4_send registered_user is: " 97 << registered_user->getUserId() << std::endl;
106 std::cout <<
"DHCP UserCheckHook : pkt4_send no registered_user" 114 }
catch (
const std::exception& ex) {
115 std::cout <<
"DHCP UserCheckHook : pkt4_send unexpected error: " 116 << ex.what() << std::endl;
147 if (addr_str.empty()) {
149 std::cout <<
"pkt6_send: Skipping packet address is blank" 162 if (registered_user) {
165 std::cout <<
"DHCP UserCheckHook : pkt6_send registered_user is: " 166 << registered_user->getUserId() << std::endl;
174 std::cout <<
"DHCP UserCheckHook : pkt6_send no registered_user" 181 }
catch (
const std::exception& ex) {
182 std::cout <<
"DHCP UserCheckHook : pkt6_send unexpected error: " 183 << ex.what() << std::endl;
210 std::string opt_value = user->getProperty(
"bootfile");
211 if (!opt_value.empty()) {
212 std::cout <<
"DHCP UserCheckHook : add4Options " 213 <<
"adding boot file:" << opt_value << std::endl;
219 response->setFile((
const uint8_t*)(opt_value.c_str()),
224 opt_value = user->getProperty(
"tftp_server");
225 if (!opt_value.empty()) {
226 std::cout <<
"DHCP UserCheckHook : add4Options " 227 <<
"adding TFTP server:" << opt_value << std::endl;
242 OptionPtr opt = response->getOption(opt_code);
244 response->delOption(opt_code);
249 response->addOption(opt);
273 std::cout <<
"DHCP UserCheckHook : add6Options " 274 <<
"response has no vendor option to update" << std::endl;
279 std::string opt_value = user->getProperty(
"bootfile");
280 if (!opt_value.empty()) {
281 std::cout <<
"DHCP UserCheckHook : add6Options " 282 <<
"adding boot file:" << opt_value << std::endl;
287 opt_value = user->getProperty(
"tftp_server");
288 if (!opt_value.empty()) {
289 std::cout <<
"DHCP UserCheckHook : add6Options " 290 <<
"adding tftp server:" << opt_value << std::endl;
304 vendor->delOption(opt_code);
306 vendor->addOption(option);
356 const std::string& id_val_str,
357 const std::string& addr_str,
358 const bool& registered)
361 <<
"client=" << id_val_str << std::endl
362 <<
"addr=" << addr_str << std::endl
363 <<
"registered=" << (registered ?
"yes" :
"no")
411 boost::shared_ptr<Option6IA> ia =
412 boost::dynamic_pointer_cast<Option6IA>(options);
420 return (std::string(
""));
428 boost::shared_ptr<Option6IAAddr> addr_option;
429 addr_option = boost::dynamic_pointer_cast<Option6IAAddr>(options);
450 boost::shared_ptr<Option6IA> ia =
451 boost::dynamic_pointer_cast<Option6IA>(options);
462 return (std::string(
""));
471 boost::shared_ptr<Option6IAPrefix> addr_option;
472 addr_option = boost::dynamic_pointer_cast<Option6IAPrefix>(options);
479 uint8_t prefix_len = addr_option->getLength();
483 buf << addr.
toText() <<
"/" << static_cast<int>(prefix_len);
499 boost::dynamic_pointer_cast
505 if (status_val != 0) {
506 std::cout <<
"SKIPPING PACKET STATUS is not success:" 507 << 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.
void getContext(const std::string &name, T &value) const
Get context.
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.
std::string getV6AddrStr(Pkt6Ptr response)
Stringify the lease address or prefix IPv6 response packet.
std::string toText() const
Convert the address to a string.
void getArgument(const std::string &name, T &value) const
Get argument.
#define DOCSIS3_V6_TFTP_SERVERS
bool checkIAStatus(boost::shared_ptr< Option6IA > &ia_opt)
Tests given IA option set for successful status.
T readInteger(const uint32_t index=0) const
Read a buffer as integer value.
UserRegistryPtr user_registry
Pointer to the registry instance.
The IOAddress class represents an IP addresses (version agnostic)
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.