# Copyright (c) 2004-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # Contributed by Alin Nastac (mrness@gentoo.org) # char* pppoe_provides(void) # # Returns a string to change module definition for starting up pppoe_provides() { echo "pppoe" } # void pppoe_depend(void) # # Sets up the dependancies for the module pppoe_depend() { after interface before dhcp } # bool pppoe_check_installed(void) # # Returns 1 if pppd is installed, otherwise 0 pppoe_check_installed() { [[ -x /usr/sbin/pppd ]] || { eerror "For PPPoE support, emerge net-dialup/ppp" return 1 } return 0 } # bool pppoe_check_depends(void) # # Checks to see if we have the needed functions pppoe_check_depends() { local f for f in interface_variable; do [[ $( type -t ${f} ) == function ]] && continue eerror "pppoe: missing required function ${f}\n" return 1 done return 0 } # bool pppoe_setup_vars(char *iface) # # Read pppd parameters pppoe_setup_vars() { local iface=${1} # Might or might not be set in conf.d/net eval user=\"\$\{pppoe_user_${ifvar}\}\" eval ondemand_idletime=\"\$\{pppoe_ondemand_idletime_${ifvar}\}\" eval mtu=\"\$\{pppoe_mtu_${ifvar}\}\" eval echo_interval=\"\$\{pppoe_echo_interval_${ifvar}\}\" eval echo_failure=\"\$\{pppoe_echo_failure_${ifvar}\}\" return 0 } # bool pppoe_start(char *iface) # # Start ADSL on an interface by calling adsl-start # # Returns 0 (true) when successful, non-zero otherwise pppoe_start() { local iface=${1} user ifvar=$( interface_variable ${1} ) cmdline=/usr/sbin/pppd pppoe_setup_vars ${iface} || return 1 einfo "Starting PPPoE for ${iface}" [[ -n ${ondemand_idletime} ]] && \ cmdline="${cmdline} demand idle ${ondemand_idletime} 10.112.112.112:10.112.112.113 \ ipcp-accept-remote ipcp-accept-local connect true" cmdline="${cmdline} plugin rp-pppoe.so ${iface} remotename ${iface} linkname ${iface} \ hide-password persist maxfail 0 default-asyncmap noipdefault noauth defaultroute \ noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp \ lcp-echo-interval ${echo_interval:-15} lcp-echo-failure ${echo_failure:-3} \ mtu ${mtu:-1492} mru ${mtu:-1492}" [[ -n ${user} ]] && \ cmdline="${cmdline} user ${user}" ${cmdline} &> /tmp/log.pppoe eend $? } # bool pppoe_stop(char *iface) # # Stop ADSL on an interface by calling adsl-stop # # Returns 0 (true) when there appears to be an ADSL interface to stop, # and we attempted to stop it. This does not necessarily indicate # that adsl-stop was successful. Returns non-zero when there was # nothing to stop. pppoe_stop() { local iface=${1} cfgfile pidfile=/var/run/ppp-${iface}.pid [[ ! -f ${pidfile} ]] && return 1 local pid=$(head -n 1 ${pidfile}) einfo "Stopping PPPoE for ${iface}" kill -s HUP ${pid} && \ process_finished ${pid} /usr/sbin/pppd eend $? return 0 # we did *attempt* to stop adsl }