]>
git.ipfire.org Git - people/stevee/network.git/blob - src/hooks/zones/bridge.configs/ipv6-static
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 HOOK_SETTINGS
="HOOK ADDRESS PREFIX GATEWAY"
26 function hook_check
() {
28 assert isinteger PREFIX
30 if [ ${PREFIX} -gt 64 ]; then
31 error
"PREFIX is greater than 64."
36 function hook_create
() {
40 while [ $# -gt 0 ]; do
43 ADDRESS
=${1#--address=}
49 GATEWAY
=${1#--gateway=}
55 # Store IPv6 address in small format.
56 ADDRESS
=$
(ipv6_implode
${ADDRESS})
58 if [ -n "${GATEWAY}" ]; then
59 GATEWAY
=$
(ipv6_implode
${GATEWAY})
62 config_write $
(zone_dir
${zone})/configs/${HOOK}.$(ipv6_hash ${ADDRESS}).${PREFIX} ${HOOK_SETTINGS}
72 if ! device_exists
${zone}; then
73 error
"Zone '${zone}' doesn't exist."
77 config_read $
(zone_dir
${zone})/configs
/${config}
79 ip_address_add
${zone} ${ADDRESS}/${PREFIX}
81 routing_db_set
${zone} ipv6 local-ip-address ${ADDRESS}/${PREFIX}
82 routing_db_set
${zone} ipv6 remote-ip-address
${GATEWAY}
83 routing_db_set
${zone} ipv6 active
1
84 routing_default_update
89 function hook_down
() {
94 if ! device_exists
${zone}; then
95 error
"Zone '${zone}' doesn't exist."
99 # Remove routing information from database.
100 routing_db_remove
${zone} ipv6
102 config_read $
(zone_dir
${zone})/configs
/${config}
104 ip_address_del
${zone} ${ADDRESS}/${PREFIX}
106 # Update routing tables.
107 routing_default_update
112 function hook_status
() {
117 if ! device_exists
${zone}; then
118 error
"Zone '${zone}' doesn't exist."
122 config_read $
(zone_dir
${zone})/configs
/${config}
124 # Make sure ADDRESS is as short as possible.
125 ADDRESS
=$
(ipv6_implode
${ADDRESS})
128 if zone_has_ip
${zone} ${ADDRESS}/${PREFIX}; then
129 status
=${MSG_HOOK_UP}
131 status
=${MSG_HOOK_DOWN}
133 cli_statusline
3 "${HOOK}" "${status}"
135 cli_print_fmt1
3 "IPv6 address" "${ADDRESS}/${PREFIX}"
136 if [ -n "${GATEWAY}" ]; then
137 cli_print_fmt1
3 "Gateway" "${GATEWAY}"