[package] pptp:
[openwrt/svn-archive/archive.git] / package / pptp / files / pptp.sh
1 find_gw() {
2 route -n | awk '$1 == "0.0.0.0" { print $2; exit }'
3 }
4
5 stop_interface_pptp() {
6 stop_interface_ppp "$1"
7 }
8
9 setup_interface_pptp() {
10 local config="$2"
11 local ifname
12
13 config_get device "$config" device
14 config_get ipproto "$config" ipproto
15 config_get server "$config" server
16
17 for module in slhc ppp_generic ppp_async ip_gre; do
18 /sbin/insmod $module 2>&- >&-
19 done
20 sleep 1
21
22 setup_interface "$device" "$config" "${ipproto:-dhcp}"
23 local gw="$(find_gw)"
24 [ -n "$gw" ] && {
25 route delete "$server" 2>/dev/null >/dev/null
26 route add "$server" gw "$gw"
27 }
28
29 # fix up the netmask
30 config_get netmask "$config" netmask
31 [ -z "$netmask" -o -z "$device" ] || ifconfig $device netmask $netmask
32
33 config_get mtu "$config" mtu
34 mtu=${mtu:-1452}
35 start_pppd "$config" \
36 pty "/usr/sbin/pptp $server --loglevel 0 --nolaunchpppd" \
37 file /etc/ppp/options.pptp \
38 mtu $mtu mru $mtu
39 }