1 # net.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 # @(#) $Header: /usr/mash/src/repository/mash/mash-1/tcl/mb/net.tcl,v 1.9 2002/02/03 04:27:17 lim Exp $
32
33
34 import Configuration SRMAgent AnnounceListenManager/AS/Client/MeGa
35
36 #
37 # Initializes some of the network state for the mediaboard.
38 #
39 Class MBNet -configuration {
40 megaMbFormat null
41 # multicast is default
42 megaRecvMbPort 0
43 mbSessionBW 20
44 megaMbCtrl 224.4.5.24/50000/31
45 megaMbCtrlBW 20000
46 mbServiceLocation urn:mbgw
47
48 delayParams default
49 mbSessionSpec "224.2.55.66/8000"
50 }
51
52 #
53 # Creates an SRMAgent and MeGa Client if desired.
54 #
55 MBNet instproc init { ui mbMgr } {
56 global mb
57
58 set srcList [$ui set srcList_]
59 set pageList [[$ui set pageNavPanel_] set pageList_]
60
61 $mbMgr proc new_source { src } "$srcList register \$src"
62 $mbMgr proc cname_update { src newname } \
63 "$srcList update_src_info \$src \$newname ; \
64 $pageList update_src_info \$src \$newname"
65
66 set luid [$self get_option uid]
67 if { $luid != "" } {
68 set luid [format %x $luid]
69 }
70
71 $self instvar mbAgent_ addr_
72 set mbAgent_ [new SRMAgent $luid]
73
74 if { [$self get_option megaMbSession] != "" } {
75 $self start_mega
76
77 set prefix [$self get_option iconPrefix]
78 set hostname [lindex [split [info hostname] .] 0]
79 append prefix "@" $hostname ":"
80 set conf "Contacting MeGa..."
81 $ui window_title $prefix $conf
82 } else {
83 set addr_ [$self get_option mbSessionSpec]
84 }
85
86 $self instvar session_
87 set session_ [$mbAgent_ create-session $mbMgr $mbMgr]
88 $mbMgr attach_session $session_
89
90 set params [$self get_option delayParams]
91 if {"$params"!="default"} {
92 eval $session_ delay-params $params
93 }
94
95 $mbMgr attach_ui $ui
96 }
97
98
99 MBNet public start_mega { } {
100 $self instvar al_ mbAgent_ addr_
101
102 if [info exists al_] { delete $al_ }
103 if { [$self get_option megaMbSession] != "" } {
104 set sname [$self get_option megaMbSession]
105 set sspec [$self get_option mbSessionSpec]
106 set rportspec [$self get_option megaRecvMbPort]
107 set ofmt [$self get_option megaMbFormat]
108
109 set sbw [$self get_option mbSessionBW]
110 set bw [expr 0.02*$sbw*1000]
111 set megaspec [$self get_option megaMbCtrl]
112 set loc [$self get_option mbServiceLocation]
113 set al_ [new AnnounceListenManager/AS/Client/MeGa \
114 $mbAgent_ $megaspec $bw mb mb \
115 $sname $sspec $rportspec $ofmt $loc]
116 $al_ start
117 set addr_ ""
118 }
119 }
120
121
122 MBNet public reset_mega {} {
123 $self instvar al_
124 if ![info exists al_] {
125 $self start_mega
126 } else {
127 $al_ reset_spec [$self get_option mbSessionSpec]
128 }
129 }
130
131
132 #
133 MBNet instproc adjust_spec {} {
134 $self instvar mbAgent_ addr_
135
136 if { $addr_ != "" } {
137 #addressblock uses a different syntax,
138 #so we have to change it..
139 set comps [split $addr_ /]
140 if {[llength $comps] > 2} {
141 $self add_default defaultTTL [lindex $comps 2]
142 }
143 $mbAgent_ reset_spec [lindex $comps 0]/[lindex $comps 1]
144 }
145 }
146
147 # accessor function
148 MBNet instproc session { } {
149 $self instvar session_
150 return $session_
151 }
152
153 # accessor function
154 MBNet instproc mbAgent { } {
155 $self instvar mbAgent_
156 return $mbAgent_
157 }
158
159
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.