]> git.entuzijast.net Git - imunes.git/commitdiff
Pokusaj dodavanja rj45 funkcionalnosti.
authorKosta Pribić <kosta.pribic@gmail.com>
Wed, 9 Sep 2009 21:34:12 +0000 (23:34 +0200)
committerKosta Pribić <kosta.pribic@gmail.com>
Wed, 9 Sep 2009 21:34:12 +0000 (23:34 +0200)
Pokusaj dodavanja spajanja na fizički interface (rj45) tako da se napravi
L2 Bridge u koji se doda fizicko sucelje i sucelje danog VEa.
U teoriji izgleda ok, izgleda ok u "sudo brctl show" medjutim jednostavno
ne radi. Dok traje simulacija host ne moze van i DNS ne radi.

Moguce da je problem u tome sto je eth0 sucelje hosta povezano sa
VirtualBoxom kao bridged adapter.

imunes.tcl
linux/exec.tcl
linux/rj45.tcl [new file with mode: 0755]
test1.imn

index c3a3429a5d2bbeb890e44dd4e0f004967584b86b..10d43f3cfe3ed54b06699000c15b492024f50213 100755 (executable)
@@ -153,7 +153,7 @@ if { $gui_unix && $gui_linux } {
     source "$ROOTDIR/$LIBDIR/linux/host.tcl"
     source "$ROOTDIR/$LIBDIR/linux/hub.tcl"
 #    source "$ROOTDIR/$LIBDIR/lanswitch.tcl"
-#    source "$ROOTDIR/$LIBDIR/rj45.tcl"
+    source "$ROOTDIR/$LIBDIR/linux/rj45.tcl"
 } else {
     source "$ROOTDIR/$LIBDIR/quagga.tcl"
     source "$ROOTDIR/$LIBDIR/xorp.tcl"
index cdf1abfd8b352b93d0569ff756e0859cdec205c7..8c4126fb55aa5190f1e76cc772c56b81a203b013 100755 (executable)
@@ -305,9 +305,11 @@ proc l3node.instantiate { eid node } {
                puts "  Interface $ifc at $node links to $peer"
 
                if { [nodeType $peer] == "rj45" } {
-# TODO: RJ-45 nodes zasad ne podrzavamo
-#                  set peerifc [getNodeName $peer]
-#                  set ether [nexec ifconfig $peerifc | fgrep "ether " | cut -c8-]
+            # TODO: RJ45 nodes zasad ne podrzavamo
+                   set peerifc [getNodeName $peer]
+                   #set ether [nexec ifconfig $peerifc | grep "HWaddr " | cut -c8-]
+                   set ether [nexec ifconfig $peerifc | grep $peerifc | awk {{print $5}}]
+                   puts "  Za RJ45 interface -> MAC(eth0) = $ether"
                } else {
                    # vzctl ne prima ako nije properly padded
                    set ether 40:00:aa:aa:[format %02x $mac_byte4]:[format %02x $mac_byte5]
@@ -735,6 +737,17 @@ proc deployCfg {} {
             nexec brctl addbr $bridge                
         }
         
+        #TODO ovo bas ne radi, ne moze komunicirati sa fizickim interface-om, iako je
+        #uredno pridruzen bridge interface-u
+        #
+        #RJ45 se ponasa kao L2 device, tj. hub, samo u njega treba odmah joinati
+        #odgovarajuci fizicki interface koji je rucno upisan u gui
+
+        if { [nodeType $bridge] == "rj45" } {
+            nexec brctl addif $bridge [getNodeName $bridge]
+            puts "  RJ45 emulacija, spojen na [getNodeName $bridge] na hostu."
+        }
+        
         #dodaje interface
         nexec brctl addif $bridge $port_if
         #dize bridge, interesantno ne baca error ako je bridge vec dignut
diff --git a/linux/rj45.tcl b/linux/rj45.tcl
new file mode 100755 (executable)
index 0000000..ae881b4
--- /dev/null
@@ -0,0 +1,154 @@
+#
+# 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: rj45.tcl,v 1.13 2008/01/28 19:03:34 marko Exp $
+
+
+#****h* imunes/rj45.tcl
+# NAME
+#  rj45.tcl -- defines rj45 specific procedures
+# FUNCTION
+#  This module is used to define all the rj45 specific procedures.
+# NOTES
+#  Procedures in this module start with the keyword rj45 and
+#  end with function specific part that is the same for all the
+#  node types that work on the same layer.
+#****
+
+set MODULE rj45
+
+#****f* rj45.tcl/rj45.layer
+# NAME
+#   rj45.layer  
+# SYNOPSIS
+#   set layer [rj45.layer]
+# FUNCTION
+#   Returns the layer on which the rj45 operates
+#   i.e. returns LINK. 
+# RESULT
+#   * layer -- set to LINK
+#****
+
+proc $MODULE.layer {} {
+    return LINK
+}
+
+#****f* rj45.tcl/rj45.instantiate
+# NAME
+#   rj45.instantiate
+# SYNOPSIS
+#   rj45.instantiate $eid $node_id
+# FUNCTION
+#   Procedure rj45.instantiate puts real interface
+#   into promiscues mode.
+# INPUTS
+#   * eid - experiment id
+#   * node_id - id of the node (type of the node is rj45)
+#****
+
+proc $MODULE.instantiate { eid node } {
+    upvar 0 ::cf::[set ::curcfg]::ngnodemap ngnodemap
+
+    set ifname [getNodeName $node]
+    set ngnodemap($ifname) $ifname
+    # nexec vimage -i $eid $ifname $ifname
+    # nexec vimage $eid ifconfig $ifname up promisc
+}
+
+
+#****f* rj45.tcl/rj45.start
+# NAME
+#   rj45.start
+# SYNOPSIS
+#   rj45.start $eid $node_id
+# FUNCTION
+#   Starts a new rj45. Since rj45 has no starting code,
+#   this procedure does nothing.
+# INPUTS
+#   * eid - experiment id
+#   * node_id - id of the node (type of the node is rj45)
+#****
+proc $MODULE.start { eid node } {
+}
+
+
+#****f* rj45.tcl/rj45.shutdown
+# NAME
+#   rj45.shutdown
+# SYNOPSIS
+#   rj45.shutdown $eid $node_id
+# FUNCTION
+#   Shutdowns a rj45. Since rj45 has no shutdown code,
+#   this procedure does nothing.
+# INPUTS
+#   * eid - experiment id
+#   * node_id - id of the node (type of the node is rj45)
+#****
+proc $MODULE.shutdown { eid node } {
+}
+
+
+#****f* rj45.tcl/rj45.destroy
+# NAME
+#   rj45.destroy
+# SYNOPSIS
+#   rj45.destroy $eid $node_id
+# FUNCTION
+#   Destroys a rj45 emulation interface. 
+# INPUTS
+#   * eid - experiment id
+#   * node_id - id of the node (type of the node is rj45)
+#****
+proc $MODULE.destroy { eid node } {
+    set ifname [getNodeName $node]
+    # nexec ifconfig $ifname up -promisc
+}
+
+#****f* rj45.tcl/rj45.nghook
+# NAME
+#   rj45.nghook
+# SYNOPSIS
+#   rj45.nghook $eid $node_id $ifc 
+# FUNCTION
+#   Returns the id of the netgraph node and the netgraph 
+#   hook name. In this case netgraph node name correspondes 
+#   to the name of the physical interface.
+# INPUTS
+#   * eid - experiment id
+#   * node_id - node id
+#   * ifc - interface name 
+# RESULT
+#   * nghook - the list containing netgraph node name and
+#   the netraph hook name (in this case: lower).
+#****
+
+proc $MODULE.nghook { eid node ifc } {
+    set nodename [getNodeName $node]
+    return [list $nodename lower]
+}
+
index 53ac29b292a22fe7e1db2b5cfe30590b988a2b62..ad97d6a60580817645ef33ed83c4d01ca517bc44 100644 (file)
--- a/test1.imn
+++ b/test1.imn
@@ -4,6 +4,10 @@ node n0 {
     network-config {
        hostname pero
        !
+       interface eth1
+        ip address 10.0.1.10/24
+        ipv6 address a:1::10/64
+       !
        interface eth0
         ip address 10.0.0.10/24
         ipv6 address a:0::10/64
@@ -13,6 +17,7 @@ node n0 {
     iconcoords {168.0 192.0}
     labelcoords {168.0 224.0}
     interface-peer {eth0 n2}
+    interface-peer {eth1 n3}
 }
 
 node n1 {
@@ -45,6 +50,18 @@ node n2 {
     interface-peer {e1 n1}
 }
 
+node n3 {
+    type rj45
+    network-config {
+       hostname eth0
+       !
+    }
+    canvas c0
+    iconcoords {144.0 384.0}
+    labelcoords {144.0 408.0}
+    interface-peer {0 n0}
+}
+
 link l0 {
     nodes {n0 n2}
     bandwidth 0
@@ -55,6 +72,10 @@ link l1 {
     bandwidth 0
 }
 
+link l2 {
+    nodes {n0 n3}
+}
+
 canvas c0 {
     name {Canvas0}
 }