#!FOOPERL

#
# Copyright (c) Xerox Corporation 1997, 1998. All rights reserved.
#
# License is granted to copy, to use, and to make and to use derivative
# works, provided that Xerox is acknowledged in all documentation
# pertaining to any such copy or derivative work. Xerox grants no other
# licenses expressed or implied. The Xerox trade name should not be used
# in any advertising without its written permission.
#
# XEROX CORPORATION MAKES NO REPRESENTATIONS CONCERNING EITHER THE
# MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS SOFTWARE
# FOR ANY PARTICULAR PURPOSE.  The software is provided "as is" without
# express or implied warranty of any kind.
#
# These notices must be retained in any copies of any part of this software.
#



#----- default directory names and executable paths ----------
# users can override these values using the command line options listed
# the output directory for the route monitor program, command line opt -d
$rtemondir = "FOORTEMONDIR";

#-----------------------------------------------
# command line options
# option: -d dir
#   action: look for the route monitor pid file in directory dir
#   default: use $rtemondir defined above as the directory for the pid file
# option: -p pid
#   action: use pid as the process id for route monitor
#   default: read the route monitor pid to obtain the pid

#------ perl standard modules and libraries -----------
use Getopt::Std;


#------ main program ------------------------------------
# check the command line args are correct
if (!getopts('p:d:')  || (@ARGV > 0)) {
    print "usage: reset_table [-d rtemondir] [-p pid]\n";
}

if (defined($opt_p)) {
    # user supplied pid on command line
    $pid = $opt_p;
} else {
    if (defined($opt_d)) {
	$rtemondir = $opt_d;
    }
    # the route monitor process id file
    $pidfile = "$rtemondir/route_monitor.pid";
    # get the route monitor process id
    open(PIDFILE, "$pidfile") || 
	die "Unable to open the route monitor's pid file: $pidfile\n";
    $pid = <PIDFILE>;
    chop($pid);
    close(PIDFILE);
}

# send signal USR1 to make route monitor dump its route table and ALSO
# reset its stats
kill 'USR1', $pid;

 
