123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
- <!ENTITY mdash "—" >
- ]>
- <chapter id="hooks-libraries">
- <title>Hooks Libraries</title>
- <section id="hooks-libraries-introduction">
- <title>Introduction</title>
- <para>
- Although Kea offers a lot of flexibility, there may be cases where
- its behavior needs customisation. To accommodate this possibility,
- Kea includes the idea of "Hooks". This feature lets Kea load one
- or more dynamically-linked libraries (known as "hooks libraries")
- and, at various points in its processing ("hook points"), call
- functions in them. Those functions perform whatever custom
- processing is required.
- </para>
- <para>
- Hooks libraries are attached to individual Kea processes, not to
- Kea as a whole. This means (for example) that it is possible
- to associate one set of libraries with the DHCP4 server and a
- different set to the DHCP6 server.
- </para>
- <para>
- Another point to note is that it is possible for a process to
- load multiple libraries. When processing reaches a hook point,
- Kea calls the hooks library functions attached to it. If multiple
- libraries have attached a function to a given hook point, Kea calls
- all of them, in the order in which the libraries are specified in
- the configuration file. The order may be important: consult the
- documentation of the libraries to see if this is the case.
- </para>
- <para>
- The next section describes how to configure hooks libraries. If you
- are interested in writing your own hooks library, information can be
- found in the <ulink url="http://git.kea.isc.org/~tester/kea/doxygen">Kea
- Developer's Guide</ulink>.
- </para>
- </section> <!-- end Introduction -->
- <section>
- <title>Configuring Hooks Libraries</title>
- <para>
- The hooks libraries for a given process are configured using the
- <command>hooks-libraries</command> keyword in the
- configuration for that process. (Note that
- the word "hooks" is plural). The value of the keyword
- is an array of map structures, each structure corresponding to a hooks
- library. For example, to set up two hooks libraries for the DHCPv4
- server, the configuration would be:
- <screen>
- <userinput>"Dhcp4": {
- :
- "hooks-libraries": [
- {
- "library": "/opt/charging.so"
- },
- {
- "library": "/opt/local/notification.so",
- "parameters": {
- "mail": "spam@example.com",
- "floor": 13,
- "debug": false,
- "users": [ "alice", "bob", "charlie" ],
- "languages": {
- "french": "bonjour",
- "klingon": "yl'el"
- }
- }
- }
- ]
- :
- }</userinput>
- </screen>
- </para>
- <note><para>
- This is a change to the syntax used in Kea 0.9.2 and earlier, where
- hooks-libraries was a list of strings, each string being the name of
- a library. The change has been made in Kea 1.0 to facilitate the
- specification of library-specific parameters, a feature that will be
- added to a future version of Kea.
- </para></note>
- <note>
- <para>
- The library reloading behavior has changed in Kea 1.1. Libraries are
- reloaded, even if their list hasn't changed. Kea does that, because
- the parameters specified for the library (or the files those
- parameters point to) may have changed.
- </para>
- </note>
- <para>
- Libraries may have additional parameters. Those are not mandatory in the
- sense that there may be libraries that don't require them. However, for
- specific library there is often specific requirement for specify certain
- set of parameters. Please consult the documentation for your library
- for details. In the example above, the first library has no parameters.
- The second library has five parameters, specifying mail (string
- parameter), floor (integer parameter), debug (boolean parameter) and
- even lists (list of strings) and maps (containing strings). Nested
- parameters could be used if the library supports it. This topic is
- explained in detail in the Hooks Developer's Guide in Configuring Hooks
- Libraries section.
- </para>
- <para>
- Notes:
- <itemizedlist mark='bullet'>
- <listitem><para>
- The full path to each library should be given.
- </para></listitem>
- <listitem><para>
- As noted above, order may be important - consult the documentation for
- each library.
- </para></listitem>
- <listitem><para>
- An empty list has the same effect as omitting the
- <command>hooks-libraries</command> configuration element all together.
- </para>
- <note><para>
- There is one case where this is not true: if Kea
- is running with a configuration that contains a
- <command>hooks-libraries</command> item, and that item is
- removed and the configuration reloaded, the removal will be
- ignored and the libraries remain loaded. As a workaround,
- instead of removing the <command>hooks-libraries</command>
- item, change it to an empty list. This will be fixed in a
- future version of Kea.
- </para></note>
- </listitem>
- </itemizedlist>
- </para>
- <para>
- At the present time, only the kea-dhcp4 and kea-dhcp6 processes support
- hooks libraries.
- </para>
- </section>
- </chapter> <!-- hooks-libraries -->
|