mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-24 00:30:16 +02: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
This commit is contained in:
parent
eb2e6ba350
commit
ac5e3c8844
@ -15,6 +15,17 @@ boot() {
|
||||
rm -f /etc/config/wireless
|
||||
/sbin/wifi detect > /etc/config/wireless
|
||||
}
|
||||
|
||||
scan_interfaces
|
||||
|
||||
local ifc
|
||||
for ifc in $interfaces; do
|
||||
local proto
|
||||
config_get proto "$ifc" proto
|
||||
|
||||
type "coldplug_interface_$proto" >/dev/null && \
|
||||
coldplug_interface_$proto "$ifc"
|
||||
done
|
||||
}
|
||||
|
||||
start() {
|
||||
|
@ -66,6 +66,35 @@ add_vlan() {
|
||||
return 1
|
||||
}
|
||||
|
||||
# add dns entries if they are not in resolv.conf yet
|
||||
add_dns() {
|
||||
local cfg="$1"; shift
|
||||
|
||||
local dns
|
||||
local add
|
||||
for dns in "$@"; do
|
||||
grep -qsF "nameserver $dns" /tmp/resolv.conf.auto || {
|
||||
add="${add:+$add }$dns"
|
||||
echo "nameserver $dns" >> /tmp/resolv.conf.auto
|
||||
}
|
||||
done
|
||||
|
||||
uci_set_state network "$cfg" dns "$add"
|
||||
}
|
||||
|
||||
# remove dns entries of the given iface
|
||||
remove_dns() {
|
||||
local cfg="$1"
|
||||
|
||||
local dns
|
||||
config_get dns "$cfg" dns
|
||||
for dns in $dns; do
|
||||
sed -i -e "/^nameserver $dns$/d" /tmp/resolv.conf.auto
|
||||
done
|
||||
|
||||
uci_revert_state network "$cfg" dns
|
||||
}
|
||||
|
||||
# sort the device list, drop duplicates
|
||||
sort_list() {
|
||||
local arg="$*"
|
||||
@ -264,7 +293,6 @@ setup_interface() {
|
||||
}
|
||||
set_interface_ifname "$config" "$iface_main"
|
||||
|
||||
pidfile="/var/run/$iface_main.pid"
|
||||
[ -n "$proto" ] || config_get proto "$config" proto
|
||||
case "$proto" in
|
||||
static)
|
||||
@ -272,11 +300,14 @@ setup_interface() {
|
||||
setup_interface_static "$iface_main" "$config"
|
||||
;;
|
||||
dhcp)
|
||||
local lockfile="/var/lock/dhcp-$iface_main"
|
||||
lock "$lockfile"
|
||||
|
||||
# prevent udhcpc from starting more than once
|
||||
lock "/var/lock/dhcp-$iface_main"
|
||||
local pidfile="/var/run/dhcp-${iface_main}.pid"
|
||||
local pid="$(cat "$pidfile" 2>/dev/null)"
|
||||
if [ -d "/proc/$pid" ] && grep udhcpc "/proc/${pid}/cmdline" >/dev/null 2>/dev/null; then
|
||||
lock -u "/var/lock/dhcp-$iface_main"
|
||||
if [ -d "/proc/$pid" ] && grep -qs udhcpc "/proc/${pid}/cmdline"; then
|
||||
lock -u "$lockfile"
|
||||
else
|
||||
local ipaddr netmask hostname proto1 clientid
|
||||
config_get ipaddr "$config" ipaddr
|
||||
@ -292,7 +323,7 @@ setup_interface() {
|
||||
local dhcpopts
|
||||
[ ."$proto1" != ."$proto" ] && dhcpopts="-n -q"
|
||||
$DEBUG eval udhcpc -t 0 -i "$iface_main" ${ipaddr:+-r $ipaddr} ${hostname:+-H $hostname} ${clientid:+-c $clientid} -b -p "$pidfile" ${dhcpopts:- -O rootpath -R &}
|
||||
lock -u "/var/lock/dhcp-$iface_main"
|
||||
lock -u "$lockfile"
|
||||
fi
|
||||
;;
|
||||
none)
|
||||
@ -329,6 +360,21 @@ setup_interface() {
|
||||
|
||||
stop_interface_dhcp() {
|
||||
local config="$1"
|
||||
|
||||
local iface
|
||||
config_get ifname "$config" ifname
|
||||
|
||||
local lock="/var/lock/dhcp-${ifname}"
|
||||
[ -f "$lock" ] && lock -u "$lock"
|
||||
|
||||
local pidfile="/var/run/dhcp-${ifname}.pid"
|
||||
local pid="$(cat "$pidfile" 2>/dev/null)"
|
||||
[ -d "/proc/$pid" ] && {
|
||||
grep -qs udhcpc "/proc/$pid/cmdline" && kill -TERM $pid && \
|
||||
while grep -qs udhcpc "/proc/$pid/cmdline"; do sleep 1; done
|
||||
rm -f "$pidfile"
|
||||
}
|
||||
|
||||
uci -P /var/state revert "network.$config"
|
||||
}
|
||||
|
||||
|
@ -29,28 +29,6 @@ config_get iface "$cfg" device
|
||||
# call interface stop handler
|
||||
( type "stop_interface_$proto" ) >/dev/null 2>/dev/null && eval "stop_interface_$proto '$cfg'"
|
||||
|
||||
# make sure all locks are removed
|
||||
for lock in "/var/lock/dhcp-$iface" "/var/lock/ppp-$iface"; do
|
||||
[ -f "$lock" ] && {
|
||||
lock -u "$lock"
|
||||
sleep 1
|
||||
}
|
||||
done
|
||||
|
||||
# kill active ppp daemon and other processes
|
||||
config_get ifname "$cfg" ifname
|
||||
pids="$(head -n1 -q /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid 2>/dev/null)"
|
||||
for pid in $pids; do
|
||||
[ -d "/proc/$pid" ] && {
|
||||
kill $pid
|
||||
[ -d "/proc/$pid" ] && {
|
||||
sleep 1
|
||||
kill -9 $pid 2>/dev/null >/dev/null
|
||||
}
|
||||
}
|
||||
done
|
||||
rm -f /var/run/${ifname}.pid /var/run/ppp-${cfg}.pid
|
||||
|
||||
config_get ifname "$cfg" ifname
|
||||
config_get device "$cfg" device
|
||||
|
||||
|
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=comgt
|
||||
PKG_VERSION:=0.32
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz
|
||||
PKG_SOURCE_URL:=@SF/comgt
|
||||
|
@ -9,8 +9,6 @@ set_3g_led() {
|
||||
|
||||
scan_3g() {
|
||||
local device
|
||||
|
||||
scan_ppp "$@"
|
||||
config_get device "$1" device
|
||||
|
||||
# try to figure out the device if it's invalid
|
||||
@ -24,6 +22,7 @@ scan_3g() {
|
||||
}
|
||||
|
||||
# enable 3G with the 3G button by default
|
||||
local button
|
||||
config_get button "$1" button
|
||||
[ -z "$button" ] && {
|
||||
config_set "$1" button 1
|
||||
@ -31,6 +30,7 @@ scan_3g() {
|
||||
}
|
||||
|
||||
stop_interface_3g() {
|
||||
stop_interface_ppp "$1"
|
||||
set_3g_led 0 0 0
|
||||
killall gcom >/dev/null 2>/dev/null
|
||||
}
|
||||
@ -39,8 +39,11 @@ setup_interface_3g() {
|
||||
local iface="$1"
|
||||
local config="$2"
|
||||
local chat="/etc/chatscripts/3g.chat"
|
||||
|
||||
|
||||
local device
|
||||
config_get device "$config" device
|
||||
|
||||
local maxwait
|
||||
config_get maxwait "$config" maxwait
|
||||
maxwait=${maxwait:-20}
|
||||
while [ ! -e "$device" -a $maxwait -gt 0 ];do # wait for driver loading to catch up
|
||||
@ -52,9 +55,16 @@ setup_interface_3g() {
|
||||
/sbin/insmod $module 2>&- >&-
|
||||
done
|
||||
|
||||
local apn
|
||||
config_get apn "$config" apn
|
||||
|
||||
local service
|
||||
config_get service "$config" service
|
||||
|
||||
local pincode
|
||||
config_get pincode "$config" pincode
|
||||
|
||||
local mtu
|
||||
config_get mtu "$config" mtu
|
||||
|
||||
set_3g_led 1 0 1
|
||||
@ -80,7 +90,7 @@ setup_interface_3g() {
|
||||
mode="AT_OPSYS=${CODE}"
|
||||
fi
|
||||
# Don't assume Option to be default as it breaks with Huawei Cards/Sticks
|
||||
|
||||
|
||||
PINCODE="$pincode" gcom -d "$device" -s /etc/gcom/setpin.gcom || {
|
||||
echo "$config(3g): Failed to set the PIN code."
|
||||
set_3g_led 0 0 0
|
||||
|
@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=ppp
|
||||
PKG_VERSION:=2.4.4
|
||||
PKG_RELEASE:=6
|
||||
PKG_RELEASE:=7
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=ftp://ftp.samba.org/pub/ppp/
|
||||
@ -140,7 +140,7 @@ define Package/ppp/install
|
||||
$(INSTALL_BIN) ./files/etc/ppp/ipv6-up $(1)/etc/ppp/
|
||||
$(INSTALL_BIN) ./files/etc/ppp/ipv6-down $(1)/etc/ppp/
|
||||
$(INSTALL_DATA) ./files/etc/ppp/options $(1)/etc/ppp/
|
||||
ln -sf /tmp/resolv.conf.auto $(1)/etc/ppp/resolv.conf
|
||||
ln -sf /tmp/resolv.conf.ppp $(1)/etc/ppp/resolv.conf
|
||||
endef
|
||||
|
||||
define Package/ppp-mod-pppoa/install
|
||||
@ -149,6 +149,8 @@ define Package/ppp-mod-pppoa/install
|
||||
$(1)/usr/lib/pppd/$(PKG_VERSION)/
|
||||
$(INSTALL_DIR) $(1)/lib/network
|
||||
$(INSTALL_BIN) ./files/pppoa.sh $(1)/lib/network/
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/atm
|
||||
$(INSTALL_DATA) ./files/etc/hotplug.d/atm/20-atm-modem $(1)/etc/hotplug.d/atm/
|
||||
endef
|
||||
|
||||
define Package/ppp-mod-pppoe/install
|
||||
|
25
package/ppp/files/etc/hotplug.d/atm/20-atm-modem
Normal file
25
package/ppp/files/etc/hotplug.d/atm/20-atm-modem
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$ACTION" = "add" ]; then
|
||||
include /lib/network
|
||||
scan_interfaces
|
||||
|
||||
local found=0
|
||||
local ifc
|
||||
for ifc in $interfaces; do
|
||||
local up
|
||||
config_get_bool up "$ifc" up 0
|
||||
|
||||
local proto
|
||||
config_get proto "$ifc" proto
|
||||
|
||||
if [ "$proto" = "pppoa" ] && [ "$up" != 1 ]; then
|
||||
found=1
|
||||
( sleep 1; ifup "$ifc" ) &
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$found" != 1 ]; then
|
||||
logger "Found no matching interface for DSL device $DEVICENAME"
|
||||
fi
|
||||
fi
|
@ -1,22 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /etc/functions.sh
|
||||
. /lib/network/config.sh
|
||||
|
||||
PPP_IFACE="$1"
|
||||
PPP_TTY="$2"
|
||||
PPP_SPEED="$3"
|
||||
PPP_LOCAL="$4"
|
||||
PPP_REMOTE="$5"
|
||||
PPP_IPPARAM="$(echo $6 | sed 's/\./_/g')"
|
||||
PPP_UNIT="${PPP_IFACE##ppp}"
|
||||
|
||||
export PPP_IFACE PPP_TTY PPP_SPEED PPP_LOCAL PPP_REMOTE PPP_IPPARAM
|
||||
[ -z "$PPP_IPPARAM" -o -z "$PPP_LOCAL" ] || {
|
||||
uci_set_state network "$PPP_IPPARAM" unit "$PPP_UNIT"
|
||||
uci_set_state network "$PPP_IPPARAM" ifname "$PPP_IFACE"
|
||||
uci_set_state network "$PPP_IPPARAM" ipaddr "$PPP_LOCAL"
|
||||
uci_set_state network "$PPP_IPPARAM" gateway "$PPP_REMOTE"
|
||||
|
||||
local dns="$DNS1${DNS2:+ $DNS2}"
|
||||
[ -n "$dns" ] && uci_set_state network "$PPP_IPPARAM" dns "$dns"
|
||||
[ -n "$dns" ] && add_dns "$PPP_IPPARAM" $dns
|
||||
}
|
||||
|
||||
[ -z "$PPP_IPPARAM" ] || env -i ACTION="ifup" INTERFACE="$PPP_IPPARAM" DEVICE="$PPP_IFACE" PROTO=ppp /sbin/hotplug-call "iface"
|
||||
|
||||
[ -d /etc/ppp/ip-up.d ] && {
|
||||
|
@ -1,63 +1,40 @@
|
||||
scan_ppp() {
|
||||
config_get ifname "$1" ifname
|
||||
pppdev="${pppdev:-0}"
|
||||
config_get devunit "$1" unit
|
||||
{
|
||||
unit=
|
||||
pppif=
|
||||
if [ ! -d /tmp/.ppp-counter ]; then
|
||||
mkdir -p /tmp/.ppp-counter
|
||||
fi
|
||||
local maxunit
|
||||
maxunit="$(cat /tmp/.ppp-counter/max-unit 2>/dev/null)"
|
||||
if [ -z "$maxunit" ]; then
|
||||
maxunit=-1
|
||||
fi
|
||||
local i
|
||||
i=0
|
||||
while [ $i -le $maxunit ]; do
|
||||
local unitdev
|
||||
unitdev="$(cat /tmp/.ppp-counter/ppp${i} 2>/dev/null)"
|
||||
if [ "$unitdev" = "$1" ]; then
|
||||
unit="$i"
|
||||
pppif="ppp${i}"
|
||||
break
|
||||
fi
|
||||
i="$(($i + 1))"
|
||||
done
|
||||
if [ -z "$unit" ] || [ -z "$pppif" ]; then
|
||||
maxunit="$(($maxunit + 1))"
|
||||
if [ -n "$devunit" ]; then
|
||||
unit="$devunit"
|
||||
elif [ "${ifname%%[0-9]*}" = ppp ]; then
|
||||
unit="${ifname##ppp}"
|
||||
else
|
||||
unit="$maxunit"
|
||||
fi
|
||||
[ "$maxunit" -lt "$unit" ] && maxunit="$unit"
|
||||
pppif="ppp${unit}"
|
||||
echo "$1" >/tmp/.ppp-counter/$pppif 2>/dev/null
|
||||
echo "$maxunit" >/tmp/.ppp-counter/max-unit 2>/dev/null
|
||||
fi
|
||||
config_set "$1" ifname "ppp$unit"
|
||||
config_set "$1" unit "$unit"
|
||||
stop_interface_ppp() {
|
||||
local cfg="$1"
|
||||
|
||||
local proto
|
||||
config_get proto "$cfg" proto
|
||||
|
||||
local link="$proto-$cfg"
|
||||
[ -f "/var/run/ppp-${link}.pid" ] && {
|
||||
local pid="$(head -n1 /var/run/ppp-${link}.pid 2>/dev/null)"
|
||||
local try=0
|
||||
grep -qs pppd "/proc/$pid/cmdline" && kill -TERM $pid && \
|
||||
while grep -qs pppd "/proc/$pid/cmdline" && [ $((try++)) -lt 5 ]; do sleep 1; done
|
||||
grep -qs pppd "/proc/$pid/cmdline" && kill -KILL $pid && \
|
||||
while grep -qs pppd "/proc/$pid/cmdline"; do sleep 1; done
|
||||
rm -f "/var/run/ppp-${link}.pid"
|
||||
}
|
||||
|
||||
remove_dns "$cfg"
|
||||
|
||||
local lock="/var/lock/ppp-$link"
|
||||
[ -f "$lock" ] && lock -u "$lock"
|
||||
}
|
||||
|
||||
start_pppd() {
|
||||
local cfg="$1"; shift
|
||||
local ifname
|
||||
|
||||
# make sure the network state references the correct ifname
|
||||
scan_ppp "$cfg"
|
||||
config_get ifname "$cfg" ifname
|
||||
set_interface_ifname "$cfg" "$ifname"
|
||||
local proto
|
||||
config_get proto "$cfg" proto
|
||||
|
||||
# unique link identifier
|
||||
local link="${proto:-ppp}-$cfg"
|
||||
|
||||
# make sure only one pppd process is started
|
||||
lock "/var/lock/ppp-${cfg}"
|
||||
local pid="$(head -n1 /var/run/ppp-${cfg}.pid 2>/dev/null)"
|
||||
lock "/var/lock/ppp-${link}"
|
||||
local pid="$(head -n1 /var/run/ppp-${link}.pid 2>/dev/null)"
|
||||
[ -d "/proc/$pid" ] && grep pppd "/proc/$pid/cmdline" 2>/dev/null >/dev/null && {
|
||||
lock -u "/var/lock/ppp-${cfg}"
|
||||
lock -u "/var/lock/ppp-${link}"
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -68,9 +45,6 @@ start_pppd() {
|
||||
local device
|
||||
config_get device "$cfg" device
|
||||
|
||||
local unit
|
||||
config_get unit "$cfg" unit
|
||||
|
||||
local username
|
||||
config_get username "$cfg" username
|
||||
|
||||
@ -91,7 +65,8 @@ start_pppd() {
|
||||
|
||||
local defaultroute
|
||||
config_get_bool defaultroute "$cfg" defaultroute 1
|
||||
[ "$defaultroute" -eq 1 ] && defaultroute="defaultroute replacedefaultroute" || defaultroute=""
|
||||
[ "$defaultroute" -eq 1 ] && \
|
||||
defaultroute="defaultroute replacedefaultroute" || defaultroute="nodefaultroute"
|
||||
|
||||
local interval="${keepalive##*[, ]}"
|
||||
[ "$interval" != "$keepalive" ] || interval=5
|
||||
@ -109,15 +84,11 @@ start_pppd() {
|
||||
local peerdns
|
||||
config_get_bool peerdns "$cfg" peerdns $peer_default
|
||||
|
||||
echo -n "" > /tmp/resolv.conf.auto
|
||||
|
||||
[ "$peerdns" -eq 1 ] && {
|
||||
peerdns="usepeerdns"
|
||||
} || {
|
||||
peerdns=""
|
||||
for dns in $dns; do
|
||||
echo "nameserver $dns" >> /tmp/resolv.conf.auto
|
||||
done
|
||||
add_dns "$cfg" $dns
|
||||
}
|
||||
|
||||
local demand
|
||||
@ -126,8 +97,7 @@ start_pppd() {
|
||||
local demandargs
|
||||
[ "$demand" -eq 1 ] && {
|
||||
demandargs="precompiled-active-filter /etc/ppp/filter demand idle"
|
||||
[ "$has_dns" -eq 0 ] && \
|
||||
echo "nameserver 1.1.1.1" > /tmp/resolv.conf.auto
|
||||
[ "$has_dns" -eq 0 ] && add_dns "$cfg" 1.1.1.1
|
||||
} || {
|
||||
demandargs="persist"
|
||||
}
|
||||
@ -136,21 +106,21 @@ start_pppd() {
|
||||
config_get_bool ipv6 "$cfg" ipv6 0
|
||||
[ "$ipv6" -eq 1 ] && ipv6="+ipv6" || ipv6=""
|
||||
|
||||
/usr/sbin/pppd "$@" \
|
||||
start-stop-daemon -S -b -x /usr/sbin/pppd -m -p /var/run/ppp-$link.pid -- "$@" \
|
||||
${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
|
||||
$demandargs \
|
||||
$peerdns \
|
||||
$defaultroute \
|
||||
${username:+user "$username" password "$password"} \
|
||||
unit "$unit" \
|
||||
linkname "$cfg" \
|
||||
ipparam "$cfg" \
|
||||
ifname "$link" \
|
||||
${connect:+connect "$connect"} \
|
||||
${disconnect:+disconnect "$disconnect"} \
|
||||
${ipv6} \
|
||||
${pppd_options}
|
||||
${pppd_options} \
|
||||
nodetach
|
||||
|
||||
lock -u "/var/lock/ppp-${cfg}"
|
||||
lock -u "/var/lock/ppp-${link}"
|
||||
}
|
||||
|
||||
setup_interface_ppp() {
|
||||
|
@ -1,28 +1,37 @@
|
||||
scan_pppoa() {
|
||||
scan_ppp "$@"
|
||||
stop_interface_pppoa() {
|
||||
stop_interface_ppp "$1"
|
||||
}
|
||||
|
||||
setup_interface_pppoa() {
|
||||
local iface="$1"
|
||||
local config="$2"
|
||||
|
||||
|
||||
local device
|
||||
config_get device "$config" device
|
||||
|
||||
local vpi
|
||||
config_get vpi "$config" vpi
|
||||
|
||||
local vci
|
||||
config_get vci "$config" vci
|
||||
|
||||
for module in slhc ppp_generic pppoatm; do
|
||||
/sbin/insmod $module 2>&- >&-
|
||||
done
|
||||
|
||||
|
||||
local encaps
|
||||
config_get encaps "$config" encaps
|
||||
|
||||
case "$encaps" in
|
||||
1|vc) ENCAPS="vc-encaps" ;;
|
||||
*) ENCAPS="llc-encaps" ;;
|
||||
1|vc) encaps="vc-encaps" ;;
|
||||
*) encaps="llc-encaps" ;;
|
||||
esac
|
||||
|
||||
local mtu
|
||||
config_get mtu "$config" mtu
|
||||
mtu=${mtu:-1500}
|
||||
|
||||
start_pppd "$config" \
|
||||
plugin pppoatm.so ${vpi:-8}.${vci:-35} ${ENCAPS} \
|
||||
plugin pppoatm.so ${vpi:-8}.${vci:-35} ${encaps} \
|
||||
mtu $mtu mru $mtu
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
scan_pppoe() {
|
||||
scan_ppp "$@"
|
||||
stop_interface_pppoe() {
|
||||
stop_interface_ppp "$1"
|
||||
}
|
||||
|
||||
setup_interface_pppoe() {
|
||||
|
128
package/ppp/patches/320-custom_iface_names.patch
Normal file
128
package/ppp/patches/320-custom_iface_names.patch
Normal file
@ -0,0 +1,128 @@
|
||||
--- a/pppd/main.c
|
||||
+++ b/pppd/main.c
|
||||
@@ -742,8 +742,11 @@ void
|
||||
set_ifunit(iskey)
|
||||
int iskey;
|
||||
{
|
||||
- info("Using interface %s%d", PPP_DRV_NAME, ifunit);
|
||||
- slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
|
||||
+ if (use_ifname[0] == 0)
|
||||
+ slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
|
||||
+ else
|
||||
+ slprintf(ifname, sizeof(ifname), "%s", use_ifname);
|
||||
+ info("Using interface %s", ifname);
|
||||
script_setenv("IFNAME", ifname, iskey);
|
||||
if (iskey) {
|
||||
create_pidfile(getpid()); /* write pid to file */
|
||||
--- a/pppd/options.c
|
||||
+++ b/pppd/options.c
|
||||
@@ -111,6 +111,7 @@ int log_to_fd = 1; /* send log messages
|
||||
bool log_default = 1; /* log_to_fd is default (stdout) */
|
||||
int maxfail = 10; /* max # of unsuccessful connection attempts */
|
||||
char linkname[MAXPATHLEN]; /* logical name for link */
|
||||
+char use_ifname[IFNAMSIZ]; /* physical name for PPP link */
|
||||
bool tune_kernel; /* may alter kernel settings */
|
||||
int connect_delay = 1000; /* wait this many ms after connect script */
|
||||
int req_unit = -1; /* requested interface unit */
|
||||
@@ -264,6 +265,9 @@ option_t general_options[] = {
|
||||
{ "linkname", o_string, linkname,
|
||||
"Set logical name for link",
|
||||
OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXPATHLEN },
|
||||
+ { "ifname", o_string, use_ifname,
|
||||
+ "Set physical name for PPP interface",
|
||||
+ OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, IFNAMSIZ },
|
||||
|
||||
{ "maxfail", o_int, &maxfail,
|
||||
"Maximum number of unsuccessful connection attempts to allow",
|
||||
--- a/pppd/pppd.h
|
||||
+++ b/pppd/pppd.h
|
||||
@@ -71,6 +71,10 @@
|
||||
#include "eui64.h"
|
||||
#endif
|
||||
|
||||
+#ifndef IFNAMSIZ
|
||||
+#define IFNAMSIZ 16
|
||||
+#endif
|
||||
+
|
||||
/*
|
||||
* Limits.
|
||||
*/
|
||||
@@ -308,6 +312,7 @@ extern char *record_file; /* File to rec
|
||||
extern bool sync_serial; /* Device is synchronous serial device */
|
||||
extern int maxfail; /* Max # of unsuccessful connection attempts */
|
||||
extern char linkname[MAXPATHLEN]; /* logical name for link */
|
||||
+extern char use_ifname[IFNAMSIZ]; /* physical name for PPP interface */
|
||||
extern bool tune_kernel; /* May alter kernel settings as necessary */
|
||||
extern int connect_delay; /* Time to delay after connect script */
|
||||
extern int max_data_rate; /* max bytes/sec through charshunt */
|
||||
--- a/pppd/sys-linux.c
|
||||
+++ b/pppd/sys-linux.c
|
||||
@@ -168,6 +168,10 @@ struct in6_ifreq {
|
||||
/* We can get an EIO error on an ioctl if the modem has hung up */
|
||||
#define ok_error(num) ((num)==EIO)
|
||||
|
||||
+#if !defined(PPP_DRV_NAME)
|
||||
+#define PPP_DRV_NAME "ppp"
|
||||
+#endif /* !defined(PPP_DRV_NAME) */
|
||||
+
|
||||
static int tty_disc = N_TTY; /* The TTY discipline */
|
||||
static int ppp_disc = N_PPP; /* The PPP discpline */
|
||||
static int initfdflags = -1; /* Initial file descriptor flags for fd */
|
||||
@@ -622,7 +626,8 @@ void generic_disestablish_ppp(int dev_fd
|
||||
*/
|
||||
static int make_ppp_unit()
|
||||
{
|
||||
- int x, flags;
|
||||
+ struct ifreq ifr;
|
||||
+ int x, flags, s;
|
||||
|
||||
if (ppp_dev_fd >= 0) {
|
||||
dbglog("in make_ppp_unit, already had /dev/ppp open?");
|
||||
@@ -645,6 +650,32 @@ static int make_ppp_unit()
|
||||
}
|
||||
if (x < 0)
|
||||
error("Couldn't create new ppp unit: %m");
|
||||
+
|
||||
+ if (use_ifname[0] != 0) {
|
||||
+ s = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
+ if (s < 0)
|
||||
+ s = socket(PF_PACKET, SOCK_DGRAM, 0);
|
||||
+ if (s < 0)
|
||||
+ s = socket(PF_INET6, SOCK_DGRAM, 0);
|
||||
+ if (s < 0)
|
||||
+ s = socket(PF_UNIX, SOCK_DGRAM, 0);
|
||||
+ if (s >= 0) {
|
||||
+ slprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s%d", PPP_DRV_NAME, ifunit);
|
||||
+ slprintf(ifr.ifr_newname, sizeof(ifr.ifr_newname), "%s", use_ifname);
|
||||
+ x = ioctl(s, SIOCSIFNAME, &ifr);
|
||||
+ close(s);
|
||||
+ } else {
|
||||
+ x = s;
|
||||
+ }
|
||||
+ if (x < 0) {
|
||||
+ error("Couldn't rename %s to %s", ifr.ifr_name, ifr.ifr_newname);
|
||||
+ close(ppp_dev_fd);
|
||||
+ ppp_dev_fd = -1;
|
||||
+ } else {
|
||||
+ info("Renamed %s to %s", ifr.ifr_name, ifr.ifr_newname);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
return x;
|
||||
}
|
||||
|
||||
--- a/pppstats/pppstats.c
|
||||
+++ b/pppstats/pppstats.c
|
||||
@@ -506,10 +506,12 @@ main(argc, argv)
|
||||
if (argc > 0)
|
||||
interface = argv[0];
|
||||
|
||||
+/*
|
||||
if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
|
||||
fprintf(stderr, "%s: invalid interface '%s' specified\n",
|
||||
progname, interface);
|
||||
}
|
||||
+*/
|
||||
|
||||
#ifndef STREAMS
|
||||
{
|
@ -8,12 +8,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=pptp
|
||||
PKG_VERSION:=1.6.0
|
||||
PKG_RELEASE:=6
|
||||
PKG_VERSION:=1.7.1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=@SF/pptpclient
|
||||
PKG_MD5SUM:=9a706327fb9827541d7c86d48ceb9631
|
||||
PKG_MD5SUM:=b47735ba5d6d37dfdbccb85afc044ede
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
@ -1,33 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
START=41
|
||||
STOP=30
|
||||
|
||||
updown_pptp_interface () {
|
||||
config_get proto "$1" proto
|
||||
if [ "$proto" = "pptp" ]; then
|
||||
if$2 "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
boot () {
|
||||
start
|
||||
}
|
||||
|
||||
start() {
|
||||
config_load network
|
||||
config_foreach updown_pptp_interface interface up
|
||||
}
|
||||
|
||||
restart() {
|
||||
config_load network
|
||||
config_foreach updown_pptp_interface interface down
|
||||
config_foreach updown_pptp_interface interface up
|
||||
}
|
||||
|
||||
stop() {
|
||||
config_load network
|
||||
config_foreach updown_pptp_interface interface down
|
||||
}
|
||||
|
@ -1,20 +1,32 @@
|
||||
scan_pptp() {
|
||||
scan_ppp "$@"
|
||||
}
|
||||
|
||||
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
|
||||
@ -23,7 +35,7 @@ setup_interface_pptp() {
|
||||
setup_interface "$device" "$config" "${ipproto:-dhcp}"
|
||||
local gw="$(find_gw)"
|
||||
[ -n "$gw" ] && {
|
||||
route delete "$server" 2>/dev/null >/dev/null
|
||||
[ "$gw" != 0.0.0.0 ] && route delete "$server" 2>/dev/null >/dev/null
|
||||
route add "$server" gw "$gw"
|
||||
}
|
||||
|
||||
@ -31,15 +43,10 @@ setup_interface_pptp() {
|
||||
config_get netmask "$config" netmask
|
||||
[ -z "$netmask" -o -z "$device" ] || ifconfig $device netmask $netmask
|
||||
|
||||
# make sure the network state references the correct ifname
|
||||
scan_ppp "$config"
|
||||
config_get ifname "$config" ifname
|
||||
uci_set_state network "$config" ifname "$ifname"
|
||||
|
||||
config_get mtu "$config" mtu
|
||||
mtu=${mtu:-1452}
|
||||
start_pppd "$config" \
|
||||
pty "/usr/sbin/pptp $server --loglevel 0 --nolaunchpppd" \
|
||||
pty "/usr/sbin/pptp $server --loglevel 0 --nolaunchpppd $buffering" \
|
||||
file /etc/ppp/options.pptp \
|
||||
mtu $mtu mru $mtu
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user