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-zone
24 HOOK_SETTINGS
="HOOK AUTH LINKNAME USER SECRET PEERDNS DEFAULTROUTE MSN MTU"
25 HOOK_SETTINGS
="${HOOK_SETTINGS} L2PROTO L3PROTO ENCAP PHONE"
44 ISDN_ALLOWED_AUTHS
="chap pap"
46 function hook_check
() {
50 assert isset DEFAULTROUTE
55 assert isbool DEFAULTROUTE
58 assert isinteger TIMEOUT
60 isset AUTH
&& assert isoneof AUTH
${ISDN_ALLOWED_AUTHS}
63 function hook_parse_cmdline
() {
66 while [ $# -gt 0 ]; do
81 value
=${1#--defaultroute=}
82 if enabled value
; then
90 if enabled value
; then
100 DEVICE
=${1#--device=}
106 TIMEOUT
=${1#--timeout=}
109 PHONE
="${PHONE} ${1#--phone=}"
112 echo "Unknown option: $1" >&2
126 zone_config_read
${zone}
128 assert
[ -e "/dev/${DEVICE}" ]
130 # Creating necessary files
131 # XXX must be PPP_RUN
132 [ -d "${RED_RUN}/${LINKNAME}" ] || mkdir -p ${RED_RUN}/${LINKNAME}
134 # Create device node.
135 isdn_create_device ${zone}
137 # Apply configuration to the ISDN stack.
138 isdn_set_l2proto ${zone} ${L2PROTO}
139 isdn_set_l3proto ${zone} ${L3PROTO}
140 isdn_set_encap ${zone} ${ENCAP}
142 isdn_set_eaz ${zone} ${MSN}
143 isdn_set_huptimeout ${zone} $(( ${TIMEOUT} * 60 ))
144 isdn_addphone ${zone} out ${PHONE}
146 # Updating PPP credentials.
147 ppp_secret "${USER}" "${SECRET}"
149 # Bring up connection.
152 --channels=${CHANNELS} \
159 function hook_down() {
163 # Bring down ISDN interface.
166 # Remove ISDN device.
167 isdn_remove_device ${zone}
172 function hook_status() {
176 cli_device_headline ${zone}
178 zone_config_read ${zone}
180 cli_headline 2 "Configuration
:"
181 cli_print_fmt1 2 "User
" "${USER}"
182 cli_print_fmt1 2 "Secret
" "<hidden
>"
185 if device_exists ${zone}; then
186 cli_headline 3 "ISDN information
:"
187 cli_print_fmt1 3 "L2 protocol
" "$
(isdn_get_l2proto
${zone})"
188 cli_print_fmt1 3 "L3 protocol
" "$
(isdn_get_l3proto
${zone})"
189 cli_print_fmt1 3 "Encapsulation
" "$
(isdn_get_encap
${zone})"
193 # Exit if zone is down
194 zone_is_up ${zone} || exit ${EXIT_ERROR}
196 # XXX display time since connection started
198 cli_headline 2 "Point-to-Point protocol
"
199 cli_print_fmt1 2 "IP address
" "$
(routing_db_get
${zone} local-ip-address
)"
200 cli_print_fmt1 2 "Gateway
" "$
(routing_db_get
${zone} remote-ip-address
)"
201 cli_print_fmt1 2 "DNS servers
" "$
(routing_db_get
${zone} dns
)"