]>
Commit | Line | Data |
---|---|---|
607d9345 MT |
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-zone | |
23 | ||
24 | HOOK_SETTINGS="HOOK MAC MTU" | |
25 | ||
26 | # Default values | |
27 | MAC=$(mac_generate) | |
28 | MTU=1500 | |
29 | ||
2181765d | 30 | function hook_check() { |
607d9345 MT |
31 | assert ismac MAC |
32 | assert isinteger MTU | |
33 | } | |
34 | ||
2181765d | 35 | function hook_parse_cmdline() { |
607d9345 MT |
36 | while [ $# -gt 0 ]; do |
37 | case "${1}" in | |
38 | --mtu=*) | |
39 | MTU=${1#--mtu=} | |
40 | ;; | |
41 | --mac=*) | |
42 | MAC=${1#--mac=} | |
43 | ;; | |
44 | *) | |
45 | warning "Ignoring unknown option '${1}'" | |
46 | ;; | |
47 | esac | |
48 | shift | |
49 | done | |
50 | } | |
51 | ||
2181765d | 52 | function hook_up() { |
607d9345 MT |
53 | local zone=${1} |
54 | shift | |
55 | ||
56 | zone_config_read ${zone} | |
57 | ||
58 | # Create the interface. | |
59 | log INFO "Creating virtual switch '${zone}'." | |
60 | switch_create ${zone} | |
61 | ||
62 | [ -n "${MAC}" ] && device_set_address ${zone} ${MAC} | |
63 | [ -n "${MTU}" ] && device_set_mtu ${zone} ${MTU} | |
64 | ||
65 | # Bring it up. | |
66 | device_set_up ${zone} | |
67 | ||
68 | # Bring all ports up | |
69 | zone_ports_up ${zone} | |
70 | zone_configs_up ${zone} | |
71 | ||
72 | exit ${EXIT_OK} | |
73 | } | |
74 | ||
2181765d | 75 | function hook_down() { |
607d9345 MT |
76 | local zone=${1} |
77 | shift | |
78 | ||
79 | zone_configs_down ${zone} | |
80 | zone_ports_down ${zone} | |
81 | ||
82 | # Bring it down. | |
83 | device_set_down ${zone} | |
84 | ||
85 | # Remove the virtual switch. | |
86 | log INFO "Removing virtual switch '${zone}'." | |
87 | switch_remove ${zone} | |
88 | ||
89 | exit ${EXIT_OK} | |
90 | } | |
91 | ||
2181765d | 92 | function hook_status() { |
607d9345 MT |
93 | local zone=${1} |
94 | assert isset zone | |
95 | ||
96 | # Print the default header. | |
97 | cli_device_headline ${zone} | |
98 | ||
99 | # Exit if zone is down | |
100 | if ! zone_is_up ${zone}; then | |
101 | echo # Empty line | |
102 | exit ${EXIT_ERROR} | |
103 | fi | |
104 | ||
105 | cli_headline 2 "Spanning Tree Protocol information" | |
106 | if switch_stp_is_enabled ${zone}; then | |
107 | # local proto=$(stp_bridge_get_protocol ${zone}) | |
108 | ||
109 | # cli_print_fmt1 2 "Version" "$(stp_get_name ${proto})" | |
110 | # cli_print_fmt1 2 "ID" "$(stp_bridge_get_id ${zone})" | |
111 | # cli_print_fmt1 2 "Priority" "$(switch_stp_get_priority ${zone})" | |
112 | ||
113 | # if stp_bridge_is_root ${zone}; then | |
114 | # cli_print 2 "This bridge is root." | |
115 | # else | |
116 | # cli_print_fmt1 2 "Designated root" \ | |
117 | # "$(stp_bridge_get_designated_root ${zone})" | |
118 | # cli_print_fmt1 2 "Root path cost" \ | |
119 | # "$(stp_bridge_get_root_path_cost ${zone})" | |
120 | # fi | |
121 | # cli_space | |
122 | ||
123 | # # Topology information | |
124 | # cli_print_fmt1 2 "Topology changing" \ | |
125 | # "$(stp_bridge_get_topology_change_detected ${zone})" | |
126 | # cli_print_fmt1 2 "Topology change time" \ | |
127 | # "$(beautify_time $(stp_bridge_get_topology_change_timer ${zone}))" | |
128 | # cli_print_fmt1 2 "Topology change count" \ | |
129 | # "$(stp_bridge_get_topology_change_count ${zone})" | |
130 | # cli_space | |
478de6f9 | 131 | : |
607d9345 MT |
132 | else |
133 | cli_print 2 "Disabled" | |
134 | cli_space | |
135 | fi | |
136 | ||
137 | #cli_headline 2 "Ports" | |
138 | #zone_ports_status ${zone} | |
139 | #cli_space | |
140 | ||
141 | #cli_headline 2 "Configurations" | |
142 | #zone_configs_cmd status ${zone} | |
143 | #cli_space | |
144 | ||
145 | exit ${EXIT_OK} | |
146 | } |