#!/usr/bin/perl
#
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Yokogawa Electric Corporation,
# IPA (Information-technology Promotion Agency, Japan).
# All rights reserved.
#
# Redistribution and use of this software in source and binary forms, with
# or without modification, are permitted provided that the following
# conditions and disclaimer are agreed and accepted by the user:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the names of the copyrighters, the name of the project which
# is related to this software (hereinafter referred to as "project") nor
# the names of the contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# 4. No merchantable use may be permitted without prior written
# notification to the copyrighters. However, using this software for the
# purpose of testing or evaluating any products including merchantable
# products may be permitted without any notification to the copyrighters.
#
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHTERS, THE PROJECT AND
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING
# BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHTERS, THE PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT,STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.
#
# $TAHI: ct/nd/recvNsBasic.seq,v 1.34 2003/06/10 11:19:07 masaxmasa Exp $
########################################################################
BEGIN { $V6evalTool::TestVersion = '$Name: REL_2_1_2 $ '; }
use V6evalTool;
use nd;
ndOptions(@ARGV);
# The following generate debugging messages.
$nd::debug=$ndOpt_v|$ndOpt_vv;
# You can specifies debug options to a remote control program.
# If you want to know more detail, please see the following:
# - V6evalTool.pm: perldoc V6evalTool
# - V6evalRemote.pm: perldoc V6evalRemote
$nd::remote_debug="-o1" if $ndOpt_vv;
$IF=Link0;
$exit_rtn=$V6evalTool::exitPass;
$idx=0;
$wait_na=2;
$wait_reachable=$nd::REACHABLE_TIME * $nd::MAX_RANDOM_FACTOR + 1;
$wait_probe=$nd::DELAY_FIRST_PROBE_TIME + 1 +
$nd::RETRANS_TIMER * $nd::MAX_UNICAST_SOLICIT + 1;
#
#
#
$type=$V6evalTool::NutDef{Type};
if($type ne router && $type ne host) {
vLogHTML(ndErrmsg("ERROR: $V6evalTool::NutDef{Type}: ".
"Unknown target type
"));
exit $V6evalTool::exitFail;
}
#
# Start capture buffer.
#
vCapture($IF);
#
#
#
if($type eq router) {
#
# A target router should be pre-configured:
# Link0: 3ffe:501:ffff:100 prefixlen 64
#
} else {
#
# Send a RA (src:x's link, dst:allnode)
# to advertise global prefix to the target.
#
$pktdesc{unsol_ra}=
"Send unsolicited RA (link-local\@X ==> all-node mcast)";
vSend($IF, unsol_ra);
}
#
#
#
$idx_snd=0;
$idx_scp=1;
$idx_exp=2;
$idx_msg=3;
#
@expects_ucast_ns_link2link_sll=
(ucast_na_link2link_RSo, ucast_na_link2link_RSO_tll)
if $type eq router;
@expects_ucast_ns_link2link_sll=
(ucast_na_link2link_rSo, ucast_na_link2link_rSO_tll)
if $type eq host;
@def_ucast_ns_link2link_sll=
(
ucast_ns_link2link_sll,
'local',
\@expects_ucast_ns_link2link_sll,
'unicast NS w/ SLLA (link => link)',
);
#
@expects_ucast_ns_link2global_sll=
(ucast_na_global2link_RSo, ucast_na_global2link_RSO_tll)
if $type eq router;
@expects_ucast_ns_link2global_sll=
(ucast_na_global2link_rSo, ucast_na_global2link_rSO_tll)
if $type eq host;
@def_ucast_ns_link2global_sll=
(
ucast_ns_link2global_sll,
'local',
\@expects_ucast_ns_link2global_sll,
'unicast NS w/ SLLA (link => global)',
);
#
@expects_ucast_ns_global2link_sll=
(ucast_na_link2global_RSo, ucast_na_link2global_RSO_tll)
if $type eq router;
@expects_ucast_ns_global2link_sll=
(ucast_na_link2global_rSo, ucast_na_link2global_rSO_tll)
if $type eq host;
@def_ucast_ns_global2link_sll=
(
ucast_ns_global2link_sll,
'global',
\@expects_ucast_ns_global2link_sll,
'unicast NS w/ SLLA (global => link)',
);
#
@expects_ucast_ns_global2global_sll=
(ucast_na_global2global_RSo, ucast_na_global2global_RSO_tll)
if $type eq router;
@expects_ucast_ns_global2global_sll=
(ucast_na_global2global_rSo, ucast_na_global2global_rSO_tll)
if $type eq host;
@def_ucast_ns_global2global_sll=
(
ucast_ns_global2global_sll,
'global',
\@expects_ucast_ns_global2global_sll,
'unicast NS w/ SLLA (global => global)',
);
#
@expects_mcast_ns_link2link_sll=
(ucast_na_link2link_RSO_tll, ucast_na_global2link_RSO_tll)
# (ucast_na_link2link_RSo, ucast_na_link2link_RSO_tll)
if $type eq router;
@expects_mcast_ns_link2link_sll=
(ucast_na_link2link_rSO_tll, ucast_na_global2link_rSO_tll)
# (ucast_na_link2link_rSo, ucast_na_link2link_rSO_tll)
if $type eq host;
@def_mcast_ns_link2link_sll=
(
mcast_ns_link2link_sll,
'local',
\@expects_mcast_ns_link2link_sll,
'multicast NS w/ SLLA (link => solnode[link])',
);
#
@expects_mcast_ns_link2global_sll=
(ucast_na_global2link_RSO_tll)
# (ucast_na_global2link_RSo, ucast_na_global2link_RSO_tll)
if $type eq router;
@expects_mcast_ns_link2global_sll=
(ucast_na_global2link_rSO_tll)
# (ucast_na_global2link_rSo, ucast_na_global2link_rSO_tll)
if $type eq host;
@def_mcast_ns_link2global_sll=
(
mcast_ns_link2global_sll,
'local',
\@expects_mcast_ns_link2global_sll,
'multicast NS w/ SLLA (link => solnode[global])',
);
#
@expects_mcast_ns_global2link_sll=
(ucast_na_link2global_RSO_tll)
# (ucast_na_link2global_RSo, ucast_na_link2global_RSO_tll)
if $type eq router;
@expects_mcast_ns_global2link_sll=
(ucast_na_link2global_rSO_tll)
# (ucast_na_link2global_rSo, ucast_na_link2global_rSO_tll)
if $type eq host;
@def_mcast_ns_global2link_sll=
(
mcast_ns_global2link_sll,
'global',
\@expects_mcast_ns_global2link_sll,
'multicast NS w/ SLLA (global => solnode[link])',
);
#
@expects_mcast_ns_global2global_sll=
(ucast_na_global2global_RSO_tll, ucast_na_link2global_RSO_tll)
# (ucast_na_global2global_RSo, ucast_na_global2global_RSO_tll)
if $type eq router;
@expects_mcast_ns_global2global_sll=
(ucast_na_global2global_rSO_tll, ucast_na_link2global_rSO_tll)
# (ucast_na_global2global_rSo, ucast_na_global2global_rSO_tll)
if $type eq host;
@def_mcast_ns_global2global_sll=
(
mcast_ns_global2global_sll,
'global',
\@expects_mcast_ns_global2global_sll,
'multicast NS w/ SLLA (global => solnode[global])',
);
#
#
#
@defs=
(
\@def_ucast_ns_link2link_sll,
\@def_ucast_ns_link2global_sll,
\@def_ucast_ns_global2link_sll,
\@def_ucast_ns_global2global_sll,
\@def_mcast_ns_link2link_sll,
\@def_mcast_ns_link2global_sll,
\@def_mcast_ns_global2link_sll,
\@def_mcast_ns_global2global_sll,
);
#
#
#
$idx=0;
foreach(@defs) {
my($snd)=@$_[$idx_snd];
my($scp)=@$_[$idx_scp];
my($exp)=@$_[$idx_exp];
my($msg)=@$_[$idx_msg];
$title{$idx}="
TN NUT -----------------------=end html =head2 JUDGMENT =begin html
State: NONCE
==== NS ===> src=TN's link-local, global dst=NUT's link-local or global or solicited-node[NUT's link-local] or solicited-node[global] w/ SLL
State: INCOMPLETE
<=== Judgment #1: NA ==== src=NUT's link-local or global dst=TN's link-local or global w/ or w/o TLL
Input & output
===============================+===================================
NS (input) | NA (expected)
-------+---------------+-------+-----------+------+-+-+-+----------
Src | Dst | SLLA | Src | Dst |r|s|o| TLLA
=======+===============+=======+===========+======+=+=+=+==========
link link exist |link link * 1 0 none
|link link * 1 1 exist
-------+---------------+-------+-----------+------+-+-+-+----------
link global exist |link/global link * 1 0 none
|link/global link * 1 1 exist
-------+---------------+-------+-----------+------+-+-+-+----------
global link exist |link/global global * 1 0 none
|link/global global * 1 1 exist
-------+---------------+-------+-----------+------+-+-+-+----------
global global exist |global global * 1 0 none
|global global * 1 1 exist
=======+===============+=======+===========+======+=+=+=+==========
link sol-node[link] exist |link/global link * 1 1 exist
-------+---------------+-------+-----------+------+-+-+-+----------
link sol-node[global]exist |link/global link * 1 1 exist
-------+---------------+-------+-----------+------+-+-+-+----------
global sol-node[link] exist |link/global global * 1 1 exist
-------+---------------+-------+-----------+------+-+-+-+----------
global sol-node[global]exist |link/global global * 1 1 exist
=======+===============+=======+===========+======+=+=+=+==========
*If NUT is a host, r-flag must be the zero.
*If NUT is a router, r-flag is must be the one.
=end html
=head1 CASE II. A valid NS without SLLA
BTN NUT ---------------------------------=end html =head2 JUDGMENT =begin html
State: NONCE
==== unicast NS ===> src=TN's link-local dst=NUT's link-local w/o SLL
State: INCOMPLETE
<=== Judgment #2: multicast NS ==== src=NUT's link-local or global dst=solicited-node[TN's link-local] w/ SLL
==== solicited NA ===> src=TN's link-local dst=NUT's link-local R=0, S=1, O=1 w/ TLL
State: REACHABLE
<=== Judgment #3: solicited NA (if any) ==== src=NUT's link-local or global dst=TN's link-local R=0/1, S=1, O=0 w/ or w/o TLL
1. Input and output
===============================+===================================
NS (input) | NA (expected)
-------+---------------+-------+-----------+------+-+-+-+----------
Src | Dst | SLLA | Src | Dst |r|s|o| TLLA
=======+===============+=======+===========+======+=+=+=+==========
link link none |link/global link * 1 0 none
|link/global link * 1 0 exist
=======+===============+=======+===========+======+=+=+=+==========
*If NUT is a host, r-flag must be the zero.
*If NUT is a router, r-flag is must be the one.
2. NUT may send at the least one multicast NS.
src=NUT's link-local, dst=solicited-node[TN's link-local], w/ SLL
3. NUT may send a solicited NA.
3.1. NUT is a host
src=NUT's link-local, dst=TN's link-local,
r=0, s=1, O=0, w/ or w/o TLL
3.2. NUT is a router
src=NUT's link-local, dst=TN's link-local,
r=1, s=1, O=0, w/ or w/o TLL
=end html
=head1 TERMINATION
Send RA with RouterLifetime=0 to clear the Default Router List.
=head1 NOTE
=for html
1. The command does not invoke any remote command.
=head1 REFERENCE
=begin html
RFC2461=end html =head1 SEE ALSO perldoc V6evalTool perldoc V6evalRemote =cut
7.2.4. Sending Solicited Neighbor Advertisements
A node sends a Neighbor Advertisement in response to a valid Neighbor Solicitation targeting one of the node's assigned addresses. The Target Address of the advertisement is copied from the Target Address of the solicitation. If the solicitation's IP Destination Address is not a multicast address, the Target Link-Layer Address option MAY be omitted; the neighboring node's cached value must already be current in order for the solicitation to have been received. If the solicitation's IP Destination Address is a multicast address, the Target Link-Layer option MUST be included in the advertisement. Furthermore, if the node is a router, it MUST set the Router flag to one; otherwise it MUST set the flag to zero.
If the Target Address is either an anycast address or a unicast address for which the node is providing proxy service, or the Target Link-Layer Address option is not included, the Override flag SHOULD be set to zero. Otherwise, the Override flag SHOULD be set to one. Proper setting of the Override flag ensures that nodes give preference to non-proxy advertisements, even when received after proxy advertisements, and also ensures that the first advertisement for an anycast address "wins".
If the source of the solicitation is the unspecified address, the node MUST set the Solicited flag to zero and multicast the advertisement to the all-nodes address. Otherwise, the node MUST set the Solicited flag to one and unicast the advertisement to the Source Address of the solicitation.
If the Target Address is an anycast address the sender SHOULD delay sending a response for a random time between 0 and MAX_ANYCAST_DELAY_TIME seconds.
Because unicast Neighbor Solicitations are not required to include a Source Link-Layer Address, it is possible that a node sending a solicited Neighbor Advertisement does not have a corresponding link- layer address for its neighbor in its Neighbor Cache. In such situations, a node will first have to use Neighbor Discovery to determine the link-layer address of its neighbor (i.e, send out a multicast Neighbor Solicitation).