Kea: load_unload.cc File Reference

| Kea 3.2.0-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 user_chk/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.
int | unload ()
| Called by the Hooks library manager when the library is unloaded.

## 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.
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.
const char * | query_user_id_label = "query_user_id"
| Text label of user id in the inbound query in callout context.
const char * | registered_user_label = "registered_user"
| Text label of registered user pointer in callout context.
const char * | registry_fname = "/usr/local/share/kea/user_chk_registry.txt"
| User registry input file name.
std::fstream | user_chk_output
| Output filestream for recording user check outcomes.
const char * | user_chk_output_fname = "/usr/local/share/kea/user_chk_outcome.txt"
| User check outcome file name.
UserRegistryPtr | user_registry
| Pointer to the registry instance.

## Detailed Description

Defines the load and unload hooks library functions.

Definition in file user_chk/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 user_chk/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 117 of file user_chk/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 user_chk/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 user_chk/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 user_chk/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 user_chk/load_unload.cc.

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

## ◆ registry_fname

const char* registry_fname = "/usr/local/share/kea/user_chk_registry.txt"

User registry input file name.

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

Definition at line 31 of file user_chk/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 user_chk/load_unload.cc.

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

## ◆ user_chk_output_fname

const char* user_chk_output_fname = "/usr/local/share/kea/user_chk_outcome.txt"

User check outcome file name.

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

Definition at line 35 of file user_chk/load_unload.cc.

Referenced by load().

## ◆ user_registry

UserRegistryPtr user_registry

Pointer to the registry instance.

Definition at line 24 of file user_chk/load_unload.cc.

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