#!/usr/bin/perl
#
# $Copyright$
#
# $TAHI: ct/spec/IH_NoNextHeader.seq,v 1.6 2003/04/23 10:50:04 ozoe Exp $
#
######################################################################
BEGIN {
	$V6evalTool::TestVersion = '$Name:  $';
}

use V6evalTool;

if ($V6evalTool::NutDef{Type} ne 'router') {
    vLogHTML("This test is for the router only<BR>");
    exit $V6evalTool::exitRouterOnly;
}

%pktdesc = (
	nonext_to_link0		=> 'Send No Next Header in IPv6 Header to Link0',
	nonext_from_link1	=> 'Recv No Next Header in IPv6 Header from Link1',
	ns_from_link0_ll	=> 'Recv Neighbor Solicitation from Link0 (Link Local Address)',
	na_to_link0_ll		=> 'Send Neighbor Advertisement to Link0 (Link Local Address)',
	ns_from_link0		=> 'Recv Neighbor Solicitation from Link0 (Global Address)',
	na_to_link0		=> 'Send Neighbor Advertisement to Link0 (Global Address)',
	ns_from_link1_ll	=> 'Recv Neighbor Solicitation from Link1 (Link Local Address)',
	na_to_link1_ll		=> 'Send Neighbor Advertisement to Link1 (Link Local Address)',
	ns_from_link1		=> 'Recv Neighbor Solicitation from Link1 (Global Address)',
	na_to_link1		=> 'Send Neighbor Advertisement to Link1 (Global Address)',
);

$IF0 = Link0;
$IF1 = Link1;

#----- start capturing

vCapture($IF0);
vCapture($IF1);

#======================================================================
# ping over router

vSend($IF0, nonext_to_link0);

%ret = vRecv($IF1, 5, 0, 0, ns_from_link1, ns_from_link1_ll, nonext_from_link1);
if ($ret{status} != 0) {
	vLogHTML('<FONT COLOR="#FF0000">NG</FONT>');
	exit $V6evalTool::exitFail;
}
if ($ret{recvFrame} eq 'ns_from_link1') {
	vSend($IF1, na_to_link1);

	%ret = vRecv($IF1, 5, 0, 0, nonext_from_link1);
	if ($ret{status} != 0) {
		vLogHTML('<FONT COLOR="#FF0000">NG</FONT>');
		exit $V6evalTool::exitFail;
	}
}
if ($ret{recvFrame} eq 'ns_from_link1_ll') {
	vSend($IF1, na_to_link1_ll);
	%ret = vRecv($IF1, 5, 0, 0, nonext_from_link1);
	if ($ret{status} != 0) {
		vLogHTML('<FONT COLOR="#FF0000">NG</FONT>');
		exit $V6evalTool::exitFail;
	}
}
if ($ret{recvFrame} ne 'nonext_from_link1') {
	vLogHTML('<FONT COLOR="#FF0000">NG</FONT>');
	exit $V6evalTool::exitFail;
}

vLogHTML('OK');
exit $V6evalTool::exitPass;

######################################################################
__END__

=head1 NAME

  IH_NoNextHeader - check No Next Header in IPv6 Header (over router)

=head1 TARGET

  Router

=head1 SYNOPSIS

=begin html
<PRE>
  <A HREF="./IH_NoNextHeader.seq">IH_NoNextHeader.seq</A> [-tooloption ...] -pkt <A HREF="./IH_NoNextHeader.def">IH_NoNextHeader.def</A>
    -tooloption : v6eval tool option
</PRE>

=end html

=head1 INITIALIZATION

  None

=head1 TEST PROCEDURE

  Tester                      Target                      Tester
              (Link0)                     (Link1)
    |                           |                           |
    |-------------------------->|                           |
    |      Packet to Link0      |                           |
    |                           |                           |
    |                           |-------------------------->|
    |                           |   Neighbor Solicitation   |
    |                           |                           |
    |                           |<--------------------------|
    |                           |   Neighbor Advertisement  |
    |                           |                           |
    |                           |-------------------------->|
    |                           |      Packet from Link1    |
    |                           |                           |
    |                           |                           |
    v                           v                           v

  1. Send Packet with No Next Header to Link0
  2. Wait Packet with No Next Header from Link1 or NS from Link1
  3. If NS received then send NA to Link1, and wait Packet with No Next Header form Link1 again
  4. Receive Packet with No Next Header from Link1

  Packet with No Next Header to Link0 Data is:

        IPv6 Header
            Version            = 6
            Traffic Class      = 0
            FlowLabel          = 0
            PayloadLength      = 8
            NextHeader         = 59 (No Next Header)
            SourceAddress      = Tester Global Address (Link0)
            DestinationAddress = Tester Global Address (Link1)

        Payload
            PayloadData    = {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87}

  Neighbor Solicitation packet's IP source Address selection may be:
    - Link Local Address
    - Global Address
  This test IS NOT the Neighbor Discovery test, so admit both implementation.

=head1 JUDGMENT

  PASS: Packet with No Next Header Received from Link1

        IPv6 Header
            Version             = 6
            Traffic Class       = 0
            FlowLabel           = 0
            PayloadLength       = 8
            NextHeader          = 59 (No Next Header)
            SourceAddress      = Tester Global Address (Link0)
            DestinationAddress = Tester Global Address (Link1)

        Payload
            PayloadData    = {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87}

=head1 REFERENCE

RFC2460

4.7 No Next Header

=begin html
<PRE>
   The value 59 in the Next Header field of an IPv6 header or any
   extension header indicates that there is nothing following that
   header.  <B>If the Payload Length field of the IPv6 header indicates the
   presence of octets past the end of a header whose Next Header field
   contains 59, those octets must be ignored, and passed on unchanged if
   the packet is forwarded.</B>
</PRE>

=begin html

=head1 SEE ALSO

  perldoc V6evalTool

=cut

