]>
git.ipfire.org Git - network.git/blob - functions.ppp
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 ppp_common_ip_pre_up
() {
26 if ! zone_exists
${zone}; then
27 error
"Zone '${zone}' does not exist."
31 # Request firewall reload
37 function ppp_common_ip_up
() {
41 if ! zone_exists
${zone}; then
42 error
"Zone '${zone}' does not exist."
46 # Emit interface-up event
47 event_interface_up
${zone}
52 function ppp_common_ip_down
() {
56 if ! zone_exists
${zone}; then
57 error
"Zone '${zone}' does not exist."
61 # Save accounting information
62 ppp_accounting
${zone}
64 # Emit interface-up event
65 event_interface_down
${zone}
70 function ppp_secret
() {
77 # Updateing secret file
79 while read user a secret
; do
80 if [ "'${USER}'" != "${user}" ]; then
81 echo "${user} ${a} ${secret}" >> ${PPP_SECRETS}.tmp
84 echo "'${USER}' * '${SECRET}'" >> ${PPP_SECRETS}.tmp
85 cat ${PPP_SECRETS}.tmp > ${PPP_SECRETS}
86 rm -f ${PPP_SECRETS}.tmp
89 function ppp_accounting() {
93 db_ppp_update ${zone} --duration="${CONNECT_TIME}" \
94 --rcvd="${BYTES_RCVD}" --sent="${BYTES_SENT}"
97 function red_defaultroute_update() {
98 local command="ip route replace default"
101 for uplink in ${RED_RUN}/*; do
102 [ -d "${uplink}" ] || continue
104 # Skip if no gateway given
105 [ -e "${uplink}/gateway" ] || continue
107 command="${command} nexthop via $(<${uplink}/gateway)"
108 if [ -e "${uplink}/weight" ]; then
109 command="${command} weight $(<${uplink}/weight)"
113 #ip route flush cache
116 function red_dns_update() {