Project

General

Profile

Download (4.42 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-2024 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
function gre_inuse($num) {
35
	$a_gres = config_get_path('gres/gre', []);
36
	$iflist = get_configured_interface_list(true);
37
	$if_config = config_get_path('interfaces', []);
38
	foreach ($iflist as $if) {
39
		if ($if_config[$if]['if'] == $a_gres[$num]['greif']) {
40
			return true;
41
		}
42
	}
43

    
44
	return false;
45
}
46

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

    
59
		write_config("GRE interface deleted");
60

    
61
		header("Location: interfaces_gre.php");
62
		exit;
63
	}
64
}
65

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

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

    
129
<nav class="action-buttons">
130
	<a href="interfaces_gre_edit.php" class="btn btn-success btn-sm">
131
		<i class="fa-solid fa-plus icon-embed-btn"></i>
132
		<?=gettext("Add")?>
133
	</a>
134
</nav>
135
<?php
136
include("foot.inc");
(79-79/232)