#!/bin/sh

#
#        +-----------------------------------------------------------------------------+
#        | Endian Firewall                                                             |
#        +-----------------------------------------------------------------------------+
#        | Copyright (c) 2005-2006 Endian                                              |
#        |         Endian GmbH/Srl                                                     |
#        |         Bergweg 41 Via Monte                                                |
#        |         39057 Eppan/Appiano                                                 |
#        |         ITALIEN/ITALIA                                                      |
#        |         info@endian.it                                                      |
#        |                                                                             |
#        | This program is free software; you can redistribute it and/or               |
#        | modify it under the terms of the GNU General Public License                 |
#        | as published by the Free Software Foundation; either version 2              |
#        | of the License, or (at your option) any later version.                      |
#        |                                                                             |
#        | This program is distributed in the hope that it will be useful,             |
#        | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
#        | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
#        | GNU General Public License for more details.                                |
#        |                                                                             |
#        | You should have received a copy of the GNU General Public License           |
#        | along with this program; if not, write to the Free Software                 |
#        | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
#        | http://www.fsf.org/                                                         |
#        +-----------------------------------------------------------------------------+
#

. ${UPLINK_SCRIPTS}/generic/pppd.sh
case "$ADSL_METHOD" in
    'pppoa')
	. ${UPLINK_SCRIPTS}/generic/pppoa.sh
	# PPPoA
	pppd_kill $uplink
	return $?
	;;
	
    'pppoe')
	. ${UPLINK_SCRIPTS}/generic/rfc1483.sh
        # PPPoE
        ret=0
	pppd_kill $uplink
        ret=$(($ret + $?))
	# FIXME: device number should not be hardcoded (multiple links)
	rfc1483_bridged_stop
        ret=$(($ret + $?))
        return $ret
	;;

    'static')
	. ${UPLINK_SCRIPTS}/generic/rfc1483.sh
	. ${UPLINK_SCRIPTS}/generic/route.sh
        ret=0
	route_stop
        ret=$(($ret + $?))
	rfc1483_if_stop
        ret=$(($ret + $?))
        return $ret
	;;
    'dhcp')
	. ${UPLINK_SCRIPTS}/generic/rfc1483.sh
	. ${UPLINK_SCRIPTS}/generic/dhcp.sh
        ret=0
	dhcp_stop
        ret=$(($ret + $?))
	rfc1483_if_stop
        ret=$(($ret + $?))
        return $ret
	;;
    *)
	bailout "adsl_method $ADSL_METHOD unknown"
	;;
esac
