Index: ols/IP.pm
===================================================================
--- /tools/IP.pm	(revision 7291)
+++ 	(revision )
@@ -1,103 +1,0 @@
-#!/usr/bin/perl -w
-#
-#Module om ip addresses makkelijk te manipuleren
-#
-#Rick van der Zwet (rick@wirelessleiden.nl)
-package IP;
-
-$nGlobal=0;
-
-
-#module voor het berekenen van de netmask
-sub len2MaskCalc {
-	my $nMask = $_[0];
-	if( $nMask < 1 ) {
-		return 0;
-	}
-	my $nCalc = 0;
-  for( my $nX = 7; $nX > -1; $nX-- ) {
-		$nCalc = $nCalc +  2**$nX;
-		$nMask = $nMask - 1;
-		$nGlobal = $nMask;
-		if( $nMask < 1 ) {
-			return( $nCalc );
-		}
-	}
-	return $nCalc;
-}
-
-
-#convert een netmask naar een subnet
-sub getSubnetAddr {
-	$nGlobal = 0;
-	my @subnet;
-	$subnet[0]=len2MaskCalc( $_[0] );
-	$subnet[1]=len2MaskCalc( $nGlobal );
-	$subnet[2]=len2MaskCalc( $nGlobal );
-	$subnet[3]=len2MaskCalc( $nGlobal );
-	return( join( ".", @subnet) );
-}
-
-
-#convert een subnet naar een netmask
-sub getNetmask {
-	my $cidr = 0;
-	my @subnet = split( /\./, $_[0] );
-	foreach my $part (@subnet) {
-		my $bin = sprintf "%b", $part;
-		$cidr = $cidr + ( $bin =~ tr/1// );
-	}
-	return( $cidr );
-}
-
-
-#netmask en subnet converten naar subnet
-sub toSubnet {
-	my $subnet = $_[0];
-	if ( not $subnet =~ /[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/ ) {
-		$subnet = getSubnetAddr($_[0]);
-	}
-	return( $subnet );
-}
-
-
-#reken broadcast address uit (ip, netmask/subnet)
-sub getBroadcastAddr {
-	my @ipAddr = split(/\./,$_[0]);
-	my $subnet = toSubnet($_[1]);
-	my @subnetAddr = split(/\./, $subnet );
-	my @broadcastAddr;
-	for( my $ctr=0; $ctr < 4; $ctr++) {
-		$broadcastAddr[$ctr] = $ipAddr[$ctr] | ($subnetAddr[$ctr] ^ 255);
-	}
-	return( join( ".", @broadcastAddr) );
-}
-
-
-#reken network address uit (ip, netmask/subnet)
-sub getNetworkAddr {
-	my @ipAddr = split(/\./,$_[0]);
-	my $subnet = toSubnet($_[1]);
-	my @subnetAddr = split(/\./, $subnet );
-	my @networkAddr;
-	for( my $ctr=0; $ctr < 4; $ctr++) {
-		$networkAddr[$ctr] = ($ipAddr[$ctr] + 0) & $subnetAddr[$ctr];
-	}
-	return( join( ".", @networkAddr) );
-}
-
-
-#reken uit of een ip nummer in een range valt (ip1, ip2 ,netmask/subnet)
-sub calcOnNetwork {
-	my $subnet = toSubnet($_[2]);
-	my $tmpNetworkAddr1 = getNetworkAddr($_[0], $subnet);
-	my $tmpNetworkAddr2 = getNetworkAddr($_[1], $subnet);
-	if( $tmpNetworkAddr1 eq $tmpNetworkAddr2 ) {
-		return(1);
-	}
-	else {
-		return(0);
-	}
-}
-
-1;
Index: ols/conf2inc.pl
===================================================================
--- /tools/conf2inc.pl	(revision 7291)
+++ 	(revision )
@@ -1,53 +1,0 @@
-#!/usr/bin/perl
-# use strict;
-use Data::Dumper;
-
-$|++;
-
-my $DIR='../nodes';
-my @nodes=();
-
-opendir(DIR,$DIR) or die $!;
-
-my $nodes = \();
-
-foreach(readdir(DIR)) {
-	next unless m/[CH]Node[\w+]/;
-	# print STDERR "Working on: $_\n";
-	my $n = $_;
-	my $f = $DIR.'/'.$n.'/wleiden.conf';
-	next unless -r $f;
-	eval qq|
-		package $n;
-		require "$f";
-		\$\::nodes->{$n} = \{
-			'location' => \$location,
-			'master_ip' => \$master_ip,
-			'nodename' => \$nodename,
-			'X' => \$X,
-			'Y' => \$Y,
-			'config' => \{ %config },
-		};
-		1;
-	|;
-	die "Parse error: $@" if $@;
-	push @nodes, $_;
-};
-
-foreach my $n (@nodes) {
-	$c = $::nodes->{$n}->{config};
-	foreach my $if (keys %$c ) {
-		foreach(split(m/\n/,$c->{$if})) {
-			chomp;
-			s/#.*//;
-			next if m/^\s*$/;
-			die unless my ($k,$v) = split /=/;
-			# print "$n\t$if\t$k\t$v\n";
-			$::nodes->{$n}->{ifaces}->{$if}->{$k}=$v;
-		};
-	};
-	delete  $::nodes->{$n}->{config};
-}
-
-print Dumper($::nodes);
-
Index: ols/firewall
===================================================================
--- /tools/firewall	(revision 7291)
+++ 	(revision )
@@ -1,177 +1,0 @@
-#! /bin/bash 
-# -x
-#
-#
-
-if [ "$1" != "-n" ]
-then
-  /bin/bash -n $0 $* || exit 1   # Check op Syntax errors!
-fi
-#echo Syntax $0 OK!
-
-. /etc/wireless.conf.sh
-
-ic='/sbin/ipchains'
-nm='/usr/local/bin/netmask'
-
-echo 0 > /proc/sys/net/ipv4/ip_forward  
-
-PATH="/sbin:/usr/sbin:/usr/local/sbin/:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/lib/java/bin:/usr/games/bin:/usr/games:/opt/gnome/bin:/opt/kde/bin:/usr/openwin/bin";
-
-gw=`route -n |grep '^0.0.0.0'|tr -s ' '`
-
-if [ "$gw" != "" ]
-then
- gw_if=`echo $gw|cut -d ' ' -f 8`	# gw. dev.
- def_gw=`echo $gw|cut -d ' ' -f 2`	# def. gw 
-else  
-  gw_if=eth0
-  def_gw=99.99.99.99
-   
-fi
- gwif_ip=`$nm $gw_if i`
- good_net=`$nm $gw_if m`
-
-
-wifs=`/sbin/ifconfig|cut -d ' ' -f 1|grep -v '^$'|grep -v $gw_if|grep -v lo`
-wifs_major=`/sbin/ifconfig|cut -d ' ' -f 1|grep -v '^$'|grep -v $gw_if|grep -v lo|grep -v ':'`
-
-wif_ip=`$nm wlan0 i`
-wnet=172.16.0.0/12
-
-tports='22 37 53 80 3128' 	# ssh,time,domain,http,squid
-uports='53 3130' 		# domain,squid
-
-modprobe ipchains
-
-
-in="$ic -A input"
-out="$ic -A output"
-fw="$ic -A forward"
-
-#modprobe ip_masq_autofw
-#modprobe ip_masq_cuseeme
-#modprobe ip_masq_ftp
-#modprobe ip_masq_irc
-#modprobe ip_masq_mfw
-#modprobe ip_masq_portfw
-#modprobe ip_masq_quake
-#modprobe ip_masq_raudio
-#modprobe ip_masq_user
-#modprobe ip_masq_vdolive
-
-$ic -F  input
-$ic -F  output
-$ic -F  forward
-
-
-echo Default policy
-
-$ic -P  input  REJECT
-$ic -P  output ACCEPT
-$ic -P  forward  DENY  # pings return 
-
-$ic -X
-
-######### Incoming
-
-echo Incoming
-
-$in -i lo -j ACCEPT
-
-$in -s 0.0.0.0/0 bootpc -d 255.255.255.255 bootps  -p udp -j ACCEPT # DHCP op broadcast
-$in -s 0.0.0.0/0 bootpc -d 255.255.255.255 bootps  -p tcp -j ACCEPT # DHCP op broadcast
-
-$in -d 224.0.0.5 -p 89 -j ACCEPT  # OSPF
-$in -d 224.0.0.6 -p 89 -j ACCEPT  # OSPF
-$in -d 224.0.0.5 -p 2 -j ACCEPT  # OSPF
-$in -d 224.0.0.6 -p 2 -j ACCEPT  # OSPF
-
-for if in $wifs_major
-do
-  ip=`$nm $if i`
-  $in -s 0.0.0.0/0 bootpc -d $ip bootps -i $if  -p udp -j ACCEPT # DHCP op eigen ip
-  $in -s 0.0.0.0/0 bootpc -d $ip bootps -i $if  -p tcp -j ACCEPT # DHCP op eigen ip
-  $in -s ! $wnet -i $if -j DENY -l       # Spoofing; alleen wnet ip wifs.
-done
-
-for p in $tports
-do
-  $in -d $gwif_ip $p -p tcp -j ACCEPT   # tports op gwif_ip
-  $in -d $wif_ip  $p -p tcp -j ACCEPT   # tports op wif_ip
-done
-
-for p in $uports
-do
-  $in -d $gwif_ip $p -p udp -j ACCEPT   # uports op gwif_ip
-  $in -d $wif_ip  $p -p udp -j ACCEPT   # uports op wif_ip
-done
-
-
-$in -d $good_net -s $wnet ! -y -p tcp -j ACCEPT  # established sessions
-
-$in -d $gwif_ip ! -y -p tcp -j ACCEPT     	 # established sessions
-for if in $wifs
-do
-   ip=`$nm $if i`
-   $in -d $ip -s $wnet ! -y -p tcp -j ACCEPT  # established sessions
-done
-
-
-for if in $wifs $gw_if
-do
-  ip=`$nm $if i`
-
-  $in -d $ip 53 -p udp -j ACCEPT	  	# named wel, 
-  $in -d $ip --sport 53 -p udp -j ACCEPT  	# named wel.
-  # Want named source adres wordt door named gekozen afhankelijk van de if.
-
-  $in -d $ip -p icmp -j ACCEPT			# icmp wel.
-
-  $in -d $ip -p 89 -j ACCEPT  # OSPF
-  $in -d $ip -p 2 -j ACCEPT  # OSPF
-
-  $in -d $ip -j REJECT -l # Vangnet
-done
-
-$in -d $wnet -j ACCEPT   			 # dst wireless=okay
-
-if [ "$gw_open" != "open" ]
-then
-  for if in $wifs_major
-  do
-  	$in -d ! $good_net -s $wnet -i $if -j ACCEPT  # wel naar Internet, niet naar goodnet.
-  done
-fi
-
-#$in --dport 137:139 -j REJECT # Netbios
-$in -j REJECT -l # vangnet
-
-######### Forward
-
-echo forwarding
-
-echo 1 > /proc/sys/net/ipv4/ip_forward  
-
-$fw -d $gwif_ip ! -y -p tcp -j ACCEPT     	 # established sessions
-for if in $wifs
-do
-   ip=`$nm $if i`
-   $fw -d $ip -s $wnet ! -y -p tcp -j ACCEPT  # established sessions
-done
-
-$fw -s $good_net -d $wnet -j MASQ   	# dst wireless=okay
-
-if [ "$gw_open" != "open" ]
-then
- $fw -d ! $good_net -i $gw_if -j MASQ	# naar Internet = okay
-fi
-
-$fw -j REJECT -l # vangnet
-
-
-#########
-
-
-#ipchains -nxvL
-
Index: ols/g_list.pl
===================================================================
--- /tools/g_list.pl	(revision 7291)
+++ 	(revision )
@@ -1,313 +1,0 @@
-#!/usr/bin/perl -w
-#
-# Copyright 2005 Stichting Wireless Leiden
-# Rick van der Zwet
-#
-
-# Config located at other file
-# my $conf_file="/home/genesis/tools/genesis.conf";
-# do($conf_file) || die("Cann't open $conf_file");
-die "Run with the preamble in cgi-bin"
-       unless defined $conf_file;
-
-my $HTML=1;
-
-#laden van tool file
-do($toolfile) || die("Cann't open $toolfile");
-
-#gebruik van simple subje om ervoor te zorgen dat de print netjes in het
-#programma gestopt kan worden
-sub printline {
-  print "$_[0]\n";
-};
-
-
-#REQUEST parsen
-$request=$ENV{'REQUEST_URI'};
-if( $request=~/cgi-bin\/g_list.pl\/(.*)$/) {
-  ($node,$file)=split(/\//,$1);
-  $title="$node $file";
-}
-else {
-  $title="listing";
-};
-
-
-#controleer wat de browser is
-#en zorgen dan er de nodige tags geprint worden
-$browser=$ENV{'HTTP_USER_AGENT'};
-if( $browser=~/curl|wget|fetch/i) {
-  $HTML=0;
-  print "Content-type: text/plain\n\n";
-}
-else {
-  $HTML=1;
-  printline("Content-type: text/html\n\n");
-  printline("<HTML>");
-  printline("<TITLE>Genesis $title</TITLE>");
-  printline("<BODY BGcolor=white>");
-};
-
-
-#als geen node gespecificeerd dan kijken of svn geupdate is gevraagd
-if( $node eq '') {
-  if( $ENV{"QUERY_STRING"}=~/update/i) {
-    printline("<H2>Please wait while updating svn...</H2><P><PRE>");
-    select(STDERR); $| = 1;     # make unbuffered
-    select(STDOUT); $| = 1;     # make unbuffered
-    system("$svn update $home");
-    printline("</PRE>");
-    printline("<H2>Done.<H2><P>");
-    printline("Click <A HREF=$source>here</A>");
-    printline("if you're not forwarded automaticly in 5 seconds.<P>");
-    printline("<META HTTP-EQUIV=REFRESH CONTENT=5;URL=$source>");
-  }
-  else {
-    g_list( );
-  };
-}
-else {
-  if( $file eq '') {
-    foreach $file ( sort @filelist) {
-      if( $HTML) {
-        print "$file<BR>\n";
-      }
-      else {
-        print "$file\n";
-      };
-    };
-  }
-  elsif( $file eq 'info') {
-    g_info($hostname);
-  }
-  elsif( $file eq 'config') {
-    g_print($hostname);
-  }
-  else {
-    foreach my $tmpFile ( sort @filelist) {
-      if( $file eq $tmpFile ) {
-        g_generate($file);
-      };
-    };
-  };
-};
-
-#plaats de sluit HTML tags
-if( $HTML) {
-  print <<EOF;
-</BODY>
-</HTML>
-EOF
-}
-
-
-#Het opbouwen van het begin scherm
-sub g_list {
-  my $version = 1;
-  $version = $1 if $ENV{"QUERY_STRING"}=~/version=(\d+)/i;
-
-  if( $HTML) {
-    my $svn_version=svn_version("$ndir");
-    if( $svn_version=~/Last Changed Rev: (\d+)/) {
-      $revision=$1;
-    };
-    printline("<H1>Genesis config (revision: $revision):</H1><P>\n<PRE>");
-    printline("$svn_version");
-    printline("</PRE>");
-    printline("<FORM METHOD=get ACTION=$source>");
-    printline('<INPUT TYPE="submit" NAME="Update" VALUE="Update">');
-    printline("</FORM>");
-    printline("<TABLE BORDER=1>");
-  };
-
-  opendir(DIR, $ndir) || die "can't opendir $home: $!";
-  @dirs = grep { /^[^\.]/ && -d "$ndir/$_" } readdir(DIR);
-  closedir DIR;
-  foreach $dir (sort @dirs) {
-    if( $dir=~/attic/ ) {
-      next;
-    };
-    my $node = $dir;
-    if( ! $HTML ) {
-      print "$node\n";
-    }
-    else {
-      printline("<TR><TD><A HREF=g_list.pl/$node/config>$node</A></TD>");
-      foreach $file (sort @filelist) {
-        printline("<TD><A HREF=g_list.pl/$node/$file>$file</A></TD>\n");
-      };
-    };
-  };
-  if( $HTML ) {
-    printline("</TABLE><P>");
-  };
-};
-
-#ophalen svn versie
-sub svn_version {
-  local($file,$char)=@_;
-  local($svn_version);
-  $svn_version=`$svn info $file`;
-  if( $char ne '' ) {
-    $svn_version=~s/^([^$char].*)/$char $1/mgi;
-  };
-  return($svn_version);
-};
-
-# Print info on this node; version of the OS
-# expected, etc..
-sub g_info {
-  my $config="$ndir/$node/$configfile";
-  parse_config($config);
-
-  $release = 'unknown' unless $release;
-  $node_config_version = 0 unless $node_config_version;
-  $genesis_control = 'NO' unless $genesis_control;
-  $OS = 'Unknown' unless $OS;
-  print <<"EOM";
-$OS $release $node_config_version $genesis_control
-#
-# Operating system release:	$OS on $release
-# Node Config script version:	$node_config_version
-# Under Gensis control:		$genesis_control
-# 
-EOM
-}
-
-#netjes de configuratie printen
-sub g_print {
-  my $config="$ndir/$node/$configfile";
-  parse_config($config);
-    
- printline("<H1>Genesis configuratie voor: $node</H1><P>");
- printline("<PRE>" . svn_version($config) . "</PRE><P>");
-
-
- my $TP='';
- if( $tproxy !~ m/no/i ) {
-   $TP .= "\n";
-   $TP .= "Tproxy on cidr range $tproxy";
-   $TP .= "<b>WARNING - specification propably wrong - should be a cidr</b>"
-   unless $tproxy =~ m/\d+\.\d+\.\d+\.\d+\/\d+/;
- };
-
- printline("<TABLE BORDER=1><TR><TD COLSPAN=4><PRE>");
- printline("master_ip=$master_ip");
- printline("AGGREGATE=$AGGREGATE");
- printline("");
- printline("gw_open=$gw_open");
- printline("nodetype=$nodetype");
- printline("nodename=$nodename");
- printline("");
- printline("NS_forward=$NS_forward");
- printline("NS_resolv=$NS_resolv");
- printline("");
- printline("location=$location");
- printline("DISK=$DISK");
- printline("");
- printline("X=$X");
- printline("Y=$Y");
- printline("");
- printline("Operating system: $OS / $release");
- printline("Config management: Version $node_config_version, Used: $genesis_control");
- printline("");
- printline("$TP");
- printline("</PRE></TD></TR>");
-
- foreach $if( sort keys %config) {
-   if( $if=~/^(.*):\d+/ ) {
-     $subs{$1}++;
-   };
- };
-
- foreach $if( sort keys %config) {
-   if( $if=~/^([^:]+)/ ) {
-     $mymain=$1;
-   }
-   else {
-     $mymain='';
-   };
-   
-   if( $if!~/:\d+/ ) {
-     $main=1;$cc='66'
-   }
-   else {
-     $main=0;
-     $cc='cc';
-   };
-   
-   if(! ($ip=$IP{$if}) ) {
-     $ip='dhcp?';
-   };
-   if( $TYPE{$if}=~/wireless/ ) {
-     $color="#${cc}FFFF";
-   };
-   if( $TYPE{$if}=~/ethernet/) {
-     $color="#FFFF${cc}";
-   };
-   
-   $cfg=$config{$if};
-   $cfg=~s/(.*KEY.*=).*/${1}***********/;
-   $cfg=~s/(.*PWD.*=).*/${1}***********/;
-   $cfg=~s/(.*CODE.*=).*/${1}***********/;
-   $cfg=~s/(.*PASS.*=).*/${1}***********/;
-
-   if( $main) {
-     printf "<TR bgcolor=$color><TD ROWSPAN=%d VALIGN=TOP><B>$if</TD>\n",(1+$subs{$if})*3,$subs{$if};
-     $c=4;
-   }
-   else {
-     $c=3;
-     print "<TR bgcolor=$color>";
-   };
-   $cfg=~s/</&lt;/gi;
-   $cfg=~s/>/&gt;/gi;
-
-   printline("<TD>$if</TD><TD><B>$ip</TD><TD>$DESC{$if}($SDESC{$if})</TD>");
-   printline("<TR><TD COLSPAN=$c><PRE>");
-   printline("$cfg");
-   printline("</PRE></TD>");
-   printline("<TR><TD COLSPAN=$c>&nbsp;</TD>");
- };
- printline("</TABLE>");
-};
-
-
-
-#Generen config
-sub g_generate {
-  my $file=$_[0];
-  $config="$ndir/$node/$configfile";
-  $svn_versiont=svn_version($toolfile,$char);
-  $svn_versionc=svn_version($config,$char);
-
-  if( $svn_versiont=~/Last Changed Rev: (\d+)/ ) {
-    $tool_rev=$1;
-  };
-  if( $svn_versionc=~/Last Changed Rev: (\d+)/ ) {
-  $config_rev=$1;
-  };
-
-  if( $tool_rev >= $config_rev) {
-    $svn_version=$svn_versiont . $svn_versionc;
-  }
-  else {
-    $svn_version=$svn_versionc;
-  };
-
-  if( $HTML) {
-    printline("<H1>Genesis $file voor: $hostname</H1><P>");
-  };
-
-  parse_config($config);
-  $pr=do_it($file);
-
-
-  if( $HTML ) {
-    $pr=~s/</&lt;/gi;
-    printline("<PRE>$pr</PRE>");
-  }
-  else {
-    print $pr;
-  };
-};
Index: ols/inc2minimal.pl
===================================================================
--- /tools/inc2minimal.pl	(revision 7291)
+++ 	(revision )
@@ -1,68 +1,0 @@
-#!/usr/bin/perl
-$|++;
-require "conf.inc"
-	or die "Did you run conf2inc.pl > conf.inc ??";
-
-# Make a reverse mapping..
-my %ips = ();
-
-foreach my $node (sort keys %$VAR1) {
-	foreach my $iface (keys %{ $VAR1->{$node}->{ifaces} }) {
-		my $v = $VAR1->{$node}->{ifaces}->{$iface};
-		next unless defined $v->{IP};
-		$ip = $v->{IP};
-		die "IP of $node:$iface malformed ($ip)"
-			unless $ip =~ m/([\d\.]+)\/(\d+)/;
-		$pip = $1;
-		$mask = $2;
-
-		my %info=();
-		if ($iface =~ m/([^:]+):(.*)/) {
-			my ($a,$b)=($1,$2);
-			%info = %{$VAR1->{$node}->{ifaces}->{$a}};
-		};
-		foreach my $k (keys(%{$v})) {
-			$info{ $k } = $v->{$k};
-		};
-		
-		$ips{ $pip } = \%info;
-		# print "$node	$iface	$pip	$info{ESSID}\n";
-	}
-}
-
-foreach my $node (sort keys %$VAR1) {
-	my $vals = $VAR1->{$node};
-	print qq|<node id="$node" ip="$vals->{master_ip}>
-	<location>$vals->{location}</location>
-|;
-	foreach my $iface (sort keys(%{$vals->{ifaces}})) {
-		my $v = $vals->{ifaces}->{$iface};
-		print qq|	<iface\tid="$iface"\n|;
-		
-		if ($v->{TYPE} =~ m/wireless/i) {
-			my $ssid = "ERROR!";
-			if ($v->{MODE} =~ m/master/i) {
-				print qq|\t\tchannel="$v->{CHANNEL}"\n|;
-				$ssid = $v->{ESSID};
-				print "\t\tmaster\n";
-			} else {
-				# Channel vollows; ESSID is
-				# that of the peer.
-				my $pip = $v->{POINT_TO_POINT};
-				if (defined $ips{ $pip }) {
-					$ssid = $ips{$pip}->{ESSID};
-				} else {
-					$ssid = 'undefined ('.$pip.')';
-				}
-			};
-			print qq|\t\tssid="$ssid"\n|;
-		}
-		if ($v->{DHCP} =~ m/(\d+)\-(\d+)/) {
-			my $x = $2 - $1;
-			print qq|\t\tdhcp="$x"\n|;
-		};
-		print "\t\t>\n";
-		print qq|	</iface>\n|;
-	}
-	print qq|</node>\n|;
-};
Index: ols/nofirewall
===================================================================
--- /tools/nofirewall	(revision 7291)
+++ 	(revision )
@@ -1,21 +1,0 @@
-#! /bin/bash 
-# -x
-#
-#
-
-modprobe ipchains
-ic='/sbin/ipchains'
-
-in=input
-out=output
-fw=forward
-
-$ic -F  $in
-$ic -F  $out
-$ic -F  $fw
-
-$ic -P  $in  ACCEPT
-$ic -P  $out ACCEPT
-$ic -P  $fw  ACCEPT 
-
-
Index: ols/wl-runlvl
===================================================================
--- /tools/wl-runlvl	(revision 7291)
+++ 	(revision )
@@ -1,59 +1,0 @@
-#!/bin/sh
-# Startup script for wireless
-#
-# chkconfig: 2345 95 05
-# description: Run cron jobs that were left out due to downtime
-
-# Source function library.
-. /etc/rc.d/init.d/functions
-
-[ -f /etc/wl/wleiden.pl ] || exit 0
-
-prog="wleiden.pl"
-
-start() {
-    echo -n $"Starting $prog: " 
-    /etc/wl/wleiden.pl start
-    RETVAL=$?
-    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/wleiden
-    echo
-    return $RETVAL
-}
-
-stop() {
-    /etc/wl/wleiden.pl stop
-    RETVAL=$?
-    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/wleiden 
-    return $RETVAL
-}
-
-case "$1" in
-	start)
-	    start
-	    ;;
-	
-	stop)
-	    stop
-	    ;;
-	
-	status)
-	    status wleiden
-	    ;;
-	restart)
-	    stop
-	    start
-	    ;;
-	condrestart)
-	    if test "x`pidof wleiden`" != x; then
-		stop
-		start
-	    fi
-	    ;;
-	
-	*)
-	    echo $"Usage: $0 {start|stop|restart|condrestart|status}"
-	    exit 1
-
-esac
-
-exit 0
Index: ols/wleiden.pl
===================================================================
--- /tools/wleiden.pl	(revision 7291)
+++ 	(revision )
@@ -1,1125 +1,0 @@
-
-#
-#
-#  aug 2002, jasper\@WirelessLeiden.NL
-#
-
-
-$now=localtime($unow=time());
-
-$config='/etc/wl/wleiden.conf';
-$domain='wLeiden.NET';
-
-$ifconfig='/sbin/ifconfig';
-$iwconfig='/sbin/iwconfig';
-$ipchains='/sbin/ipchains';
-$indexmaker='/usr/bin/indexmaker';
-$sroute='/sbin/route';
-$OSPFPWD='huppel';
-$separator=';';
-$author='feb 2003 jasper@WirelessLeiden.NL';
-$wicontrol='/usr/sbin/wicontrol';
-
-if ($functions_only) {goto functions;}
-$source='/etc/wl/wleiden.pl';
-
-do($config) || die;
-parse_config();
-
-
-$hostname=`/bin/hostname |cut -d . -f 1`;chomp($hostname);
-$maxmask= pack("CCCC", 255, 255, 255, 255);
-
-
-if (! $ARGV[0]) {die "use start/stop/startall";}
-
-if ($ARGV[1]=~/debug/i) {$DEBUG=1;}
-if ($ARGV[0]=~/start/i)
-{
-
-######################################################################
-do_it();
-
-open_files();
-$nwcfg.="$indexmaker /etc/mrtg/mrtg.cfg> /var/www/html/mrtg/index.html 2> /dev/null\n";
-
-print_files();close_files();
-
-system("chmod 755 /etc/wl/nwcfg.sh;/etc/wl/nwcfg.sh");
-
-if ($DEBUG) {die "DEBUGGING!";}
-
-if ($DEBUG) {print "\nDEBUG: making mrtg index.\n";}
-
-changeline("/etc/sysconfig/dhcpd","DHCPDARGS","DHCPDARGS=\"$dhcpints\"");
-
-#if ($DEBUG) {print "\nDEBUG: reloading firewall.\n";}
-#$nwcfg.="/usr/local/sbin/firewall\n";
-
-if ($DEBUG) {print "\nDEBUG: restarting daemons.\n";}
-
-if ($ARGV[0]=~/startall/) {$restart='restart';}
-else  {$restart='condrestart';}
-$nwcfg.="/etc/init.d/dhcpd $restart\n";
-$nwcfg.="/etc/init.d/zebra $restart\n";
-$nwcfg.="/etc/init.d/ospfd $restart\n";
-$nwcfg.="/etc/init.d/httpd $restart\n";
-$nwcfg.="/etc/init.d/named $restart\n";
-
-
-########################################################################
-} else  # geen start -> stop
-{
-  $nwcfg.="$ifconfig lo:1 down\n";
-
-  foreach $if (keys %config)
-  {
-     $nwcfg.="$ifconfig $if down\n";
-  }
-}
-
-
-exit;
-
-########################################################################
-
-functions:
-
-$ahum=1;
-
-sub do_it
-{
-  if ($OS=~/FreeBSD/i) {$FreeBSD=1;}
-  elsif ($OS=~/Linux/i) {$Linux=1;}
-
-init_files();
-
-#system("/sbin/modprobe ipv6");
-#system("/sbin/modprobe ipchains");
-
-$nwcfg.="$ifconfig lo:1 down\n";
-#print "ifconfig lo:1 $master_ip\n";
-#$nwcfg.="$ifconfig lo:1 $master_ip netmask 255.255.255.255\n";	# altijd up!
-
-$last='';
-foreach $if (sort {$b <=> $a} keys %config)
-{
-  if ($TYPE{$if}=~/wireless/) {$last=$if}
-} if ($last) {iwconfig("$last &> /dev/null");} # Laatste het eerste...
-
-$keys=1;
-foreach $if (sort keys %config)
-{
-   if ($if=~/^([^:]+):(\d+)/) {$mymain=$1;$mysub=$2;} else {$mymain='';}
-
-   if ($functions_only<1) {print "Doing interface: $if IP: $IP{$if}\n";}
-
-   if ($if!~/:\d+/) {$main=1;} else {$main=0;}
-
-					##################### DOWN
-   if ($DOWN{$if}=~/yes/) 
-   {   print "$if configured DOWN.\n";
-       $nwcfg.="$ifconfig $if 127.0.0.1 down\n";
-
-       if ($main)
-       {       
-       $zebra1.=sprintf <<EOZ3;
-
-interface $if
- description $DESC{$if}
- ip address 127.0.0.1/0
- shutdown
-
-EOZ3
-       $ospfd2{$if}.=" interface $if\n\n";
-       }
-       next;   # Interface down.
-   }
-					##################### DOWN
-   if ($main)
-   {
-    $if=~/(\d+)/;$ifnum=$1;
-    $nick="${nodename}$ifnum.$domain";
-
-    if ($TYPE{$if}=~/wireless/) 
-    {
-
-     if ($SDESC{$if}) {$nick="$SDESC{$if}.$nick";}
-#print "$nick\n";
-     if (iwconfig("$if mode $MODE{$if}"))
-     {
-      if ($DEBUG) {print "\nDEBUG: iwconfig $if mode $MODE{$if} essid $ESSID{$if} nick $nick ap $AP{$if} channel $CHANNEL{$if} sens $SENS{$if} txpower $TXPOWER{$if} rate $RATE{$if}\n";}
-      iwconfig("$if essid $ESSID{$if}");
-      iwconfig("$if nick $nick");
-
-     $freebsd.=sprintf<<EOFB33;
-$wicontrol -i $if -s $nick	 # Nickname
-#$wicontrol -i $if -t 7		 # TXrate
-$wicontrol -i $if -P 0		 # PowerSave
-$wicontrol -i $if -Z		 # Zero SNR cache
-EOFB33
-      if ($MODE{$if}=~/master/i)
-      {
-     $freebsd.=sprintf<<EOFB3;
-$wicontrol -i $if -p 6		 # hostap mode
-$wicontrol -i $if -n $ESSID{$if} # network name
-$wicontrol -i $if -q $ESSID{$if} # ESSID
-$wicontrol -i $if -c 1		 # broadcasting essid on
-EOFB3
-      } else {
-     $freebsd.=sprintf<<EOFB4;
-$wicontrol -i $if -p 1		 # Client mode (managed)
-$wicontrol -i $if -n $ESSID{$if} # ESSID
-EOFB4
-      }
-      if ($AP{$if}) 		{iwconfig("$if ap $AP{$if}");}
-      
-if ($MODE{$if}=~/master/) { 
-	if ($CHANNEL{$if})  {
-		$freebsd.="$wicontrol -i $if -f $CHANNEL{$if}		# Channel\n";
-	} else {
-		$freebsd .= "# WARNING  - master but no channel defined.\n";
-	};
-} else {
-	$freebsd.="# No channel - client follows\n# $wicontrol -i $if -f 0		# Channel\n";
-}
-				
-      if ($SENS{$if}) 		{iwconfig("$if sens $SENS{$if}");}
-      if ($TXPOWER{$if}) 	{iwconfig("$if txpower $TXPOWER{$if}");}
-      if ($RATE{$if}) 		{iwconfig("$if rate $RATE{$if}");}
-     } #else { print "ERROR: Could not configure interface $if\n";next;}
-
-     $rcconf.="\nifconfig_$if=\"inet $IP{$if} -promisc\"\n";
-     #$rcconf.="ifconfig_$if=\"inet $IP{$if} -promisc \"\n  ssid $ESSID{$if} \\"\n";
-     #if ($CHANNEL{$if}) 	{$rcconf.="  channel $CHANNEL{$if}";}
-     #$rcconf.="\\\n  stationname $nick\"\n";
-     #if ($MODE{$if}=~/master/) 		{$rcconf.="#mediaopt hostap\n";}
-     #$rcconf.="\n";
-
-     $freebsd.="\n";
-    } # if wireless
-    mrtg1();
-    if ($OS=~/FreeBSD/)
-{
-       $ospfd2{$if}.=sprintf <<EOO2;
-
-interface $if
- ip ospf message-digest-key 1 md5 $OSPFPWD
- ip ospf authentication message-digest
- ip ospf dead-interval 180
-EOO2
-
-   $keys++;  
-
-      $zebra.=sprintf  <<EOZ2;
-
-interface $if
- description $DESC{$if}
- no shutdown
-EOZ2
-}
-
-    }                     ######################   MAIN
-
-    if ($OS=~/Linux/)
-{
-       $ospfd2{$if}.=sprintf <<EOO21;
-
-interface $if
- ip ospf message-digest-key 1 md5 $OSPFPWD
- ip ospf authentication message-digest
-EOO21
-   $keys++;  
-
-      $zebra.=sprintf  <<EOZ21;
-
-interface $if
- description $DESC{$if}
- no shutdown
-EOZ21
-}
-
-   if ($IP{$if})
-   {
-    $zebra.=sprintf " ip address $IP{$if}\n";
-    ($ip,$netmask,$broadcast,$network,$width)=calc_ip($IP{$if});
-    if ($netmask == '0.0.0.0') 
-{print "Forgot netmask in config $hostname $if: $IP{$if}!\n";
-die "Forgot netmask in config $hostname $if: $IP{$if}!\n";
-}
-
-#    if ($DEBUG) {print("\nDEBUG: $ifconfig $if $ip netmask $netmask broadcast $broadcast up\n");}
-    if ($DEBUG) {print("\nDEBUG: $if $ip $netmask $network $broadcast\n");}
-
-    if (! $main) {$nwcfg.="$ifconfig $mymain up\n";}
-    $nwcfg.="$ifconfig $if $ip down\n";
-    $nwcfg.="$ifconfig $if $ip netmask $netmask broadcast $broadcast up\n";
-    if ($main)
-    {
-	if ($TYPE{$if}!~/wireless/) {$rcconf.="\nifconfig_$if=\"inet $IP{$if}\"\n";}
-    } else {$rcconf.="ifconfig_${mymain}_alias${mysub}=\"inet $IP{$if}\"\n";}
-   }
-   if (($OS=~/Linux/) || ($main)) {$zebra.= "\n";}
-
-   if ($ROUTE{$if})
-   {
-	if ($DEBUG) {print "\nDEBUG: ROUTE: $ROUTE{$if}\n";}
-
-	foreach $r (split(/$separator/,$ROUTE{$if}))
-	{
-	   if ($DEBUG) {print "\nDEBUG: ROUTE2: $r\n";}
-	    
-	   $r=~/([^\/ ]+)\/?(\S+)\s+(\S+)/;
-	   $R="$1/$2";$gw=$3;$nm=$2;
-	   ($route,$r_netmask,$r_broadcast,$r_network,$r_width)=calc_ip($R);
-	   if ($R eq '0.0.0.0/0') 
-	   {   $doit="$sroute add default gw $gw dev $mymain";
-	       $rcconf.="\ndefaultrouter=\"$gw\"\n\n";
-	   }
-           elsif ($nm eq 32)      {$doit="$sroute add $route gw $gw dev $mymain";}
-	   else {$doit="$sroute add -net $route netmask $r_netmask gw $gw dev $mymain";}
-
-	   if ($DEBUG) {print "\nROUTE3: $doit\n";}
-	   $nwcfg.="$doit\n";
-	   if ($R eq '0.0.0.0/0') {$ospfd3.=" default-information originate\n"}
-	   else
-	   {
-		$area=get_area($R);
-		$ospfd4.="! static route $R\nnetwork $R area $area\n\n";
-		$NW{$area}.="$network/$width ";
-	   }
-	   $zebra.="ip route $r\n";
-	}	
-   }
-
-   ($ip,$netmask,$broadcast,$network,$width)=calc_ip($IP{$if});
-   if (($DHCP{$if}) && ($DHCP{$if}!~/off|no/i))  
-   {
-       ($from,$upto)=split(/-/,$DHCP{$if});
-       $ip=~/(^\d+\.\d+\.\d+)\.\d+$/;
-       $dip=$1;
-       $dhcp.=sprintf <<EOD2; 
-
-	#
-	#  $if $DESC{$if}
-	#
-	subnet $network netmask $netmask {
-  		range  $dip.$from $dip.$upto;
-  		option broadcast-address $broadcast;
-  		option subnet-mask $netmask;
-  		option routers $ip;
-		$DHCP_STATIC{$if}
-	}   
-
-EOD2
-	if ($dhcpints!~/$mymain/) {$dhcpints.=" $mymain";}
-     }  # DHCP
-     else
-     {
-	if ( ($main) ) #|| ($DHCP{$mymain}=~/off|no/i))
-	{  # niet als main wel dhcp heeft.
-	  $dhcp.="subnet $network netmask $netmask {not authoritative; } # $if\n\n";
-	}
-     }
-     if ($OSPF_NEIGHBORS{$if}=~/no/i) 
-     {
-	if ($main) {$OSPF_PASSIVE{$if}=1;}
-     }
-
-     if ($OSPF_AREA{$if}!~/no/i)
-     {
-    	($ip,$netmask,$broadcast,$network,$width)=calc_ip($IP{$if});
-
-	  if ($IP{$if}) 
-	    { 
-#		if (($OSPF_NEIGHBORS{$if}!~/no/) || 
-		if ($OSPF_AREA{$if} eq '') {$area=get_area($network);}
-		else {$area=int($OSPF_AREA{$if});}
-		 
-		$ospfd4.="! $if ($DESC{$if})\nnetwork $network/$width area $area\n\n";
-		$NW{$area}.="$network/$width ";
-	    }
-
-	 if ($OSPF_BROADCAST{$if}=~/no/i)
-	 {
-	   if ($main)
-	   {
-#if ($DEBUG) {print "DEBUG: OSPF_NEIGHBORS{$if}: ($OSPF1_NEIGHBORS{$if})\n";}
-	   $OSPFD_NONBROADCAST{$if}=1;
-	   }
-	   if ($OSPF_NEIGHBORS{$if}!~/no/i)
-           {
-	     foreach $n (split(/[\s$separator]+/,$OSPF_NEIGHBORS{$if}))
-             {
-                if ($DEBUG) {print "DEBUG: OSPF2_NEIGHBOR{$if}: [$n]\n";}
-                $ospfd5.="! $if link: $SDESC{$if}\n neighbor $n\n\n";
-	     }
-	     if ($main) {$OSPF_PASSIVE{$if}=0;}
-	     else {$OSPF_PASSIVE{$mymain}=0;}
-           } #ospf_neighbors
-	 }
-    	
-     } # ospf_area
-
-     if ($POINT_TO_POINT{$if})
-     {
-	   foreach $p (split(/$separator/,$POINT_TO_POINT{$if}))
-	   {
-		mrtg2();
-	   } #foreach $pointtopoint	
-     } # pointopoint
-} # foreach if
-
-foreach $if (sort keys %config)
-{
-   if ($if!~/:\d+/) {$main=1;} else {$main=0;}
-   if ($main)
-   {
-	$ospfd2.=$ospfd2{$if};
-	if ($OSPF_PASSIVE{$if})
-	{
-	  $ospfd22.=" passive-interface $if\n";
-	}
-	if ($OSPFD_NONBROADCAST{$if})
-	{
-	   $ospfd2.= " ip ospf network non-broadcast\n";
-	}
-	if ($OSPF_COST{$if})
-	{
-	  $ospfd2.=" ip ospf cost $OSPF_COST{$if}\n";
-	}
-
-   }
-}
-
- $zebra.= "\n\nlog file /var/log/zebra.log\n\n";
-
-foreach $area (keys %NW)
-{
-  if ($area eq 0) {next;}
-  $nwa=0xffffffff;
-  foreach $nw (split(/\s+/,$NW{$area}))
-  {
-     ($ip,$width)=split(/\//,$nw);
-     ($a,$b,$c,$d)=split(/\./,$ip);
-     ($II)=($a<<24)+($b<<16)+($c<<8)+$d;
-     if ($width eq 32) {$nm=0xffffffff;}
-     else {$nm=0xffffffff-1<<(31-$width);}
-
-     $II=$II & $nm;
-     $nwa=$nwa & $II;
-#     $ospfd.=sprintf ("NW-$area: $nw ==> %08x enne %08x\n",$II,$nwa);
-  }
-  $nwa=itoadr($nwa);
-
-  if ($AGGREGATE) {$agg=$AGGREGATE;}
-  else {$agg=21;}
-
-  if (($nwa!~/^172\.16\./) && ($area > 0))
-  { $ospfarea.="area $area range $nwa/$agg substitute $nwa/$agg\n"; }
-
-  $ospf21.="! area $area authentication message-digest\n";
-}
-
-
-$ospfd.=sprintf <<EOOL;
-
-!  ================>   interfaces  <================
-
-$ospfd2
-
-!  ================>   OSPF router  <================
-router ospf
- ospf router-id $master_ip
- $ospfd21
-
- passive-interface lo0
-$ospfd22
-
-!default
-$ospfd3
-
-$ospfarea
-
-!  ================>   networks  <================
-$ospfd4
-
-!  ================>  neighbors  <================
-$ospfd5
-
-log file /var/log/ospf.log
-
-EOOL
-# $rcconf.="\n\n" . $freebsd;
-}
-
-sub get_area
-{
-  local($IP)=@_;
-  local($range);
-  local($ip,$netmask,$broadcast,$network,$width);
-  local($a,$b,$c,$d)=split(/\./,$IP);
-  local($II)=($a<<24)+($b<<16)+($c<<8)+$d;
-  local($ii,$ip,$nm,$I2);
-
-#  for ($i=0;$i<=$maxareas;$i++)
-#  {
-#    $ii=$II[$i];
-#    $nm=$NM[$i];
-#    $I2=$II & $nm;    
-##$ospfd.=sprintf "i=$i\t $RANGE[$i]\t ii=$ii\t nm=$nm\t I2=$I2 $II $IP $a,$b,$c,$d\n";
-#    if ($I2 == $ii) {return($AREA[$i]);}    
-#  }
-#  return(12345);
-
-   $area=1;
-   if ($b eq 16) {$area=0;}
-   elsif ($c < 128) {$area=($b * 10)}
-   else {$area=(1+($b*10));}
-   if ($area > 255) {$area/=10;}
-   return($area);
-}
-
-
-sub read_areas
-{
-   $maxareas=0;
-   open(AC,"$home/areas.conf") || die;
-   while (<AC>)
-   {
-	chomp();
-	s/#.*$//;
-        if (! $_) {next;}
-	($area,$range,$desc,$counter,$junk)=split(/\s+/);
-	$AREA[$maxareas]=$area;
-	$RANGE[$maxareas]=$range;
-	$DESC[$maxareas]=$desc;
-
-        ($ip,$width)=split(/\//,$range);
-        ($a,$b,$c,$d)=split(/\./,$ip);
-        $ii=($a<<24)+($b<<16)+($c<<8)+$d;
-    
-        if ($width eq 32) {$nm=0xffffffff;}
-        else {$nm=0xffffffff-1<<(31-$width);}
-        $II[$maxareas]=$ii;
-        $NM[$maxareas]=$nm;
-
-	$maxareas++;
-   }
-   close(AC);
-}
-
-sub parse_config
-{
-  foreach $if (keys %config)
-  {
-     $cfg=$config{$if};
-if (! $html) {print "Parsing interface: $if\n";}
-     while ($cfg)
-     {
-	$cfg=~s/^([^\n\r]+)[\r\n]*//m;
-	$line=$1;
-	$line=~s/\s*#.*//;
-	if ((($name,$value)=split(/=/,$line)) eq 2)
-	{
-	   if ($name eq 'ESSID') {$value=lc($value);}
-#print "VAL($name)=$value\n";
-	   $doit="if (exists(\$$name\{\"$if\"\})) {\$$name\{\"$if\"\}.=\"$separator$value\";} else {\$$name\{\"$if\"\}.=\"$value\";}";
-#print "DOIT: [$doit]\n";
-	   eval($doit);
-	}
-#print "CFG:[$cfg]\n";
-	$cfg=~s/[\r\n]*$//m;
-     }
-  }
-if ($functions_only<1) {print "Done parsing config.\n";}
-}
-
-sub iwconfig
-{
-  local($line)=@_;
-  $nwcfg.="$iwconfig $line\n";
-
-}
-
-sub ipchains
-{
-  local($line)=@_;
-  return(system("$ipchains $line"));
-}
-
-#($a,$b,$c,$d) = unpack('C4',$addr[0]);
-
-#$IP = pack("CCCC", 152, 2, 128, 184);  # create IP address
-#($var1, $var2, $var3, $var4) = unpack("CCCC", $IP);  #inverse of the above
-
-
-
-sub calc_ip
-{  local($i)=@_;
-  local($a,$b,$c,$d);
-  local($ip,$width)=split(/\//,$i);
-  local($a,$b,$c,$d)=split(/\./,$ip);
-  local($ii)=($a<<24)+($b<<16)+($c<<8)+$d;
-
-  if ($width eq 32) {$nm=0xffffffff;} 
-  else {$nm=0xffffffff-1<<(31-$width);}
-  $nw=($ii & $nm);
-  $br=$nw | (0xffffffff & ~$nm);
-  $netmask=itoadr($nm);; 
-  $broadcast=itoadr($br);; 
-  $network=itoadr($nw); # $i=itoadr($ii);
-
-#  printf "ip=$ip|width=$width|nm=%0x|$netmask|br=%0x|$broadcast|$i|\n",$nm,$br;
-
-  return($ip,$netmask,$broadcast,$network,$width);
-}
-
-sub itoadr
-{
-  local($ip)=@_;
-  local($a,$b,$c,$d);
-  $a=($ip & 0xff000000) >> 24;
-  $b=($ip & 0x00ff0000) >> 16;
-  $c=($ip & 0x0000ff00) >> 8;
-  $d=($ip & 0x000000ff);
-  return("$a.$b.$c.$d");
-}
-
-sub changeline
-{
-   local($file,$old,$new)=@_;
-   open(OLD,$file) || die "Could not open old file: $file\n";
-   open(NEW,">$file.genesis.$$") || die "Could not create new file: $file.genesis.$$";
-   while(<OLD>)
-   {
-        if (/$old/) {print NEW "$new\n";}
-        else {print NEW $_;}
-   }
-   close(NEW);
-   close(OLD);
-   rename("$file.genesis.$$",$file) || die "Could not overwrite old file: $file";
-}
- 
-                                                                                
-sub open_files
-{
- open (SH,">/etc/wireless.conf.sh"); # Voor firewall script. 
- open (NWCFG,">/etc/wl/nwcfg.sh"); # Voor network config
- open (DHCP,">/etc/dhcpd.conf") || die "Could not create dhcpd.conf";
- open (ZEBRA,">/etc/zebra/zebra.conf") || die "Could not create zebra.conf";
- open (OSPFD,">/etc/zebra/ospfd.conf") || die "Could not create ospfd.conf";
- open (MRTG,">/etc/mrtg/mrtg.cfg") || die "Could not create mrtg.cfg";
- open (RCCONF,">/etc/rc.conf") || die "Could not create rc.conf";
- open (FREEBSD,">/etc/rc.node.conf") || die "Could not create rc.node.conf";
- open (RESOLV,">/etc/resolv.conf") || die "Could not create resolv.conf";
- open (NAMED,">/etc/named.conf") || die "Could not create named.conf";
-}
-
-
-sub close_files
-{
- close (SH);
- close (NWCFG);
- close (DHCP);
- close (ZEBRA);
- close (OSPFD);
- close (MRTG);
- close(RCCONF);
- close(FREEBSD);
- close(RESOLV);
- close(NAMED);
-}
-
-sub print_files
-{
- print SH $sh;
- print NWCFG $nwcfg;
- print DHCP $dhcp;
- print ZEBRA $zebra;
- print OSPFD $ospfd;
- print MRTG $mrtg;
- print RCFONG $rcconf;
- print FREEBSD $freebsd;
- print RESOLV $resolv;
- print NAMED $named;
-}
-
-
-sub init_files
-{
-$sh=sprintf  <<EOSH;
-#! /bin/bash
-#
-# Generated by $source
-# on $now
-#
-$svn_version
-
-
-gw_open=$gw_open
-EOSH
-
-$nwcfg=sprintf <<EONW;
-#! /bin/bash
-#
-# Generated by $source
-# on $now
-#
-#  DO NOT CHANGE!
-#
-# $author
-# home: /etc/wl/nwcfg
-#
-$svn_version
-
-EONW
-
-
-$dhcp=sprintf <<EOD;
-# dhcpd.conf
-#
-# Generated by $source
-# on $now
-#
-#  $author
-# home: /usr/local/etc/dhcpd.conf
-#
-$svn_version
-
-option domain-name "$domain";
-
-default-lease-time 7200;
-max-lease-time 2592000;
-
-ddns-update-style none;
-
-# Hack for the WET11 
-#
-always-broadcast on;
-
-EOD
-#foreach $ns (split(/\s+/,$NS_forward)) 
-#	{$dhcp.="option domain-name-servers ${ns};\n";}
-	{$dhcp.="option domain-name-servers ${master_ip};\n";}
-
-$dhcp.="\n\n";
-
-$zebra= sprintf <<EOZ;
-! -*- zebra -*-
-!
-! Zebra configuration for $hostname
-!
-! Generated by $source
-! on $now
-!
-!  DO NOT CHANGE!
-!
-!   $author
-!   home=/usr/local/etc/zebra/zebra.conf
-!
-$svn_version
-
-hostname $hostname
-password getronics
-enable password getronics
-
-! Interfaces
-
-interface lo0
- description loopback                                                           
- ip address 127.0.0.1/8
-
-
-EOZ
-
-$ospfd=init_ospfd();
-
-$mrtg=sprintf <<EOM;
-
-#
-# mrtg configuration for $hostname
-#
-# Generated by $source
-# on $now
-#
-#  DO NOT CHANGE!
-#
-#   $author
-#   home=/etc/mrtg
-#
-$svn_version
-
-Workdir: /var/www/html/mrtg
-
-
-#
-#
-#
-
-Target[${hostname}_load]: `/usr/local/sbin/cpuload.pl`
-MaxBytes[${hostname}_load]: 1000
-Title[${hostname}_load]: CPU load on $hostname
-PageTop[${hostname}_load]: <H1>CPU load on ${hostname}</H1>
-Options[${hostname}_load]: transparent, gauge, nopercent 
-Legendi[${hostname}_load]: 5min
-Legendo[${hostname}_load]: 15min
-ShortLegend[${hostname}_load]: %
-YLegend[${hostname}_load]: %
-WithPeak[${hostname}_load]: wmy
-
-Target[${hostname}_mem]: `/usr/local/sbin/memusage.pl`
-MaxBytes[${hostname}_mem]: 256000000
-Title[${hostname}_mem]: Memory usage on ${hostname}
-PageTop[${hostname}_mem]: <H1>Memory usage on ${hostname}</H1>
-Options[${hostname}_mem]: transparent, gauge, nopercent 
-Legendi[${hostname}_mem]: free
-Legendo[${hostname}_mem]: swap
-ShortLegend[${hostname}_mem]: Bytes
-YLegend[${hostname}_mem]: Bytes
-WithPeak[${hostname}_mem]: wmy
-
-Target[${hostname}_up]: `/usr/local/sbin/uptime.pl`
-MaxBytes[${hostname}_up]: 10000
-Title[${hostname}_up]: ${hostname} Uptime
-PageTop[${hostname}_up]: <H1>${hostname} Uptime</H1>
-Options[${hostname}_up]: transparent, gauge, nopercent 
-Legendi[${hostname}_up]: uptime
-Legendo[${hostname}_up]: 
-ShortLegend[${hostname}_up]: Days
-YLegend[${hostname}_up]: Days
-WithPeak[${hostname}_up]: wmy
-
-EOM
-
-$master_ip_on_alias="ifconfig_lo0_alias1=\"inet $master_ip/32\"";
-foreach my $if (keys %config) {
-  if( $IP{$if} =~ /([0-9\.]+).*/ ) {
-    if( $1 eq $master_ip ) {
-      $master_ip_on_alias="#ifconfig_lo0_alias1=\"inet $master_ip/32\"";
-      break;
-    };
-  };
-};
-
-
-$rcconf.=sprintf <<EORC1;
-# This file is read by /etc/rc.conf - and specific to wireless
-# leiden. Please make all changes in Genesis.
-#
-# Generated by $source
-# on $now
-#
-#  $author
-#
-$svn_version
-
-hostname="$hostname.wLeiden.NET"
-location="$location"
-
-ifconfig_lo0_alias0="inet 172.31.255.1/32"
-$master_ip_on_alias
-EORC1
-
-if ($tproxy !~ m/no/i) {
-	$rcconf .= "# WARNING - specification propably wrong - check genesis. It should be a pure CIDR\n"
-		unless $tproxy =~ m/\d+\.\d+\.\d+\.\d+\/\d+/;
-	$rcconf .= "# Tproxy is ran on this system\n".
-		"tproxy_enable='YES'\n".
-		"tproxy_range='$tproxy'\n".
-		"\n";
-};
-
-#$freebsd.=sprintf <<EOFB1;
-# Wireless Leiden startup script om wireless kaarten te initialiseren
-#
-# Generated by $source
-# on $now
-#
-#  $author
-# home=/etc/wl/freebsd.sh
-#
-#$svn_version
-#EOFB1
-
-$resolv.=sprintf <<EOR1;
-search wleiden.net .
-
-# Local machine / own nameserver.
-nameserver 127.0.0.1
-EOR1
-
-#foreach $ns (split(/\s+/,$NS_resolv)) {
-#	$resolv.="nameserver $ns\n";
-#}
-
-foreach $if (sort keys %config) {
-	foreach $ns (split(/[\s$separator]+/,$OSPF_NEIGHBORS{$if})) {
-		next unless $ns =~  m/\d+/;
-		$resolv.="# Nameserver on adjacent node - $DESC{$if} over $if\nnameserver $ns\n\n";
-	};
-};
-
-
-
-$named.=sprintf <<EON1;
-# named.conf
-#
-# Generated by $source
-# on $now
-#
-#  $author
-#  home=/etc/namedb/named.conf
-#
-$svn_version
-
-options {
-        directory "/var/db/namedb";
-        forward only;
-        forwarders {
-          172.17.8.68;   // proxy1
-          172.17.143.4;  // proxy2
-          172.20.128.98; // proxy3
-//        172.18.8.66;   // Internet GW Jasper
-//        172.17.32.66;  // Internet GW Dirkx
-EON1
-
-%x=();
-foreach $ns (split(/\s+/,$NS_forward)) {
-	next if $ns eq $master_ip;
-	$named.="                   ${ns};\n";
-	$x{ $ns } = 1;
-	}
-
-foreach $if (sort keys %config) {
-	foreach $ns (split(/[\s$separator]+/,$OSPF_NEIGHBORS{$if})) {
-		next unless $ns =~  m/\d+/;
-		$x{ $ns } = 0;
-	};
-};
-
-#foreach(sort keys(%x)) {
-#	next if $x{$_};
-#	$named.="//                 $_; // Next door Neighbour..\n";
-#	}
-
-$named.=sprintf <<EON2;
-	 };
-};
-
-zone "." {
-        type hint;
-        file "/etc/namedb/named.root";
-};
-
-zone "0.0.127.IN-ADDR.ARPA" {
-        type master;
-        file "/etc/namedb/localhost.rev";
-};
-
-zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT" {
-        type master;
-        file "/etc/namedb/localhost-v6.rev";
-};
-
-EON2
-
-push (@ZONES,"wLeiden.NET");
-push (@ZONES,"wZoeterwoude.NET");
-for ($i=16;$i<32;$i++) {push(@ZONES,"$i.172.in-addr.arpa");}
-foreach $zone (@ZONES)
-{
- $named.=sprintf<<EON3;
-zone "$zone" {
-        type slave;
-        file "slave-$zone";
-        masters {
-          172.21.16.99;  // rambo
-          172.17.8.68;   // proxy1
-          172.17.143.4;  // proxy2
-          172.20.128.98; // proxy3
-          172.27.129.66; // Rick
-          172.18.8.66;   // Jasper
-        };
-};
-
-EON3
-}
-
-
-$snmpd=<<EOM;
-# /usr/local/share/snmp/snmpd.local.conf
-# overwrites/augments the data in snmpd.conf
-# which is identical on each node with data
-# specific to this node.
-#
-#
-#MIBS is not availible, commented by Rick van der Zwet
-#mibs +LIGHT80211-MIB
-EOM
-
-$snmpd .= qq|
-# Location of the physical node.
-#
-syslocation "$location"
-
-|	if defined $location;
-
-$snmpd .= qq|
-# Location of the physical node.
-#
-syscontact "$contact"
-
-|	if defined $contact;
-
-$snmpd .= 
-	"# Verify that disk is RO\n".
-	"sh diskro /usr/local/sbin/diskro.sh\n\n"
-	if ($DISK eq 'FLASH');
-
-$snmpd.=<<EOM;
-
-# Also listen to tcp
-agentaddress 161,tcp:161
-EOM
-
-my $master_ip_in_snmpd = "agentaddress $master_ip";
-foreach my $if (keys %config) {
-  if( $IP{$if} =~ /([0-9\.]+).*/ ) {
-    if($master_ip eq $1) {$master_ip_in_snmpd=""};
-$snmpd.=<<EOM;
-agentaddress $1
-EOM
-  };
-};
-
-$snmpd.=<<EOM;
-$master_ip_in_snmpd
-
-# end of file 
-EOM
-}
-
-
-
-sub init_ospfd
-{
-  
-   local($init)=sprintf <<EOO;
-! -*- ospfd -*-
-!
-! osfpd configuration for $hostname
-!
-! Configuration generated by $source
-! on $now
-!
-!  DO NOT CHANGE!
-!
-!   $author
-!   home=/usr/local/etc/zebra/ospfd.conf
-!
-$svn_version
-
-hostname $hostname
-password getronics
-enable password getronics
-
-interface lo0
-EOO
-  return($init);
-}
-
-
-sub mrtg1
-{
-$mrtg.=sprintf <<EOM2;
-Target[${if}_traf]: `/usr/local/sbin/ipchains_traf.pl ${if}`
-MaxBytes[${if}_traf]: $SPEED{$if}
-Title[${if}_traf]: Traffic Analysis ${if} $SDESC{$if}
-PageTop[${if}_traf]: <H1>Traffic on $if $DESC{$if}</H1>
-Options[${if}_traf]: transparent
-WithPeak[${if}_traf]: wmy                                                        
-
-EOM2
-
-if ($functions_only<1)
-{
-	ipchains("-N ${if}-i");
-	ipchains("-N ${if}-o");
-	ipchains("-I input -i ${if} -j ${if}-i");
-	ipchains("-I output -i ${if} -j ${if}-o");
-
-}
-	if ($TYPE{$if}=~/wireless/i)
-	{
-	  $mrtg.=sprintf  <<EOM3;
-Target[${if}_quality]: `/usr/local/sbin/wlan_quality.pl ${if}`
-MaxBytes1[${if}_quality]: 100
-MaxBytes2[${if}_quality]: 100
-Title[${if}_quality]:  Quality $if $SDESC{$if}
-PageTop[${if}_quality]: <H1>Quality $if $DESC{$if}</H1>
-Options[${if}_quality]: transparent, gauge, nopercent
-Legendi[${if}_quality]: Quality
-Legendo[${if}_quality]: Noise
-ShortLegend[${if}_quality]: /100
-YLegend[${if}_quality]: /100
-WithPeak[${if}_quality]: wmy                                                    
-
-Target[${if}_rate]: `/usr/local/sbin/wlan_bitrate.pl ${if}`
-MaxBytes1[${if}_rate]: 11
-MaxBytes2[${if}_rate]: 11
-Title[${if}_rate]: Bitrate $if $SDESC{$if}
-PageTop[${if}_rate]: <H1>Bitrate $if $DESC{$if}</H1>
-Options[${if}_rate]: transparent, gauge, nopercent
-Legendi[${if}_rate]: Bitrate
-ShortLegend[${if}_rate]: Mb/s
-YLegend[${if}_rate]: Mb/s
-WithPeak[${if}_rate]: wmy                                                      
-
-EOM3
-	  if ($MODE{$if}=~/master/i)
-	  {
-	  $mrtg.=sprintf  <<EOM4;
-Target[${if}_users]: `/usr/local/sbin/wlan_users.pl ${if}`
-MaxBytes[${if}_users]: 100
-Title[${if}_users]: Users on $if $SDESC{$if}
-PageTop[${if}_users]: <H1>Users on $if $DESC{$if}</H1>
-Options[${if}_users]: transparent, gauge, nopercent
-Legendi[${if}_users]: Users
-ShortLegend[${if}_users]: users
-YLegend[${if}_users]: users
-WithPeak[${if}_users]: wmy                                                      
-
-EOM4
-	  }
-	}  # wireless
-
-
-}
-
-sub mrtg2
-{
-$mrtg.=sprintf <<EOM5;
-Target[${if}_lat]: `/usr/local/sbin/latency.pl $p`
-MaxBytes1[${if}_lat]: 100
-MaxBytes2[${if}_lat]: 200
-Title[${if}_lat]: Latency/PktLoss Analysis to $p on $if $SDESC{$if}
-PageTop[${if}_lat]: <H1>Latency/PktLoss to $p on $if $DESC{$if}</H1>
-Options[${if}_lat]: transparent, gauge, nopercent
-Legendi[${if}_lat]: PacketLoss%
-Legendo[${if}_lat]: Max Latency (ms)
-ShortLegend[${if}_lat]: %/ms
-YLegend[${if}_lat]: %/ms
-WithPeak[${if}_lat]: wmy
-  
-EOM5
-
-}
-
-sub ahum
-{
-  print "AHUM!\n";
-}
-
-#return(1);
-
