]>
git.ipfire.org Git - people/stevee/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 ###############################################################################
23 mkdir
-p /var
/run
/ppp
2>/dev
/null
26 init_register ppp_init
28 function ppp_common_ip_pre_up
() {
32 if ! zone_exists
${zone}; then
33 error
"Zone '${zone}' does not exist."
37 # XXX protocol hardcoded
38 routing_db_from_ppp
${zone} ipv4
40 # Request firewall reload
46 function ppp_common_ip_up
() {
50 if ! zone_exists
${zone}; then
51 error
"Zone '${zone}' does not exist."
55 # XXX protocol is hardcoded
56 routing_db_set
${zone} ipv4 active
1
57 routing_update
${zone} ipv4
59 # Emit interface-up event
60 event_interface_up
${zone}
65 function ppp_common_ip_down
() {
69 if ! zone_exists
${zone}; then
70 error
"Zone '${zone}' does not exist."
74 # Save accounting information
75 ppp_accounting
${zone}
77 # Emit interface-up event
78 event_interface_down
${zone}
83 function ppp_secret
() {
90 # Updateing secret file
92 while read user a secret
; do
93 if [ "'${USER}'" != "${user}" ]; then
94 echo "${user} ${a} ${secret}" >> ${PPP_SECRETS}.tmp
97 echo "'${USER}' * '${SECRET}'" >> ${PPP_SECRETS}.tmp
98 cat ${PPP_SECRETS}.tmp > ${PPP_SECRETS}
99 rm -f ${PPP_SECRETS}.tmp
102 function ppp_accounting() {
106 db_ppp_update ${zone} --duration="${CONNECT_TIME}" \
107 --rcvd="${BYTES_RCVD}" --sent="${BYTES_SENT}"
110 function pppd_exec() {
111 log DEBUG "Running pppd with parameters '$@
'."