1#!/bin/sh 2 3# /* ******** netUstad: Network Ustadi (Network Master) *********/ 4# /* This software is Copyright (C) 2004 by Ozkan KIRIK. */ 5# /* Permission is granted to redistribute and modify this */ 6# /* software under the terms of the GNU General Public License */ 7# /* available at http://www.gnu.org/ */ 8# /**************************************************************/ 9 10cd $work_path 11 12action=`echo $QUERY_STRING | $awk_cmd -F\& '{print $1}'` 13if test "x$action" = "xapply"; then 14 olddest=`echo $QUERY_STRING | $awk_cmd -F\& '{print $2}' | $sed_cmd s/olddest=//` 15 dest=`echo $QUERY_STRING | $awk_cmd -F\& '{print $3}' | $sed_cmd s/dest=//` 16 gw=`echo $QUERY_STRING | $awk_cmd -F\& '{print $4}' | $sed_cmd s/gw=//` 17 netmask=`echo $QUERY_STRING | $awk_cmd -F\& '{print $5}' | $sed_cmd s/netmask=//` 18 oldnetmask=`$netstat_cmd -rn -A inet | $grep_cmd $olddest | $awk_cmd '{print $3}'` 19 # deleting old route 20 echo $netmask | $grep_cmd '255\.255\.255\.255' > /dev/null 21 if test $? -eq 0; then 22 $route_cmd del -host $olddest > /dev/null 23 else 24 $route_cmd del -net $olddest netmask $oldnetmask > /dev/null 25 fi 26 # adding new route 27 echo $netmask | $grep_cmd '255\.255\.255\.255' > /dev/null 28 if test $? -eq 0; then 29 $route_cmd add -host $dest gw $gw 2>&1 30 else 31 $route_cmd add -net $dest gw $gw netmask $netmask 2>&1 32 fi 33 ./rt_table 34else 35 route=`echo $QUERY_STRING | $awk_cmd -F\& '{print $2}' | $sed_cmd s/route=//` 36 export route 37 38 #================== 39 #== Send headers == 40 #================== 41 ./header 42 43 #================ 44 #== Print Data == 45 #================ 46 echo '<script language="JavaScript" type="text/javascript">' 47 echo "function rt_del(dest) {" 48 echo " if (confirm('`$gettext_cmd "Route"`: '+dest+' `$gettext_cmd "will be deleted. Is it Okay?"`')) window.location='rt_del?'+dest+'"'$'$server_sid"'" 49 echo "}" 50 echo "function apply(olddest) {" 51 echo " destination= document.getElementById('dest').value;" 52 echo " gateway=document.getElementById('gw').value;" 53 echo " netmask=document.getElementById('genmask').value;" 54 echo " if (destination!='' && gateway!='' && olddest!='') {" 55 echo " window.location='rt_edit?apply&olddest='+olddest+'&dest='+destination+'&gw='+gateway+'&netmask='+netmask+'"'$'$server_sid"';" 56 echo " } else {" 57 echo " alert('`$gettext_cmd "Destination and Gateway fields cannot be empty."`'); }" 58 echo "}" 59 echo "</script>" 60 echo " " 61 echo "<h5>`$gettext_cmd "Routing Table"`</h5>" 62 echo "<table cellspacing=3 cellpadding=0>" 63 echo " <tr align=center class=header>" 64 echo " <td class=editdelete><b>v</b></td>" 65 echo " <td class=std><b>`$gettext_cmd "Destination"`</b></td>" 66 echo " <td class=std><b>`$gettext_cmd "Gateway"`</b></td>" 67 echo " <td class=std><b>`$gettext_cmd "Genmask"`</b></td>" 68 echo " <td class=std><b>`$gettext_cmd "Flags"`</b></td>" 69 echo " <td class=std><b>`$gettext_cmd "NetIf"`</b></td>" 70 echo " <td class=editdelete><b>v</b></td></tr>" 71 $netstat_cmd -rn -A inet | $awk_cmd -f rt-edit 72 echo "</table><br>" 73 74 #================= 75 #== Send footer == 76 #================= 77 ./footer 78fi 79