option_info.cc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright (C) 2011 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 "option_info.h"
  15. // Define the various options for the command switches
  16. namespace {
  17. isc::badpacket::OptionInfo::Parameter option_information[] = {
  18. {"qr", 0x8000, 15, 0, 1},
  19. {"op", 0x7800, 11, 0, 15},
  20. {"aa", 0x0400, 10, 0, 1},
  21. {"tc", 0x0200, 9, 0, 1},
  22. {"rd", 0x0100, 8, 0, 1},
  23. {"ra", 0x0080, 7, 0, 1},
  24. {"z", 0x0040, 6, 0, 1},
  25. {"ad", 0x0020, 5, 0, 1},
  26. {"cd", 0x0010, 4, 0, 1},
  27. {"rc", 0x000F, 0, 0, 15}
  28. };
  29. } // Anonymous namespace
  30. namespace isc {
  31. namespace badpacket {
  32. // Methods to return values from the array
  33. const char*
  34. OptionInfo::name(OptionInfo::Index i) {
  35. checkIndex(i);
  36. return (option_information[i].long_form);
  37. }
  38. uint16_t
  39. OptionInfo::mask(OptionInfo::Index i) {
  40. checkIndex(i);
  41. return (option_information[i].mask);
  42. }
  43. int
  44. OptionInfo::offset(OptionInfo::Index i) {
  45. checkIndex(i);
  46. return (option_information[i].offset);
  47. }
  48. uint32_t
  49. OptionInfo::minval(OptionInfo::Index i) {
  50. checkIndex(i);
  51. return (option_information[i].minval);
  52. }
  53. uint32_t
  54. OptionInfo::maxval(OptionInfo::Index i) {
  55. checkIndex(i);
  56. return (option_information[i].maxval);
  57. }
  58. } // namespace badpacket
  59. } // namespace isc