command.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <string>
  15. #include <cc/data.h>
  16. #ifndef COMMAND_H
  17. #define COMMAND_H 1
  18. class AuthSrv;
  19. /// Execute a control command on \c AuthSrv
  20. ///
  21. /// It executes the operation identified by \c command_id with arguments
  22. /// \c args on \c server, and returns the result in the form of the standard
  23. /// command/config answer message (see \c isc::config::createAnswer()).
  24. ///
  25. /// This method internally performs minimal validation on \c command_id and
  26. /// \c args to not cause a surprising result such as a crash, but it is
  27. /// generally expected that the caller has performed syntax level validation
  28. /// based on the command specification for the authoritative server.
  29. /// For example, the caller is responsible \c command_id is a valid command
  30. /// name for the authoritative server.
  31. ///
  32. /// The execution of the command may internally trigger an exception; for
  33. /// instance, if a string that is expected to be a valid domain name is bogus,
  34. /// the underlying DNS library will throw an exception. These internal
  35. /// exceptions will be caught inside this function, and will be converted
  36. /// to a return value with a non 0 error code.
  37. /// However, exceptions thrown outside of BIND 10 modules (including standard
  38. /// exceptions) are expected to be handled at a higher layer, and will be
  39. /// propagated to the caller. In particular if memory allocation fails and
  40. /// \c std::bad_alloc is thrown it will be propagated.
  41. ///
  42. /// \param server The \c AuthSrv object on which the command is executed.
  43. /// \param command_id The identifier of the command (such as "shutdown")
  44. /// \param args Command specific argument in a map type of
  45. /// \c isc::data::Element, or a \c NULL \c ElementPtr if the argument isn't
  46. /// specified.
  47. /// \return The result of the command operation.
  48. isc::data::ConstElementPtr
  49. execAuthServerCommand(AuthSrv& server, const std::string& command_id,
  50. isc::data::ConstElementPtr args);
  51. #endif // COMMAND_H
  52. // Local Variables:
  53. // mode: c++
  54. // End: