#!/bin/sh
#
# Copyright (C) 2007 Nokia Corporation. All rights reserved.
# Contact: jukka.rissanen@nokia.com
#
# Set route for new connection. This should not be necessary
# but because of this bug http://bugzilla.kernel.org/show_bug.cgi?id=8382
# the packets will not go out via default route, but we must
# manually setup the route. Remove the script when the bug in kernel
# is fixed.
#

# Only for IPv6
if [ "$ADDRFAM" != inet6 ]; then
    exit 0
fi

# Only when starting the interface
if [ "$MODE" != start ]; then
    exit 0
fi

# First we need the ip address
IP_ADDR=`/sbin/ip -f inet6 addr show dev $IFACE scope global | grep inet6 | awk '{ print $2 }' | awk -F/ '{print $1}'`
if [ -z "$IP_ADDR" ]; then
	exit 0
fi
echo $IP_ADDR | grep : >/dev/null 2>&1
if [ $? -eq 0 ]; then
	# Got the ip address, then just guess the netmask
	# to be 64 (we can only guess at this stage)
	/sbin/ip -f inet6 route add ${IP_ADDR}/64 dev $IFACE
fi

exit 0



