]>
git.ipfire.org Git - people/ms/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 routing_db_from_ppp
${zone} ipv4
39 # Request firewall reload
45 function ppp_common_ip_up
() {
49 if ! zone_exists
${zone}; then
50 error
"Zone '${zone}' does not exist."
54 routing_db_set
${zone} ipv4 active
1
55 routing_update
${zone} ipv4
57 # Emit interface-up event
58 event_interface_up
${zone}
63 function ppp_common_ip_down
() {
67 if ! zone_exists
${zone}; then
68 error
"Zone '${zone}' does not exist."
72 # Remove the information about this zone from the routing database
73 # and update the routing table.
74 routing_db_remove
${zone} ipv4
75 routing_update
${zone} ipv4
77 # Save accounting information
78 ppp_accounting
${zone}
80 # Emit interface-up event
81 event_interface_down
${zone}
86 function ppp_common_ipv6_up
() {
90 if ! zone_exists
${zone}; then
91 error
"Zone '${zone}' does not exist."
95 # Add information about this zone to the routing database.
96 routing_db_from_ppp
${zone} ipv6
98 routing_db_set
${zone} ipv6 active
1
99 routing_update
${zone} ipv6
101 # Emit interface-up event
102 event_interface_up
${zone}
107 function ppp_common_ipv6_down
() {
111 if ! zone_exists
${zone}; then
112 error
"Zone '${zone}' does not exist."
116 # Remove the information about this zone from the routing database
117 # and update the routing table.
118 routing_db_remove
${zone} ipv6
119 routing_update
${zone} ipv6
121 # Save accounting information
122 ppp_accounting
${zone}
124 # Emit interface-up event
125 event_interface_down
${zone}
130 function ppp_secret
() {
137 # Updateing secret file
139 while read user a secret
; do
140 if [ "'${USER}'" != "${user}" ]; then
141 echo "${user} ${a} ${secret}" >> ${PPP_SECRETS}.tmp
143 done < ${PPP_SECRETS}
144 echo "'${USER}' * '${SECRET}'" >> ${PPP_SECRETS}.tmp
145 cat ${PPP_SECRETS}.tmp > ${PPP_SECRETS}
146 rm -f ${PPP_SECRETS}.tmp
149 function ppp_accounting() {
153 db_ppp_update ${zone} --duration="${CONNECT_TIME}" \
154 --rcvd="${BYTES_RCVD}" --sent="${BYTES_SENT}"
157 function pppd_exec() {
158 log DEBUG "Running pppd with parameters '$@
'."