Class: Dnsruby::Types

Inherits:
CodeMapper show all
Defined in:
lib/dnsruby.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
DS =

APL = 42 # RFC 3123

43
SSHFP =

RFC 4034

44
IPSECKEY =

RFC 4255

45
RRSIG =

RFC 4025

46
NSEC =

RFC 4034

47
DNSKEY =

RFC 4034

48
DHCID =

RFC 4034

49
NSEC3 =

RFC 4701

50
NSEC3PARAM =

RFC still pending at time of writing

51
HIP =

RFC still pending at time of writing

55
SPF =

RFC 5205

99
UINFO =

RFC 4408

100
UID =

non-standard

101
GID =

non-standard

102
UNSPEC =

non-standard

103
TKEY =

non-standard

249
TSIG =

RFC 2930

250
IXFR =

RFC 2931

251
AXFR =

RFC 1995

252
MAILB =

RFC 1035

253
MAILA =

RFC 1035 (MB, MG, MR)

254
ANY =

RFC 1035 (obsolete - see MX)

255
DLV =

RFC 1035

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, maxcode, 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.



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/dnsruby.rb', line 315

def Types.typesbyname(name)  #:nodoc: all
  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)


339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/dnsruby.rb', line 339

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



304
305
306
307
# File 'lib/dnsruby.rb', line 304

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

#unknown_string(arg) ⇒ Object

:nodoc: all



295
296
297
298
299
300
301
302
# File 'lib/dnsruby.rb', line 295

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