blob: 3ba933282a41edcdc297326d4ccb09a255272e46 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
|
#! /bin/sh
#
# ifup-ippp
#
# This script is normally called from the ifup script when it detects a ippp device.
. /etc/init.d/functions
cd /etc/sysconfig/network-scripts
. ./network-functions
# Get global network configuration
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network
GATEWAY=""
# set device
CONFIG=$1
[ -f "${CONFIG}" ] || CONFIG=ifcfg-${1}
source_config
if [ "${2}" = "boot" -a "${ONBOOT}" = "no" ]; then
exit
fi
if [ ! -f /var/lock/subsys/isdn ] && [ -x /etc/init.d/isdn ] ; then
/etc/init.d/isdn start
fi
# check that ipppd is available for syncppp
if [ "$ENCAP" = "syncppp" ]; then
if [ ! -x /sbin/ipppd ] && [ ! -x /usr/sbin/ipppd ] ; then
/usr/bin/logger -p daemon.info -t ifup-ippp "ipppd does not exist or is not executable"
exit 1
fi
fi
# check that isdnctrl is available
if [ ! -x /sbin/isdnctrl ] && [ ! -x /usr/sbin/isdnctrl ] ; then
/usr/bin/logger -p daemon.info -t ifup-ippp "isdnctrl does not exist or is not executable"
exit 1
fi
# check all ISDN devices
if ! isdnctrl list all >/dev/null 2>&1 ; then
/usr/bin/logger -p daemon.info -t ifup-ippp "cannot list ISDN devices"
exit 1
fi
# check if device already is configured
isdnctrl list $DEVICE >/dev/null 2>&1 && exit 0
function log_echo()
{
/usr/bin/logger -p daemon.info -t ifup-ippp $"$*"
}
function log_isdnctrl()
{
/usr/bin/logger -p daemon.info -t ifup-ippp isdnctrl $*
isdnctrl $* >/dev/null 2>&1 || exit 1
}
function create_option_file()
{
umask 066
echo "$1" > /etc/ppp/ioption-secret-$DEVICE
umask 022
}
function start_ibod()
{
# don't start ibod, if it's running
[ -f /var/lock/subsys/ibod ] && return
device=$1
if [ -f /etc/isdn/ibod.cf ] && [ -x /usr/sbin/ibod ] ; then
ibod $device &
pid=$(pidof ibod)
[ -n "$pid" ] && touch /var/lock/subsys/ibod
fi
}
function addprovider()
{
options=
if [ -z "$PHONE_OUT" ]; then
log_echo "Error: $1: no outgoing phone number set"
return 1
fi
# set the encapsulation mode
[ -z "$ENCAP" ] && ENCAP="syncppp"
# set the dial mode
[ -z "$DIALMODE" ] && DIALMODE="off"
[ "$AUTH" = "none" -o "$AUTH" = "noauth" -o -z "$AUTH" ] && AUTH="-pap -chap"
# set layer-2/3 protocol
[ -z "$L2_PROT" ] && L2_PROT="hdlc"
[ -z "$L3_PROT" ] && L3_PROT="trans"
# check local/remote IP
[ -z "$IPADDR" ] && IPADDR="0.0.0.0"
[ -z "$GATEWAY" ] && GATEWAY="0.0.0.0"
# set default route
[ "$DEFROUTE" = "yes" ] && options="$options defaultroute deldefaultroute"
# set authentication
_auth=$(echo "$AUTH" | sed 's/[a-z -]*//g')
if [ -n "$_auth" ]; then
if [ -z "$USER" -a "$DIALIN" != "on" ]; then
log_echo " Error: $1 (syncppp) user is not set"
return 1
fi
if [ "$DIALIN" != "on" ]; then
# we should hide the user name, so i add user name to option file.
if [ "$AUTH" = "-pap +chap" ]; then
create_option_file "name \"$USER\""
else
create_option_file "user \"$USER\""
fi
options="$options file /etc/ppp/ioption-secret-$DEVICE"
fi
# authentication options:
# +pap and/or +chap does not work correct by dialout - remove
# them if it's configured as dialout
[ "$DIALIN" = "on" ] || AUTH=$(echo "$AUTH" | sed 's/+[a-z]*//g')
fi
# add ISDN device
log_isdnctrl addif $DEVICE
# set local MSN
[ -z "$MSN" ] || log_isdnctrl eaz $DEVICE $MSN
# set dialout numbers
if echo $COUNTRYCODE | grep ":" >/dev/null 2>&1 ; then
COUNTRYCODE="$(echo $COUNTRYCODE | cut -f 2 -d ':')"
[ "$COUNTRYCODE" = "0" ] && COUNTRYCODE=
else
COUNTRYCODE=
fi
for i in $PHONE_OUT; do
log_isdnctrl addphone $DEVICE out $COUNTRYCODE$PREFIX$AREACODE$i
done
for i in $PHONE_IN; do
log_isdnctrl addphone $DEVICE in $i
done
# set layer-2/3 protocol
log_isdnctrl l2_prot $DEVICE $L2_PROT
log_isdnctrl l3_prot $DEVICE $L3_PROT
# set encapsulation
log_isdnctrl encap $DEVICE $ENCAP
# set dialmode
log_isdnctrl dialmode $DEVICE $DIALMODE
[ -n "$SECURE" ] && log_isdnctrl secure $DEVICE $SECURE
[ -n "$HUPTIMEOUT" ] && log_isdnctrl huptimeout $DEVICE $HUPTIMEOUT
[ -n "$CHARGEHUP" ] && log_isdnctrl chargehup $DEVICE $CHARGEHUP
[ -n "$CHARGEINT" ] && log_isdnctrl chargeint $DEVICE $CHARGEINT
[ -n "$IHUP" ] && log_isdnctrl ihup $DEVICE $IHUP
# set the number of dial atempts for each number
[ -n "$DIALMAX" ] && log_isdnctrl dialmax $DEVICE $DIALMAX
# set callback
if [ "$CALLBACK" = "out" -o "$CALLBACK" = "in" ] ; then
log_isdnctrl callback $DEVICE $CALLBACK
else
log_isdnctrl callback $DEVICE off
fi
[ -n "$CBDELAY" ] && log_isdnctrl cbdelay $DEVICE $CBDELAY
[ -n "$CBHUP" ] && log_isdnctrl cbhup $DEVICE $CBHUP
options="$options ipparam $DEVNAME"
[ "$ENCAP" = "syncppp" ] && log_isdnctrl pppbind $DEVICE
if [ "$IPADDR" = "0.0.0.0" ]; then
options="$options ipcp-accept-local"
else
if [ "$DIALIN" != "on" ]; then
options="$options noipdefault"
fi
fi
# Add device
options="$options /dev/$DEVICE"
# set channel bundling
if [ "$BUNDLING" = "yes" -o "$BUNDLING" = "on" ] && [ -n "$SLAVE_DEVICE" ]; then
[ -z "$SLAVE_MSN" ] && SLAVE_MSN="$MSN"
[ -z "$SLAVE_PHONE_OUT" ] && SLAVE_PHONE_OUT="$PHONE_OUT"
[ -z "$SLAVE_PHONE_IN" ] && SLAVE_PHONE_IN="$PHONE_IN"
[ -z "$SLAVE_HUPTIMEOUT" ] && SLAVE_HUPTIMEOUT="$HUPTIMEOUT"
[ -z "$SLAVE_CHARGEHUP" ] && SLAVE_CHARGEHUP="$CHARGEHUP"
[ -z "$SLAVE_CHARGEINT" ] && SLAVE_CHARGEINT="$CHARGEINT"
[ -z "$SLAVE_CBHUP" ] && SLAVE_CBHUP="$CBHUP"
[ -z "$SLAVE_IHUP" ] && SLAVE_IHUP="$IHUP"
[ -z "$SLAVE_DIALMAX" ] && SLAVE_DIALMAX="$DIALMAX"
[ -z "$SLAVE_CALLBACK" ] && SLAVE_CALLBACK="$CALLBACK"
[ -z "$SLAVE_CBDELAY" ] && SLAVE_CBDELAY="$CBDELAY"
if [ "$DIALIN" != "on" ] ; then
[ -z "$SLAVE_DIALMODE" ] && SLAVE_DIALMODE="auto"
else
# Master should not dial by default on incoming MPPP
[ -z "$SLAVE_DIALMODE" ] && SLAVE_DIALMODE="$DIALMODE"
fi
slave=$SLAVE_DEVICE
options="$options /dev/$slave +mp"
# Create slave and set options
log_isdnctrl addslave $DEVICE $slave
[ -z $SLAVE_MSN ] || log_isdnctrl eaz $slave $SLAVE_MSN
# set phone number
for i in $SLAVE_PHONE_OUT; do
log_isdnctrl addphone $slave out $COUNTRYCODE$PREFIX$AREACODE$i
done
for i in $SLAVE_PHONE_IN; do
log_isdnctrl addphone $slave in $i
done
# set layer-2/3 protocol
log_isdnctrl l2_prot $slave $L2_PROT
log_isdnctrl l3_prot $slave $L3_PROT
# set encapsulation
log_isdnctrl encap $slave $ENCAP
# set dial mode
log_isdnctrl dialmode $slave $SLAVE_DIALMODE
[ -n "$SECURE" ] && log_isdnctrl secure $slave $SECURE
[ -n "$SLAVE_HUPTIMEOUT" ] && log_isdnctrl huptimeout $slave $SLAVE_HUPTIMEOUT
[ -n "$SLAVE_CHARGEHUP" ] && log_isdnctrl chargehup $slave $SLAVE_CHARGEHUP
[ -n "$SLAVE_CHARGEINT" ] && log_isdnctrl chargeint $slave $SLAVE_CHARGEINT
[ -n "$SLAVE_IHUP" ] && log_isdnctrl ihup $slave $SLAVE_IHUP
[ -n "$SLAVE_DIALMAX" ] && log_isdnctrl dialmax $slave $SLAVE_DIALMAX
# set callback
[ -n "$SLAVE_CBHUP" ] && log_isdnctrl cbhup $slave $SLAVE_CBHUP
[ -n "$SLAVE_CALLBACK" ] || SLAVE_CALLBACK="off"
log_isdnctrl callback $slave $SLAVE_CALLBACK
[ -n "$SLAVE_CBDELAY" ] && log_isdnctrl cbdelay $DEVICE $SLAVE_CBDELAY
# options for master device
[ -n "$SLAVE_DELAY" ] && log_isdnctrl sdelay $DEVICE $SLAVE_DELAY
[ -n "$SLAVE_TRIGGER" ] && log_isdnctrl trigger $DEVICE $SLAVE_TRIGGER
fi
if [ "$GATEWAY" = "0.0.0.0" ]; then
if [ "$DIALIN" != "on" ]; then
options="$options ipcp-accept-remote"
fi
options="$IPADDR:$GATEWAY $options"
else
options="$options $IPADDR:$GATEWAY"
fi
# Van Jacobson style TCP/IP header compression and
# VJ connection-ID compression
[ "$VJ" = "off" ] && options="$options -vj"
[ "$VJCCOMP" = "off" ] && options="$options -vjccomp"
# Address/Control compression, protocol field compression,
[ "$AC" = "off" ] && options="$options -ac"
[ "$PC" = "off" ] && options="$options -pc"
# BSD-Compression scheme
if [ "$BSDCOMP" = "on" ] ; then
options="$options bsdcomp 9,9"
else
options="$options -bsdcomp"
fi
# Stac compression
if [ "$LZS" = "on" ] ; then
# supports LZS check mode 3 and 4
[ -n "$LZS_MODE" ] || LZS_MODE="4"
[ "$LZS_MODE" = "3" ] && options="$options lzs 1"
[ "$LZS_MODE" = "4" ] && options="$options lzs 1:4"
fi
# Set max receive and max transmit units
[ -n "$MRU" ] && options="$options mru $MRU"
[ -n "$MTU" ] && options="$options mtu $MTU"
# set CBCP protocoll
if [ "$CBCP" = "on" ] ; then
if [ -n "$CBCP_MSN" ] ; then
# User managed callback
options="$options callback $CBCP_MSN"
else
# admin managed callback, it's enabled by default
options="$options callback 6"
fi
else
# Disable CBCP
options="$options -callback-cbcp"
fi
# set CCP protocoll
[ "$CCP" = "off" ] && options="$options noccp"
# set host name
[ -n "$ISDN_HOSTNAME" ] && options="$options remotename $ISDN_HOSTNAME"
# Set authentication
for i in $AUTH ; do
options="$options $i"
done
# add ppp options
for i in $PPPOPTIONS ; do
options="$options $i"
done
# check dns entry
if [ -z "$DNS1" -a -z "$DNS2" ]; then
options="$options ms-get-dns"
else
[ -n "$DNS1" ] && options="$options ms-dns $DNS1"
[ -n "$DNS2" ] && options="$options ms-dns $DNS2"
fi
# set debug
[ "$DEBUG" = "yes" ] && options="-d $options"
# set netmask, if available
[ -n "$NETMASK" ] && {
val=$(ipcalc --prefix $IPADDR $NETMASK)
pfx=${val##PREFIX=}
}
# activate ISDN device
/usr/bin/logger -p daemon.info -t ifup-ippp "ip addr add $IPADDR peer $GATEWAY${pfx:/$pfx} dev $DEVICE"
ip addr add $IPADDR peer $GATEWAY${pfx:/$pfx} dev $DEVICE
ip link set dev $DEVICE up
if [ "$ENCAP" = "syncppp" ]; then
# start ipppd daemon
/usr/bin/logger -p daemon.info -t ifup-ippp "ipppd $options $netmask"
ipppd $options $netmask >/dev/null 2>&1
# start ibod daemon
if [ "$DIALIN" != "on" ]; then
[ "$BUNDLING" = "yes" -o "$BUNDLING" = "on" ] && [ -n "$SLAVE_DEVICE" ] && start_ibod $DEVICE
fi
fi
# set default gateway for dial on demand
if [ "$DIALMODE" = "auto" ] ; then
echo 1 > /proc/sys/net/ipv4/ip_dynaddr
if [ "$DEFROUTE" = "yes" ] ; then
if [ "$GATEWAY" = "0.0.0.0" ]; then
ip route replace default ${METRIC:+metric $METRIC} dev ${DEVICE} >/dev/null 2>&1
else
ip route replace default ${METRIC:+metric $METRIC} via ${GATEWAY} dev ${DEVICE} >/dev/null 2>&1
fi
fi
fi
# Setup IPv6
if [ "$IPV6INIT" = "yes" -a ! -z "$IPV6ADDR" ]; then
# Native IPv6 use of device configured, check of encapsulation required
if [ "$ENCAP" = "syncppp" ]; then
echo $"Warning: ipppd (kernel 2.4.x and below) doesn't support IPv6 using encapsulation 'syncppp'"
elif [ "$ENCAP" = "rawip" ]; then
echo $"Warning: link doesn't support IPv6 using encapsulation 'rawip'"
fi
fi
/etc/sysconfig/network-scripts/ifup-ipv6 $CONFIG
}
addprovider || exit 1
exit 0
|