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

Open Mash Cross Reference
mash/tcl/nsdr/source-mega.tcl

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

  1 # source-mega.tcl --
  2 #
  3 #       Used to tie-in SAP announcments with MeGa.
  4 #
  5 # Copyright (c) 1997-2002 The Regents of the University of California.
  6 # All rights reserved.
  7 #
  8 # Redistribution and use in source and binary forms, with or without
  9 # modification, are permitted provided that the following conditions are met:
 10 #
 11 # A. Redistributions of source code must retain the above copyright notice,
 12 #    this list of conditions and the following disclaimer.
 13 # B. Redistributions in binary form must reproduce the above copyright notice,
 14 #    this list of conditions and the following disclaimer in the documentation
 15 #    and/or other materials provided with the distribution.
 16 # C. Neither the names of the copyright holders nor the names of its
 17 #    contributors may be used to endorse or promote products derived from this
 18 #    software without specific prior written permission.
 19 #
 20 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
 21 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 23 # ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
 24 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 26 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 28 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 30 
 31 import AnnounceListenManager/AS/Client/MeGa
 32 
 33 #FIXME making this class is a temporary hack
 34 Class AnnounceListenManager/SAP/MeGa -superclass AnnounceListenManager/SAP
 35 
 36 #
 37 AnnounceListenManager/SAP/MeGa public init {s spec {mtu 2048} } {
 38     $self next $spec $mtu
 39     $self set s_ $s
 40 }
 41 
 42 #
 43 AnnounceListenManager/SAP/MeGa private recv_announcement {args} {
 44     $self instvar s_
 45     eval $s_ recv $self $args
 46 }
 47 
 48 #FIXME
 49 AnnounceListenManager/SAP/MeGa private incrnsrcs {args} {}
 50 AnnounceListenManager/SAP/MeGa private sample_size {args} {}
 51 AnnounceListenManager/SAP/MeGa private interval {args} { return 0 }
 52 
 53 
 54 # Receives program announcements via SAP and uses the MeGa
 55 # architecture to receive announcements through a proxy.  (See
 56 # <a href=http://www.cs.berkeley.edu/~elan/mega/>Elan's MeGa page</a>
 57 # for more info about MeGa...)
 58 Class ProgramSource/SAP/MeGa -superclass ProgramSource/SAP
 59 
 60 # Initializes a new object.  Arguments have the same meaning as
 61 # for ProgramSource/SAP::init but there can be only a single address
 62 # rather than a list of them.
 63 ProgramSource/SAP/MeGa public init {ui addr} {
 64     # need to do these things before calling next constructor
 65     $self set name_ "MeGa Proxy: $addr"
 66     set addr [intoa [lookup_host_addr $addr]]
 67     set d [$self get_option cachedir]
 68     if {$d != ""} {
 69         $self set cache_ [file join $d $addr]
 70     }
 71 
 72     eval $self next $ui
 73 
 74     $self instvar app_
 75     set app_ [Application instance]
 76 
 77     $self instvar bw_
 78     set bw_ [$app_ get_option megaBW]
 79     # use 2% of capacity for sdp gateway
 80     set bw [expr 0.02 * $bw_]
 81 
 82     set spec "$addr/60000:10002/1"
 83     $app_ add_default megaStartupWait 60
 84     set sname sdp:0:0:IN:IP4:224.2.127.254
 85     set sspec 224.2.127.254/9875/127
 86     $app_ add_default megaCtrl $spec
 87     set rportspec 10000:10002
 88 
 89     $self instvar al_
 90     set loc [$self get_option serviceLocation]
 91     set al_ [new AnnounceListenManager/AS/Client/MeGa $self \
 92                  $spec $bw Nsdr sdp $sname $sspec $rportspec null $loc]
 93     $al_ start
 94 }
 95 
 96 # Used to set the name of the tag for this program source in the
 97 # user interface.
 98 ProgramSource/SAP/MeGa public name {} {
 99     return [$self set name_]
100 }
101 
102 # Invoked by MeGa to tell the object it should listen for SAP
103 # messages on the address/port given by <i>spec</i>.
104 ProgramSource/SAP/MeGa public reset_spec {spec} {
105     set l [split $spec /]
106 
107     $self instvar addr_ sport_ rport_ ttl_
108     set addr_ [lindex $l 0]
109     set ports [split [lindex $l 1] :]
110     set sport_ [lindex $ports 0]
111     set rport_ [lindex $ports 1]
112     set ttl_ [lindex $l 3]
113 
114     $self instvar addrs_
115     foreach a $addrs_ {
116         delete $a
117     }
118     set addrs_ {}
119     set s $addr_/$sport_:$rport_/$ttl_
120     lappend addrs_ [new AnnounceListenManager/SAP/MeGa $self $s]
121 }
122 
123 ProgramSource/SAP/MeGa public scopes {} {
124     #FIXME
125     return {}
126 }
127 
128 #FIXME should this stuff be in AnnounceListenManager/MeGa/Client ?
129 ProgramSource/SAP/MeGa instproc have_network {} {
130     $self instvar addr_
131     return [info exists addr_]
132 }
133 
134 ProgramSource/SAP/MeGa instproc session-addr {} {
135     $self instvar addr_
136     return $addr_
137 }
138 
139 ProgramSource/SAP/MeGa instproc session-sport {} {
140     $self instvar sport_
141     return $sport_
142 }
143 
144 ProgramSource/SAP/MeGa instproc session-rport {} {
145     $self instvar rport_
146     return $rport_
147 }
148 
149 ProgramSource/SAP/MeGa instproc session-ttl {} {
150     $self instvar ttl_
151     return $ttl_
152 }
153 
154 

~ [ 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.