PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/Dnsruby-1.0/Dnsruby/resource/AAAA.rb

https://github.com/adamwiggins/whatswrong
Ruby | 54 lines | 28 code | 7 blank | 19 comment | 0 complexity | 091c1017d9585a59b9a7218d6a3e9450 MD5 | raw file
  1. #--
  2. #Copyright 2007 Nominet UK
  3. #
  4. #Licensed under the Apache License, Version 2.0 (the "License");
  5. #you may not use this file except in compliance with the License.
  6. #You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. #Unless required by applicable law or agreed to in writing, software
  11. #distributed under the License is distributed on an "AS IS" BASIS,
  12. #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. #See the License for the specific language governing permissions and
  14. #limitations under the License.
  15. #++
  16. module Dnsruby
  17. class RR
  18. module IN
  19. #Class for DNS IPv6 Address (AAAA) resource records.
  20. #
  21. #RFC 1886 Section 2, RFC 1884 Sections 2.2 & 2.4.4
  22. class AAAA < RR
  23. ClassHash[[TypeValue = Types::AAAA, ClassValue = ClassValue]] = self #:nodoc: all
  24. # The RR's (Resolv::IPv6) address field
  25. attr_accessor :address
  26. def from_data(data) #:nodoc: all
  27. @address = IPv6.create(data)
  28. end
  29. def from_hash(hash) #:nodoc: all
  30. @address = IPv6.create(hash[:address])
  31. end
  32. def from_string(input) #:nodoc: all
  33. @address = IPv6.create(input)
  34. end
  35. def rdata_to_string #:nodoc: all
  36. return @address.to_s
  37. end
  38. def encode_rdata(msg) #:nodoc: all
  39. msg.put_bytes(@address.address)
  40. end
  41. def self.decode_rdata(msg) #:nodoc: all
  42. return self.new(IPv6.new(msg.get_bytes(16)))
  43. end
  44. end
  45. end
  46. end
  47. end