hooks.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. When processing reaches a hook point,
  28. Kea calls the hooks library functions attached to it. If multiple
  29. libraries have attached a function to a given hook point, Kea calls
  30. all of them, in the order in which the libraries are specified in
  31. the configuration file. The order may be important: consult the
  32. documentation of the libraries to see if this is the case.
  33. </para>
  34. <para>
  35. The next section describes how to configure hooks libraries. If you
  36. are interested in writing your own hooks library, information can be
  37. found in the <ulink url="http://git.kea.isc.org/~tester/kea/doxygen">Kea
  38. Developer's Guide</ulink>.
  39. </para>
  40. </section> <!-- end Introduction -->
  41. <section>
  42. <title>Configuring Hooks Libraries</title>
  43. <para>
  44. The hooks libraries for a given process are configured using the
  45. <command>hooks-libraries</command> keyword in the
  46. configuration for that process. (Note that
  47. the word "hooks" is plural). The value of the keyword
  48. is an array of strings, each string corresponding to a hooks library.
  49. For example, to set up two hooks libraries for the DHCPv4 server, the
  50. configuration would be:
  51. <screen>
  52. <userinput>"Dhcp4": {
  53. :
  54. "hooks-libraries": [
  55. "/opt/charging.so",
  56. "/opt/local/notification.so"
  57. ]
  58. :
  59. }</userinput>
  60. </screen>
  61. </para>
  62. <note><para>
  63. At present, the libraries are specified as a simple list. A future
  64. version of Kea will support the capability of specifying a set of
  65. parameters for each library. When that is added, it is likely
  66. that the syntax for specifying hooks libraries will change.
  67. </para></note>
  68. <para>
  69. Notes:
  70. <itemizedlist mark='bullet'>
  71. <listitem><para>
  72. The full path to each library should be given.
  73. </para></listitem>
  74. <listitem><para>
  75. As noted above, order may be important - consult the documentation for
  76. each library.
  77. </para></listitem>
  78. <listitem><para>
  79. An empty list has the same effect as omitting the
  80. <command>hooks-libraries</command> configuration element all together.
  81. </para></listitem>
  82. </itemizedlist>
  83. </para>
  84. <para>
  85. At the present time, only the kea-dhcp4 and kea-dhcp6 processes support
  86. hooks libraries.
  87. </para>
  88. </section>
  89. </chapter> <!-- hooks-libraries -->