Kea
1.9.9-git
|
Per-packet callout handle. More...
#include <callout_handle.h>
Public Types | |
enum | CalloutNextStep { NEXT_STEP_CONTINUE = 0, NEXT_STEP_SKIP = 1, NEXT_STEP_DROP = 2, NEXT_STEP_PARK = 3 } |
Specifies allowed next steps. More... | |
typedef std::map< int, ElementCollection > | ContextCollection |
Typedef to allow abbreviations in specifications when accessing context. More... | |
typedef std::map< std::string, boost::any > | ElementCollection |
Typedef to allow abbreviation of iterator specification in methods. More... | |
Public Member Functions | |
CalloutHandle (const boost::shared_ptr< CalloutManager > &manager, const boost::shared_ptr< LibraryManagerCollection > &lmcoll=boost::shared_ptr< LibraryManagerCollection >()) | |
Constructor. More... | |
~CalloutHandle () | |
Destructor. More... | |
void | deleteAllArguments () |
Delete all arguments. More... | |
void | deleteAllContext () |
Delete all context items. More... | |
void | deleteArgument (const std::string &name) |
Delete argument. More... | |
void | deleteContext (const std::string &name) |
Delete context element. More... | |
template<typename T > | |
void | getArgument (const std::string &name, T &value) const |
Get argument. More... | |
std::vector< std::string > | getArgumentNames () const |
Get argument names. More... | |
template<typename T > | |
void | getContext (const std::string &name, T &value) const |
Get context. More... | |
std::vector< std::string > | getContextNames () const |
Get context names. More... | |
int | getCurrentHook () const |
Get current hook index. More... | |
int | getCurrentLibrary () const |
Get current library index. More... | |
std::string | getHookName () const |
Get hook name. More... | |
ParkingLotHandlePtr | getParkingLotHandlePtr () const |
Returns pointer to the parking lot handle for this hook point. More... | |
CalloutNextStep | getStatus () const |
Returns the next processing step. More... | |
template<typename T > | |
void | setArgument (const std::string &name, T value) |
Set argument. More... | |
template<typename T > | |
void | setContext (const std::string &name, T value) |
Set context. More... | |
void | setCurrentHook (int hook_index) |
Set current hook index. More... | |
void | setCurrentLibrary (int library_index) |
Set current library index. More... | |
void | setStatus (const CalloutNextStep next) |
Sets the next processing step. More... | |
Per-packet callout handle.
An object of this class is associated with every packet (or request) processed by the server. It forms the principle means of passing data between the server and the user-library callouts.
The class allows access to the following information:
Definition at line 77 of file callout_handle.h.
typedef std::map<int, ElementCollection> isc::hooks::CalloutHandle::ContextCollection |
Typedef to allow abbreviations in specifications when accessing context.
The ElementCollection is the name/value collection for a particular context. The "int" corresponds to the index of an associated library - there is a 1:1 correspondence between libraries and a name.value collection.
The collection of contexts is stored in a map, as not every library will require creation of a context associated with each packet. In addition, the structure is more flexible in that the size does not need to be set when the CalloutHandle is constructed.
Definition at line 108 of file callout_handle.h.
typedef std::map<std::string, boost::any> isc::hooks::CalloutHandle::ElementCollection |
Typedef to allow abbreviation of iterator specification in methods.
The std::string is the argument name and the "boost::any" is the corresponding value associated with it.
Definition at line 96 of file callout_handle.h.
Specifies allowed next steps.
Those values are used to designate the next step in packet processing. They are set by hook callouts and read by the Kea server. See setStatus for detailed description of each value.
Enumerator | |
---|---|
NEXT_STEP_CONTINUE |
continue normally |
NEXT_STEP_SKIP |
skip the next processing step |
NEXT_STEP_DROP |
drop the packet |
NEXT_STEP_PARK |
park the packet |
Definition at line 85 of file callout_handle.h.
isc::hooks::CalloutHandle::CalloutHandle | ( | const boost::shared_ptr< CalloutManager > & | manager, |
const boost::shared_ptr< LibraryManagerCollection > & | lmcoll = boost::shared_ptr<LibraryManagerCollection>() |
||
) |
Constructor.
Creates the object and calls the callouts on the "context_create" hook.
Of the two arguments passed, only the pointer to the callout manager is actively used. The second argument, the pointer to the library manager collection, is used for lifetime control: after use, the callout handle may contain pointers to memory allocated by the loaded libraries. The used of a shared pointer to the collection of library managers means that the libraries that could have allocated memory in a callout handle will not be unloaded until all such handles have been destroyed. This issue is discussed in more detail in the documentation for isc::hooks::LibraryManager.
manager | Pointer to the callout manager object. |
lmcoll | Pointer to the library manager collection. This has a null default for testing purposes. |
Definition at line 24 of file callout_handle.cc.
References isc::hooks::ServerHooks::CONTEXT_CREATE.
isc::hooks::CalloutHandle::~CalloutHandle | ( | ) |
Destructor.
Calls the context_destroy callback to release any per-packet context. It also clears stored data to avoid problems during member destruction.
Definition at line 37 of file callout_handle.cc.
References isc::hooks::ServerHooks::CONTEXT_DESTROY.
|
inline |
Delete all arguments.
Deletes all arguments associated with this context.
N.B. If any elements are raw pointers, the pointed-to data is NOT deleted by this method.
Definition at line 200 of file callout_handle.h.
|
inline |
Delete all context items.
Deletes all items from the context associated with the current library.
N.B. If any elements are raw pointers, the pointed-to data is NOT deleted by this.
Definition at line 312 of file callout_handle.h.
|
inline |
Delete argument.
Deletes an argument of the given name. If an argument of that name does not exist, the method is a no-op.
N.B. If the element is a raw pointer, the pointed-to data is NOT deleted by this method.
name | Name of the element in the argument list to set. |
Definition at line 190 of file callout_handle.h.
|
inline |
Delete context element.
Deletes an item of the given name from the context associated with the current library. If an item of that name does not exist, the method is a no-op.
N.B. If the element is a raw pointer, the pointed-to data is NOT deleted by this.
name | Name of the context item to delete. |
Definition at line 302 of file callout_handle.h.
|
inline |
Get argument.
Gets the value of an argument.
name | Name of the element in the argument list to get. |
value | [out] Value to set. The type of "value" is important: it must match the type of the value set. |
NoSuchArgument | No argument with the given name is present. |
boost::bad_any_cast | An argument with the given name is present, but the data type of the value is not the same as the type of the variable provided to receive the value. |
Definition at line 163 of file callout_handle.h.
References isc_throw.
Referenced by buffer4_receive(), isc::ha::HAImpl::buffer4Receive(), isc::ha::HAImpl::buffer6Receive(), isc::ha::HAImpl::commandProcessed(), dhcp4_srv_configured(), dhcp6_srv_configured(), isc::config::CmdsImpl::extractCommand(), isc::ha::HAImpl::leases4Committed(), isc::ha::HAImpl::leases6Committed(), isc::ha::HAImpl::maintenanceNotifyHandler(), pkt4_receive(), pkt4_send(), pkt6_receive(), pkt6_send(), isc::ha::HAImpl::scopesHandler(), subnet4_select(), subnet6_select(), and isc::ha::HAImpl::synchronizeHandler().
vector< string > isc::hooks::CalloutHandle::getArgumentNames | ( | ) | const |
Get argument names.
Returns a vector holding the names of arguments in the argument vector.
Definition at line 65 of file callout_handle.cc.
|
inline |
Get context.
Gets an element from the context associated with the current library.
name | Name of the element in the context to get. |
value | [out] Value to set. The type of "value" is important: it must match the type of the value set. |
NoSuchCalloutContext | Thrown if no context element with the name "name" is present. |
boost::bad_any_cast | Thrown if the context element is present but the type of the data is not the same as the type of the variable provided to receive its value. |
Definition at line 270 of file callout_handle.h.
References isc_throw.
Referenced by pkt4_send(), pkt6_send(), subnet4_select(), and subnet6_select().
vector< string > isc::hooks::CalloutHandle::getContextNames | ( | ) | const |
Get context names.
Returns a vector holding the names of items in the context associated with the current library.
Definition at line 111 of file callout_handle.cc.
|
inline |
Get current hook index.
Definition at line 347 of file callout_handle.h.
Referenced by isc::hooks::CalloutManager::callCallouts().
|
inline |
Get current library index.
Definition at line 333 of file callout_handle.h.
Referenced by isc::hooks::CalloutManager::callCallouts().
string isc::hooks::CalloutHandle::getHookName | ( | ) | const |
Get hook name.
Get the name of the hook to which the current callout is attached. This can be the null string if the CalloutHandle is being accessed outside of the CalloutManager's "callCallouts" method.
Definition at line 127 of file callout_handle.cc.
References isc::hooks::ServerHooks::getName().
ParkingLotHandlePtr isc::hooks::CalloutHandle::getParkingLotHandlePtr | ( | ) | const |
Returns pointer to the parking lot handle for this hook point.
Definition at line 76 of file callout_handle.cc.
References isc::hooks::ServerHooks::getParkingLotPtr().
Referenced by isc::ha::HAImpl::leases4Committed(), and isc::ha::HAImpl::leases6Committed().
|
inline |
Returns the next processing step.
Gets the current value of the next step. See setStatus for detailed definition.
Definition at line 240 of file callout_handle.h.
Referenced by buffer4_receive(), isc::ha::HAImpl::buffer4Receive(), buffer6_receive(), isc::ha::HAImpl::buffer6Receive(), leases4_committed(), leases6_committed(), pkt4_receive(), pkt4_send(), pkt6_receive(), pkt6_send(), subnet4_select(), and subnet6_select().
|
inline |
Set argument.
Sets the value of an argument. The argument is created if it does not already exist.
name | Name of the argument. |
value | Value to set. That can be of any data type. |
Definition at line 146 of file callout_handle.h.
Referenced by isc::ha::HAImpl::continueHandler(), isc::ha::HAImpl::haResetHandler(), isc::ha::HAImpl::heartbeatHandler(), isc::ha::HAImpl::maintenanceCancelHandler(), isc::ha::HAImpl::maintenanceNotifyHandler(), isc::ha::HAImpl::maintenanceStartHandler(), isc::ha::HAImpl::scopesHandler(), isc::config::CmdsImpl::setResponse(), subnet4_select(), subnet6_select(), and isc::ha::HAImpl::synchronizeHandler().
|
inline |
Set context.
Sets an element in the context associated with the current library. If an element of the name is already present, it is replaced.
name | Name of the element in the context to set. |
value | Value to set. |
Definition at line 252 of file callout_handle.h.
Referenced by pkt4_receive(), and pkt6_receive().
|
inline |
Set current hook index.
hook_index | The hook index |
Definition at line 354 of file callout_handle.h.
Referenced by isc::hooks::CalloutManager::callCallouts().
|
inline |
Set current library index.
library_index | The library index |
Definition at line 340 of file callout_handle.h.
Referenced by isc::hooks::CalloutManager::callCallouts().
|
inline |
Sets the next processing step.
This method is used by the callouts to determine the next step in processing. This method replaces former setSkip() method that allowed only two values.
Currently there are three possible value allowed: NEXT_STEP_CONTINUE - tells the server to continue processing as usual (equivalent of previous setSkip(false) )
NEXT_STEP_SKIP - tells the server to skip the processing. Exact meaning is hook specific. See hook documentation for details. (equivalent of previous setSkip(true))
NEXT_STEP_DROP - tells the server to unconditionally drop the packet and do not process it further.
NEXT_STEP_PARK - tells the server to "park" the packet. The packet will wait in the queue for being unparked, e.g. as a result of completion of the asynchronous performed by the hooks library operation.
This variable is interrogated by the server to see if the remaining callouts associated with the current hook should be bypassed.
next | New value of the next step status. |
Definition at line 230 of file callout_handle.h.
Referenced by buffer4_receive(), isc::ha::HAImpl::buffer4Receive(), isc::ha::HAImpl::buffer6Receive(), isc::hooks::CalloutManager::callCallouts(), isc::ha::HAImpl::leases4Committed(), isc::ha::HAImpl::leases6Committed(), and pkt4_send().