]>
git.ipfire.org Git - people/arne_f/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_pre_up
() {
24 #connection --starting --zone=${zone}
27 function ppp_post_up
() {
29 #connection --up --zone=${zone}
32 function ppp_pre_down
() {
34 # connection --stopping --zone=${zone}
37 function ppp_post_down
() {
39 #connection --down --zone=${zone}
42 function ppp_common_ip_pre_up
() {
46 if ! zone_exists
${zone}; then
47 error
"Zone '${zone}' does not exist."
51 # Request firewall reload
57 function ppp_common_ip_up
() {
61 if ! zone_exists
${zone}; then
62 error
"Zone '${zone}' does not exist."
66 # Emit interface-up event
67 event_interface_up
${zone}
72 function ppp_common_ip_down
() {
76 if ! zone_exists
${zone}; then
77 error
"Zone '${zone}' does not exist."
81 # Emit interface-up event
82 event_interface_down
${zone}
87 function ppp_secret
() {
94 # Updateing secret file
96 while read user a secret
; do
97 if [ "'${USER}'" != "${user}" ]; then
98 echo "${user} ${a} ${secret}" >> ${PPP_SECRETS}.tmp
100 done < ${PPP_SECRETS}
101 echo "'${USER}' * '${SECRET}'" >> ${PPP_SECRETS}.tmp
102 cat ${PPP_SECRETS}.tmp > ${PPP_SECRETS}
103 rm -f ${PPP_SECRETS}.tmp
106 function ppp_stat() {
112 local file="${LOG_DIR}/ppp_${name}.db"
113 if ! [ -e "${file}" ]; then
114 sqlite3 -batch ${file} <<EOF
115 CREATE TABLE connections(date, duration, rcvd, sent);
118 ppp_stat_init ${file}
120 sqlite3 -batch ${file} <<EOF
121 INSERT INTO connections(date, duration, rcvd, sent) VALUES('$
(date -u '+%s')', '${time}', '${rcvd}', '${sent}');
125 function ppp_linkname_get() {
133 function red_defaultroute_update() {
134 local command="ip route replace default"
137 for uplink in ${RED_RUN}/*; do
138 [ -d "${uplink}" ] || continue
140 # Skip if no gateway given
141 [ -e "${uplink}/gateway" ] || continue
143 command="${command} nexthop via $(<${uplink}/gateway)"
144 if [ -e "${uplink}/weight" ]; then
145 command="${command} weight $(<${uplink}/weight)"
149 #ip route flush cache
152 function red_dns_update() {