# 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() { if [[ ! -x /usr/sbin/pppd ]]; then eerror "For PPPoE support, emerge net-dialup/ppp" return 1 fi 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_start(char *iface) # # Start PPPoE on an interface by calling pppd # # Returns 0 (true) when successful, non-zero otherwise pppoe_start() { local iface=${1} user ifvar=$( interface_variable ${1} ) cmdline=/usr/sbin/pppd # Might or might not be set in conf.d/net local user password ondemand_idletime echo_interval echo_failure mtu service access_concentrator eval user=\"\$\{pppoe_user_${ifvar}\}\" eval password=\"\$\{pppoe_password_${ifvar}\}\" eval ondemand_idletime=\"\$\{pppoe_ondemand_idletime_${ifvar}\}\" eval echo_interval=\"\$\{pppoe_echo_interval_${ifvar}\}\" eval echo_failure=\"\$\{pppoe_echo_failure_${ifvar}\}\" eval mtu=\"\$\{pppoe_mtu_${ifvar}\}\" eval service=\"\$\{pppoe_service_${ifvar}\}\" eval access_concentrator=\"\$\{pppoe_access_concentrator_${ifvar}\}\" #Add/update info in PAP/CHAP secrets files if [[ -n "${password}" ]]; then if ! update_secrets_file "/etc/ppp/pap-secrets" "${user}" "${iface}" "${password}" ; then eerror "Failed to update PAP secrets file" return 1 fi if ! update_secrets_file "/etc/ppp/chap-secrets" "${user}" "${iface}" "${password}" ; then eerror "Failed to update CHAP secrets file" return 1 fi fi #Load pppoe module (if compiled as module) modprobe pppoe &>/dev/null 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" [[ -n ${servicename} ]] && \ cmdline="${cmdline} rp_pppoe_service ${servicename}" [[ -n ${access_concentrator} ]] && \ cmdline="${cmdline} rp_pppoe_ac ${access_concentrator}" cmdline="${cmdline} ${iface} remotename ${iface} linkname ${iface} ipparam ${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} &>/dev/null eend $? } # bool pppoe_stop(char *iface) # # Stop PPPoE link by killing the associated pppd process # # Returns 0 (true) when there appears to be an PPPoE interface to stop, # and we attempted to stop it. 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 }