#!/usr/bin/perl
#
# Copyright (C) 1999, 2000, 2001, 2002, 2003 Yokogawa Electric Corporation,
# YDC 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: v6eval/bin/remotes/manual/dhcp6c.rmt,v 1.4 2003/03/11 07:22:38 akisada Exp $
#
########################################################################
use V6evalRemote;

rOpen() || goto error;
$type=rType();

#
if($rOpt_Start && !$rOpt_link0 && !$rOpt_link1) {
    print STDERR "Specify link0=XXX and/or link1=XXX\n";
    goto error;
}

#
$rOpt_timeout=5
    if ! defined($rOpt_timeout);

#Included option
##Rapid Commit option
if (defined($rOpt_rapidcommit)){
   $rOpt_rapidcommit="send\ rapid-commit";
}
else{
   $rOpt_rapidcommit="\#";
}

##IA_PD option
##IAID
if (defined($rOpt_iaid)){
   $rOpt_iaid="send\ ia-pd\ $rOpt_iaid";
}
else{
   $rOpt_iaid="\#";
}

#Option Request option
##ex. Domain Name Server option
if (defined($rOpt_requestoptions)){
   $rOpt_requestoptions="request\ $rOpt_requestoptions";
}
else{
   $rOpt_requestoptions="\#";
}

#Msg type
#INFORMATION-REQUEST
if (defined($rOpt_inforeq)){
   $rOpt_inforeq="information-only";
}
else{
   $rOpt_inforeq="\#";
}

#
$rOpt_slaid=1
    if ! defined($rOpt_slaid);
$rOpt_slalen=16
    if ! defined($rOpt_slalen);
#
$dhcp6c_tmpl="$type".".dhcp6c.tmpl";
$dhcp6c_conf="$type".".dhcp6c.conf";
$dhcp6c_rmt="/tmp/dhcp6c.conf";
$put_timeout=180;
#
if ($V6evalRemote::debug){
    $dhcp6c_cmd="";
}
else{
    $dhcp6c_cmd="";
}

#
print "set/start/stop dhcp client ".
      "of NUT($type) manually, ".
      "then press enter key.\a\n";
      <STDIN>;

rClose();
exit($V6evalRemote::exitPass);

error:
    rClose();
    exit($V6evalRemote::exitFail);

notsupported:
    rClose();
    exit($V6evalRemote::exitNS);

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

=head1 NAME

B<dhcp6c.rmt> - set/start/stop/release dhcp client

=head1 SYNOPSIS

B<dhcp6c.rmt> [-commonoption ...] set [rapidcommit|inforeq]
              link0=LINK0_DEV link1=LINK1_DEV
              [timeout=SEC_VALUE]

B<dhcp6c.rmt> [-commonoption ...] start [rapidcommit|inforeq]
              link0=LINK0_DEV link1=LINK1_DEV
              [timeout=SEC_VALUE]

B<dhcp6c.rmt> [-commonoption ...] stop
B<dhcp6c.rmt> [-commonoption ...] release

=head1 DESCRIPTION

B<dhcp6c.rmt set> sets dhcp client parameters.
B<dhcp6c.rmt start> starts dhcp client process associating iapd.
B<dhcp6c.rmt start rapidcommit> starts dhcp client process using rapid commit option.
B<dhcp6c.rmt start inforeq> starts dhcp client process to get configuration parameter.
B<dhcp6c.rmt stop> stop dhcp client process.
B<dhcp6c.rmt release> release delegated prefix information.

B<timeout>: Default timeout value is five seconds.
B<common options>: Please see ``preldoc V6evalRemote''.
B<link0> and B<link1>: NUT's network i/f names for Link0 and Link1.
B<dhcp6c.rmt start> can specifies the following DHCP parameters whose
values are depend on dhcp6c of kame-freebsd now.

  ---------------+----------------------------------
  left value      right value
  ---------------+----------------------------------
  iaid            0
  slaid           1
  slalen          16
  requestoptions  domain-name-servers
  ---------------+----------------------------------

B<dhcp6c.rmt stop> stop to dhcp client process.
B<timeout>: Default timeout value is five seconds.
B<common options>: Please see ``preldoc V6evalRemote''.

=head1 RETURN VALUES

B<dhcp6c.rmt> exits with one of the following values:
 0      command completed successfully
 not 0  command failed

=head1 BUGS

B<dhcp6c.rmt> can run for kame-freebsd only.
Current version of the command needs B<kame-freebsd.rtadvd.tmpl>
on the current directory.

=head1 SEE ALSO

 perldoc V6evalRemote
 dhcp6c.conf(5) for kame-freebsd
 draft-ietf-dhc-dhcpv6-28.txt
 draft-ietf-dhc-dhcpv6-opt-prefix-delegation-01.txt

=cut
