~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/tcl/handoffServer/main.tcl

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 # main.tcl --
  2 #
  3 #       This is the main entry point for the handoffServer tool.
  4 #       Tcl source code expansion with tcl-expand.tcl starts here.
  5 #       Tcl execution also starts here.
  6 #
  7 # Copyright (c) 1997-2002 The Regents of the University of California.
  8 # All rights reserved.
  9 #
 10 # Redistribution and use in source and binary forms, with or without
 11 # modification, are permitted provided that the following conditions are met:
 12 #
 13 # A. Redistributions of source code must retain the above copyright notice,
 14 #    this list of conditions and the following disclaimer.
 15 # B. Redistributions in binary form must reproduce the above copyright notice,
 16 #    this list of conditions and the following disclaimer in the documentation
 17 #    and/or other materials provided with the distribution.
 18 # C. Neither the names of the copyright holders nor the names of its
 19 #    contributors may be used to endorse or promote products derived from this
 20 #    software without specific prior written permission.
 21 #
 22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 23 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 24 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 25 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 26 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 27 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 28 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 30 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 31 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 32 
 33 
 34 # handoffServer
 35 #
 36 # must be run as root for routing updates to work
 37 #-----
 38 #
 39 
 40 
 41 import AnnounceListenManager
 42 
 43 #
 44 # Accepts msgs to update routing tables for manual mobility management
 45 #
 46 Class AnnounceListenManager/RoutingTableAgent -superclass AnnounceListenManager
 47 
 48 #
 49 AnnounceListenManager/RoutingTableAgent instproc recv_announcement  {args} {
 50         puts "$args"
 51         set addr [lindex $args 0]
 52         set cmd [lindex $args 2]
 53         # ignore args port 1, length 3
 54         if {[llength $cmd] == 4} {
 55                 if {[lindex $cmd 0] == "SetRoute"} {
 56                         # Assuming '$addr == [lindex $cmd 1]' for now --
 57                         # should do DNS check?
 58                         #puts "SetRoute $addr [lindex $cmd 2]"
 59                         eval $self SetRoute $addr [lindex $cmd 2]
 60                 }
 61         }
 62 }
 63 
 64 #
 65 AnnounceListenManager/RoutingTableAgent private SetRoute {client newBS} {
 66 
 67         puts "\[[exec date]\]: SetRoute $client $newBS"
 68         set client [$self NSLookup $client]
 69         if {[catch "exec netstat -rn | grep $client" netstatReply]} {
 70                 puts "no route to client $client"
 71                 if {[catch "eval exec route add $client $newBS" result]} {
 72                         puts "Error on route add:\n$result"
 73                 }
 74         } else {
 75                 exec route delete -host $client
 76                 if {[catch "eval exec route add $client $newBS" result]} {
 77                         puts "Error on route add:\n$result"
 78                 }
 79         }
 80         return 0
 81 }
 82 
 83 #
 84 AnnounceListenManager/RoutingTableAgent private NSLookup {name} {
 85     set firstchar [string index $name 0]
 86     if [string match \[a-zA-Z\] $firstchar] {
 87         return [gethostbyname $name]
 88     } else {
 89         return $name
 90     }
 91 }
 92 
 93 #
 94 ## ---  just start the agent in lieu of embedding in an application
 95 #
 96 set netObj [new AnnounceListenManager/RoutingTableAgent 4096 127.0.0.1/3443]
 97 
 98 # run a tk event loop in tclsh
 99 vwait forever
100 
101 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.