]>
git.ipfire.org Git - people/stevee/network.git/blob - functions.radvd
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 RADVD_CONFIGFILE
="/etc/radvd.conf"
24 function radvd_update
() {
25 # (Re-)write the configuration file
28 # Reload the radvd service.
32 function radvd_write_config
() {
33 # Clear the config file.
36 # Write header to the file.
38 __radvd_write
"# This is the radvd daemon configuration file."
39 __radvd_write
"# THIS FILE IS AUTOMATICALLY GENERATED AND WILL OVERWRITE"
40 __radvd_write
"# ANY CUSTOM CHANGES!"
43 # Write the configuration for all zones.
45 for zone
in $
(zones_get_all
); do
46 __radvd_config_interface
${zone}
50 function __radvd_clear
() {
51 log DEBUG
"Clearing radvd config file."
53 : > ${RADVD_CONFIGFILE}
56 function __radvd_write
() {
57 echo -e "$@" >> ${RADVD_CONFIGFILE}
60 function __radvd_config_interface
() {
66 # If the interface does not provide any routing information,
67 # we can skip this whole stuff.
68 if ! routing_db_exists
${zone} ipv6
; then
72 # Skip if zone is not active.
73 local active
=$
(routing_db_get
${zone} ipv6 active
)
74 [ "${active}" = "0" ] && return ${EXIT_OK}
76 # Skip if there is no prefix or prefix is link-local.
77 local prefix
=$
(routing_db_get
${zone} ipv6 local-ip-address
)
78 if [ -z "${prefix}" ] ||
[ "${prefix:0:5}" = "fe80:" ]; then
82 __radvd_write
"interface ${zone} {"
83 __radvd_write
" AdvSendAdvert on;"
84 __radvd_write
" MinRtrAdvInterval 3;"
85 __radvd_write
" MaxRtrAdvInterval 10;"
86 __radvd_write
" IgnoreIfMissing on;"
88 __radvd_write
" prefix ${prefix} {"
89 __radvd_write
" AdvOnLink on;"
90 __radvd_write
" AdvAutonomous on;"
91 __radvd_write
" AdvRouterAddr on;"