]>
git.ipfire.org Git - people/stevee/network.git/blob - src/functions/functions.pppoe-server
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012 IPFire Network Development Team #
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 # Load the pppoe kernel module
27 pppoe_server_start
() {
31 # Initialise the system for this
34 service_start
"pppoe-server@${zone}.service"
41 service_stop
"pppoe-server@${zone}.service"
44 pppoe_server_status
() {
48 service_status
"pppoe-server@${zone}.service"
51 pppoe_server_options
() {
61 local default_asyncmap
="true"
64 local lcp_echo_failure
=5
65 local lcp_echo_interval
=60
70 while [ $# -gt 0 ]; do
73 auth
=$
(cli_get_val
"${1}")
76 default_asyncmap
=$
(cli_get_val
"${1}")
82 dns_servers
="$(cli_get_val "${1}")"
85 lcp_echo_failure
=$
(cli_get_val
"${1}")
86 assert isinteger
${lcp_echo_failure}
88 --lcp-echo-interval=*)
89 lcp_echo_interval
=$
(cli_get_val
"${1}")
90 assert isinteger
${lcp_echo_interval}
93 proxyarp
=$
(cli_get_val
"${1}")
96 required_auths
="${required_auths} $(cli_get_val "${1}")"
102 mkdir
-p $
(dirname ${file}) 2>/dev
/null
103 config_header
"pppoe-server options configuration file" > ${file}
107 print
"# Authentication"
108 if enabled auth
; then
116 # If there are only a number of auth algorithms allowed, we
118 if isset required_auths
; then
119 print
"# Required authentication methods" >> ${file}
121 for method
in ${required_auths}; do
122 print
"require-${method}"
128 if enabled ipv6
; then
129 # Generate a random gateway address
130 local gw_addr
="::$(random 4):$(random 4)"
133 print
"ipv6 ${gw_addr}"
139 if isset dns_servers
; then
140 print
"# DNS servers" >> ${file}
142 for server
in ${dns_servers}; do
143 print
"ms-dns ${server}"
149 if enabled default_asyncmap
; then
151 print
"# Default asyncmap"
152 print
"default-asyncmap"
159 print
"# LCP settings"
160 print
"lcp-echo-failure ${lcp_echo_failure}"
161 print
"lcp-echo-interval ${lcp_echo_interval}"
168 if enabled proxyarp
; then
176 # Default options, we always set.
179 print
"nodefaultroute"
187 pppoe_server_poolfile
() {
194 config_header
"PPPoE server IP address pool file" > ${file}
196 # The network address will be the gateway address.
197 local netaddr
=$
(ipv4_get_network
${subnet})
200 for addr
in $
(ipv4_range_explicit
${subnet}); do
201 [ "${addr}" = "${netaddr}" ] && continue