2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012-2013 IPFire Network Development Team #
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 ###############################################################################
24 function ip_tunnel_add
() {
34 while [ $# -gt 0 ]; do
37 mode
="$(cli_get_val ${1})"
40 ttl
="$(cli_get_val ${1})"
44 remote_address
="$(cli_get_val ${1})"
47 local_address
="$(cli_get_val ${1})"
54 assert isoneof mode
${IP_TUNNEL_MODES}
56 # If TTL is set, make sure it is an integer.
57 isset ttl
&& assert isinteger ttl
59 assert isset local_address
63 # Apply TTL if a value has been set.
65 cmd_args
="${cmd_args} ttl ${ttl}"
68 # Apply remote address if a value has been set.
69 if isset remote_address
; then
70 cmd_args
="${cmd_args} remote ${remote_address}"
73 log DEBUG
"Creating tunnel device '${device}' (mode=${mode})..."
76 cmd ip tunnel add
${device} mode
${mode} \
77 local ${local_address} ${cmd_args}
81 function ip_tunnel_del
() {
83 assert device_exists
${device}
85 # Make sure the device has been shut down.
86 device_set_down
${device}
88 log DEBUG
"Removing tunnel device '${device}'..."
90 ip tunnel del
${device}
94 function ip_tunnel_6rd_set_prefix
() {
101 # Validate the prefix.
102 assert ipv6_is_valid
"${prefix}"
104 log INFO
"Setting 6rd-prefix ${prefix} on ${device}"
107 cmd ip tunnel
6rd dev
"${device}" 6rd-prefix
"${prefix}"