]> git.ipfire.org Git - people/ms/network.git/blob - src/hooks/ports/ethernet
hostapd: Enable WMM by default.
[people/ms/network.git] / src / hooks / ports / ethernet
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2010 Michael Tremer & Christian Schmidt #
6 # #
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. #
11 # #
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. #
16 # #
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/>. #
19 # #
20 ###############################################################################
21
22 . /usr/lib/network/header-port
23
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.
26
27 HOOK_SETTINGS="HOOK ADDRESS DEVICE"
28
29 function hook_check() {
30 assert ismac DEVICE
31
32 if isset ADDRESS; then
33 assert ismac ADDRESS
34 fi
35 }
36
37 function hook_create() {
38 local port=${1}
39 assert isset port
40 shift
41
42 ADDRESS=""
43 DEVICE=$(device_get_address ${port})
44
45 config_write $(port_file ${port}) ${HOOK_SETTINGS}
46
47 exit ${EXIT_OK}
48 }
49
50 function hook_up() {
51 local port=${1}
52 assert isset port
53
54 # Read in the confguration file.
55 port_config_read ${port}
56
57 # Check if the MAC address is the right one.
58 if isset ADDRESS; then
59 device_set_address "${device}" "${ADDRESS}"
60 fi
61
62 # Bring up the device.
63 device_set_up ${port}
64
65 exit ${EXIT_OK}
66 }
67
68 function hook_down() {
69 local port=${1}
70 assert isset port
71
72 # Set down the device.
73 device_set_down ${port}
74
75 exit ${EXIT_OK}
76 }
77
78 function hook_hotplug_rename() {
79 local port=${1}
80 assert isset port
81
82 local device=${2}
83 assert isset device
84
85 # Read in the conifguration file.
86 port_config_read ${port}
87
88 # Get the current MAC address of the device.
89 local address=$(device_get_address ${device})
90 assert isset address
91
92 # Check if the address matches with the configuration.
93 if list_match "${address}" ${DEVICE} ${ADDRESS}; then
94 log DEBUG "Device '${device}' equals port '${port}'."
95
96 # Change the MAC address, if needed.
97 if isset ADDRESS; then
98 device_set_address "${device}" "${ADDRESS}"
99 fi
100
101 # Everything is done.
102 exit ${EXIT_OK}
103 fi
104
105 log DEBUG "Device '${device}' does not equal port '${port}'."
106 exit ${EXIT_ERROR}
107 }