home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
- #
- # Tasks.dhcp-start.cgi
- #
- # Copyright 1988-1996 Silicon Graphics, Inc.
- # All rights reserved.
- #
- # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- # the contents of this file may not be disclosed to third parties, copied or
- # duplicated in any form, in whole or in part, without the prior written
- # permission of Silicon Graphics, Inc.
- #
- # RESTRICTED RIGHTS LEGEND:
- # Use, duplication or disclosure by the Government is subject to restrictions
- # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- # rights reserved under the Copyright Laws of the United States.
- #
- # $Id: Tasks.dhcp-start.cgi,v 1.8 1997/04/17 23:44:51 shotes Exp $
-
- require "/usr/OnRamp/lib/OnRamp.pm";
- require "/usr/OnRamp/lib/java.pm";
-
- $myname = "Tasks.dhcp-start.cgi";
- $def_config_dir = "/var/dhcp/config";
- $temp = "task.tmp";
- $data = "task.dummy";
- $action = "Tasks.dhcp-start.cgi?loop";
-
- $it = "<td align=right>";
- $ni = "</td>";
- $bo = "<td><font size=5><i>";
- $nb = "</i></font></td>";
-
- @find_vals = ('status','leases');
-
- &get_fields;
- &getLeases;
-
- # clear temporary file for initial call
- if (!$ARGV[0]) {
- open(OUT,"> $temp");
- close(OUT);
-
- } elsif ($ARGV[0] eq 'loop') { %vals = %fld; }
- else { &readValues; }
-
- if ($ARGV[0] eq loop) {
- &errorCheck;
- &writeFile;
-
- $go = "/tasks/dhcp-end.cgi?st";
- # printf("Location: %s%c%c",$go,10,10);
- print "Content-type: text/html\n\n";
- print "<HTML><HEAD>";
- print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$go\">";
- print "</HEAD><BODY></BODY></HTML>";
- exit 0;
- }
-
- &generic;
-
- sub readValues {
- open(IN,"< $temp");
- while(<IN>) {
- @items = split(/=/);
- foreach $arg (@find_vals) {
- if ($arg eq $items[0]) {
- if ($items[1] ne "\n") {
- $vals{$arg} = $items[1];
- chop $vals{$arg};
- }
- }
- }
- }
- close(IN);
- }
-
- sub errorCheck {
- }
-
- sub error {
- $error = $_[0];
- &generic;
- exit 0;
- }
-
- sub writeFile {
- undef %terms;
- open(IN,"< $temp");
- while(<IN>) {
- @items = split(/=/);
- chop $items[1];
- $terms{$items[0]} = $items[1];
- }
- close(IN);
- foreach $arg (@find_vals) {
- $fld{$arg} =~ s/\r\n/&&/g;
- $terms{$arg} = $fld{$arg};
- }
- open(OUT,"> $temp");
- foreach $arg (keys(%terms)) {
- print OUT "$arg=$terms{$arg}\n";
- }
- close(OUT);
- }
-
- sub getLeases {
- undef @lst;
- opendir(CONFIG, $def_config_dir) ||
- &error("Unable to open directory $def_config_dir");
- while ($name = readdir(CONFIG) ) {
- if ($name =~ /^config\./) {
- $ipa = $name;
- $ipa =~ s/^config\.//;
- if ($ipa ne "Default") { push(@lst,$ipa); }
- }
- }
- closedir(CONFIG);
- }
-
- sub generic {
- print "Content-type: text/html\n\n";
- print "<html><head><title>DHCP Setup</title>\n";
- print "<script language=\"JavaScript\">\n<!--\n";
-
- # JavaScript
- print "
- $js_error_box
- $js_ip
- $js_iplist
- function Next() {
- form = document.page1;
- if (!testIPList(form.leases, \"lease address\")) return;
- setTimeout('form.submit()',0);
- return;
- }\n";
-
- print "//-->\n";
- print "</script></head>\n\n";
-
- print "<body bgcolor=\'ddc4b2\' background=/tasks/dhcp-task.bg.gif>\n";
- if ($error) {
- print "<font size=4 color=ff0000><b>Error: </b>$error<br></font>";
- }
- print "<i>$message</i>";
-
- print "<table width=100%>",
- "<tr><th align=left><h1>DHCP Setup</h1></th>\n",
- "<th align=right><a href=\"/newsplash.shtml\">",
- "<img height=55 width=57 border=0 src=/tasks/home.gif></a>\n",
- " <a href=\"Tasks.shtml\">",
- "<img height=55 width=57 border=0 src=/tasks/back.gif></a>",
- "</tr></table>\n";
-
- printf("\n<form name=\"page1\" action=\"%s\" method=post>\n", $action);
-
- print "<center><table width=620>\n";
-
- print " <tr><td colspan=2>
- Dynamic Host Configuration Protocol (DHCP) automatically configures
- new hosts for membership in a network. When DHCP is enabled, new hosts
- request network configuration information from the DHCP server as soon
- as they are connected to the network. The server responds by sending a
- hostname and an IP address, which is based on the address of the network
- where the new host is connecting. Because the name and address may be
- surrendered or allowed to expire, it is considered a lease.
- <br><br></td></tr>\n";
-
- print "<tr>$bo Enable the DHCP server: $nb\n$it",
- "<font size=5>", &radio("status","Yes","Yes","No"), "</font>",
- "$ni </tr>\n";
- print " <tr><td colspan=2>
- If you select <I>Yes</I>, the Internet Gateway will act as a DHCP
- server, automatically supplying network configuration information
- to new hosts connecting to the network. If you select <I>No</I>,
- you will need to assign new hosts a name and address by some other
- method, such as the DHCP pages that are available in the Internet
- Gateway Administration tools or (for IRIX workstations) the Network
- Setup tools that are part of the IRIX Desktop toolchest.
- <br><br></td></tr>\n";
-
- print "<tr>$bo Subnets for this DHCP server: $nb\n$it",
- "<font size=5><textarea name='leases' rows=5 cols=15>";
- foreach (@lst) {
- print "$_\r\n";
- }
- print "</textarea>$ni </tr>\n";
- print "<tr><td colspan=2>Add, edit or delete addresses of the networks
- where the DHCP server will supply name and address information to
- new hosts.<br><br></td></tr>\n";
- print "</td></tr><tr><td> </td></tr>\n\n";
-
- print "</table></center>\n";
-
- print '<MAP NAME="js_map">',
- '<AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Next()">',
- '</MAP>';
- print "\n";
- print '<IMG SRC="/tasks/rightarrow.gif" BORDER=0 USEMAP="#js_map" align="right">';
-
- print "\n</form></body></html>";
- }
-