]>
git.ipfire.org Git - people/ms/network.git/blob - src/hooks/ports/ethernet
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2010 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 .
/usr
/lib
/network
/header-port
24 # DEVICE equals the actual MAC address of the device.
25 # If ADDRESS is set, the device will get ADDRESS set for its MAC address.
27 HOOK_SETTINGS
="HOOK ADDRESS DEVICE"
29 function hook_check
() {
32 if isset ADDRESS
; then
43 DEVICE
=$
(device_get_address
${port})
45 port_settings_write
"${port}" ${HOOK_SETTINGS}
50 function hook_create
() {
51 # Nothing to do here. Real ethernet devices cannot
52 # be created. They are just there.
56 function hook_remove
() {
60 function hook_hotplug_rename
() {
67 # Read in the conifguration file.
68 port_settings_read
"${port}" ${HOOK_SETTINGS}
70 # Get the current MAC address of the device.
71 local address
=$
(device_get_address
${device})
74 # Check if the address matches with the configuration.
75 if list_match
"${address}" ${DEVICE} ${ADDRESS}; then
76 log DEBUG "Device
'${device}' equals port
'${port}'.
"
78 # Change the MAC address, if needed.
79 if isset ADDRESS; then
80 device_set_address "${device}" "${ADDRESS}"
87 log DEBUG "Device
'${device}' does not equal port
'${port}'.
"