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 .
/usr
/lib
/network
/header-config
32 DEFAULT_MAX_SESSIONS
=0
34 hook_check_config_settings
() {
37 assert isset MAX_SESSIONS
40 for server
in ${DNS_SERVERS}; do
41 assert ipv4_is_valid
"${server}"
45 hook_parse_cmdline
() {
49 while [ $# -gt 0 ]; do
52 local dns_servers
="$(cli_get_val "${1}")"
55 for dns_server
in ${dns_servers}; do
56 if ! ipv4_is_valid
"${dns_server}"; then
57 warning
"Invalid IPv4 address: ${dns_server}. Skipped."
61 list_append DNS_SERVERS
"${dns_server}"
65 MAX_SESSIONS
=$
(cli_get_val
"${1}")
66 if ! isinteger
${MAX_SESSIONS} ||
! [ ${MAX_SESSIONS} -ge 0 ]; then
67 error
"Invalid value for '--max-session'. This value must be an integer greate or eqal zero."
72 MTU
=$
(cli_get_val
"${1}")
73 if ! mtu_is_valid
"ipv4" ${MTU}; then
74 error
"Invalid value for '--mtu'. Cannot be larger then 9000 or smaller than 576"
79 SERVICE_NAME
=$
(cli_get_val
"${1}")
82 SUBNET
=$
(cli_get_val
"${1}")
83 if ! ipv4_net_is_valid
"${SUBNET}"; then
84 error
"Invalid IPv4 Subnet ${SUBNET}."
89 warning
"Ignoring unknown option '${1}'"
101 # Start the PPPoE server.
102 pppoe_server_start
${zone}
112 if ! device_exists
${zone}; then
113 error
"Zone '${zone}' doesn't exist."
117 # Stop the PPPoE server.
118 pppoe_server_stop
${zone}
128 if ! device_exists
${zone}; then
129 error
"Zone '${zone}' doesn't exist."
133 zone_config_settings_read
"${zone}" "${config}"
136 if pppoe_server_status
${zone}; then
137 status
="${MSG_HOOK_UP}"
139 status
="${MSG_HOOK_DOWN}"
141 cli_statusline
3 "PPPoE server" "${status}"
143 local gateway
=$
(ipv4_get_network
${SUBNET})
144 cli_print_fmt1
3 "Gateway" "${gateway}"
146 local start_address
=$
(ipv4_encode
${gateway})
147 start_address
=$
(( ${start_address} + 1 ))
148 start_address
=$
(ipv4_decode
${start_address})
149 local end_address
=$
(ipv4_get_broadcast
${SUBNET})
151 cli_print_fmt1
3 "Client range" \
152 "${start_address}-${end_address}"
155 local max_sessions
=${MAX_SESSIONS}
156 if [ "${max_sessions}" = "0" ]; then
157 max_sessions
="unlimited"
159 cli_print_fmt1
3 "${max_sessions} session(s) per MAC"