1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-24 07:42:48 +02:00
openwrt-xburst/package/pptp/files/pptp.sh
jow ac5e3c8844 [backfire] merge ppp, pppoe, pptp and 3g fixes
r21283, r21284, r21285, r21287, r21302, r21303, r21341,
r21361, r21379, r21383, r21386, r21387, r21388, r21389,
r21390, r21391, r21392, r21393, r21426, r21556, r21563


git-svn-id: svn://svn.openwrt.org/openwrt/branches/backfire@21564 3c298f89-4303-0410-b956-a3cf2f4a3e73
2010-05-24 17:06:58 +00:00

53 lines
1.1 KiB
Bash

find_gw() {
route -n | awk '$1 == "0.0.0.0" { print $2; exit }'
}
stop_interface_pptp() {
stop_interface_ppp "$1"
}
coldplug_interface_pptp() {
setup_interface_pptp "pptp-$1" "$1"
}
setup_interface_pptp() {
local config="$2"
local ifname
local device
config_get device "$config" device
local ipproto
config_get ipproto "$config" ipproto
local server
config_get server "$config" server
local buffering
config_get_bool buffering "$config" buffering 1
[ "$buffering" == 0 ] && buffering="--nobuffer" || buffering=
for module in slhc ppp_generic ppp_async ip_gre; do
/sbin/insmod $module 2>&- >&-
done
sleep 1
setup_interface "$device" "$config" "${ipproto:-dhcp}"
local gw="$(find_gw)"
[ -n "$gw" ] && {
[ "$gw" != 0.0.0.0 ] && route delete "$server" 2>/dev/null >/dev/null
route add "$server" gw "$gw"
}
# fix up the netmask
config_get netmask "$config" netmask
[ -z "$netmask" -o -z "$device" ] || ifconfig $device netmask $netmask
config_get mtu "$config" mtu
mtu=${mtu:-1452}
start_pppd "$config" \
pty "/usr/sbin/pptp $server --loglevel 0 --nolaunchpppd $buffering" \
file /etc/ppp/options.pptp \
mtu $mtu mru $mtu
}