#!/bin/sh

# Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.

# $Id: aftr-script 1001 2010-11-30 18:56:00Z pselkirk $

# on this system the IPv6 route can be added only if the interface
# has an IPv6 address, so the script adds a link-local to tun0

# the commented arp command must be run once to get back packets
# to the AFTR box (this is particular to this testbed which has
# no direct Internet connectivity)

aftr_start()
{
    set -x

    ip link set tun0 up
    ip addr add 192.0.0.1 peer 192.0.0.2 dev tun0
    ip route add 192.168.0.111/32 dev tun0
    ip -6 addr add fe80::1 dev tun0
    ip -6 route add 2001:240:63f:ff01::/64 dev tun0
    #arp -i eth0 -s 192.168.0.111 00:23:8b:b5:bb:3c pub
}

aftr_stop()
{
    set -x

    ip link set tun0 down
}

case "$1" in
start)
	aftr_start
	;;
stop)
	aftr_stop
	;;
*)
	echo "Usage: $0 start|stop"
	exit 1
	;;
esac

exit 0
