]> git.entuzijast.net Git - imunes.git/commitdiff
lanswitch najosnovnije
authorJosip Rodin <joy@numa-ubuntu-vm.(none)>
Sun, 13 Sep 2009 21:31:25 +0000 (23:31 +0200)
committerJosip Rodin <joy@numa-ubuntu-vm.(none)>
Sun, 13 Sep 2009 21:31:25 +0000 (23:31 +0200)
imunes.tcl
linux/lanswitch.tcl [new file with mode: 0755]

index 29a33772b54e542d1f67103a4f9a2e9b25c767c8..07806baa50fd270a266c8cc4d58094e6a615c973 100755 (executable)
@@ -152,7 +152,7 @@ if { $gui_unix && $gui_linux } {
     source "$ROOTDIR/$LIBDIR/linux/pc.tcl"
     source "$ROOTDIR/$LIBDIR/linux/host.tcl"
     source "$ROOTDIR/$LIBDIR/linux/hub.tcl"
-#    source "$ROOTDIR/$LIBDIR/lanswitch.tcl"
+    source "$ROOTDIR/$LIBDIR/linux/lanswitch.tcl"
     source "$ROOTDIR/$LIBDIR/linux/rj45.tcl"
 } else {
     source "$ROOTDIR/$LIBDIR/quagga.tcl"
diff --git a/linux/lanswitch.tcl b/linux/lanswitch.tcl
new file mode 100755 (executable)
index 0000000..2036fc7
--- /dev/null
@@ -0,0 +1,163 @@
+#
+# Copyright 2005-2008 University of Zagreb, Croatia.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# This work was supported in part by Croatian Ministry of Science
+# and Technology through the research contract #IP-2003-143.
+#
+
+# $Id: lanswitch.tcl,v 1.15 2009/03/17 14:35:19 marko Exp $
+
+
+#****h* imunes/lanswitch.tcl
+# NAME
+#  lanswitch.tcl -- defines lanswitch specific procedures
+# FUNCTION
+#  This module is used to define all the lanswitch specific procedures.
+# NOTES
+#  Procedures in this module start with the keyword lanswitch and
+#  end with function specific part that is the same for all the
+#  node types that work on the same layer.
+#****
+
+set MODULE lanswitch
+
+#****f* lanswitch.tcl/lanswitch.layer
+# NAME
+#   lanswitch.layer  
+# SYNOPSIS
+#   set layer [lanswitch.layer]
+# FUNCTION
+#   Returns the layer on which the lanswitch operates
+#   i.e. returns LINK. 
+# RESULT
+#   * layer -- set to LINK
+#****
+
+proc $MODULE.layer {} {
+    return LINK
+}
+
+#****f* lanswitch.tcl/lanswitch.instantiate
+# NAME
+#   lanswitch.instantiate
+# SYNOPSIS
+#   lanswitch.instantiate $eid $node_id
+# FUNCTION
+#   Procedure lanswitch.instantiate cretaes a new netgraph node
+#   of the type bridge. The name of the netgraph node is in the form
+#   of exprimentId_nodeId.
+# INPUTS
+#   * eid - experiment id
+#   * node_id - id of the node (type of the node is lanswitch)
+#****
+
+proc $MODULE.instantiate { eid node } {
+    upvar 0 ::cf::[set ::curcfg]::ngnodemap ngnodemap
+
+# FreeBSD-only:
+#    catch {exec vimage $eid ngctl mkpeer bridge anchor anchor | tail -1} resp
+#    catch {exec vimage $eid ngctl l | fgrep "  Name: <unnamed>" | cut -c51-58 | xargs echo } nglist
+#    set id [lindex $nglist 0]
+#    catch {exec vimage $eid ngctl name \[$id\]: $node}
+
+# TODO mozda mapformat treba biti standardni nghook format?
+#    upvar 0 ::cf::[set ::curcfg]::[set node]::node_id node_id
+#    set mapformat $ifc@$node_id
+    set mapformat "$eid\.$node"
+    set ngnodemap($mapformat) $node
+}
+
+
+#****f* lanswitch.tcl/lanswitch.start
+# NAME
+#   lanswitch.start
+# SYNOPSIS
+#   lanswitch.start $eid $node_id
+# FUNCTION
+#   Starts a new lanswitch. Since lanswitch has no starting code,
+#   this procedure does nothing.
+# INPUTS
+#   * eid - experiment id
+#   * node_id - id of the node (type of the node is lanswitch)
+#****
+proc $MODULE.start { eid node } {
+}
+
+
+#****f* lanswitch.tcl/lanswitch.shutdown
+# NAME
+#   lanswitch.shutdown
+# SYNOPSIS
+#   lanswitch.shutdown $eid $node_id
+# FUNCTION
+#   Shutdowns a lanswitch. Since lanswitch has no shutdown code,
+#   this procedure does nothing.
+# INPUTS
+#   * eid - experiment id
+#   * node_id - id of the node (type of the node is lanswitch)
+#****
+proc $MODULE.shutdown { eid node } {
+}
+
+#****f* lanswitch.tcl/lanswitch.destroy
+# NAME
+#   lanswitch.destroy
+# SYNOPSIS
+#   lanswitch.destroy $eid $node_id
+# FUNCTION
+#   Destroys a lanswitch. Destroys the netgraph node that represents 
+#   the lanswitch by sending a shutdown message.
+# INPUTS
+#   * eid - experiment id
+#   * node_id - id of the node (type of the node is lanswitch)
+#****
+proc $MODULE.destroy { eid node } {
+    catch { nexec vimage $eid ngctl msg $node: shutdown }
+}
+
+
+#****f* lanswitch.tcl/lanswitch.nghook
+# NAME
+#   lanswitch.nghook
+# SYNOPSIS
+#   set nghook [lanswitch.nghook $eid $node_id $ifc] 
+# FUNCTION
+#   Returns the id of the netgraph node and the name of the 
+#   netgraph hook which is used for connecting two netgraph 
+#   nodes. Netgraph node name is in format experimentId_nodeId
+#   and the netgraph hook is in the form of linkN, where N is
+#   interface number.
+# INPUTS
+#   * eid - experiment id
+#   * node_id - node id
+#   * ifc - interface name 
+# RESULT
+#   * nghook - the list containing netgraph node id and the 
+#     netgraph hook (ngNode ngHook).
+#****
+
+proc $MODULE.nghook { eid node ifc } {
+    set ifunit [string range $ifc 1 end]
+    return [list $eid\.$node link$ifunit]
+}