#
# Copyright (C) 1999,2000 Yokogawa Electric Corporation and
#                         YDC Corporation.
# 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.
# 
# 5. The copyrighters, the project and the contributors may prohibit
#    the use of this software at any time.
# 
# 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.
#
# Perl Module for IPv6 Specification Conformance Test
#
# $Name:  $
#
# $Id: SPEC.pm,v 1.1.1.1 2000/09/28 00:15:57 sekiya Exp $
#

########################################################################
package SPEC;

use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(
	createIdDef
	specReboot
	);

use V6evalTool;

#======================================================================
# createIdDef() - create unique Fragment ID and write to ./ID.def
#======================================================================

sub createIdDef() {
	sleep 1;				# make time unique
	$id = time & 0x00000fff;		# use lower 12 bit
	open(OUT, ">./ID.def") || return 1;

	# Fragment ID (32bit)

	printf OUT "#define FRAG_ID   0x0%07x\n", $id;
	printf OUT "#define FRAG_ID_A 0xa%07x\n", $id;
	printf OUT "#define FRAG_ID_B 0xb%07x\n", $id;

	# Echo Request ID (16bit)

	printf OUT "#define REQ_ID   0x0%03x\n", $id;
	printf OUT "#define REQ_ID_A 0xa%03x\n", $id;
	printf OUT "#define REQ_ID_B 0xb%03x\n", $id;

	# Echo Request Sequence No. (16bit)

	printf OUT "#define SEQ_NO   0x00\n", $id;
	printf OUT "#define SEQ_NO_A 0x0a\n", $id;
	printf OUT "#define SEQ_NO_B 0x0b\n", $id;

	close(OUT);
	return 0;
}

#======================================================================
# specReboot() - reboot NUT
#======================================================================

$remote_debug = "";

sub specReboot() {
	vLogHTML("Target: Reboot");
	vRemote("reboot.rmt", $remote_debug) && return 1;
	return 0;
}

1;

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

=head1 NAME

=begin html
<PRE>
  <A HREF="./SPEC.pm">SPEC.pm</A> - utility functions for IPv6 Specification test
</PRE>

=end html

=head1 SYNOPSIS

  createIdDef()
  specReboot()

=head1 DESCRIPTION

  createIdDef() - create unique Fragment Identifier for fragment test.

    This Identifier generated by current system time, and stored to ./ID.def file
    ./ID.def file are included from ./Fragment.def - common packet definition file
    for Fragment test.
    This routine must be called before Fragment Tests.

  specReboot() - reboot target

    This routine calls vRemote("reboot.rmt") simply.

=head1 SEE ALSO

  perldoc V6EvalTool
  perldoc V6Remote

=cut


