Project

General

Profile

Download (4.34 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-2018 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
if (!is_array($config['gres'])) {
33
	$config['gres'] = array();
34
}
35
if (!is_array($config['gres']['gre'])) {
36
	$config['gres']['gre'] = array();
37
}
38

    
39
$a_gres = &$config['gres']['gre'] ;
40

    
41
function gre_inuse($num) {
42
	global $config, $a_gres;
43

    
44
	$iflist = get_configured_interface_list(true);
45
	foreach ($iflist as $if) {
46
		if ($config['interfaces'][$if]['if'] == $a_gres[$num]['greif']) {
47
			return true;
48
		}
49
	}
50

    
51
	return false;
52
}
53

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

    
66
		write_config();
67

    
68
		header("Location: interfaces_gre.php");
69
		exit;
70
	}
71
}
72

    
73
$pgtitle = array(gettext("Interfaces"), gettext("GREs"));
74
$shortcut_section = "interfaces";
75
include("head.inc");
76
if ($input_errors) {
77
	print_input_errors($input_errors);
78
}
79

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

    
136
<nav class="action-buttons">
137
	<a href="interfaces_gre_edit.php" class="btn btn-success btn-sm">
138
		<i class="fa fa-plus icon-embed-btn"></i>
139
		<?=gettext("Add")?>
140
	</a>
141
</nav>
142
<?php
143
include("foot.inc");
(77-77/234)