opt_41.cc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 <config.h>
  15. #include <string>
  16. #include <util/buffer.h>
  17. #include <dns/messagerenderer.h>
  18. #include <dns/rdata.h>
  19. #include <dns/rdataclass.h>
  20. using namespace std;
  21. using namespace isc::util;
  22. // BEGIN_ISC_NAMESPACE
  23. // BEGIN_RDATA_NAMESPACE
  24. OPT::OPT(const std::string&) {
  25. isc_throw(InvalidRdataText, "OPT RR cannot be constructed from text");
  26. }
  27. OPT::OPT(InputBuffer& buffer, size_t rdata_len) {
  28. // setPosition() will throw against a short buffer anyway, but it's safer
  29. // to check it explicitly here.
  30. if (buffer.getLength() - buffer.getPosition() < rdata_len) {
  31. isc_throw(InvalidRdataLength, "RDLEN of OPT is too large");
  32. }
  33. // This simple implementation ignores any options
  34. buffer.setPosition(buffer.getPosition() + rdata_len);
  35. }
  36. OPT::OPT(const OPT&) : Rdata() {
  37. // there's nothing to copy in this simple implementation.
  38. }
  39. std::string
  40. OPT::toText() const {
  41. return ("");
  42. }
  43. void
  44. OPT::toWire(OutputBuffer&) const {
  45. // nothing to do, as this simple version doesn't support any options.
  46. }
  47. void
  48. OPT::toWire(AbstractMessageRenderer&) const {
  49. // nothing to do, as this simple version doesn't support any options.
  50. }
  51. int
  52. OPT::compare(const Rdata& other) const {
  53. //const OPT& other_opt = dynamic_cast<const OPT&>(other);
  54. // right now we don't need other_opt:
  55. static_cast<void>(dynamic_cast<const OPT&>(other));
  56. return (0);
  57. }
  58. // END_RDATA_NAMESPACE
  59. // END_ISC_NAMESPACE