Update rfc8416.php comment field

updated comments for locallyAddedAssertions > prefixAssertions.
This commit is contained in:
netravnen 2018-12-14 16:05:07 +00:00
parent 56145bb844
commit ebc4055b81

View file

@ -86,10 +86,11 @@ foreach ($files6 as $file)
{ {
$str = trim_special_chars ($str); $str = trim_special_chars ($str);
if (startsWith ($str, ("max"), 3)) $raw_array[$i]["max"] = $str; if (startsWith ($str, "max", 3)) $raw_array[$i]["max"] = $str;
elseif (startsWith ($str, ("source"), 6)) $raw_array[$i]["source"] = $str; elseif (startsWith ($str, "source", 6)) $raw_array[$i]["source"] = $str;
elseif (startsWith ($str, ("route"), 5)) $raw_array[$i]["route"] = $str; elseif (startsWith ($str, "route", 5)) $raw_array[$i]["route"] = $str;
elseif (startsWith ($str, ("origin"), 6)) $raw_array[$i]["asn"][$j++] = $str; elseif (startsWith ($str, "origin", 6)) $raw_array[$i]["asn"][$j++] = $str;
elseif (startsWith ($str, "mnt", 3)) $raw_array[$i]["mnt"] = $str;
// Catch max-length not set in route object. // Catch max-length not set in route object.
if (empty ($raw_array[$i]["max"])) $raw_array[$i]["max"] = -1; if (empty ($raw_array[$i]["max"])) $raw_array[$i]["max"] = -1;
@ -104,26 +105,33 @@ foreach ($raw_array as $sub_array)
// Extract prefix and subnet size // Extract prefix and subnet size
// Match prefix sizes 29-64, 80. // Match prefix sizes 29-64, 80.
$prefix = array(); $prefix = array();
preg_match("/([a-f0-9\:]{0,128})\/(29|[3-5][0-9]|6[0-4]|80)/", preg_match ("/([a-f0-9\:]{0,128})\/(29|[3-5][0-9]|6[0-4]|80)/",
explode("6: ", $sub_array["route"])[1], explode ("6: ", $sub_array["route"])[1],
$prefix); $prefix);
// Extract ta information // Extract ta information
$source = array(); $source = array();
preg_match ("/([A-Z0-4]+)/", preg_match ("/([A-Z0-4]+)/",
explode(":", $sub_array["source"])[1], explode (":", $sub_array["source"])[1],
$source); $source);
// Try to extract max-length information // Try to extract max-length information
$maxlength = array(); $maxlength = array();
if (($sub_array["max"]) != -1) if (($sub_array["max"]) != -1)
preg_match ("/([0-9]+)/", preg_match ("/([0-9]+)/",
explode(":", $sub_array["max"])[1], explode (":", $sub_array["max"])[1],
$maxlength); $maxlength);
// Extract mnt-by information
$mnt = array();
preg_match ("/([A-Z0-9\-]+)/",
explode (":", $sub_array["mnt"])[1],
$mnt);
// Store extracted values // Store extracted values
$_prefix = $prefix[0]; $_prefix = $prefix[0];
$_ta = (isset ($source[0]) ? $source[0] : ""); $_ta = (isset ($source[0]) ? $source[0] : "");
// We need to do conditional setting of maxLength to avoid errornous output. // We need to do conditional setting of maxLength to avoid errornous output.
if (($sub_array["max"]) != -1) if (($sub_array["max"]) != -1)
$_maxlength = (isset ($maxlength[0]) ? $maxlength[0] : ""); $_maxlength = (isset ($maxlength[0]) ? $maxlength[0] : "");
@ -131,6 +139,8 @@ foreach ($raw_array as $sub_array)
// Do fallback to default prefix size if max-length was not set. // Do fallback to default prefix size if max-length was not set.
$_maxlength = $prefix[2]; $_maxlength = $prefix[2];
$_mnt = $mnt[0];
// Loop through each asn in single route6 object and assign // Loop through each asn in single route6 object and assign
// other values accordingly. // other values accordingly.
foreach ($sub_array["asn"] as $asn) foreach ($sub_array["asn"] as $asn)
@ -141,7 +151,7 @@ foreach ($raw_array as $sub_array)
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["asn"] = $_asn[0]; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["asn"] = $_asn[0];
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["prefix"] = $_prefix; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["prefix"] = $_prefix;
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["maxPrefixLength"] = $_maxlength; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["maxPrefixLength"] = $_maxlength;
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["comment"] = $_ta; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["comment"] = "$_ta - mnt-by $_mnt";
$k++; $k++;
} }
@ -177,10 +187,11 @@ foreach ($files4 as $file)
{ {
$str = trim_special_chars ($str); $str = trim_special_chars ($str);
if (startsWith ($str, ("max"), 3)) $raw_array[$i]["max"] = $str; if (startsWith ($str, "max", 3)) $raw_array[$i]["max"] = $str;
elseif (startsWith ($str, ("source"), 6)) $raw_array[$i]["source"] = $str; elseif (startsWith ($str, "source", 6)) $raw_array[$i]["source"] = $str;
elseif (startsWith ($str, ("route"), 5)) $raw_array[$i]["route"] = $str; elseif (startsWith ($str, "route", 5)) $raw_array[$i]["route"] = $str;
elseif (startsWith ($str, ("origin"), 6)) $raw_array[$i]["asn"][$j++] = $str; elseif (startsWith ($str, "origin", 6)) $raw_array[$i]["asn"][$j++] = $str;
elseif (startsWith ($str, "mnt", 3)) $raw_array[$i]["mnt"] = $str;
// Catch max-length not set in route object. // Catch max-length not set in route object.
if (empty ($raw_array[$i]["max"])) $raw_array[$i]["max"] = -1; if (empty ($raw_array[$i]["max"])) $raw_array[$i]["max"] = -1;
@ -193,26 +204,33 @@ foreach ($raw_array as $sub_array)
// Extract prefix and subnet size // Extract prefix and subnet size
// Match prefix sizes 8-32. // Match prefix sizes 8-32.
$prefix = array(); $prefix = array();
preg_match("/([0-9\.]{7,15})\/([8-9]|[1-2][0-9]|3[0-2])/", preg_match ("/([0-9\.]{7,15})\/([8-9]|[1-2][0-9]|3[0-2])/",
explode(":", $sub_array["route"])[1], explode (":", $sub_array["route"])[1],
$prefix); $prefix);
// Extract ta information // Extract ta information
$source = array(); $source = array();
preg_match ("/([A-Z0-4]+)/", preg_match ("/([A-Z0-4]+)/",
explode(":", $sub_array["source"])[1], explode (":", $sub_array["source"])[1],
$source); $source);
// Try to extract max-length information // Try to extract max-length information
$maxlength = array(); $maxlength = array();
if (($sub_array["max"]) != -1) if (($sub_array["max"]) != -1)
preg_match ("/([0-9]+)/", preg_match ("/([0-9]+)/",
explode(":", $sub_array["max"])[1], explode (":", $sub_array["max"])[1],
$maxlength); $maxlength);
// Extract mnt-by information
$mnt = array();
preg_match ("/([A-Z0-9\-]+)/",
explode (":", $sub_array["mnt"])[1],
$mnt);
// Store extracted values // Store extracted values
$_prefix = $prefix[0]; $_prefix = $prefix[0];
$_ta = (isset ($source[0]) ? $source[0] : ""); $_ta = (isset ($source[0]) ? $source[0] : "");
// We need to do conditional setting of maxLength to avoid errornous output. // We need to do conditional setting of maxLength to avoid errornous output.
if (($sub_array["max"]) != -1) if (($sub_array["max"]) != -1)
$_maxlength = (isset ($maxlength[0]) ? $maxlength[0] : ""); $_maxlength = (isset ($maxlength[0]) ? $maxlength[0] : "");
@ -220,6 +238,8 @@ foreach ($raw_array as $sub_array)
// Do fallback to default prefix size if max-length was not set. // Do fallback to default prefix size if max-length was not set.
$_maxlength = $prefix[2]; $_maxlength = $prefix[2];
$_mnt = $mnt[0];
// Loop through each asn in single route6 object and assign // Loop through each asn in single route6 object and assign
// other values accordingly. // other values accordingly.
foreach ($sub_array["asn"] as $asn) foreach ($sub_array["asn"] as $asn)
@ -230,7 +250,7 @@ foreach ($raw_array as $sub_array)
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["asn"] = $_asn[0]; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["asn"] = $_asn[0];
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["prefix"] = $_prefix; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["prefix"] = $_prefix;
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["maxPrefixLength"] = $_maxlength; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["maxPrefixLength"] = $_maxlength;
$roas["locallyAddedAssertions"]["prefixAssertions"][$k]["comment"] = $_ta; $roas["locallyAddedAssertions"]["prefixAssertions"][$k]["comment"] = "$_ta - mnt-by $_mnt";
$k++; $k++;
} }