Project

General

Profile

Download (4.23 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-2019 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 * http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 */
21

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

    
29
require_once("guiconfig.inc");
30
require_once("functions.inc");
31

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

    
35
function gre_inuse($num) {
36
	global $config, $a_gres;
37

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

    
45
	return false;
46
}
47

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

    
60
		write_config();
61

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

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

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

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