#----------------------------------------------------------------------------
# /etc/rc.d/pppoe - configuration of PPPoE
#
# Creation:	09.09.2000  fm
# Last Update:  $Id: pppoe,v 1.2 2002/02/03 22:53:50 fm Exp $
#----------------------------------------------------------------------------

/usr/local/bin/colecho "starting pppoe ..." gn

if [ "$PPPOE_DO_DEBUG" = "yes" ]
then
    set -x
fi

clampmss="-m 1412"				# clamp the MSS
lcp_interval=30					# LCP interval
lcp_failure=5					# LCP failure count
pppoe_timeout=120				# should be 4 * lcp_interval
usepeerdns="$PPPOE_USEPEERDNS"                  # get configuration usepeerdns from config

ifconfig $PPPOE_ETH up mtu 1500			# set mtu to 1500

pppoe_synchronous=no				# fm: "yes" not possible

if [ "$pppoe_synchronous" = "yes" ]
then
    pppoe_sync=-s
    pppd_sync=sync
else
    pppoe_sync=''
    pppd_sync=''
fi

if [ "$PPPOE_DEBUG" = "yes" ]
then
    debug='debug'
else
    debug=''
fi

if [ "$usepeerdns" = "yes" ]
then
    usepeerdns='usepeerdns'
else
    usepeerdns=''
fi

# PPPoE invocation
PPPOE_CMD="exec /usr/sbin/pppoe -p /var/run/pppoe.pid -I $PPPOE_ETH -T $pppoe_timeout $pppoe_sync $clampmss"

echo '"'"$PPPOE_USER"'"  *  "'"$PPPOE_PASS"'"' >> /etc/ppp/pap-secrets
echo '"'"$PPPOE_USER"'"  *  "'"$PPPOE_PASS"'"' >> /etc/ppp/chap-secrets

/sbin/insmod slhc
/sbin/insmod ppp

if [ "$START_IMOND" = "yes" ]
then
    defaultroute=''				# imond handles default route
    echo $DIALMODE >/var/run/pppoe.dialmode
else
    defaultroute='defaultroute'
    echo auto >/var/run/pppoe.dialmode
fi

local=10.112.112.112
remote=10.112.112.113
netmask=255.255.255.0

echo $local >/var/run/$dev.conf
echo $remote >>/var/run/$dev.conf
echo $netmask >>/var/run/$dev.conf

while [ 1 ]
do
    /usr/sbin/pppd  $usepeerdns                         \
		    pty "$PPPOE_CMD"			\
		    noipdefault				\
		    noauth				\
		    $defaultroute			\
		    hide-password			\
		    nodetach				\
		    local				\
		    $debug				\
		    mtu "$PPPOE_MTU_SIZE"		\
		    mru "$PPPOE_MRU_SIZE"		\
		    noaccomp				\
		    noccp				\
		    nobsdcomp				\
		    nodeflate				\
		    nopcomp				\
		    novj				\
		    novjccomp				\
		    user "$PPPOE_USER"			\
		    lcp-echo-interval $lcp_interval	\
		    lcp-echo-failure $lcp_failure	\
		    demand				\
		    persist				\
		    idle $PPPOE_HUP_TIMEOUT		\
		    $local:$remote			\
		    ipcp-accept-remote			\
		    ipcp-accept-local			\
		    connect true			\
		    ktune				\
		    $pppd_sync
    sleep 1
done &

if [ -f /usr/local/sbin/pppoe-status ]
then
    /usr/local/sbin/pppoe-status >/dev/tty3 &
fi

set +x
