Subject: | A patch to make Net::DNS::RR::DS->digtype() work |
After grepping and reading the documentation, I expected to be able to write
my $ds = Net::DNS::RR->new("... IN DS ...");
print $ds->digtype('mnemonic');
And see "SHA256" (etc) as the result. But it wasn't working. After
some trial-and-error I got it to work the way I expected by having
Net::DNS::RR::DS inherit from Net::DNS::SEC and by changing lots of
"digest" to "digtype"
My patch is attached.
Subject: | digtype.patch |
Index: RR/DS.pm
===================================================================
--- RR/DS.pm (revision 861)
+++ RR/DS.pm (working copy)
@@ -25,7 +25,7 @@
$VERSION = do { my @r=(q$Revision$=~/\d+/g); sprintf "%d."."%03d"x$#r,@r };
my $debug=0;
-@ISA = qw(Net::DNS::RR);
+@ISA = qw(Net::DNS::RR Net::DNS::SEC);
sub new {
my ($class, $self, $data, $offset) = @_;
Index: SEC.pm
===================================================================
--- SEC.pm (revision 861)
+++ SEC.pm (working copy)
@@ -142,7 +142,7 @@
$memonic=$self->digtype("mnemonic");
-The algorithm method is used to set or read the value of the digest or
+The digtype method is used to set or read the value of the digestype or
hash algorithm field in Net::DNS::RR::DS and Net::DNS::RR::NSEC3
objects.
@@ -300,39 +300,39 @@
if (!defined $argument){
return if $classmethod;
- return $self->{"digest"};
+ return $self->{"digtype"};
}
# Argument has some value...
$argument =~ s/\s//g; # Remove strings to be kind
if ($argument =~ /^\d+$/ ){ #Numeric argument.
- carp "$argument does not map to a valid digest" unless
+ carp "$argument does not map to a valid digest type" unless
exists $digestbyval{$argument};
if ($classmethod){
return $argument ;
}else{
- return $self->{"digest"}=$argument ;
+ return $self->{"digtype"}=$argument ;
}
}else{ # argument is not numeric
if ($classmethod){
- carp "$argument does not map to a valid digest" unless
+ carp "$argument does not map to a valid digest type" unless
exists $digestbyname{uc($argument)};
return $digestbyname{uc($argument)};
}else{ # Not a class method..
if (lc($argument) eq "mnemonic"){
- return $digestbyval{$self->{"digest"}};
+ return $digestbyval{$self->{"digtype"}};
}else{
- carp "$argument does not map to a valid digest" unless
+ carp "$argument does not map to a valid digest type" unless
exists $digestbyname{uc($argument)};
- return $self->{"digest"}=$digestbyname{uc($argument)};
+ return $self->{"digtype"}=$digestbyname{uc($argument)};
}
}
}
- die "digest method should never end here";
+ die "digtype method should never end here";
}