Revision 42753d25
Added by Ermal Luçi over 16 years ago
etc/inc/interfaces.inc | ||
---|---|---|
560 | 560 |
/* bring ip IP aliases */ |
561 | 561 |
interfaces_ipalias_configure(); |
562 | 562 |
|
563 |
/* configure interface groups */ |
|
564 |
interfaces_group_setup(); |
|
565 |
|
|
563 | 566 |
if (!$g['booting']) { |
564 | 567 |
/* reconfigure static routes (kernel may have deleted them) */ |
565 | 568 |
system_routing_configure(); |
... | ... | |
1758 | 1761 |
|
1759 | 1762 |
return 0; |
1760 | 1763 |
} |
1764 |
|
|
1765 |
function interfaces_group_setup() { |
|
1766 |
global $config; |
|
1767 |
|
|
1768 |
if (!is_array($config['ifgroups']['ifgroupentry'])) |
|
1769 |
return; |
|
1770 |
|
|
1771 |
foreach ($config['ifgroups']['ifgroupentry'] as $grouppar) |
|
1772 |
interface_group_setup($groupar); |
|
1773 |
|
|
1774 |
return; |
|
1775 |
} |
|
1776 |
|
|
1777 |
function interface_group_setup($groupname /* The parameter is an array */) { |
|
1778 |
global $config; |
|
1779 |
|
|
1780 |
if (!is_array($groupname)) |
|
1781 |
return; |
|
1782 |
$members = explode(" ", $groupname['members']); |
|
1783 |
foreach($members as $ifs) { |
|
1784 |
$realif = get_real_interface($ifs); |
|
1785 |
if ($realif) |
|
1786 |
mwexec("/sbin/ifconfig {$realif} group {$groupname['ifname']}"); |
|
1787 |
} |
|
1788 |
|
|
1789 |
return; |
|
1790 |
} |
|
1761 | 1791 |
|
1762 | 1792 |
/* XXX: stub for code that references the old functions(mostly packages) */ |
1763 | 1793 |
function get_real_wan_interface($interface = "wan") { |
usr/local/www/interfaces_groups.php | ||
---|---|---|
43 | 43 |
|
44 | 44 |
if ($_GET['act'] == "del") { |
45 | 45 |
if ($a_ifgroups[$_GET['id']]) { |
46 |
$members = explode(" ", $a_ifgroups[$_GET[$id]]); |
|
47 |
foreach ($members as $ifs) { |
|
48 |
$realif = get_real_interface($ifs); |
|
49 |
if ($realif) |
|
50 |
mwexec("/sbin/ifconfig {$realif} -group " . $a_ifgroups[$_GET[$id]]['ifname']); |
|
51 |
} |
|
46 | 52 |
unset($a_ifgroups[$_GET['id']]); |
47 | 53 |
write_config(); |
48 |
touch($d_ifgroupsdirty_path); |
|
49 | 54 |
header("Location: interfaces_groups.php"); |
50 | 55 |
exit; |
51 | 56 |
} |
... | ... | |
93 | 98 |
</td> |
94 | 99 |
<td class="listr" ondblclick="document.location='interfaces_groups_edit.php?id=<?=$i;?>';"> |
95 | 100 |
<?php |
96 |
$members_arr = array_slice(explode(" ", $ifgroupentry['members']), 0, 10);
|
|
101 |
$members_arr = explode(" ", $ifgroupentry['members']);
|
|
97 | 102 |
$iflist = get_configured_interface_with_descr(); |
98 | 103 |
foreach ($members_arr as $memb) |
99 | 104 |
$memberses_arr[] = $iflist[$memb] ? $iflist[$memb] : $memb; |
... | ... | |
113 | 118 |
<table border="0" cellspacing="0" cellpadding="1"> |
114 | 119 |
<tr> |
115 | 120 |
<td valign="middle"><a href="interfaces_groups_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0" title="edit group"></a></td> |
116 |
<td><a href="interfaces_ifgroups.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this group? All elements that still use it will become invalid (e.g. filter rules)!')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="delete ifgroupentry"></a></td>
|
|
121 |
<td><a href="interfaces_groups.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this group? All elements that still use it will become invalid (e.g. filter rules)!')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" title="delete ifgroupentry"></a></td> |
|
117 | 122 |
</tr> |
118 | 123 |
</table> |
119 | 124 |
</td> |
usr/local/www/interfaces_groups_edit.php | ||
---|---|---|
59 | 59 |
unset($input_errors); |
60 | 60 |
$pconfig = $_POST; |
61 | 61 |
|
62 |
foreach ($a_ifgroups as $groupentry) |
|
63 |
if ($groupentry['ifname'] == $_POST['ifname']) |
|
64 |
$input_errors[] = "Group name already exists!"; |
|
62 |
if (empty($id)) { |
|
63 |
foreach ($a_ifgroups as $groupentry) |
|
64 |
if ($groupentry['ifname'] == $_POST['ifname']) |
|
65 |
$input_errors[] = "Group name already exists!"; |
|
66 |
} |
|
67 |
if (preg_match("/([^a-zA-Z])+/", $_POST['ifname'], $match)) |
|
68 |
$input_errors[] = "Only characters in a-z A-Z are allowed as interface name."; |
|
65 | 69 |
|
66 | 70 |
$ifgroupentry = array(); |
67 | 71 |
$ifgroupentry['ifname'] = $_POST['ifname']; |
... | ... | |
81 | 85 |
$ifgroupentry['members'] = $members; |
82 | 86 |
$ifgroupentry['descr'] = mb_convert_encoding($_POST['descr'],"HTML-ENTITIES","auto"); |
83 | 87 |
|
84 |
if (isset($id) && $a_ifgroups[$id]) |
|
88 |
if (isset($id) && $a_ifgroups[$id]) { |
|
89 |
$omembers = explode(" ", $a_ifgroups[$id]['members']); |
|
90 |
$nmembers = explode(" ", $members); |
|
91 |
$delmembers = array_diff($omembers, $nmembers); |
|
92 |
if (count($delmembers) > 0) { |
|
93 |
foreach ($delmembers as $ifs) { |
|
94 |
$realif = get_real_interface($ifs); |
|
95 |
if ($realif) |
|
96 |
mwexec("/sbin/ifconfig {$realif} -group " . $a_ifgroups[$id]['ifname']); |
|
97 |
} |
|
98 |
} |
|
85 | 99 |
$a_ifgroups[$id] = $ifgroupentry; |
86 |
else |
|
100 |
} else
|
|
87 | 101 |
$a_ifgroups[] = $ifgroupentry; |
88 | 102 |
|
89 | 103 |
write_config(); |
90 | 104 |
|
105 |
interface_group_setup($ifgroupentry); |
|
106 |
|
|
91 | 107 |
header("Location: interfaces_groups.php"); |
92 | 108 |
exit; |
93 | 109 |
} else { |
... | ... | |
186 | 202 |
<td valign="top" class="vncellreq">Interface</td> |
187 | 203 |
<td class="vtable"> |
188 | 204 |
<input class="formfld unknown" name="ifname" id="ifname" value="<?=$pconfig['ifname'];?>" /> |
205 |
<br /> |
|
206 |
No numbers or spaces are allowed. Only characters in a-zA-Z |
|
189 | 207 |
</td> |
190 | 208 |
</tr> |
191 | 209 |
<tr> |
Also available in: Unified diff
Actually merge the part that does the real work with FreeBSD groups.