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 LOCAL_ADDRESS REMOTE_ADDRESS MSN MTU MRU"
25 HOOK_SETTINGS
="${HOOK_SETTINGS} L2PROTO L3PROTO ENCAP"
27 # The peer address of the ISDN server.
43 assert isset LOCAL_ADDRESS
44 assert isset REMOTE_ADDRESS
50 assert isinteger TIMEOUT
52 isset AUTH
&& assert isoneof AUTH
${ISDN_ALLOWED_AUTHS}
55 function _parse_cmdline
() {
58 while [ $# -gt 0 ]; do
61 LOCAL_ADDRESS
=${1#--local-address=}
64 REMOTE_ADDRESS
=${1#--remote-address=}
76 value
=${1#--defaultroute=}
77 if enabled value
; then
85 if enabled value
; then
101 TIMEOUT
=${1#--timeout=}
104 PHONE
="${PHONE} ${1#--phone=}"
107 echo "Unknown option: $1" >&2
121 zone_config_read
${zone}
123 assert
[ -e "/dev/${DEVICE}" ]
125 # Creating necessary files
126 # XXX must be PPP_RUN
127 [ -d "${RED_RUN}/${LINKNAME}" ] || mkdir -p ${RED_RUN}/${LINKNAME}
129 # Create device node.
130 isdn_create_device ${zone}
132 # Apply configuration to the ISDN stack.
133 isdn_set_l2proto ${zone} ${L2PROTO}
134 isdn_set_l3proto ${zone} ${L3PROTO}
135 isdn_set_encap ${zone} ${ENCAP}
137 isdn_set_eaz ${zone} ${MSN}
138 isdn_set_huptimeout ${zone} $(( ${TIMEOUT} * 60 ))
140 # Set our ip address.
141 ip_address_add ${zone} ${LOCAL_ADDRESS}
142 device_set_up ${zone}
144 # Start ipppd in server mode and make it listening for
145 # incoming connections:
148 # Get a list of all DNS servers.
150 for dns_server in ${dns_servers}; do
151 options="${options} --dns-server=${dns_server}"
155 local prefix=$(ip_get_prefix ${LOCAL_ADDRESS})
156 local netmask=$(ipv4_prefix2netmask ${prefix})
158 # Split prefix from LOCAL_ADDRESS.
159 local local_address=$(ip_split_prefix ${LOCAL_ADDRESS})
161 ipppd_start ${zone} \
163 --local-address="${local_address}" \
164 --remote-address="${REMOTE_ADDRESS}" \
165 --netmask="${netmask}" \
176 # Kill ipppd service.
179 # Bring down ISDN interface.
180 device_set_down ${zone}
182 # Remove ISDN device.
183 isdn_remove_device ${zone}
192 cli_device_headline ${zone}
194 zone_config_read ${zone}
196 cli_headline " Configuration
:"
197 printf "${DEVICE_PRINT_LINE1}" "User
:" "${USER}"
198 printf "${DEVICE_PRINT_LINE1}" "Secret
:" "<hidden
>"
200 printf "${DEVICE_PRINT_LINE1}" "MTU
:" "${MTU}"
201 printf "${DEVICE_PRINT_LINE1}" "Use default route?
" "$
(enabled DEFAULTROUTE
&& echo "enabled" ||
echo "disabled")"
202 printf "${DEVICE_PRINT_LINE1}" "Use peer DNS?
" "$
(enabled PEERDNS
&& echo "enabled" ||
echo "disabled")"
205 if device_exists ${zone}; then
206 cli_headline " ISDN information
:"
207 printf "${DEVICE_PRINT_LINE1}" "L2 protocol
:" "$
(isdn_get_l2proto
${zone})"
208 printf "${DEVICE_PRINT_LINE1}" "L3 protocol
:" "$
(isdn_get_l3proto
${zone})"
209 printf "${DEVICE_PRINT_LINE1}" "Encapsulation
:" "$
(isdn_get_encap
${zone})"
213 # Exit if zone is down
214 if ! zone_is_up ${zone}; then
219 # XXX display time since connection started
221 cli_headline " Point-to-Point-over-Ethernet protocol
:"
222 echo " IP-Address
: $
(routing_db_get
${zone} local-ip-address
)"
223 echo " Gateway
: $
(routing_db_get
${zone} remote-ip-address
)"
224 echo " DNS-Server
: $
(routing_db_get
${zone} dns
)"
226 echo " MAC-Remote
: $
(routing_db_get
${zone} remote-address
)"
228 echo " MTU
: $
(device_get_mtu
${zone})"