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 .
/lib
/network
/header-zone
24 HOOK_SETTINGS
="HOOK AUTH DEVICE BAUDRATE LINKNAME USER SECRET PEERDNS DEFAULTROUTE MTU"
36 MODEM_ALLOWED_AUTHS
="chap pap"
42 cat /var
/run
/${zone}.pid
2>/dev
/null
49 assert isset DEFAULTROUTE
53 assert isbool DEFAULTROUTE
55 assert isinteger BAUDRATE
57 isset AUTH
&& assert isoneof AUTH
${MODEM_ALLOWED_AUTHS}
60 function _parse_cmdline
() {
63 while [ $# -gt 0 ]; do
78 value
=${1#--defaultroute=}
79 if enabled value
; then
87 if enabled value
; then
100 BAUDRATE
=${1#--baudrate=}
103 echo "Unknown option: $1" >&2
117 zone_config_read
${zone}
119 assert
[ -e "/dev/${DEVICE}" ]
121 # Creating necessary files
122 # XXX must be PPP_RUN
123 [ -d "${RED_RUN}/${LINKNAME}" ] || mkdir -p ${RED_RUN}/${LINKNAME}
125 ppp_secret "${USER}" "${SECRET}"
127 cat <<EOF >${RED_RUN}/${LINKNAME}/options
133 # Device configuration
134 /dev/${DEVICE} ${BAUDRATE}
135 connect "/usr
/sbin
/chat
-v -f /etc
/ppp
/dialer
"
143 $(enabled PEERDNS && echo "usepeerdns
")
144 $(enabled DEFAULTROUTE && echo "defaultroute
")
147 $(isset AUTH && echo "require-
${AUTH}")
151 # Maximum transmission/receive unit
155 # Disable the compression
156 noccp noaccomp nodeflate nopcomp novj novjccomp nobsdcomp nomppe
161 pppd_exec file ${RED_RUN}/${LINKNAME}/options
165 # Get exit code from ppp daemon and handle it:
168 log DEBUG "pppd detached successfully
"
173 error_log "pppd exited with unknown
exit code
'${ret}'"
184 kill $(pppd_pid ${zone}) &>/dev/null
194 cli_status_headline ${zone}
196 zone_config_read ${zone}
198 cli_headline " Configuration
:"
199 printf "${DEVICE_PRINT_LINE1}" "User
:" "${USER}"
200 printf "${DEVICE_PRINT_LINE1}" "Secret
:" "<hidden
>"
202 printf "${DEVICE_PRINT_LINE1}" "MTU
:" "${MTU}"
203 printf "${DEVICE_PRINT_LINE1}" "Use default route?
" "$
(enabled DEFAULTROUTE
&& echo "enabled" ||
echo "disabled")"
204 printf "${DEVICE_PRINT_LINE1}" "Use peer DNS?
" "$
(enabled PEERDNS
&& echo "enabled" ||
echo "disabled")"
206 cli_headline " Ports
:"
207 zone_ports_status ${zone}
208 if [ -z "$
(zone_get_ports
${zone})" ]; then
209 echo -e " ${COLOUR_WARN}No ports attached. Won
't be able to start.${COLOUR_NORMAL}"
212 # Exit if zone is down
213 if ! zone_is_up ${zone}; then
218 # XXX display time since connection started
220 cli_headline " Point-to-Point-over-Ethernet protocol:"
221 echo " IP-Address : $(red_db_get ${zone} local-ip-address)"
222 echo " Gateway : $(red_db_get ${zone} remote-ip-address)"
223 echo " DNS-Server : $(red_db_get ${zone} dns)"
225 echo " MAC-Remote : $(red_db_get ${zone} remote-address)"
227 echo " MTU : $(device_get_mtu ${zone})"