2008-04-07 09:07:50 +08:00
|
|
|
find_gw() {
|
|
|
|
route -n | awk '$1 == "0.0.0.0" { print $2; exit }'
|
|
|
|
}
|
|
|
|
|
2010-05-02 01:55:41 +08:00
|
|
|
stop_interface_pptp() {
|
|
|
|
stop_interface_ppp "$1"
|
|
|
|
}
|
2008-04-07 09:07:50 +08:00
|
|
|
|
2010-05-07 03:51:27 +08:00
|
|
|
coldplug_interface_pptp() {
|
|
|
|
setup_interface_pptp "pptp-$1" "$1"
|
|
|
|
}
|
|
|
|
|
2006-09-24 02:01:51 +08:00
|
|
|
setup_interface_pptp() {
|
2006-07-30 11:09:09 +08:00
|
|
|
local config="$2"
|
2007-08-31 00:53:22 +08:00
|
|
|
local ifname
|
2010-05-07 03:51:27 +08:00
|
|
|
|
2006-07-30 11:09:09 +08:00
|
|
|
config_get device "$config" device
|
2007-08-28 00:37:37 +08:00
|
|
|
config_get ipproto "$config" ipproto
|
2009-03-15 20:08:31 +08:00
|
|
|
config_get server "$config" server
|
2006-07-30 11:09:09 +08:00
|
|
|
|
|
|
|
for module in slhc ppp_generic ppp_async ip_gre; do
|
|
|
|
/sbin/insmod $module 2>&- >&-
|
|
|
|
done
|
2007-08-31 00:53:22 +08:00
|
|
|
sleep 1
|
|
|
|
|
|
|
|
setup_interface "$device" "$config" "${ipproto:-dhcp}"
|
2008-04-07 09:07:50 +08:00
|
|
|
local gw="$(find_gw)"
|
|
|
|
[ -n "$gw" ] && {
|
2010-05-07 09:57:02 +08:00
|
|
|
[ "$gw" != 0.0.0.0 ] && route delete "$server" 2>/dev/null >/dev/null
|
2008-04-07 09:07:50 +08:00
|
|
|
route add "$server" gw "$gw"
|
|
|
|
}
|
2007-08-31 00:53:22 +08:00
|
|
|
|
|
|
|
# fix up the netmask
|
|
|
|
config_get netmask "$config" netmask
|
|
|
|
[ -z "$netmask" -o -z "$device" ] || ifconfig $device netmask $netmask
|
|
|
|
|
2009-03-15 21:40:11 +08:00
|
|
|
config_get mtu "$config" mtu
|
2006-07-30 11:09:09 +08:00
|
|
|
mtu=${mtu:-1452}
|
|
|
|
start_pppd "$config" \
|
2007-04-22 04:19:54 +08:00
|
|
|
pty "/usr/sbin/pptp $server --loglevel 0 --nolaunchpppd" \
|
|
|
|
file /etc/ppp/options.pptp \
|
2006-09-24 02:01:51 +08:00
|
|
|
mtu $mtu mru $mtu
|
2006-07-30 11:09:09 +08:00
|
|
|
}
|