Kea  2.1.7-git
load_unload.cc File Reference

Defines the load and unload hooks library functions. More...

#include <config.h>
#include <hooks/hooks.h>
#include <user_chk_log.h>
#include <user_registry.h>
#include <user_file.h>
#include <iostream>
#include <fstream>
#include <errno.h>
+ Include dependency graph for load_unload.cc:

Go to the source code of this file.

Functions

int load (LibraryHandle &)
 Called by the Hooks library manager when the library is loaded. More...
 
int unload ()
 Called by the Hooks library manager when the library is unloaded. More...
 

Variables

const char * default_user4_id_str = "00000000"
 Text id used to identify the default IPv4 user in the registry The format is a string containing an even number of hex digits. More...
 
const char * default_user6_id_str = "00000000"
 Text id used to identify the default IPv6 user in the registry The format is a string containing an even number of hex digits. More...
 
const char * query_user_id_label = "query_user_id"
 Text label of user id in the inbound query in callout context. More...
 
const char * registered_user_label = "registered_user"
 Text label of registered user pointer in callout context. More...
 
const char * registry_fname = "/tmp/user_chk_registry.txt"
 User registry input file name. More...
 
std::fstream user_chk_output
 Output filestream for recording user check outcomes. More...
 
const char * user_chk_output_fname = "/tmp/user_chk_outcome.txt"
 User check outcome file name. More...
 
UserRegistryPtr user_registry
 Pointer to the registry instance. More...
 

Detailed Description

Defines the load and unload hooks library functions.

Definition in file load_unload.cc.

Function Documentation

◆ load()

int load ( LibraryHandle )

Called by the Hooks library manager when the library is loaded.

Instantiates the UserRegistry and opens the outcome file. Failure in either results in a failed return code.

Returns
Returns 0 upon success, non-zero upon failure.

Definition at line 66 of file load_unload.cc.

References isc_throw, LOG_ERROR, registry_fname, USER_CHK_HOOK_LOAD_ERROR, user_chk::user_chk_logger, user_chk_output, user_chk_output_fname, and user_registry.

◆ unload()

int unload ( )

Called by the Hooks library manager when the library is unloaded.

Destroys the UserRegistry and closes the outcome file.

Returns
Always returns 0.

Definition at line 113 of file load_unload.cc.

References LOG_ERROR, USER_CHK_HOOK_UNLOAD_ERROR, user_chk::user_chk_logger, user_chk_output, and user_registry.

Variable Documentation

◆ default_user4_id_str

const char* default_user4_id_str = "00000000"

Text id used to identify the default IPv4 user in the registry The format is a string containing an even number of hex digits.

Text id used to identify the default IPv4 user in the registry.

This value is to look up the default IPv4 user in the user registry for the the purpose of retrieving default values for user options.

Definition at line 47 of file load_unload.cc.

Referenced by getDefaultUser4().

◆ default_user6_id_str

const char* default_user6_id_str = "00000000"

Text id used to identify the default IPv6 user in the registry The format is a string containing an even number of hex digits.

Text id used to identify the default IPv6 user in the registry.

This value is to look up the default IPv6 user in the user registry for the the purpose of retrieving default values for user options.

Definition at line 53 of file load_unload.cc.

Referenced by getDefaultUser6().

◆ query_user_id_label

const char* query_user_id_label = "query_user_id"

Text label of user id in the inbound query in callout context.

Definition at line 38 of file load_unload.cc.

Referenced by pkt4_receive(), pkt4_send(), pkt6_receive(), and pkt6_send().

◆ registered_user_label

const char* registered_user_label = "registered_user"

Text label of registered user pointer in callout context.

Definition at line 41 of file load_unload.cc.

Referenced by pkt4_receive(), pkt4_send(), pkt6_receive(), pkt6_send(), subnet4_select(), and subnet6_select().

◆ registry_fname

const char* registry_fname = "/tmp/user_chk_registry.txt"

User registry input file name.

Todo:
Hard-coded for now, this should be configurable.

Definition at line 31 of file load_unload.cc.

Referenced by load().

◆ user_chk_output

std::fstream user_chk_output

Output filestream for recording user check outcomes.

Definition at line 27 of file load_unload.cc.

Referenced by generate_output_record(), load(), and unload().

◆ user_chk_output_fname

const char* user_chk_output_fname = "/tmp/user_chk_outcome.txt"

User check outcome file name.

Todo:
Hard-coded for now, this should be configurable.

Definition at line 35 of file load_unload.cc.

Referenced by load().

◆ user_registry

UserRegistryPtr user_registry

Pointer to the registry instance.

Definition at line 24 of file load_unload.cc.

Referenced by getDefaultUser4(), getDefaultUser6(), load(), pkt4_receive(), pkt6_receive(), subnet4_select(), subnet6_select(), and unload().