hooks.xml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 map structures, each structure corresponding to a hooks
  49. library. For example, to set up two hooks libraries for the DHCPv4
  50. server, the configuration would be:
  51. <screen>
  52. <userinput>"Dhcp4": {
  53. :
  54. "hooks-libraries": [
  55. {
  56. "library": "/opt/charging.so"
  57. },
  58. {
  59. "library": "/opt/local/notification.so"
  60. }
  61. ]
  62. :
  63. }</userinput>
  64. </screen>
  65. </para>
  66. <note><para>
  67. This is a change to the syntax used in Kea 0.9.2 and earlier, where
  68. hooks-libraries was a list of strings, each string being the name of
  69. a library. The change has been made in Kea 1.0 to facilitate the
  70. specification of library-specific parameters, a feature that will be
  71. added to a future version of Kea.
  72. </para></note>
  73. <para>
  74. Notes:
  75. <itemizedlist mark='bullet'>
  76. <listitem><para>
  77. The full path to each library should be given.
  78. </para></listitem>
  79. <listitem><para>
  80. As noted above, order may be important - consult the documentation for
  81. each library.
  82. </para></listitem>
  83. <listitem><para>
  84. An empty list has the same effect as omitting the
  85. <command>hooks-libraries</command> configuration element all together.
  86. </para>
  87. <note><para>
  88. There is one case where this is not true: if Kea
  89. is running with a configuration that contains a
  90. <command>hooks-libraries</command> item, and that item is
  91. removed and the configuration reloaded, the removal will be
  92. ignored and the libraries remain loaded. As a workaround,
  93. instead of removing the <command>hooks-libraries</command>
  94. item, change it to an empty list. This will be fixed in a
  95. future version of Kea.
  96. </para></note>
  97. </listitem>
  98. </itemizedlist>
  99. </para>
  100. <para>
  101. At the present time, only the kea-dhcp4 and kea-dhcp6 processes support
  102. hooks libraries.
  103. </para>
  104. </section>
  105. </chapter> <!-- hooks-libraries -->