Net-DNS-Extlang
view release on metacpan or search on metacpan
lib/Net/DNS/Extlang.pm view on Meta::CPAN
$decode}
CODE
}
# turn fields into binary data
# triple of pack codes, and code to create the stuff to pack, size
# default code is the field
# size of -1 means unknown, will fail if something later wants it
# stores the data into $encdata
sub _fieldencode {
my ($rrfields) = @_;
my ($packpat, @args, $packcode);
foreach my $f (@$rrfields) {
my ($type, $quals, $name) = ($f->{type}, $f->{quals}, $f->{name});
my $cch = _cchunk($f, 'default' => [ '???', '???', -1 ],
'I1' => [ 'C', undef, 1 ],
lib/Net/DNS/Extlang.pm view on Meta::CPAN
'X8' => [ 'a8', undef, 8 ],
);
my ($pat, $field, $size) = @$cch;
$field = '#F#' unless $field;
# handle names that need to know the offset
if($field =~ m{#O#}) {
if($packpat) { # flush out any pending stuff
if($packcode) {
$packcode .= "\t\$encdata .= ";
} else {
$packcode = "\t\$encdata = ";
}
if($packpat =~ m{^(a\*)+$}) { # all a's, just concat
$packcode .= join(" . ", @args) . ";\n";
} else {
$packcode .= "pack '$packpat'," . join(", ", @args) . ";\n";
}
$packpat = ""; @args = ();
}
if($packcode) {
$field =~ s{#O#}{\$offset+(length \$encdata)};
} else {
$field =~ s{#O#}{\$offset}; # first field, plain offset
}
}
$packpat .= $pat;
for ($field) {
s/#F#/join('', '$self->{', _bn($type, $name, $quals), '}')/eg;
push @args, $_;
}
}
# now generate the code
if($packpat) {
if($packcode) {
$packcode .= "\t\$encdata .= ";
} else {
$packcode = "\t\$encdata = ";
}
if($packpat =~ m{^(a\*)+$}) { # all a's, just concat
$packcode .= join(" . ", @args) . ";\n";
} else {
$packcode .= "pack '$packpat'," . join(", ", @args) . ";\n";
}
}
return $packcode ? <<"CODE" : '';
sub _encode_rdata { ## encode rdata as wire-format octet string
my (\$self, \$offset, \@opaque) = \@_;
my \$encdata = '';
$packcode}
CODE
}
# parse arguments to make a new RR
sub _fieldparse {
my ($rrfields) = @_;
my ($decode, $eaten); # $eaten means all the arguments have been eaten
( run in 0.256 second using v1.01-cache-2.11-cpan-454fe037f31 )