本文整理汇总了PHP中get_interface_ipv6函数的典型用法代码示例。如果您正苦于以下问题:PHP get_interface_ipv6函数的具体用法?PHP get_interface_ipv6怎么用?PHP get_interface_ipv6使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_interface_ipv6函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find_ip_interface
function find_ip_interface($ip, $bits = null)
{
if (!is_ipaddr($ip)) {
return false;
}
$isv6ip = is_ipaddrv6($ip);
/* if list */
$ifdescrs = get_configured_interface_list();
foreach ($ifdescrs as $ifdescr => $ifname) {
$ifip = $isv6ip ? get_interface_ipv6($ifname) : get_interface_ip($ifname);
if (is_null($ifip)) {
continue;
}
if (is_null($bits)) {
if ($ip == $ifip) {
$int = get_real_interface($ifname);
return $int;
}
} else {
if (ip_in_subnet($ifip, $ip . "/" . $bits)) {
$int = get_real_interface($ifname);
return $int;
}
}
}
return false;
}
示例2: gettext
$input_errors[] = gettext("For this type of vip localhost is not allowed.");
} else {
if (strpos($_POST['interface'], '_vip')) {
$input_errors[] = gettext("A CARP parent interface can only be used with IP Alias type Virtual IPs.");
}
}
break;
case 'ipalias':
if (strstr($_POST['interface'], "_vip")) {
if (is_ipaddrv4($_POST['subnet'])) {
$parent_ip = get_interface_ip($_POST['interface']);
$parent_sn = get_interface_subnet($_POST['interface']);
$subnet = gen_subnet($parent_ip, $parent_sn);
} else {
if (is_ipaddrv6($_POST['subnet'])) {
$parent_ip = get_interface_ipv6($_POST['interface']);
$parent_sn = get_interface_subnetv6($_POST['interface']);
$subnet = gen_subnetv6($parent_ip, $parent_sn);
}
}
if (isset($parent_ip) && !ip_in_subnet($_POST['subnet'], "{$subnet}/{$parent_sn}") && !ip_in_interface_alias_subnet(link_carp_interface_to_parent($_POST['interface']), $_POST['subnet'])) {
$cannot_find = $_POST['subnet'] . "/" . $_POST['subnet_bits'];
$input_errors[] = sprintf(gettext("Sorry, we could not locate an interface with a matching subnet for %s. Please add an IP alias in this subnet on this interface."), $cannot_find);
}
unset($parent_ip, $parent_sn, $subnet);
}
break;
default:
if ($_POST['interface'] == 'lo0') {
$input_errors[] = gettext("For this type of vip localhost is not allowed.");
} else {
示例3: foreach
/* make sure no inbound NAT mappings reference this entry */
if (is_array($config['nat']['rule'])) {
foreach ($config['nat']['rule'] as $rule) {
if ($rule['destination']['address'] != "") {
if ($rule['destination']['address'] == $a_vip[$_GET['id']]['subnet']) {
$input_errors[] = gettext("This entry cannot be deleted because it is still referenced by at least one NAT mapping.");
break;
}
}
}
}
if (is_ipaddrv6($a_vip[$_GET['id']]['subnet'])) {
$is_ipv6 = true;
$subnet = gen_subnetv6($a_vip[$_GET['id']]['subnet'], $a_vip[$_GET['id']]['subnet_bits']);
$if_subnet_bits = get_interface_subnetv6($a_vip[$_GET['id']]['interface']);
$if_subnet = gen_subnetv6(get_interface_ipv6($a_vip[$_GET['id']]['interface']), $if_subnet_bits);
} else {
$is_ipv6 = false;
$subnet = gen_subnet($a_vip[$_GET['id']]['subnet'], $a_vip[$_GET['id']]['subnet_bits']);
$if_subnet_bits = get_interface_subnet($a_vip[$_GET['id']]['interface']);
$if_subnet = gen_subnet(get_interface_ip($a_vip[$_GET['id']]['interface']), $if_subnet_bits);
}
$subnet .= "/" . $a_vip[$_GET['id']]['subnet_bits'];
$if_subnet .= "/" . $if_subnet_bits;
if (is_array($config['gateways']['gateway_item'])) {
foreach ($config['gateways']['gateway_item'] as $gateway) {
if ($a_vip[$_GET['id']]['interface'] != $gateway['interface']) {
continue;
}
if ($is_ipv6 && $gateway['ipprotocol'] == 'inet') {
continue;
示例4: explode
$cached_ip_s = explode("|", file_get_contents($filename));
$cached_ip = $cached_ip_s[0];
if ($ipaddr != $cached_ip) {
print '<span class="text-danger">';
} else {
print '<span class="text-success">';
}
print htmlspecialchars($cached_ip);
print '</span>';
} else {
print 'IPv4: N/A';
}
print '<br />';
if (file_exists("{$filename}.ipv6")) {
print 'IPv6: ';
$ipaddr = get_interface_ipv6($rfc2136['interface']);
$cached_ip_s = explode("|", file_get_contents("{$filename}.ipv6"));
$cached_ip = $cached_ip_s[0];
if ($ipaddr != $cached_ip) {
print '<span class="text-danger">';
} else {
print '<span class="text-success">';
}
print htmlspecialchars($cached_ip);
print '</span>';
} else {
print 'IPv6: N/A';
}
?>
</td>
<td>
示例5: escapeshellarg
$filename = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}.cache";
$filename_v6 = "/conf/dyndns_{$dyndns['interface']}{$dyndns['type']}" . escapeshellarg($dyndns['host']) . "{$dyndns['id']}_v6.cache";
if (file_exists($filename)) {
$ipaddr = dyndnsCheckIP($dyndns['interface']);
$cached_ip_s = explode(":", file_get_contents($filename));
$cached_ip = $cached_ip_s[0];
if ($ipaddr != $cached_ip) {
echo "<font color='red'>";
} else {
echo "<font color='green'>";
}
echo htmlspecialchars($cached_ip);
echo "</font>";
} else {
if (file_exists($filename_v6)) {
$ipv6addr = get_interface_ipv6($dyndns['interface']);
$cached_ipv6_s = explode("|", file_get_contents($filename_v6));
$cached_ipv6 = $cached_ipv6_s[0];
if ($ipv6addr != $cached_ipv6) {
echo "<font color='red'>";
} else {
echo "<font color='green'>";
}
echo htmlspecialchars($cached_ipv6);
echo "</font>";
} else {
echo "N/A";
}
}
?>
</td>
示例6: build_interface_list
function build_interface_list()
{
global $pconfig;
$iflist = array('options' => array(), 'selected' => array());
$interfaces = get_configured_interface_with_descr();
foreach ($interfaces as $iface => $ifacename) {
if (!is_ipaddr(get_interface_ip($iface)) && !is_ipaddrv6(get_interface_ipv6($iface))) {
continue;
}
$iflist['options'][$iface] = $ifacename;
if (in_array($iface, $pconfig['interface'])) {
array_push($iflist['selected'], $iface);
}
}
return $iflist;
}
示例7: isset
##|+PRIV
##|*IDENT=page-services-dhcpv6relay
##|*NAME=Services: DHCPv6 Relay
##|*DESCR=Allow access to the 'Services: DHCPv6 Relay' page.
##|*MATCH=services_dhcpv6_relay.php*
##|-PRIV
require "guiconfig.inc";
$pconfig['enable'] = isset($config['dhcrelay6']['enable']);
if (empty($config['dhcrelay6']['interface'])) {
$pconfig['interface'] = array();
} else {
$pconfig['interface'] = explode(",", $config['dhcrelay6']['interface']);
}
$pconfig['agentoption'] = isset($config['dhcrelay6']['agentoption']);
$iflist = array_intersect_key(get_configured_interface_with_descr(), array_flip(array_filter(array_keys(get_configured_interface_with_descr()), function ($if) {
return is_ipaddrv6(get_interface_ipv6($if));
})));
/* set the enabled flag which will tell us if DHCP server is enabled
* on any interface. We will use this to disable dhcp-relay since
* the two are not compatible with each other.
*/
$dhcpd_enabled = false;
if (is_array($config['dhcpdv6'])) {
foreach ($config['dhcpdv6'] as $dhcp) {
if (isset($dhcp['enable']) && isset($config['interfaces'][$dhcpif]['enable'])) {
$dhcpd_enabled = true;
break;
}
}
}
if ($_POST) {
示例8: foreach
}
$found = false;
foreach ($subnets as $subnet) {
if (ip_in_subnet($pconfig['gateway'], $subnet)) {
$found = true;
break;
}
}
if (!$found) {
$input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within one of the chosen interface's subnets."), $pconfig['gateway']);
}
}
} elseif (is_ipaddrv6($pconfig['gateway'])) {
/* do not do a subnet match on a link local address, it's valid */
if (!is_linklocal($pconfig['gateway'])) {
$parent_ip = get_interface_ipv6($pconfig['interface']);
$parent_sn = get_interface_subnetv6($pconfig['interface']);
if (empty($parent_ip) || empty($parent_sn)) {
$input_errors[] = gettext("Cannot add IPv6 Gateway Address because no IPv6 address could be found on the interface.");
} else {
$subnets = array(gen_subnetv6($parent_ip, $parent_sn) . "/" . $parent_sn);
$vips = link_interface_to_vips($pconfig['interface']);
if (is_array($vips)) {
foreach ($vips as $vip) {
if (!is_ipaddrv6($vip['subnet'])) {
continue;
}
$subnets[] = gen_subnetv6($vip['subnet'], $vip['subnet_bits']) . "/" . $vip['subnet_bits'];
}
}
$found = false;
示例9: switch
$nc_args .= " -6";
} else {
switch ($ipprotocol) {
case "ipv4":
$ifaddr = get_interface_ip($sourceip);
$nc_ipproto = " -4";
break;
case "ipv6":
$ifaddr = is_linklocal($sourceip) ? $sourceip : get_interface_ipv6($sourceip);
$nc_ipproto = " -6";
break;
case "any":
$ifaddr = get_interface_ip($sourceip);
$nc_ipproto = !empty($ifaddr) ? " -4" : "";
if (empty($ifaddr)) {
$ifaddr = is_linklocal($sourceip) ? $sourceip : get_interface_ipv6($sourceip);
$nc_ipproto = !empty($ifaddr) ? " -6" : "";
}
break;
}
/* Netcat doesn't like it if we try to connect using a certain type of IP without specifying the family. */
if (!empty($ifaddr)) {
$nc_args .= $nc_ipproto;
} elseif ($sourceip == "any") {
switch ($ipprotocol) {
case "ipv4":
$nc_ipproto = " -4";
break;
case "ipv6":
$nc_ipproto = " -6";
break;
示例10: explode
$cached_ip_s = explode("|", file_get_contents($filename));
$cached_ip = $cached_ip_s[0];
if ($ipaddr != $cached_ip) {
print '<span class="text-danger">';
} else {
print '<span class="text-success">';
}
print htmlspecialchars($cached_ip);
print '</span>';
} else {
print 'IPv4: N/A';
}
print '<br />';
if (file_exists("{$filename}.ipv6")) {
print 'IPv6: ';
$ipaddr = get_interface_ipv6($if);
$cached_ip_s = explode("|", file_get_contents("{$filename}.ipv6"));
$cached_ip = $cached_ip_s[0];
if ($ipaddr != $cached_ip) {
print '<span class="text-danger">';
} else {
print '<span class="text-success">';
}
print htmlspecialchars($cached_ip);
print '</span>';
} else {
print 'IPv6: N/A';
}
?>
</td>
<td>
示例11: deleteVIPEntry
/**
* delete virtual ip
*/
function deleteVIPEntry($id)
{
global $config;
$input_errors = array();
$a_vip =& $config['virtualip']['vip'];
/* make sure no inbound NAT mappings reference this entry */
if (isset($config['nat']['rule'])) {
foreach ($config['nat']['rule'] as $rule) {
if (!empty($rule['destination']['address'])) {
if ($rule['destination']['address'] == $a_vip[$id]['subnet']) {
$input_errors[] = gettext("This entry cannot be deleted because it is still referenced by at least one NAT mapping.");
break;
}
}
}
}
if (is_ipaddrv6($a_vip[$id]['subnet'])) {
$is_ipv6 = true;
$subnet = gen_subnetv6($a_vip[$id]['subnet'], $a_vip[$id]['subnet_bits']);
$if_subnet_bits = get_interface_subnetv6($a_vip[$id]['interface']);
$if_subnet = gen_subnetv6(get_interface_ipv6($a_vip[$id]['interface']), $if_subnet_bits);
} else {
$is_ipv6 = false;
$subnet = gen_subnet($a_vip[$id]['subnet'], $a_vip[$id]['subnet_bits']);
$if_subnet_bits = get_interface_subnet($a_vip[$id]['interface']);
$if_subnet = gen_subnet(get_interface_ip($a_vip[$id]['interface']), $if_subnet_bits);
}
$subnet .= "/" . $a_vip[$id]['subnet_bits'];
$if_subnet .= "/" . $if_subnet_bits;
if (isset($config['gateways']['gateway_item'])) {
foreach ($config['gateways']['gateway_item'] as $gateway) {
if ($a_vip[$id]['interface'] != $gateway['interface']) {
continue;
}
if ($is_ipv6 && $gateway['ipprotocol'] == 'inet') {
continue;
}
if (!$is_ipv6 && $gateway['ipprotocol'] == 'inet6') {
continue;
}
if (ip_in_subnet($gateway['gateway'], $if_subnet)) {
continue;
}
if (ip_in_subnet($gateway['gateway'], $subnet)) {
$input_errors[] = gettext("This entry cannot be deleted because it is still referenced by at least one Gateway.");
break;
}
}
}
if ($a_vip[$id]['mode'] == "ipalias") {
$subnet = gen_subnet($a_vip[$id]['subnet'], $a_vip[$id]['subnet_bits']) . "/" . $a_vip[$id]['subnet_bits'];
$found_if = false;
$found_carp = false;
$found_other_alias = false;
if ($subnet == $if_subnet) {
$found_if = true;
}
$vipiface = $a_vip[$id]['interface'];
foreach ($a_vip as $vip_id => $vip) {
if ($vip_id != $id) {
if ($vip['interface'] == $vipiface && ip_in_subnet($vip['subnet'], $subnet)) {
if ($vip['mode'] == "carp") {
$found_carp = true;
} else {
if ($vip['mode'] == "ipalias") {
$found_other_alias = true;
}
}
}
}
}
if ($found_carp === true && $found_other_alias === false && $found_if === false) {
$input_errors[] = gettext("This entry cannot be deleted because it is still referenced by a CARP IP with the description") . " {$vip['descr']}.";
}
}
if (count($input_errors) == 0) {
// Special case since every proxyarp vip is handled by the same daemon.
if ($a_vip[$id]['mode'] == "proxyarp") {
$viface = $a_vip[$id]['interface'];
unset($a_vip[$id]);
interface_proxyarp_configure($viface);
} else {
interface_vip_bring_down($a_vip[$id]);
unset($a_vip[$id]);
}
if (count($config['virtualip']['vip']) == 0) {
unset($config['virtualip']['vip']);
}
}
return $input_errors;
}
示例12: escapeshellarg
}
if (count($input_errors) == 0) {
$nc_args = "-w 10";
if (empty($pconfig['showtext'])) {
$nc_args .= " -z ";
}
if (!empty($pconfig['srcport'])) {
$nc_args .= " -p " . escapeshellarg($pconfig['srcport']) . " ";
}
switch ($pconfig['ipprotocol']) {
case "ipv4":
$ifaddr = $pconfig['sourceip'] == "any" ? "" : get_interface_ip($pconfig['sourceip']);
$nc_args .= " -4";
break;
case "ipv6":
$ifaddr = is_linklocal($pconfig['sourceip']) ? $pconfig['sourceip'] : get_interface_ipv6($pconfig['sourceip']);
$nc_args .= " -6";
break;
}
if (!empty($ifaddr)) {
$nc_args .= " -s " . escapeshellarg($ifaddr) . " ";
$scope = get_ll_scope($ifaddr);
if (!empty($scope) && !strstr($host, "%")) {
$host .= "%{$scope}";
}
}
$cmd_action = "/usr/bin/nc {$nc_args} " . escapeshellarg($pconfig['host']) . " " . escapeshellarg($pconfig['port']) . " 2>&1";
$process = proc_open($cmd_action, array(array("pipe", "r"), array("pipe", "w"), array("pipe", "w")), $pipes);
if (is_resource($process)) {
$cmd_output = stream_get_contents($pipes[1]);
$cmd_output .= stream_get_contents($pipes[2]);
示例13: trim
$host = trim($pconfig['host']);
$ipproto = $pconfig['ipproto'];
if ($pconfig['ipproto'] == "ipv4" && is_ipaddrv6($host)) {
$input_errors[] = gettext("When using IPv4, the target host must be an IPv4 address or hostname.");
} elseif ($pconfig['ipproto'] == "ipv6" && is_ipaddrv4($host)) {
$input_errors[] = gettext("When using IPv6, the target host must be an IPv6 address or hostname.");
}
if (count($input_errors) == 0) {
$cmd_args = "-w 2";
$cmd_args .= !empty($pconfig['useicmp']) ? " -I " : "";
$cmd_args .= !empty($pconfig['resolve']) ? "" : " -n ";
$cmd_args .= " -m " . escapeshellarg($pconfig['ttl']);
$command = "/usr/sbin/traceroute";
if ($pconfig['ipproto'] == "ipv6") {
$command .= "6";
$ifaddr = is_ipaddr($pconfig['sourceip']) ? $pconfig['sourceip'] : get_interface_ipv6($pconfig['sourceip']);
} else {
$ifaddr = is_ipaddr($pconfig['sourceip']) ? $pconfig['sourceip'] : get_interface_ip($pconfig['sourceip']);
}
if ($ifaddr && (is_ipaddr($host) || is_hostname($host))) {
$cmd_args .= " -s " . escapeshellarg($ifaddr) . " ";
}
$cmd_action = "{$command} {$cmd_args} " . " " . escapeshellarg($host);
$process = proc_open($cmd_action, array(array("pipe", "r"), array("pipe", "w"), array("pipe", "w")), $pipes);
if (is_resource($process)) {
$cmd_output = stream_get_contents($pipes[2]);
$cmd_output .= stream_get_contents($pipes[1]);
}
}
}
legacy_html_escape_form_data($pconfig);
示例14: openvpn_create_key
$pconfig['shared_key'] = openvpn_create_key();
}
// all input validators
if (strpos($pconfig['interface'], '|') !== false) {
list($iv_iface, $iv_ip) = explode("|", $pconfig['interface']);
} else {
$iv_iface = $pconfig['interface'];
$iv_ip = null;
}
if (is_ipaddrv4($iv_ip) && stristr($pconfig['protocol'], "6") !== false) {
$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv6 protocol and an IPv4 IP address.");
} elseif (is_ipaddrv6($iv_ip) && stristr($pconfig['protocol'], "6") === false) {
$input_errors[] = gettext("Protocol and IP address families do not match. You cannot select an IPv4 protocol and an IPv6 IP address.");
} elseif (stristr($pconfig['protocol'], "6") === false && !get_interface_ip($iv_iface) && $pconfig['interface'] != "any") {
$input_errors[] = gettext("An IPv4 protocol was selected, but the selected interface has no IPv4 address.");
} elseif (stristr($pconfig['protocol'], "6") !== false && !get_interface_ipv6($iv_iface) && $pconfig['interface'] != "any") {
$input_errors[] = gettext("An IPv6 protocol was selected, but the selected interface has no IPv6 address.");
}
if (empty($pconfig['authmode']) && ($pconfig['mode'] == "server_user" || $pconfig['mode'] == "server_tls_user")) {
$input_errors[] = gettext("You must select a Backend for Authentication if the server mode requires User Auth.");
}
if ($result = openvpn_validate_port($pconfig['local_port'], 'Local port')) {
$input_errors[] = $result;
}
if ($result = openvpn_validate_cidr($pconfig['tunnel_network'], 'IPv4 Tunnel Network', false, "ipv4")) {
$input_errors[] = $result;
}
if ($result = openvpn_validate_cidr($pconfig['tunnel_networkv6'], 'IPv6 Tunnel Network', false, "ipv6")) {
$input_errors[] = $result;
}
if ($result = openvpn_validate_cidr($pconfig['remote_network'], 'IPv4 Remote Network', true, "ipv4")) {
示例15: header
}
require "guiconfig.inc";
$if = $_GET['if'];
if ($_POST['if']) {
$if = $_POST['if'];
}
if (!$if) {
header("Location: services_dhcpv6.php");
exit;
}
if (!is_array($config['dhcpdv6'][$if]['staticmap'])) {
$config['dhcpdv6'][$if]['staticmap'] = array();
}
$netboot_enabled = isset($config['dhcpdv6'][$if]['netboot']);
$a_maps =& $config['dhcpdv6'][$if]['staticmap'];
$ifcfgipv6 = get_interface_ipv6($if);
$ifcfgsnv6 = get_interface_subnetv6($if);
$ifcfgdescr = convert_friendly_interface_to_friendly_descr($if);
$id = $_GET['id'];
if (isset($_POST['id'])) {
$id = $_POST['id'];
}
if (isset($id) && $a_maps[$id]) {
$pconfig['duid'] = $a_maps[$id]['duid'];
$pconfig['hostname'] = $a_maps[$id]['hostname'];
$pconfig['ipaddrv6'] = $a_maps[$id]['ipaddrv6'];
$pconfig['filename'] = $a_maps[$id]['filename'];
$pconfig['rootpath'] = $a_maps[$id]['rootpath'];
$pconfig['descr'] = $a_maps[$id]['descr'];
} else {
$pconfig['duid'] = $_GET['duid'];