hooks.xml 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
  4. <!ENTITY mdash "&#x2014;" >
  5. ]>
  6. <chapter id="hooks-libraries">
  7. <title>Hooks Libraries</title>
  8. <section id="hooks-libraries-introduction">
  9. <title>Introduction</title>
  10. <para>
  11. Although Kea offers a lot of flexibility, there may be cases where
  12. its behavior needs customisation. To accommodate this possibility,
  13. Kea includes the idea of "Hooks". This feature lets Kea load one
  14. or more dynamically-linked libraries (known as "hooks libraries")
  15. and, at various points in its processing ("hook points"), call
  16. functions in them. Those functions perform whatever custom
  17. processing is required.
  18. </para>
  19. <para>
  20. Hooks libraries are attached to individual Kea processes, not to
  21. Kea as a whole. This means (for example) that it is possible
  22. to associate one set of libraries with the DHCP4 server and a
  23. different set to the DHCP6 server.
  24. </para>
  25. <para>
  26. Another point to note is that it is possible for a process to
  27. load multiple libraries. At every hook point, Kea calls all
  28. hooks library functions attached it. If multiple libraries have
  29. attached a function to a given hook point, Kea calls all of them.
  30. The order in which the functions are called is the order in which
  31. the libraries are specified in the configuration file. This may
  32. be important: consult the documentation of the libraries to see
  33. if this is the case.
  34. </para>
  35. <para>
  36. The next section describes how to configure hooks libraries. If you
  37. are interested in writing your own hooks library, information can be
  38. found in the <ulink url="http://git.kea.isc.org/~tester/kea/doxygen">Kea
  39. Developer's Guide</ulink>.
  40. </para>
  41. </section> <!-- end Introduction -->
  42. <section>
  43. <title>Configuring Hooks Libraries</title>
  44. <para>
  45. The hooks libraries for a given process are configured using the
  46. <command>hooks-libraries</command> keyword in the
  47. configuration for that process. (Note that
  48. the word "hooks" is plural). The value of the keyword
  49. is an array of strings, each string corresponding to a hooks library.
  50. For example, to set up two hooks libraries for the DHCPv4 server, the
  51. configuration would be:
  52. <screen>
  53. <userinput>"Dhcp4": {
  54. :
  55. "hooks-libraries": [
  56. "/opt/charging.so",
  57. "/opt/local/notification.so"
  58. ]
  59. :
  60. }</userinput>
  61. </screen>
  62. </para>
  63. <note><para>
  64. At present, the libraries are specified as a simple list. A future
  65. version of Kea will support the capability of specifying a set of
  66. parameters for each library. When that is added, it is likely
  67. that the syntax for specifying hooks libraries will change.
  68. </para></note>
  69. <para>
  70. Notes:
  71. <itemizedlist mark='bullet'>
  72. <listitem><para>
  73. The full path to each library should be given.
  74. </para></listitem>
  75. <listitem><para>
  76. As noted above, order may be important - consult the documentation for
  77. each library.
  78. </para></listitem>
  79. <listitem><para>
  80. An empty list has the same effect as omitting the
  81. <command>hooks-libraries</command> configuration element all together.
  82. </para></listitem>
  83. </itemizedlist>
  84. </para>
  85. <para>
  86. At the present time, only the kea-dhcp4 and kea-dhcp6 processes support
  87. hooks libraries.
  88. </para>
  89. </section>
  90. </chapter> <!-- hooks-libraries -->