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

Open Mash Cross Reference
mash/tcl/srmv2/session-srmv2.tcl

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

  1 # session-srmv2.tcl --
  2 #
  3 #       FIXME: This file needs a description here.
  4 #
  5 # Copyright (c) 1998-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 
 32 # Transmitter requires these
 33 
 34 Session/SRMv2 set nf_ 0
 35 Session/SRMv2 set np_ 0
 36 Session/SRMv2 set nb_ 0
 37 Session/SRMv2 set loopback_ 0
 38 Session/SRMv2 set loopbackLayer_ 0
 39 Session/SRMv2 set lossProb_ 0.20
 40 Session/SRMv2 set c1_ 1.0
 41 Session/SRMv2 set c2_ 0.0
 42 
 43 # Right now, we use a periodic timer. This needs
 44 # to change to an adaptive timer, once we
 45 # determine the best scheme.
 46 Class SRMv2AnnounceTimer -superclass Timer/Periodic
 47 
 48 
 49 SRMv2AnnounceTimer instproc init { session } {
 50         $self next
 51         $self set session_ $session
 52 }
 53 
 54 SRMv2AnnounceTimer instproc timeout { } {
 55         $self instvar session_
 56         $session_ send-announcement
 57 }
 58 
 59 Session/SRMv2 instproc send-data { data seqno len {name "/"} } {
 60         $self instvar lsrc_
 61         $self transmit-data $lsrc_ $data $seqno $len $name
 62 }
 63 
 64 #Session/SRMv2 instproc start-announce { } {
 65 #       $self instvar timer_ simloss_
 66 #
 67 #       set timer_ [new SRMv2AnnounceTimer $self]
 68 #       $timer_ start 2000
 69 #       set simloss_ 0
 70 #}
 71 
 72 Session/SRMv2 instproc destroy {} {
 73         $self instvar timer_
 74         delete $timer_
 75 
 76         $self next
 77 }
 78 
 79 #Session/SRMv2 instproc print-local-ns { } {
 80 #       $self instvar lsrc_
 81 #       [$lsrc_ set ns_] print
 82 #}
 83 
 84 Session/SRMv2 instproc send-bind { oid {name "/"} } {
 85 #       $self transmit-bind "$oid:$name"
 86 }
 87 
 88 Session/SRMv2 instproc send-rreq { addr uid inst oid ss es } {
 89 #       $self transmit-rreq "$addr,$uid,$inst $ss-$es" $oid
 90 }
 91 
 92 Session/SRMv2 instproc send-announcement { } {
 93         $self instvar lsrc_
 94         if [info exists lsrc_] {
 95                 set announcement [$lsrc_ get-recent]
 96 #               $self transmit-announcement "$announcement"
 97         }
 98 }
 99 
100 Session/SRMv2 instproc manager { mgr } {
101         $self instvar manager_
102         set manager_ $mgr
103         $self set-manager $mgr
104 }
105 
106 Session/SRMv2 instproc have-network {} {
107         $self instvar network_
108         return [info exists network_]
109 }
110 
111 Session/SRMv2 instproc install-key {key} {
112         $self instvar network_
113         if [info exists network_] {
114                 $network_ install-key $key
115         }
116 }
117 
118 Session/SRMv2 instproc network {} {
119         $self instvar network_
120         if ![info exists network_] {
121                 return none
122         }
123         return [$network_ data-net 0]
124 }
125 
126 Session/SRMv2 instproc session-addr {} {
127         $self instvar network_
128         if ![info exists network_] {
129                 return none
130         }
131         return [[$self network] addr]
132 }
133 
134 Session/SRMv2 instproc session-port {} {
135         $self instvar network_
136         if ![info exists network_] {
137                 return none
138         }
139         return [[$self network] port]
140 }
141 
142 Session/SRMv2 instproc session-rport {} {
143         $self instvar network_
144         if ![info exists network_] {
145                 return none
146         }
147         return [[$self network] rport]
148 }
149 
150 Session/SRMv2 instproc session-sport {} {
151         $self instvar network_
152         if ![info exists network_] {
153                 return none
154         }
155         return [[$self network] sport]
156 }
157 
158 Session/SRMv2 instproc session-ttl {} {
159         $self instvar network_
160         if ![info exists network_] {
161                 return none
162         }
163         return [[$self network] ttl]
164 }
165 
166 Session/SRMv2 instproc crypt_clear {} {
167         if [info exists network_] {
168                 $network_ crypt_clear
169         }
170 }
171 
172 Session/SRMv2 instproc create-source { srcID } {
173         $self instvar map_
174 
175         if ![info exists map_($srcID)] {
176                 set agent [new SRMv2_Source $srcID]
177                 $agent  init-vars $self $srcID
178                 set map_($srcID) $agent
179                 return $agent
180         }
181         $self start-announce
182         return $map_($srcID)
183 }
184 
185 
186 Session/SRMv2 instproc create-local-source { srcID } {
187         $self instvar lsrc_
188         if ![info exists lsrc_] {
189                 set lsrc_ [$self create-source $srcID]
190                 $lsrc_ session $self
191                 $lsrc_ host [info hostname]
192                 $self local-source $lsrc_
193         }
194         return $lsrc_
195 }
196 
197 Session/SRMv2 instproc get-name { oid srcID } {
198         $self instvar map_
199         if [info exists map_($srcID)] {
200                 set s $map_($srcID)
201                 return [$s name $oid]
202         }
203         set s [$self create-source $srcID]
204         #
205         # Since we just created the source, the bind message must've
206         # been lost
207         #
208         # Request a pair for container 0 [0-cnt_]
209         $self send-rreq $srcID  0 1 $oid
210         return ""
211 }
212 
213 Session/SRMv2 instproc bind-name { combo srcID } {
214         $self instvar map_
215         if [info exists map_($srcID)] {
216                 set s $map_($srcID)
217         }
218         set s [$self create-source $srcID]
219         $s add-binding $combo $srcID
220 }
221 
222 
223 Session/SRMv2 instproc handle-data { data oid ss len srcID } {
224         $self instvar simloss_
225         incr simloss_
226         if {$simloss_ == 3} {
227                 set simloss_ 0
228                 return
229         }
230         # Packet survived this time.
231         set s [$self create-source $srcID]
232         $s detect-loss $oid $ss [expr $ss + $len - 1]
233 }
234 
235 Session/SRMv2 instproc handle-rreq { srcID range oid } {
236         $self instvar map_
237         if [info exists map_($srcID)] {
238                 # Zero'th object corresponds to
239                 # bind container, which we cache.
240                 # For other objects, the request has to be
241                 # propagated up to the SRMv2Manager.
242                 if {$oid == 0} {
243                         $self repair-bind $map_($srcID) $range
244                 } else {
245                         puts "No data repairs yet."
246                 }
247         }
248 }
249 
250 Session/SRMv2 instproc handle-rrep { oid srcID data } {
251         if {$oid == 0} {
252                 set blist [split $data " "]
253                 foreach b $blist {
254                         $self bind-name $b $srcID
255                 }
256         }
257 }
258 
259 Session/SRMv2 instproc handle-announce { announcement srcID } {
260         set agent [$self create-source $srcID]
261         foreach a $announcement {
262                 set alist [split   $announcement ":"]
263                 set oid   [lindex  $alist 0]
264                 set last  [lindex  $alist 1]
265 
266                 # This is similar to receiving a 1B data packet
267                 # when it comes to updating object database information
268                 $agent update-objinfo $oid $last $last
269         }
270 }
271 
272 Session/SRMv2 instproc repair-bind { agent range } {
273         set f  [split $range "-"]
274         set ss [lindex $f 0]
275         set es [lindex $f 1]
276 
277         set data ""
278         for {set i $ss} {$i <= $es} {incr i} {
279                 set data "$data $i:[$agent name $i]"
280         }
281 #       puts "repair data :: $data"
282 #       $self transmit-rrep $data 0
283 }
284 
285 

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