Lines 16-23
Link Here
|
16 |
# Returns 1 if pppd is installed, otherwise 0 |
16 |
# Returns 1 if pppd is installed, otherwise 0 |
17 |
pppd_check_installed() { |
17 |
pppd_check_installed() { |
18 |
if [[ ! -x /usr/sbin/pppd ]]; then |
18 |
if [[ ! -x /usr/sbin/pppd ]]; then |
19 |
${1:-false} && eerror "For PPP support, emerge net-dialup/ppp" |
19 |
${1:-false} && eerror "For PPP support, emerge net-dialup/ppp" |
20 |
return 1 |
20 |
return 1 |
21 |
fi |
21 |
fi |
22 |
return 0 |
22 |
return 0 |
23 |
} |
23 |
} |
Lines 101-106
Link Here
|
101 |
# |
101 |
# |
102 |
# Returns 0 (true) when successful, otherwise 1 |
102 |
# Returns 0 (true) when successful, otherwise 1 |
103 |
pppd_start() { |
103 |
pppd_start() { |
|
|
104 |
${IN_BACKGROUND} && return 0 |
105 |
|
104 |
local iface="$1" ifvar=$( bash_variable "$1" ) opts="" link |
106 |
local iface="$1" ifvar=$( bash_variable "$1" ) opts="" link |
105 |
if [[ ${iface%%[0-9]*} != "ppp" ]]; then |
107 |
if [[ ${iface%%[0-9]*} != "ppp" ]]; then |
106 |
eerror "PPP can only be invoked from net.ppp[0-9]" |
108 |
eerror "PPP can only be invoked from net.ppp[0-9]" |
Lines 114-121
Link Here
|
114 |
fi |
116 |
fi |
115 |
|
117 |
|
116 |
# PPP requires a link to communicate over - normally a serial port |
118 |
# PPP requires a link to communicate over - normally a serial port |
117 |
# PPPoE communicates over ethernet |
119 |
# PPPoE communicates over Ethernet |
118 |
# PPPoA communictes over ATM |
120 |
# PPPoA communicates over ATM |
119 |
# In all cases, the link needs to be available before we start PPP |
121 |
# In all cases, the link needs to be available before we start PPP |
120 |
eval link=\"\$\{link_${ifvar}\}\" |
122 |
eval link=\"\$\{link_${ifvar}\}\" |
121 |
if [[ -z ${link} ]]; then |
123 |
if [[ -z ${link} ]]; then |
Lines 142-149
Link Here
|
142 |
# Load any commandline options |
144 |
# Load any commandline options |
143 |
eval opts=\"\$\{pppd_${ifvar}\[@\]}\" |
145 |
eval opts=\"\$\{pppd_${ifvar}\[@\]}\" |
144 |
|
146 |
|
145 |
# We don't work if unit, no detach or linkname is set. |
147 |
# We don't work with these options set by the user |
146 |
for i in unit nodetach linkname ; do |
148 |
for i in unit nodetach linkname maxfail persist ; do |
147 |
if [[ " ${opts} " == *" ${i} "* ]]; then |
149 |
if [[ " ${opts} " == *" ${i} "* ]]; then |
148 |
eerror "The option \"${i}\" is not allowed" |
150 |
eerror "The option \"${i}\" is not allowed" |
149 |
return 1 |
151 |
return 1 |
Lines 215-239
Link Here
|
215 |
#Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi) |
217 |
#Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi) |
216 |
local insert_link_in_opts=1 |
218 |
local insert_link_in_opts=1 |
217 |
if [[ " ${opts} " == *" plugin rp-pppoe.so "* ]]; then |
219 |
if [[ " ${opts} " == *" plugin rp-pppoe.so "* ]]; then |
|
|
220 |
if [[ ! -e /proc/net/pppoe ]]; then |
221 |
# Load the pppoe kernel module |
222 |
if ! modprobe pppoe 2>/dev/null ; then |
223 |
eerror "Your kernel does not support pppoe" |
224 |
return 1 |
225 |
fi |
226 |
fi |
227 |
|
218 |
# Ensure that the link exists and is up |
228 |
# Ensure that the link exists and is up |
219 |
interface_exists "${link}" true || return 1 |
229 |
interface_exists "${link}" true || return 1 |
220 |
interface_up "${link}" |
230 |
interface_up "${link}" |
221 |
|
231 |
|
222 |
# Load the pppoe kernel module - if this fails, we have to hope |
232 |
insert_link_in_opts=0 |
223 |
# that pppoe support is compiled into the kernel |
233 |
fi |
224 |
modprobe pppoe 2>/dev/null |
|
|
225 |
|
234 |
|
226 |
insert_link_in_opts=0 |
235 |
if [[ " ${opts} " == *" plugin pppoatm.so "* ]]; then |
|
|
236 |
# Load the kernell pppoa module |
237 |
# AFAIK there is no way of knowing if pppoatm is available via /proc :/ |
238 |
modprobe pppoatm 2>/dev/null |
227 |
fi |
239 |
fi |
228 |
[[ ${insert_link_in_opts} -eq 0 ]] || opts="${link} ${opts}" |
240 |
[[ ${insert_link_in_opts} -eq 0 ]] || opts="${link} ${opts}" |
229 |
|
241 |
|
230 |
ebegin "Running pppd" |
242 |
ebegin "Running pppd" |
|
|
243 |
[[ " ${opts} " != *" updetach "* ]] && mark_service_inactive "net.${iface}" |
231 |
i=$( eval /usr/sbin/pppd ${opts} 2>&1 ) |
244 |
i=$( eval /usr/sbin/pppd ${opts} 2>&1 ) |
232 |
eend $? "${i}" || return 1 |
245 |
eend $? "${i}" || return 1 |
233 |
|
246 |
|
234 |
if [[ " ${opts} " == *" updetach "* ]]; then |
247 |
if [[ " ${opts} " == *" updetach "* ]]; then |
235 |
local addr=$( interface_get_address "${iface}" ) |
248 |
local addr=$( interface_get_address "${iface}" ) |
236 |
einfo "${iface} received address ${addr}" |
249 |
einfo "${iface} received address ${addr}" |
|
|
250 |
else |
251 |
einfo "Backgrounding ..." |
252 |
exit 0 |
237 |
fi |
253 |
fi |
238 |
} |
254 |
} |
239 |
|
255 |
|
Lines 244-249
Link Here
|
244 |
# Returns 0 (true) if no process to kill or it terminates successfully, |
260 |
# Returns 0 (true) if no process to kill or it terminates successfully, |
245 |
# otherwise non-zero (false) |
261 |
# otherwise non-zero (false) |
246 |
pppd_stop() { |
262 |
pppd_stop() { |
|
|
263 |
${IN_BACKGROUND} && return 0 |
247 |
local iface="$1" pidfile="/var/run/ppp-$1.pid" |
264 |
local iface="$1" pidfile="/var/run/ppp-$1.pid" |
248 |
|
265 |
|
249 |
[[ ! -s ${pidfile} ]] && return 0 |
266 |
[[ ! -s ${pidfile} ]] && return 0 |