Re: dom-net tag under domain
- Date: Tue, 30 Nov 1993 12:23:07 +0100
bonito@localhost (Antonio_Blasco Bonito) writes:
* >
* > As Tony already said we'd rather not do that right now to avoid valatilit
* y
* > in database semantics. Please note that this will be fixed automatically
* > and in a very general manner once the database goes classless!
* >
* > Suggestion: The dom-net field is a "hint" field only. It does not hurt at
* all
* > to list the whole network even if only part of it is used by the particul
* ar
* > domain. One net can appear in several domain objects.
* >
* > Daniel
*
* In principle I agree, but to apply your suggestion we would have to change
* many entries which were written under the assumption that subnetworks were
* allowed in dom-net...
* We will rewrite dom-net: as remarks: dom-net: unless you can give us a piec
* e
* of perl software (to put before the sintax checker) which converts from
* "subnet" to "whole net". Perl programmers are a very scarse resource here..
* .
Okay,
seeing as I seemed a bit harsh yesterday (wasn't intended). Here is
a piece of perl that do it. Just did this in a few mins but should do it.
Just pipe it through. Something like cat object | perl this-prog
while (<>) {
chop;
if(/^di:/ || /^dom-net:/) {
($tmp,$value) = split (/\s+/, $_, 2);
printf "%-10s", $tmp;
@list = split(/\s+/,$value);
foreach $j (0..$#list) {
$net = &munge($list[$j]);
printf " %s", $net;
}
print "\n";
next;
} else {
printf "%s\n", $_;
}
}
sub munge {
local($str) = @_;
local($ind) = 0;
local($val) = "";
local(@add) = split(/\./, $str);
foreach $ind (0..$#add) {
if ($add[0] < 128) {
$val = "$add[0]".".0.0.0";
return $val;
}
if ($add[0] < 192) {
$val = "$add[0]"."."."$add[1]".".0.0";
return $val;
}
if ($add[0] < 224) {
$val = "$add[0]"."."."$add[1]"."."."$add[2]".".0";
return $val;
}
}
}
Cheers,
--Tony.
|