32 || $_POST['tunnel-remote-net'] < 1) { $input_errors[] = gettext("The GRE tunnel subnet must be an integer between 1 and 32."); } } if (is_ipaddrv6($_POST['tunnel-local-addr'])) { if (!is_ipaddrv6($_POST['tunnel-remote-addr'])) { $input_errors[] = gettext("The GRE Tunnel remote address must be IPv6 where tunnel local address is IPv6."); } if ($_POST['tunnel-remote-net'] > 128 || $_POST['tunnel-remote-net'] < 1) { $input_errors[] = gettext("The GRE tunnel subnet must be an integer between 1 and 128."); } } foreach ($a_gres as $gre) { if (isset($id) && ($a_gres[$id]) && ($a_gres[$id] === $gre)) { continue; } if (($gre['if'] == $_POST['if']) && ($gre['tunnel-remote-addr'] == $_POST['tunnel-remote-addr'])) { $input_errors[] = sprintf(gettext("A GRE tunnel with the network %s is already defined."), $gre['remote-network']); break; } } if (!$input_errors) { $gre = array(); $gre['if'] = $_POST['if']; $gre['tunnel-local-addr'] = $_POST['tunnel-local-addr']; $gre['tunnel-remote-addr'] = $_POST['tunnel-remote-addr']; $gre['tunnel-remote-net'] = $_POST['tunnel-remote-net']; $gre['remote-addr'] = $_POST['remote-addr']; $gre['descr'] = $_POST['descr']; if (isset($_POST['link1'])) { $gre['link1'] = ''; } $gre['greif'] = $_POST['greif']; $gre['greif'] = interface_gre_configure($gre); if ($gre['greif'] == "" || !stristr($gre['greif'], "gre")) { $input_errors[] = gettext("Error occurred creating interface, please retry."); } else { if (isset($id) && $a_gres[$id]) { $a_gres[$id] = $gre; } else { $a_gres[] = $gre; } write_config(); $confif = convert_real_interface_to_friendly_interface_name($gre['greif']); if ($confif != "") { interface_configure($confif); } header("Location: interfaces_gre.php"); exit; } } } function build_parent_list() { $parentlist = array(); $portlist = get_possible_listen_ips(); foreach ($portlist as $ifn => $ifinfo) { $parentlist[$ifn] = $ifinfo; } return($parentlist); } $pgtitle = array(gettext("Interfaces"), gettext("GREs"), gettext("Edit")); $shortcut_section = "interfaces"; include("head.inc"); if ($input_errors) { print_input_errors($input_errors); } $form = new Form(); $section = new Form_Section('GRE Configuration'); $section->addInput(new Form_Select( 'if', 'Parent Interface', $pconfig['if'], build_parent_list() ))->setHelp('This interface serves as the local address to be used for the GRE tunnel.'); $section->addInput(new Form_IpAddress( 'remote-addr', 'GRE Remote Address', $pconfig['remote-addr'] ))->setHelp('Peer address where encapsulated GRE packets will be sent.'); $section->addInput(new Form_IpAddress( 'tunnel-local-addr', 'GRE tunnel local address', $pconfig['tunnel-local-addr'] ))->setHelp('Local GRE tunnel endpoint.'); $section->addInput(new Form_IpAddress( 'tunnel-remote-addr', 'GRE tunnel remote address', $pconfig['tunnel-remote-addr'] ))->setHelp('Remote GRE address endpoint.'); $section->addInput(new Form_Select( 'tunnel-remote-net', 'GRE tunnel subnet', $pconfig['tunnel-remote-net'], array_combine(range(128, 1, -1), range(128, 1, -1)) ))->setHelp('The subnet is used for determining the network that is tunnelled.'); $section->addInput(new Form_Checkbox( 'link1', 'Add Static Route', 'Add an explicit static route for the remote inner tunnel address/subnet via the local tunnel address', $pconfig['link1'] )); $section->addInput(new Form_Input( 'descr', 'Description', 'text', $pconfig['descr'] ))->setHelp('A description may be entered here for administrative reference (not parsed).'); $section->addInput(new Form_Input( 'greif', null, 'hidden', $pconfig['greif'] )); if (isset($id) && $a_gres[$id]) { $section->addInput(new Form_Input( 'id', null, 'hidden', $id )); } $form->add($section); print($form); include("foot.inc");