$pgtitle = array(gettext("Services"), gettext("Router Advertisements")); include "head.inc"; if ($input_errors) { print_input_errors($input_errors); } if ($savemsg) { print_info_box($savemsg, 'success'); } /* active tabs */ $tab_array = array(); $tabscounter = 0; $i = 0; foreach ($iflist as $ifent => $ifname) { $oc = $config['interfaces'][$ifent]; // We need at least one interface configured with a NON-LOCAL IPv6 static address. fd80:8dba:82e1::/64 fits the bill if (is_array($config['dhcpdv6'][$ifent]) && !isset($config['dhcpdv6'][$ifent]['enable']) && !(is_ipaddrv6($oc['ipaddrv6']) && !is_linklocal($oc['ipaddrv6'])) || !is_array($config['dhcpdv6'][$ifent]) && !(is_ipaddrv6($oc['ipaddrv6']) && !is_linklocal($oc['ipaddrv6']))) { continue; } if ($ifent == $if) { $active = true; } else { $active = false; } $tab_array[] = array($ifname, $active, "services_router_advertisements.php?if={$ifent}"); $tabscounter++; } if ($tabscounter == 0) { include "foot.inc"; exit; } display_top_tabs($tab_array);
foreach ($config['installedpackages']['olsrd']['config'] as $olsrd) { if ($olsrd['enable']) { $is_olsr_enabled = true; break; } } } if (!$_GET['if']) { $savemsg = gettext("The DHCPv6 Server can only be enabled on interfaces configured with static, non unique local IP addresses.") . "<br />" . gettext("Only interfaces configured with a static IP will be shown."); } $iflist = get_configured_interface_with_descr(); /* set the starting interface */ if (!$if || !isset($iflist[$if])) { foreach ($iflist as $ifent => $ifname) { $oc = $config['interfaces'][$ifent]; $valid_if_ipaddrv6 = (bool) ($oc['ipaddrv6'] == 'track6' || is_ipaddrv6($oc['ipaddrv6']) && !is_linklocal($oc['ipaddrv6'])); if ((!is_array($config['dhcpdv6'][$ifent]) || !isset($config['dhcpdv6'][$ifent]['enable'])) && !$valid_if_ipaddrv6) { continue; } $if = $ifent; break; } } if (is_array($config['dhcpdv6'][$if])) { /* RA specific */ $pconfig['ramode'] = $config['dhcpdv6'][$if]['ramode']; $pconfig['rapriority'] = $config['dhcpdv6'][$if]['rapriority']; $pconfig['rainterface'] = $config['dhcpdv6'][$if]['rainterface']; if ($pconfig['rapriority'] == "") { $pconfig['rapriority'] = "medium"; }
} $found = false; foreach ($subnets as $subnet) { if (ip_in_subnet($_POST['gateway'], $subnet)) { $found = true; break; } } if ($found === false) { $input_errors[] = sprintf(gettext("The gateway address %1\$s does not lie within one of the chosen interface's subnets."), $_POST['gateway']); } } } else { if (is_ipaddrv6($_POST['gateway'])) { /* do not do a subnet match on a link local address, it's valid */ if (!is_linklocal($_POST['gateway'])) { $parent_ip = get_interface_ipv6($_POST['interface']); $parent_sn = get_interface_subnetv6($_POST['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."); } elseif (!isset($_POST["nonlocalgateway"])) { $subnets = array(gen_subnetv6($parent_ip, $parent_sn) . "/" . $parent_sn); $vips = link_interface_to_vips($_POST['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']; } }
<?php echo "<textarea id=\"pingCaptured\" style=\"width:98%\" name=\"code\" rows=\"15\" cols=\"66\" readonly=\"readonly\">"; $ifscope = ''; $command = "/sbin/ping"; if ($ipproto == "ipv6") { $command .= "6"; $ifaddr = is_ipaddr($sourceip) ? $sourceip : get_interface_ipv6($sourceip); if (is_linklocal($ifaddr)) { $ifscope = get_ll_scope($ifaddr); } } else { $ifaddr = is_ipaddr($sourceip) ? $sourceip : get_interface_ip($sourceip); } if ($ifaddr && (is_ipaddr($host) || is_hostname($host))) { $srcip = "-S" . escapeshellarg($ifaddr); if (is_linklocal($host) && !strstr($host, "%") && !empty($ifscope)) { $host .= "%{$ifscope}"; } } $cmd = "{$command} {$srcip} -c" . escapeshellarg($count) . " " . escapeshellarg($host); //echo "Ping command: {$cmd}\n"; system($cmd); echo '</textarea> </font>'; } ?> </td> </tr> <tr> <td width="22%" valign="top"> </td> <td width="78%"> </td> </tr>
} } $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']; } }
$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;
} 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]);
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?> <?php if (isset($savemsg)) print_info_box($savemsg); ?> <?php if (is_subsystem_dirty('staticmaps')): ?><p> <?php print_info_box_np(gettext("The static mapping configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br /> <?php endif; ?> <section class="col-xs-12"> <?php /* active tabs */ $tab_array = array(); $tabscounter = 0; $i = 0; foreach ($iflist as $ifent => $ifname) { $oc = $config['interfaces'][$ifent]; if ((is_array($config['dhcpdv6'][$ifent]) && !isset($config['dhcpdv6'][$ifent]['enable']) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6'])))) || (!is_array($config['dhcpdv6'][$ifent]) && !(is_ipaddrv6($oc['ipaddrv6']) && (!is_linklocal($oc['ipaddrv6']))))) continue; if ($ifent == $if) $active = true; else $active = false; $tab_array[] = array($ifname, $active, "services_dhcpv6.php?if={$ifent}"); $tabscounter++; } /* tack on PPPoE or PPtP servers here */ /* pppoe server */ if (is_array($config['pppoes']['pppoe'])) { foreach($config['pppoes']['pppoe'] as $pppoe) { if ($pppoe['mode'] == "server") { $ifent = "poes". $pppoe['pppoeid']; $ifname = strtoupper($ifent);
$ifscope = ''; $command = "/sbin/ping"; if ($pconfig['ipproto'] == "ipv6") { $command .= "6"; $ifaddr = is_ipaddr($pconfig['sourceip']) ? $pconfig['sourceip'] : get_interface_ipv6($pconfig['sourceip']); if (is_linklocal($ifaddr)) { $ifscope = get_ll_scope($ifaddr); } } else { $ifaddr = is_ipaddr($pconfig['sourceip']) ? $pconfig['sourceip'] : get_interface_ip($pconfig['sourceip']); } $host = trim($pconfig['host']); $srcip = ""; if (!empty($ifaddr) && (is_ipaddr($pconfig['host']) || is_hostname($pconfig['host']))) { $srcip = "-S" . escapeshellarg($ifaddr); if (is_linklocal($pconfig['host']) && !strstr($pconfig['host'], "%") && !empty($ifscope)) { $host .= "%{$ifscope}"; } } // execute ping command and catch both stdout and stderr $cmd_action = "{$command} {$srcip} -c" . escapeshellarg($pconfig['count']) . " " . 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[1]); $cmd_output .= stream_get_contents($pipes[2]); } } } legacy_html_escape_form_data($pconfig); include "head.inc"; ?>