]>
git.ipfire.org Git - people/arne_f/network.git/blob - functions.red
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 function red_db_path
() {
25 echo "${RED_DB_DIR}/${zone}"
28 function red_db_exists
() {
31 [ -d "$(red_db_path ${zone})" ]
34 function red_db_create
() {
37 red_db_exists
${zone} && return ${EXIT_OK}
39 mkdir
-p $
(red_db_path
${zone})
42 function red_db_remove
() {
45 [ -z "${zone}" ] && return ${EXIT_ERROR}
50 function red_db_set
() {
59 echo "${value}" > $(red_db_path ${zone})/${parameter}
62 function red_db_get() {
67 cat $(red_db_path ${zone})/${parameter} 2>/dev/null
70 function red_db_from_ppp() {
73 # Save ppp configuration
74 red_db_set ${zone} type "ppp
"
75 red_db_set ${zone} local-ip-address ${PPP_IPLOCAL}
76 red_db_set ${zone} remote-ip-address ${PPP_IPREMOTE}
78 red_db_set ${zone} dns ${PPP_DNS1} ${PPP_DNS2}
80 red_db_set ${zone} remote-address ${PPP_MACREMOTE,,}
83 function red_routing_update() {
88 # Create routing table if not exists
89 routing_table_create ${table}
91 local remote_ip_address=$(red_db_get ${zone} remote-ip-address)
92 local local_ip_address=$(red_db_get ${zone} local-ip-address)
94 ip route replace table ${table} default nexthop via ${remote_ip_address}
96 ip rule add from ${local_ip_address} lookup ${table}