Net::DNS::RR::NXT - DNS NXT resource record


Net-DNS-SEC documentation Contained in the Net-DNS-SEC distribution.

Index


Code Index:

NAME

Top

Net::DNS::RR::NXT - DNS NXT resource record

SYNOPSIS

Top

use Net::DNS::RR;

DESCRIPTION

Top

NOTE: THE NXT RR has been deprecated! Use NSEC instead.

Class for DNS Address (NXT) resource records.

METHODS

Top

nxtdname

    print "nxtdname" = ", $rr->nxtdname, "\n";

Returns the RR's next domain name field.

typelist

    print "typelist" = ", $rr->typelist, "\n";

Returns a string with the list of qtypes for which data exists for this particular label.

typebm

    print "typebm" = " unpack("B*", $rr->typebm), "\n";

Same as the typelist but now in a representation bitmap as in specified in the RFC. This is not the kind of method you will need on daily basis.

COPYRIGHT

Top

SEE ALSO

Top

http://www.net-dns.org/

perl(1), Net::DNS, Net::DNS::Resolver, Net::DNS::Packet, Net::DNS::Header, Net::DNS::Question, Net::DNS::RR, RFC 2435 Section 5


Net-DNS-SEC documentation Contained in the Net-DNS-SEC distribution.

package Net::DNS::RR::NXT;

# $Id: NXT.pm 318 2005-05-30 16:36:52Z olaf $

use strict;
use vars qw(@ISA $VERSION);
use Carp;
use bytes;
use Net::DNS;
use Net::DNS::Packet;


use Carp;

@ISA = qw(Net::DNS::RR);
$VERSION = do { my @r=(q$Revision: 318 $=~/\d+/g); sprintf "%d."."%03d"x$#r,@r };

sub new {
    my ($class, $self, $data, $offset) = @_;
    carp "The NXT RR is depricated as of RFC3755, please refrain from using this record";
    
    if ($self->{"rdlength"} > 0) {
	my($nxtdname,$nxtoffset) = 
	  Net::DNS::Packet::dn_expand($data, $offset);

	$self->{"nxtdname"} = "$nxtdname";

	my $typebm =substr($$data,$nxtoffset,
				 $self->{"rdlength"}-
				 $nxtoffset+$offset);

	$self->{"typebm"}=$typebm;
	$self->{"typelist"} = join " " 
	    ,  _typebm2typestr($typebm);
    }
    return bless $self, $class;
}

sub new_from_string {
    my ($class, $self, $string) = @_;
    carp "The NXT RR is depricated as of RFC3755";
    if ($string) {
	$string =~ tr/()//d;
	$string =~ s/;.*$//mg;
	$string =~ s/\n//mg;
	my ($nxtdname,$nxtstr) = 
	    $string =~ /^\s*(\S+)\s+(.*)/;
	my @nxttypes = split /\s+/ , $nxtstr;       # everything after last match...
	
	$self->{"nxtdname"}= lc($nxtdname) ;
	$self->{"typelist"}= join " " , sort @nxttypes ;
	$self->{"typebm"}=_typestr2typebm(@nxttypes);
	
    }
    return bless $self, $class;
}




#sub is_optin {
#    my $self =shift;
#    return 1 if $self->{"typelist"}!~/NXT/;
#    0;
#}

#sub set_optin {
#    my $self =shift;
#    $self->{"typelist"}=~s/NXT//;
#    1;
#}

sub rdatastr {
	my $self = shift;
	my $rdatastr;

	if (exists $self->{"nxtdname"}) {
	    $rdatastr  = $self->{nxtdname};
	    $rdatastr .= "  "  . "$self->{typelist}";
	    }
	else {
	    $rdatastr = "; no data";
	}

	return $rdatastr;
}

sub rr_rdata {
    my ($self, $packet, $offset) = @_;
    my $rdata = "" ;
    if (exists $self->{"nxtdname"}) {
	# Compression used here... 
	$rdata = $packet->dn_comp($self->{"nxtdname"},$offset);
	$rdata .= $self->{"typebm"};
    }
    
    return $rdata;
    
}



sub _canonicalRdata {
    # rdata contains a compressed domainname... we should not have that.
	my ($self) = @_;
	my $rdata;

	$rdata=$self->_name2wire($self->{"nxtdname"});
	$rdata .= $self->{"typebm"};	
	return $rdata;
}


sub _typestr2typebm {
    # RFC2535 5.1 needs the typebm
    # This needs to check for values > 127....

    # Sets a bit for every qtype in the input array.
    # Minimum bitmaplenght 4 octets because NXT (30) is allways there
    # may be longer but trailing all zero octets should be dropped.

    my (@typelist, @typebitarray);
    @typelist= @_;
    for(my $i=0;$i < @typelist; $i++){
	$typebitarray[$Net::DNS::typesbyname{uc($typelist[$i])}]=1;
    }
    
    my $finalsize=0;
    {
	use integer;
	$finalsize = 8 * ((@typebitarray / 8)  + 1);
    }

    for (my $i=0;$i< $finalsize; $i++){
	$typebitarray[$i]=0 if ! defined $typebitarray[$i];
    }
    my $typebm= pack("B$finalsize",join "", @typebitarray );
    return $typebm

}

sub _typebm2typestr {
    # RFC2535 5.1 needs the typebm
    # This needs to check for values > 127....
    my @typebm=split //, unpack("B*", shift);  # bit representation in array
    my @typelist;
    carp "Cannot deal with qtype > 127" 
	if ($#typebm > 127);
    
    my($foo);
    foreach $foo (sort { $a <=> $b } keys(%Net::DNS::typesbyval)  ){
	next if $foo > $#typebm;           # Skip larger aray vallues.
	@typelist=(@typelist,$Net::DNS::typesbyval{$foo}) if 
	    ($typebm[$foo] eq "1");
    }

    return sort @typelist;
}


1;