SVCBRecordInfo.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. Technitium DNS Server
  3. Copyright (C) 2024 Shreyas Zare (shreyas@technitium.com)
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. using System.IO;
  16. namespace DnsServerCore.Dns.ResourceRecords
  17. {
  18. class SVCBRecordInfo : GenericRecordInfo
  19. {
  20. #region variables
  21. bool _autoIpv4Hint;
  22. bool _autoIpv6Hint;
  23. #endregion
  24. #region constructor
  25. public SVCBRecordInfo()
  26. { }
  27. public SVCBRecordInfo(BinaryReader bR)
  28. : base(bR)
  29. { }
  30. #endregion
  31. #region protected
  32. protected override void ReadExtendedRecordInfoFrom(BinaryReader bR)
  33. {
  34. byte version = bR.ReadByte();
  35. switch (version)
  36. {
  37. case 0: //no extended info
  38. break;
  39. case 1:
  40. _autoIpv4Hint = bR.ReadBoolean();
  41. _autoIpv6Hint = bR.ReadBoolean();
  42. break;
  43. default:
  44. throw new InvalidDataException("SVCBRecordInfo format version not supported.");
  45. }
  46. }
  47. protected override void WriteExtendedRecordInfoTo(BinaryWriter bW)
  48. {
  49. bW.Write((byte)1); //version
  50. bW.Write(_autoIpv4Hint);
  51. bW.Write(_autoIpv6Hint);
  52. }
  53. #endregion
  54. #region properties
  55. public bool AutoIpv4Hint
  56. {
  57. get { return _autoIpv4Hint; }
  58. set { _autoIpv4Hint = value; }
  59. }
  60. public bool AutoIpv6Hint
  61. {
  62. get { return _autoIpv6Hint; }
  63. set { _autoIpv6Hint = value; }
  64. }
  65. #endregion
  66. }
  67. }