Project

General

Profile

Download (4.35 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * interfaces_gre.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14
 *
15
 * http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22
 */
23

    
24
##|+PRIV
25
##|*IDENT=page-interfaces-gre
26
##|*NAME=Interfaces: GRE
27
##|*DESCR=Allow access to the 'Interfaces: GRE' page.
28
##|*MATCH=interfaces_gre.php*
29
##|-PRIV
30

    
31
require_once("guiconfig.inc");
32
require_once("functions.inc");
33

    
34
init_config_arr(array('gres', 'gre'));
35
$a_gres = &$config['gres']['gre'] ;
36

    
37
function gre_inuse($num) {
38
	global $config, $a_gres;
39

    
40
	$iflist = get_configured_interface_list(true);
41
	foreach ($iflist as $if) {
42
		if ($config['interfaces'][$if]['if'] == $a_gres[$num]['greif']) {
43
			return true;
44
		}
45
	}
46

    
47
	return false;
48
}
49

    
50
if ($_POST['act'] == "del") {
51
	if (!isset($_POST['id'])) {
52
		$input_errors[] = gettext("Wrong parameters supplied");
53
	} else if (empty($a_gres[$_POST['id']])) {
54
		$input_errors[] = gettext("Wrong index supplied");
55
	/* check if still in use */
56
	} else if (gre_inuse($_POST['id'])) {
57
		$input_errors[] = gettext("This GRE tunnel cannot be deleted because it is still being used as an interface.");
58
	} else {
59
		pfSense_interface_destroy($a_gres[$_POST['id']]['greif']);
60
		unset($a_gres[$_POST['id']]);
61

    
62
		write_config("GRE interface deleted");
63

    
64
		header("Location: interfaces_gre.php");
65
		exit;
66
	}
67
}
68

    
69
$pgtitle = array(gettext("Interfaces"), gettext("GREs"));
70
$shortcut_section = "interfaces";
71
include("head.inc");
72
if ($input_errors) {
73
	print_input_errors($input_errors);
74
}
75

    
76
$tab_array = array();
77
$tab_array[] = array(gettext("Interface Assignments"), false, "interfaces_assign.php");
78
$tab_array[] = array(gettext("Interface Groups"), false, "interfaces_groups.php");
79
$tab_array[] = array(gettext("Wireless"), false, "interfaces_wireless.php");
80
$tab_array[] = array(gettext("VLANs"), false, "interfaces_vlan.php");
81
$tab_array[] = array(gettext("QinQs"), false, "interfaces_qinq.php");
82
$tab_array[] = array(gettext("PPPs"), false, "interfaces_ppps.php");
83
$tab_array[] = array(gettext("GREs"), true, "interfaces_gre.php");
84
$tab_array[] = array(gettext("GIFs"), false, "interfaces_gif.php");
85
$tab_array[] = array(gettext("Bridges"), false, "interfaces_bridge.php");
86
$tab_array[] = array(gettext("LAGGs"), false, "interfaces_lagg.php");
87
display_top_tabs($tab_array);
88
?>
89
<div class="panel panel-default">
90
	<div class="panel-heading"><h2 class="panel-title"><?=gettext('GRE Interfaces')?></h2></div>
91
	<div class="panel-body">
92
		<div class="table-responsive">
93
			<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
94
				<thead>
95
					<tr>
96
						<th><?=gettext("Interface"); ?></th>
97
						<th><?=gettext("Tunnel to &hellip;"); ?></th>
98
						<th><?=gettext("Description"); ?></th>
99
						<th><?=gettext("Actions"); ?></th>
100
					</tr>
101
				</thead>
102
				<tbody>
103
<?php foreach ($a_gres as $i => $gre):
104
	if (substr($gre['if'], 0, 4) == "_vip") {
105
		$if = convert_real_interface_to_friendly_descr(get_real_interface($gre['if']));
106
	} else {
107
		$if = $gre['if'];
108
	}
109
?>
110
					<tr>
111
						<td>
112
							<?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($if))?>
113
						</td>
114
						<td>
115
							<?=htmlspecialchars($gre['remote-addr'])?>
116
						</td>
117
						<td>
118
							<?=htmlspecialchars($gre['descr'])?>
119
						</td>
120
						<td>
121
							<a class="fa fa-pencil"	title="<?=gettext('Edit GRE interface')?>"	href="interfaces_gre_edit.php?id=<?=$i?>"></a>
122
							<a class="fa fa-trash"	title="<?=gettext('Delete GRE interface')?>"	href="interfaces_gre.php?act=del&amp;id=<?=$i?>" usepost></a>
123
						</td>
124
					</tr>
125
<?php endforeach; ?>
126
				</tbody>
127
			</table>
128
		</div>
129
	</div>
130
</div>
131

    
132
<nav class="action-buttons">
133
	<a href="interfaces_gre_edit.php" class="btn btn-success btn-sm">
134
		<i class="fa fa-plus icon-embed-btn"></i>
135
		<?=gettext("Add")?>
136
	</a>
137
</nav>
138
<?php
139
include("foot.inc");
(77-77/228)