lease_cmds_callouts.cc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // This Source Code Form is subject to the terms of the End User License
  4. // Agreement. See COPYING file in the premium/ directory.
  5. // Functions accessed by the hooks framework use C linkage to avoid the name
  6. // mangling that accompanies use of the C++ compiler as well as to avoid
  7. // issues related to namespaces.
  8. #include <lease_cmds.h>
  9. #include <lease_cmds_log.h>
  10. #include <cc/command_interpreter.h>
  11. #include <hooks/hooks.h>
  12. using namespace isc::config;
  13. using namespace isc::data;
  14. using namespace isc::hooks;
  15. using namespace isc::lease_cmds;
  16. extern "C" {
  17. /// @brief This is a command callout for 'lease4-add' command.
  18. ///
  19. /// @param handle Callout handle used to retrieve a command and
  20. /// provide a response.
  21. /// @return 0 if this callout has been invoked successfully,
  22. /// 1 otherwise.
  23. int lease4_add(CalloutHandle& handle) {
  24. LeaseCmds lease_cmds;
  25. return(lease_cmds.leaseAddHandler(handle));
  26. }
  27. /// @brief This is a command callout for 'lease6-add' command.
  28. ///
  29. /// @param handle Callout handle used to retrieve a command and
  30. /// provide a response.
  31. /// @return 0 if this callout has been invoked successfully,
  32. /// 1 otherwise.
  33. int lease6_add(CalloutHandle& handle) {
  34. LeaseCmds lease_cmds;
  35. return(lease_cmds.leaseAddHandler(handle));
  36. }
  37. /// @brief This is a command callout for 'lease4-get' command.
  38. ///
  39. /// @param handle Callout handle used to retrieve a command and
  40. /// provide a response.
  41. /// @return 0 if this callout has been invoked successfully,
  42. /// 1 otherwise.
  43. int lease4_get(CalloutHandle& handle) {
  44. LeaseCmds lease_cmds;
  45. return(lease_cmds.leaseGetHandler(handle));
  46. }
  47. /// @brief This is a command callout for 'lease6-get' command.
  48. ///
  49. /// @param handle Callout handle used to retrieve a command and
  50. /// provide a response.
  51. /// @return 0 if this callout has been invoked successfully,
  52. /// 1 otherwise.
  53. int lease6_get(CalloutHandle& handle) {
  54. LeaseCmds lease_cmds;
  55. return(lease_cmds.leaseGetHandler(handle));
  56. }
  57. /// @brief This is a command callout for 'lease4-del' command.
  58. ///
  59. /// @param handle Callout handle used to retrieve a command and
  60. /// provide a response.
  61. /// @return 0 if this callout has been invoked successfully,
  62. /// 1 otherwise.
  63. int lease4_del(CalloutHandle& handle) {
  64. LeaseCmds lease_cmds;
  65. return(lease_cmds.lease4DelHandler(handle));
  66. }
  67. /// @brief This is a command callout for 'lease6-del' command.
  68. ///
  69. /// @param handle Callout handle used to retrieve a command and
  70. /// provide a response.
  71. /// @return 0 if this callout has been invoked successfully,
  72. /// 1 otherwise.
  73. int lease6_del(CalloutHandle& handle) {
  74. LeaseCmds lease_cmds;
  75. return(lease_cmds.lease6DelHandler(handle));
  76. }
  77. /// @brief This is a command callout for 'lease4-update' command.
  78. ///
  79. /// @param handle Callout handle used to retrieve a command and
  80. /// provide a response.
  81. /// @return 0 if this callout has been invoked successfully,
  82. /// 1 otherwise.
  83. int lease4_update(CalloutHandle& handle) {
  84. LeaseCmds lease_cmds;
  85. return(lease_cmds.lease4UpdateHandler(handle));
  86. }
  87. /// @brief This is a command callout for 'lease6-update' command.
  88. ///
  89. /// @param handle Callout handle used to retrieve a command and
  90. /// provide a response.
  91. /// @return 0 if this callout has been invoked successfully,
  92. /// 1 otherwise.
  93. int lease6_update(CalloutHandle& handle) {
  94. LeaseCmds lease_cmds;
  95. return(lease_cmds.lease6UpdateHandler(handle));
  96. }
  97. /// @brief This is a command callout for 'lease4-wipe' command.
  98. ///
  99. /// @param handle Callout handle used to retrieve a command and
  100. /// provide a response.
  101. /// @return 0 if this callout has been invoked successfully,
  102. /// 1 otherwise.
  103. int lease4_wipe(CalloutHandle& handle) {
  104. LeaseCmds lease_cmds;
  105. return(lease_cmds.lease4WipeHandler(handle));
  106. }
  107. /// @brief This is a command callout for 'lease6-wipe' command.
  108. ///
  109. /// @param handle Callout handle used to retrieve a command and
  110. /// provide a response.
  111. /// @return 0 if this callout has been invoked successfully,
  112. /// 1 otherwise.
  113. int lease6_wipe(CalloutHandle& handle) {
  114. LeaseCmds lease_cmds;
  115. return(lease_cmds.lease6WipeHandler(handle));
  116. }
  117. /// @brief This function is called when the library is loaded.
  118. ///
  119. /// @param handle library handle
  120. /// @return 0 when initialization is successful, 1 otherwise
  121. int load(LibraryHandle& handle) {
  122. handle.registerCommandCallout("lease4-add", lease4_add);
  123. handle.registerCommandCallout("lease6-add", lease6_add);
  124. handle.registerCommandCallout("lease4-get", lease4_get);
  125. handle.registerCommandCallout("lease6-get", lease6_get);
  126. handle.registerCommandCallout("lease4-del", lease4_del);
  127. handle.registerCommandCallout("lease6-del", lease6_del);
  128. handle.registerCommandCallout("lease4-update", lease4_update);
  129. handle.registerCommandCallout("lease6-update", lease6_update);
  130. handle.registerCommandCallout("lease4-wipe", lease4_wipe);
  131. handle.registerCommandCallout("lease6-wipe", lease6_wipe);
  132. LOG_INFO(lease_cmds_logger, LEASE_CMDS_INIT_OK);
  133. return (0);
  134. }
  135. /// @brief This function is called when the library is unloaded.
  136. ///
  137. /// @return 0 if deregistration was successful, 1 otherwise
  138. int unload() {
  139. LOG_INFO(lease_cmds_logger, LEASE_CMDS_DEINIT_OK);
  140. return (0);
  141. }
  142. } // end extern "C"