3 # Copyright (c) 2011 Nathan Whitehorn
5 # Copyright (c) 2011 The FreeBSD Foundation
8 # Portions of this software were developed by Bjoern Zeeb
9 # under sponsorship from the FreeBSD Foundation.
11 # Redistribution and use in source and binary forms, with or without
12 # modification, are permitted provided that the following conditions
14 # 1. Redistributions of source code must retain the above copyright
15 # notice, this list of conditions and the following disclaimer.
16 # 2. Redistributions in binary form must reproduce the above copyright
17 # notice, this list of conditions and the following disclaimer in the
18 # documentation and/or other materials provided with the distribution.
20 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 # - Add DHCPv6 support once FreeBSD ships with it.
43 : ${DIALOG_ITEM_HELP=4}
47 case "${INTERFACE}" in
48 "") dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' \
49 --msgbox 'No interface specified for IPv6 configuration.' 0 0
56 MSG="Would you like to try stateless address autoconfiguration (SLAAC)${AGAIN}?"
57 dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' \
59 if [ $? -eq $DIALOG_OK ]; then
60 if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
61 dialog --backtitle 'FreeBSD Installer' \
62 --infobox "Sending Router Solicitation ..." 0 0
63 ifconfig ${INTERFACE} inet6 -ifdisabled accept_rtadv up
64 rtsol -F $INTERFACE 2>> $BSDINSTALL_LOG
66 dialog --backtitle 'FreeBSD Installer' --msgbox "SLAAC failed." 0 0
71 echo ifconfig_${INTERFACE}_ipv6=\"inet6 accept_rtadv\" >> $BSDINSTALL_TMPETC/._rc.conf.net
78 ROUTER6=`netstat -Wrn -f inet6 | awk '/default/ {printf("%s\n", $2);}'`
79 ADDRS=`ifconfig ${INTERFACE} inet6 | \
80 awk -v dfr="${ROUTER6}" '
86 if (match($2, "^fe80:")) { next; };
87 # For the moment ignore all but the first address; it might confuse the user.
90 printf "\"IPv6 Address\" %d 0 \"%s/%s\" %d 16 50 0 0 ", n, $2, $4, n;
96 printf "\"IPv6 Address\" %d 0 \"\" %d 16 50 0 0 ", n, n;
99 # Nasty trick adding a (hidden, same y) read-only field as a marker
100 # to separate interface address(es) from the default router.
101 printf "\"Default Router\" %d 0 \"%s\" %d 16 50 0 2 ", n, "DefaultRouter", n;
102 printf "\"Default Router\" %d 0 \"%s\" %d 16 50 0 0 ", n, dfr, n;
106 IF_CONFIG=$(echo ${ADDRS} | xargs dialog --backtitle 'FreeBSD Installer' \
107 --title 'Network Configuration' \
108 --mixedform 'Static IPv6 Network Interface Configuration' 0 0 0 \
110 if [ $? -eq $DIALOG_CANCEL ]; then exit 1; fi
113 echo ${IF_CONFIG} | tr ' ' '\n' | \
114 awk -v iface="${INTERFACE}" '
120 if (/^[[:space:]]+$/) {
123 if (/DefaultRouter/) {
128 printf("ipv6_defaultrouter=\"%s\"\n", $1);
132 # Ignore all but the first IP address for now.
136 if (!match($1, "/")) {
139 printf("ifconfig_%s_ipv6=\"inet6 %s\"\n", iface, $1);
140 }' >> $BSDINSTALL_TMPETC/._rc.conf.net
142 if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
143 . $BSDINSTALL_TMPETC/._rc.conf.net
144 ifconfig ${INTERFACE} `eval echo \\\$ifconfig_${INTERFACE}_ipv6`
145 if [ -n "${ipv6_defaultrouter}" ]; then
146 route delete -inet6 default
147 route add -inet6 default ${ipv6_defaultrouter}