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