/**
 * return option array for valid translation networks
 */
function formTranslateAddresses()
{
    global $config;
    $retval = array();
    // add this hosts ips
    foreach ($config['interfaces'] as $intf => $intfdata) {
        if (isset($intfdata['ipaddr']) && $intfdata['ipaddr'] != 'dhcp') {
            $retval[$intfdata['ipaddr']] = (!empty($intfdata['descr']) ? $intfdata['descr'] : $intf) . " " . gettext("address");
        }
    }
    // add VIPs's
    if (isset($config['virtualip']['vip'])) {
        foreach ($config['virtualip']['vip'] as $sn) {
            if (!isset($sn['noexpand'])) {
                if ($sn['mode'] == "proxyarp" && $sn['type'] == "network") {
                    $start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
                    $end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
                    $len = $end - $start;
                    $retval[$sn['subnet'] . '/' . $sn['subnet_bits']] = htmlspecialchars("Subnet: {$sn['subnet']}/{$sn['subnet_bits']} ({$sn['descr']})");
                    for ($i = 0; $i <= $len; $i++) {
                        $snip = long2ip32($start + $i);
                        $retval[$snip] = htmlspecialchars("{$snip} ({$sn['descr']})");
                    }
                } else {
                    $retval[$sn['subnet']] = htmlspecialchars("{$sn['subnet']} ({$sn['descr']})");
                }
            }
        }
    }
    // add Aliases
    foreach (legacy_list_aliases("network") as $alias) {
        if ($alias['type'] == "host") {
            $retval[$alias['name']] = $alias['name'];
        }
    }
    return $retval;
}
Example #2
0
										<tr>
										<td width="22%" valign="top" class="vncellreq"><?php 
    echo gettext("Available range");
    ?>
</td>
										<td width="78%" class="vtable">
										<?php 
    $range_from = ip2long(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
    $range_from++;
    echo long2ip32($range_from);
    ?>
										-
										<?php 
    $range_to = ip2long(long2ip32(ip2long($ifcfgip) | ~gen_subnet_mask_long($ifcfgsn)));
    $range_to--;
    echo long2ip32($range_to);
    ?>
										<?php 
    if (is_numeric($pool) || $act == "newpool") {
        ?>
											<br />In-use DHCP Pool Ranges:
											<?php 
        if (is_array($config['dhcpd'][$if]['range'])) {
            ?>
												<br /><?php 
            echo $config['dhcpd'][$if]['range']['from'];
            ?>
-<?php 
            echo $config['dhcpd'][$if]['range']['to'];
            ?>
											<?php 
Example #3
0
} else {
    $section->addInput(new Form_StaticText(null, '<div class="alert alert-info"> Editing Pool-Specific Options. To return to the Interface, click its tab above. </div>'));
}
$section->addInput(new Form_Checkbox('denyunknown', 'Deny unknown clients', 'Only the clients defined below will get DHCP leases from this server.', $pconfig['denyunknown']));
$section->addInput(new Form_Checkbox('nonak', 'Ignore denied clients', 'Denied clients will be ignored rather than rejected.', $pconfig['nonak']));
if (is_numeric($pool) || $act == "newpool") {
    $section->addInput(new Form_Input('descr', 'Pool Description', 'text', $pconfig['descr']));
}
$section->addInput(new Form_StaticText('Subnet', gen_subnet($ifcfgip, $ifcfgsn)));
$section->addInput(new Form_StaticText('Subnet mask', gen_subnet_mask($ifcfgsn)));
// Compose a string to display the required address ranges
$range_from = ip2long(gen_subnetv4($ifcfgip, $ifcfgsn));
$range_from++;
$range_to = ip2long(gen_subnetv4_max($ifcfgip, $ifcfgsn));
$range_to--;
$rangestr = long2ip32($range_from) . ' - ' . long2ip32($range_to);
if (is_numeric($pool) || $act == "newpool") {
    $rangestr .= '<br />' . gettext('In-use DHCP Pool Ranges:');
    if (is_array($config['dhcpd'][$if]['range'])) {
        $rangestr .= '<br />' . $config['dhcpd'][$if]['range']['from'] . ' - ' . $config['dhcpd'][$if]['range']['to'];
    }
    foreach ($a_pools as $p) {
        if (is_array($p['range'])) {
            $rangestr .= '<br />' . $p['range']['from'] . ' - ' . $p['range']['to'];
        }
    }
}
$section->addInput(new Form_StaticText('Available range', $rangestr));
if ($is_olsr_enabled) {
    $section->addInput(new Form_Select('netmask', 'Subnet mask', $pconfig['netmask'], array_combine(range(32, 1, -1), range(32, 1, -1))));
}
Example #4
0
     foreach ($config['virtualip']['vip'] as $vip) {
         if (!preg_match("/{$interface_regex}/", $vip['interface'])) {
             $vip_description = $vip['descr'] != "" ? " ({$vip['descr']}) " : " ";
         }
         switch ($vip['mode']) {
             case "ipalias":
             case "carp":
                 $ips[] = array('ip' => $vip['subnet'], 'description' => "{$vip['subnet']} {$vip_description}");
                 break;
             case "proxyarp":
                 if ($vip['type'] == "network") {
                     $start = ip2long32(gen_subnet($vip['subnet'], $vip['subnet_bits']));
                     $end = ip2long32(gen_subnet_max($vip['subnet'], $vip['subnet_bits']));
                     $len = $end - $start;
                     for ($i = 0; $i <= $len; $i++) {
                         $ips[] = array('ip' => long2ip32($start + $i), 'description' => long2ip32($start + $i) . " from {$vip['subnet']}/{$vip['subnet_bits']} {$vip_description}");
                     }
                 } else {
                     $ips[] = array('ip' => $vip['subnet'], 'description' => "{$vip['subnet']} {$vip_description}");
                 }
                 break;
         }
     }
 }
 sort($ips);
 if (isset($pkga['showlistenall'])) {
     array_unshift($ips, array('ip' => gettext('All'), 'description' => gettext('Listen on All interfaces/ip addresses ')));
 }
 if (!preg_match("/{$interface_regex}/", "loopback")) {
     $loopback_text = gettext("loopback");
     $iface_description = isset($pkga['showips']) ? "127.0.0.1 (" . $loopback_text . ")" : $loopback_text;
     if (isset($id) && $a_maps[$id] && $a_maps[$id] === $mapent) {
         continue;
     }
     if ($mapent['hostname'] == $_POST['hostname'] && $mapent['hostname'] || $mapent['mac'] == $_POST['mac']) {
         $input_errors[] = "Bu sunucu adı, IP adresi veya MAC adresi zaten kayıtlı.";
         break;
     }
 }
 if ($_POST['ipaddr']) {
     $dynsubnet_start = ip2ulong($config['dhcpd'][$if]['range']['from']);
     $dynsubnet_end = ip2ulong($config['dhcpd'][$if]['range']['to']);
     if (ip2ulong($_POST['ipaddr']) >= $dynsubnet_start && ip2ulong($_POST['ipaddr']) <= $dynsubnet_end) {
         $input_errors[] = "Sabit IP adresi otomatik dağıtım aralığında olmamalıdır.";
     }
     $lansubnet_start = ip2ulong(long2ip32(ip2long($ifcfgip) & gen_subnet_mask_long($ifcfgsn)));
     $lansubnet_end = ip2ulong(long2ip32(ip2long($ifcfgip) | ~gen_subnet_mask_long($ifcfgsn)));
     if (ip2ulong($_POST['ipaddr']) < $lansubnet_start || ip2ulong($_POST['ipaddr']) > $lansubnet_end) {
         $input_errors[] = sprintf("IP adresi %s ağında bulunmalıdır.", $ifcfgdescr);
     }
 }
 if (!$input_errors) {
     $mapent = array();
     $mapent['mac'] = $_POST['mac'];
     $mapent['ipaddr'] = $_POST['ipaddr'];
     $mapent['hostname'] = $_POST['hostname'];
     $mapent['descr'] = base64_encode($_POST['descr']);
     if (isset($id) && $a_maps[$id]) {
         $a_maps[$id] = $mapent;
     } else {
         $a_maps[] = $mapent;
     }
function build_target_list()
{
    global $config, $sn, $a_aliases;
    $list = array();
    $list[""] = gettext('Interface Address');
    if (is_array($config['virtualip']['vip'])) {
        foreach ($config['virtualip']['vip'] as $sn) {
            if (isset($sn['noexpand'])) {
                continue;
            }
            if ($sn['mode'] == "proxyarp" && $sn['type'] == "network") {
                $start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
                $end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
                $len = $end - $start;
                $list[$sn['subnet'] . '/' . $sn['subnet_bits']] = 'Subnet: ' . $sn['subnet'] . '/' . $sn['subnet_bits'] . ' (' . $sn['descr'] . ')';
                for ($i = 0; $i <= $len; $i++) {
                    $snip = long2ip32($start + $i);
                    $list[$snip] = $snip . ' (' . $sn['descr'] . ')';
                }
            } else {
                $list[$sn['subnet']] = $sn['subnet'] . ' (' . $sn['descr'] . ')';
            }
        }
    }
    foreach ($a_aliases as $alias) {
        if ($alias['type'] != "host") {
            continue;
        }
        $list[$alias['name']] = gettext('Host Alias: ') . $alias['name'] . ' (' . $alias['descr'] . ')';
    }
    $list['other-subnet'] = gettext('Other Subnet (Enter Below)');
    return $list;
}
            ?>
				<option value="<?php 
            echo $sn['subnet'] . '/' . $sn['subnet_bits'];
            ?>
" <?php 
            if ($sn['subnet'] . '/' . $sn['subnet_bits'] == $pconfig['target']) {
                echo "selected";
            }
            ?>
><?php 
            echo htmlspecialchars("Subnet: {$sn['subnet']}/{$sn['subnet_bits']} ({$sn['descr']})");
            ?>
</option>
			<?php 
            for ($i = 0; $i <= $len; $i++) {
                $snip = long2ip32($start + $i);
                ?>
				<option value="<?php 
                echo $snip;
                ?>
" <?php 
                if ($snip == $pconfig['target']) {
                    echo "selected";
                }
                ?>
><?php 
                echo htmlspecialchars("{$snip} ({$sn['descr']})");
                ?>
</option>
				<?php 
            }
function build_radiusnas_list()
{
    $list = array();
    $iflist = get_configured_interface_with_descr();
    foreach ($iflist as $ifdesc => $ifdescr) {
        $ipaddr = get_interface_ip($ifdesc);
        if (is_ipaddr($ipaddr)) {
            $list[$ifdescr] = $ifdescr . ' - ' . $ipaddr;
        }
    }
    if (is_array($config['virtualip']['vip'])) {
        foreach ($config['virtualip']['vip'] as $sn) {
            if ($sn['mode'] == "proxyarp" && $sn['type'] == "network") {
                $start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
                $end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
                $len = $end - $start;
                for ($i = 0; $i <= $len; $i++) {
                    $snip = long2ip32($start + $i);
                    $list[$snip] = $sn['descr'] . ' - ' . $snip;
                }
            } else {
                $list[$sn['subnet']] = $sn['descr'] . ' - ' . $sn['subnet'];
            }
        }
    }
    return $list;
}
Example #9
0
function build_dsttype_list()
{
    global $pconfig, $config, $ifdisp;
    $sel = is_specialnet($pconfig['dst']);
    $list = array('any' => 'Any', 'single' => 'Single host or alias', 'network' => 'Network', '(self)' => 'This Firewall (self)');
    if (have_ruleint_access("pppoe")) {
        $list['pppoe'] = 'PPPoE clients';
    }
    if (have_ruleint_access("l2tp")) {
        $list['l2tp'] = 'L2TP clients';
    }
    foreach ($ifdisp as $if => $ifdesc) {
        if (have_ruleint_access($if)) {
            $list[$if] = $ifdesc;
            $list[$if . 'ip'] = $ifdesc . ' address';
        }
    }
    if (is_array($config['virtualip']['vip'])) {
        foreach ($config['virtualip']['vip'] as $sn) {
            if ($sn['mode'] == "proxyarp" && $sn['type'] == "network") {
                if (isset($sn['noexpand'])) {
                    continue;
                }
                $start = ip2long32(gen_subnet($sn['subnet'], $sn['subnet_bits']));
                $end = ip2long32(gen_subnet_max($sn['subnet'], $sn['subnet_bits']));
                $len = $end - $start;
                for ($i = 0; $i <= $len; $i++) {
                    $snip = long2ip32($start + $i);
                    $list[$snip] = $snip . ' (' . $sn['descr'] . ')';
                }
                $list[$sn['subnet']] = $sn['subnet'] . ' (' . $sn['descr'] . ')';
            } else {
                $list[$sn['subnet']] = $sn['subnet'] . ' (' . $sn['descr'] . ')';
            }
        }
    }
    return $list;
}
function _long2ip32($f)
{
    return long2ip32($f);
}
Example #11
0
 $natent['natport'] = "";
 $a_out[] = $natent;
 $natent = array();
 $natent['source']['network'] = "127.0.0.0/8";
 $natent['dstport'] = "";
 $natent['descr'] = sprintf(gettext('Auto created rule for localhost to %1$s'), $ifdesc2);
 $natent['target'] = "";
 $natent['interface'] = $if2;
 $natent['destination']['any'] = true;
 $natent['staticnatport'] = false;
 $natent['natport'] = "1024:65535";
 $a_out[] = $natent;
 /* PPTP subnet */
 if ($config['pptpd']['mode'] == "server" && is_private_ip($config['pptpd']['remoteip'])) {
     $pptptopip = $config['pptpd']['n_pptp_units'] - 1;
     $pptp_subnets = ip_range_to_subnet_array($config['pptpd']['remoteip'], long2ip32(ip2long($config['pptpd']['remoteip']) + $pptptopip));
     foreach ($pptp_subnets as $pptpsn) {
         $natent = array();
         $natent['source']['network'] = $pptpsn;
         $natent['sourceport'] = "";
         $natent['descr'] = gettext("Auto created rule for PPTP server");
         $natent['target'] = "";
         $natent['interface'] = $if2;
         $natent['destination']['any'] = true;
         $natent['natport'] = "";
         $a_out[] = $natent;
     }
 }
 /* PPPoE subnet */
 if (is_pppoe_server_enabled() && have_ruleint_access("pppoe")) {
     foreach ($config['pppoes']['pppoe'] as $pppoes) {