Class: Dnsruby::Types

Inherits:
CodeMapper show all
Defined in:
lib/dnsruby/code_mappers.rb

Overview

The RR types explicitly supported by Dnsruby.

New RR types should be added to this set

Constant Summary collapse

SIGZERO =

RFC2931 consider this a pseudo type

0
A =

RFC 1035, Section 3.4.1

1
NS =

RFC 1035, Section 3.3.11

2
MD =

RFC 1035, Section 3.3.4 (obsolete)

3
MF =

RFC 1035, Section 3.3.5 (obsolete)

4
CNAME =

RFC 1035, Section 3.3.1

5
SOA =

RFC 1035, Section 3.3.13

6
MB =

RFC 1035, Section 3.3.3

7
MG =

RFC 1035, Section 3.3.6

8
MR =

RFC 1035, Section 3.3.8

9
NULL =

RFC 1035, Section 3.3.10

10
WKS =

RFC 1035, Section 3.4.2 (deprecated)

11
PTR =

RFC 1035, Section 3.3.12

12
HINFO =

RFC 1035, Section 3.3.2

13
MINFO =

RFC 1035, Section 3.3.7

14
MX =

RFC 1035, Section 3.3.9

15
TXT =

RFC 1035, Section 3.3.14

16
RP =

RFC 1183, Section 2.2

17
AFSDB =

RFC 1183, Section 1

18
X25 =

RFC 1183, Section 3.1

19
ISDN =

RFC 1183, Section 3.2

20
RT =

RFC 1183, Section 3.3

21
NSAP =

RFC 1706, Section 5

22
NSAP_PTR =

RFC 1348 (obsolete)

23
SIG =

RFC 2535, Section 4.1

24
KEY =

RFC 2535, Section 3.1

25
PX =

RFC 2163,

26
GPOS =

RFC 1712 (obsolete)

27
AAAA =

RFC 1886, Section 2.1

28
LOC =

RFC 1876

29
NXT =

RFC 2535, Section 5.2 obsoleted by RFC3755

30
EID =

draft-ietf-nimrod-dns-xx.txt

31
NIMLOC =

draft-ietf-nimrod-dns-xx.txt

32
SRV =

RFC 2052

33
ATMA =

???

34
NAPTR =

RFC 2168

35
KX =

RFC 2230

36
CERT =

RFC 2538

37
DNAME =

RFC 2672

39
OPT =

RFC 2671

41
APL =

RFC 3123

42
DS =

RFC 4034

43
SSHFP =

RFC 4255

44
IPSECKEY =

RFC 4025

45
RRSIG =

RFC 4034

46
NSEC =

RFC 4034

47
DNSKEY =

RFC 4034

48
DHCID =

RFC 4701

49
NSEC3 =

RFC still pending at time of writing

50
NSEC3PARAM =

RFC still pending at time of writing

51
TLSA =

RFC 6698

52
HIP =

RFC 5205

55
CDS =

RFC 7344

59
CDNSKEY =

RFC 7344

60
SPF =

RFC 4408

99
UINFO =

non-standard

100
UID =

non-standard

101
GID =

non-standard

102
UNSPEC =

non-standard

103
TKEY =

RFC 2930

249
TSIG =

RFC 2931

250
IXFR =

RFC 1995

251
AXFR =

RFC 1035

252
MAILB =

RFC 1035 (MB, MG, MR)

253
MAILA =

RFC 1035 (obsolete - see MX)

254
ANY =

RFC 1035

255
URI =

RFC 7553

256
CAA =

RFC 6844

257
DLV =

RFC 4431 (informational)

32769

Instance Attribute Summary

Attributes inherited from CodeMapper

#code, #string

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CodeMapper

#<=>, #==, add_pair, #hash, #initialize, #inspect, method_missing, regexp, #set_code, #set_string, strings, to_code, to_string, update

Constructor Details

This class inherits a constructor from Dnsruby::CodeMapper

Class Method Details

.typesbyname(name) ⇒ Object

typesbyval and typesbyname functions are wrappers around the similarly named
hashes. They are used for 'unknown' DNS RR types (RFC3597)
typesbyname returns they TYPEcode as a function of the TYPE
mnemonic. If the TYPE mapping is not specified the generic mnemonic
TYPE### is returned.


205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/dnsruby/code_mappers.rb', line 205

def Types.typesbyname(name)  #:nodoc: all
  name = name.upcase

  if to_code(name)
    return to_code(name)
  end


  if ((name =~/^\s*TYPE(\d+)\s*$/o)==nil)
    raise ArgumentError, "Net::DNS::typesbyname() argument (#{name}) is not TYPE###"
  end

  val = $1.to_i
  if val > 0xffff
    raise ArgumentError, 'Net::DNS::typesbyname() argument larger than ' + 0xffff
  end

  return val;
end

.typesbyval(val) ⇒ Object

typesbyval returns they TYPE mnemonic as a function of the TYPE

code. If the TYPE mapping is not specified the generic mnemonic
TYPE### is returned.

Raises:

  • (ArgumentError)


229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/dnsruby/code_mappers.rb', line 229

def Types.typesbyval(val) #:nodoc: all
  if (!defined?val)
    raise ArgumentError,  "Net::DNS::typesbyval() argument is not defined"
  end

  if val.class == String
    #       if val.gsub!("^\s*0*(\d+)\s*$", "$1")
    if ((val =~ /^\s*0*(\d+)\s*$", "$1/o) == nil)
      raise ArgumentError,  "Net::DNS::typesbyval() argument (#{val}) is not numeric"
      #           val =~s/^\s*0*(\d+)\s*$/$1/o;
    end

    val = $1.to_i
  end


  if to_string(val)
    return to_string(val)
  end

  raise ArgumentError,  'Net::DNS::typesbyval() argument larger than ' + 0xffff if
      val > 0xffff;

  return "TYPE#{val}";
end

Instance Method Details

#unknown_code(arg) ⇒ Object

:nodoc: all



194
195
196
197
# File 'lib/dnsruby/code_mappers.rb', line 194

def unknown_code(arg) #:nodoc: all
  Types.add_pair('TYPE' + arg.to_s, arg)
  set_code(arg)
end

#unknown_string(arg) ⇒ Object

:nodoc: all



185
186
187
188
189
190
191
192
# File 'lib/dnsruby/code_mappers.rb', line 185

def unknown_string(arg) #:nodoc: all
  if (arg=~/^TYPE/i)
    Types.add_pair(arg, arg.gsub('TYPE', '').to_i)
    set_string(arg)
  else
    raise ArgumentError.new("String #{arg} not a member of #{self.class}")
  end
end