This commit is contained in:
laf
2015-06-03 15:41:10 +01:00
parent 1ca02fb3c5
commit 702b75c0b7
3 changed files with 34 additions and 10 deletions

View File

@@ -1202,8 +1202,7 @@ function first_oid_match($device, $list) {
}
}
function ip_to_hex($ip) {
function ip_to_dec($ip) {
$return = '';
if (strstr($ip, ":")) {
$ipv6 = explode(':', $ip);
@@ -1216,3 +1215,19 @@ function ip_to_hex($ip) {
}
return $return;
}
function hex_to_ip($hex) {
$return = "";
if (filter_var($hex, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === FALSE && filter_var($hex, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === FALSE) {
$hex_exp = explode(' ', $hex);
foreach ($hex_exp as $item) {
if (!empty($item) && $item != "\"") {
$return .= hexdec($item).'.';
}
}
$return = substr($return, 0, -1);
} else {
$return = $ip;
}
return $return;
}