]> git.entuzijast.net Git - imunes.git/commitdiff
Initial import
authormarko <marko>
Mon, 4 Jul 2005 21:33:40 +0000 (21:33 +0000)
committermarko <marko>
Mon, 4 Jul 2005 21:33:40 +0000 (21:33 +0000)
hub.tcl [new file with mode: 0755]
initgui.tcl [new file with mode: 0755]
install.sh [new file with mode: 0755]

diff --git a/hub.tcl b/hub.tcl
new file mode 100755 (executable)
index 0000000..d369b54
--- /dev/null
+++ b/hub.tcl
@@ -0,0 +1,53 @@
+#
+# Copyright 2005 University of Zagreb, Croatia.  All rights reserved.
+#
+# 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.
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+# This product includes software developed by the University of Zagreb,
+# Croatia and its contributors.
+# 4. Neither the name of the University nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY 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 THE UNIVERSITY 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.
+#
+
+
+proc hub.instantiate { eid node } {
+    catch {exec ngctl mkpeer hub anchor anchor | tail -1} resp
+    foreach elem [split [lindex [split $resp "\{\}"] 1]] {
+       if {[string equal -length 5 $elem "id=0x"]} {
+           set id [string range $elem 5 end]
+           catch {exec ngctl name \[$id\]: "$eid\_$node"}
+       }
+    }
+    return
+}
+
+
+proc hub.nghook { eid node ifc } {
+    set ifunit [string range $ifc 1 end]
+    return [list $eid\_$node link$ifunit]
+}
+
diff --git a/initgui.tcl b/initgui.tcl
new file mode 100755 (executable)
index 0000000..bb2853c
--- /dev/null
@@ -0,0 +1,242 @@
+#
+# Copyright 2004 University of Zagreb, Croatia.  All rights reserved.
+#
+# 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.
+# 3. All advertising materials mentioning features or use of this software
+#    must display the following acknowledgement:
+# This product includes software developed by the University of Zagreb,
+# Croatia and its contributors.
+# 4. Neither the name of the University nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY 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 THE UNIVERSITY 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.
+#
+
+
+#
+# Window / canvas setup section
+#
+
+wm minsize . 640 480
+wm geometry . 800x600
+wm title . IMUNES
+
+menu .menubar
+. config -menu .menubar -bg white
+
+.menubar add cascade -label File -underline 0 -menu .menubar.file
+.menubar add cascade -label Edit -underline 0 -menu .menubar.edit
+.menubar add cascade -label View -underline 0 -menu .menubar.view
+.menubar add cascade -label Experiment -underline 1 -menu .menubar.experiment
+.menubar add cascade -label Help -underline 0 -menu .menubar.help
+
+menu .menubar.file -tearoff 0
+
+.menubar.file add command -label New -underline 0 \
+  -accelerator "Ctrl+N" -command { fileNewDialogBox }
+bind . <Control-n> "fileNewDialogBox"
+
+.menubar.file add command -label Open -underline 0 \
+  -accelerator "Ctrl+O" -command { fileOpenDialogBox }
+bind . <Control-o> "fileOpenDialogBox"
+
+.menubar.file add command -label Save -underline 0 \
+  -accelerator "Ctrl+S" -command { fileSaveDialogBox }
+bind . <Control-s> "fileSaveDialogBox"
+
+.menubar.file add command -label "Save As" -underline 5 \
+  -command { fileSaveAsDialogBox }
+
+.menubar.file add separator
+.menubar.file add command -label "Print" -underline 0 \
+  -command {
+    set w .entry1
+    catch {destroy $w}
+    toplevel $w
+    wm title $w "IMUNES"
+    wm iconname $w "IMUNESt"
+
+    label $w.msg -wraplength 5i -justify left -text "Print command:"
+    pack $w.msg -side top
+
+    frame $w.buttons
+    pack $w.buttons -side bottom -fill x -pady 2m
+    button $w.buttons.print -text Print -command "printCanvas $w"
+    button $w.buttons.cancel -text "Cancel" -command "destroy $w"
+    pack $w.buttons.print $w.buttons.cancel -side left -expand 1
+
+    entry $w.e1 -bg white
+    $w.e1 insert 0 "lpr"
+    pack $w.e1 -side top -pady 5 -padx 10 -fill x
+}
+.menubar.file add separator
+.menubar.file add command -label Quit -underline 0 -command { exit }
+
+menu .menubar.edit -tearoff 0
+.menubar.edit add command -label "Undo" -underline 0 \
+    -accelerator "Ctrl+Z" -command undo
+bind . <Control-z> undo
+.menubar.edit add command -label "Redo" -underline 0 \
+    -accelerator "Ctrl+Y" -command redo
+bind . <Control-y> redo
+
+menu .menubar.view -tearoff 0
+.menubar.view add cascade -label "Show" -underline 0 \
+    -menu .menubar.view.show
+menu .menubar.view.show -tearoff 0
+.menubar.view.show add checkbutton -label "Interface Names" \
+    -underline 0 -variable showIfNames \
+    -command { redrawAllLinks }
+.menubar.view.show add checkbutton -label "IP Addresses " \
+    -underline 3 -variable showIfIPaddrs \
+    -command { redrawAllLinks }
+.menubar.view.show add checkbutton -label "Node Labels" \
+    -underline 0 -variable showNodeLabels -command {
+    foreach object [.c find withtag nodelabel] {
+       if { $showNodeLabels } {
+           .c itemconfigure $object -state normal
+       } else {
+           .c itemconfigure $object -state hidden
+       }
+    }
+}
+.menubar.view.show add checkbutton -label "Link Labels" \
+    -underline 0 -variable showLinkLabels -command {
+    foreach object [.c find withtag linklabel] {
+       if { $showLinkLabels } {
+           .c itemconfigure $object -state normal
+       } else {
+           .c itemconfigure $object -state hidden
+       }
+    }
+}
+.menubar.view.show add separator
+.menubar.view.show add command -label "Show All" \
+    -command {
+       set showIfNames 1
+       set showIfIPaddrs 1
+       set showNodeLabels 1
+       set showLinkLabels 1
+       redrawAllLinks
+        foreach object [.c find withtag linklabel] {
+           .c itemconfigure $object -state normal
+       }
+    }
+
+menu .menubar.experiment -tearoff 0
+.menubar.experiment add command -label "Execute" -underline 0 \
+       -command "setOperMode exec"
+.menubar.experiment add command -label "Terminate" -underline 0 \
+       -command "setOperMode edit" -state disabled
+
+menu .menubar.tools -tearoff 0
+
+menu .menubar.help -tearoff 0
+.menubar.help add command -label "About" -command {
+    toplevel .about
+    text .about.text -bg white -height 40 -wrap word -setgrid 1 \
+       -highlightthickness 0 -pady 2 -padx 3
+    pack .about.text -expand yes -fill both
+    .about.text insert 1.0 "$copyright"
+    after 100 {
+       grab .about
+    }
+}
+
+frame .left
+pack .left -side left -fill y
+
+foreach b {select delete link hub lanswitch router host pc rj45} {
+       set image [image create photo -file $ROOTDIR/$LIBDIR/icons/tiny/$b.gif]
+       radiobutton .left.$b -indicatoron 0 \
+               -variable activetool -value $b -selectcolor [.left cget -bg] \
+               -width 32 -height 32 -activebackground gray -image $image
+       pack .left.$b -side top
+}
+foreach b {router host pc hub lanswitch frswitch rj45} {
+       set $b [image create photo -file $ROOTDIR/$LIBDIR/icons/normal/$b.gif]
+}
+
+
+frame .grid
+set c [canvas .c -relief sunken -bd 1 \
+       -scrollregion "-32 -32 [expr $sizex + 32] [expr $sizey + 32]" \
+       -xscrollcommand ".hscroll set" -yscrollcommand ".vscroll set"]
+set background [.c create rectangle 0 0 $sizex $sizey \
+       -fill white -tags "background"]
+.c lower $background
+scrollbar .hscroll -orient horiz -command "$c xview"
+scrollbar .vscroll -command "$c yview"
+pack .grid -expand yes -fill both -padx 0 -pady 0
+grid rowconfig .grid 0 -weight 1 -minsize 0
+grid columnconfig .grid 0 -weight 1 -minsize 0
+grid .c -padx 1 -in .grid -pady 0 -padx 0 -row 0 -column 0 \
+       -rowspan 1 -columnspan 1 -sticky news
+grid .vscroll -in .grid -pady 0 -padx 0 -row 0 -column 1 \
+       -rowspan 1 -columnspan 1 -sticky news
+grid .hscroll -in .grid -pady 0 -padx 0 -row 1 -column 0 \
+       -rowspan 1 -columnspan 1 -sticky news
+
+frame .bottom
+pack .bottom -side bottom -fill x
+label .bottom.textbox -relief sunken -bd 1 -font helvetica -anchor w -width 999
+label .bottom.cpu_load -relief sunken -bd 1 -font helvetica -anchor w -width 9
+label .bottom.mbuf -relief sunken -bd 1 -font helvetica -anchor w -width 15
+label .bottom.oper_mode -relief sunken -bd 1 -font helvetica -anchor w -width 9
+pack .bottom.oper_mode .bottom.mbuf .bottom.cpu_load .bottom.textbox \
+       -side right -padx 1 -fill both
+
+
+#
+# Event bindings and procedures for main canvas:
+#
+
+$c bind node <Any-Enter> "nodeEnter $c"
+$c bind link <Any-Enter> "linkEnter $c"
+$c bind linklabel <Any-Enter> "linkEnter $c"
+$c bind node <Any-Leave> "anyLeave $c"
+$c bind link <Any-Leave> "anyLeave $c"
+$c bind linklabel <Any-Leave> "anyLeave $c"
+$c bind node <Double-1> "popupConfigDialog $c"
+$c bind nodelabel <Double-1> "popupConfigDialog $c"
+$c bind link <Double-1> "popupConfigDialog $c"
+#$c bind link <Double-3> "startethereal $c"
+$c bind link <B3-ButtonRelease> "startethereal $c"
+#$c bind linklabel <Double-3> "startethereal $c"
+$c bind linklabel <B3-ButtonRelease> "startethereal $c"
+$c bind linklabel <Double-1> "popupConfigDialog $c"
+bind $c <1> "button1 $c %x %y none"
+bind $c <Control-Button-1> "button1 $c %x %y ctrl"
+bind $c <3> "button3 $c %x %y"
+bind $c <B1-Motion> "button1-motion $c %x %y"
+bind $c <B1-ButtonRelease> "button1-release $c %x %y"
+bind . <Delete> "delete_object $c %x %y"
+bind .menubar <Destroy> {setOperMode edit}
+
+# Scrolling and panning support
+bind $c <2> "$c scan mark %x %y"
+bind $c <B2-Motion> "$c scan dragto %x %y 1"
+bind $c <4> "$c yview scroll 1 units"
+bind $c <5> "$c yview scroll -1 units"
+
diff --git a/install.sh b/install.sh
new file mode 100755 (executable)
index 0000000..68c907e
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+ROOTDIR="/usr/local"
+BINDIR="bin"
+LIBDIR="lib/imunes"
+
+mkdir -p $ROOTDIR/$LIBDIR/icons/tiny
+mkdir -p $ROOTDIR/$LIBDIR/icons/normal
+
+echo Installing IMUNES in $ROOTDIR ...
+
+#
+# Update the ROOTDIR and LIBDIR initial values in imunes file
+#
+sed -e "s,set LIBDIR \"\",set LIBDIR $LIBDIR," \
+    -e "s,set ROOTDIR \".\",set ROOTDIR $ROOTDIR," \
+    imunes.tcl > $ROOTDIR/$LIBDIR/imunes.tcl
+
+sed -e "s,LIBDIR=\"\",LIBDIR=$LIBDIR," \
+    -e "s,ROOTDIR=\".\",ROOTDIR=$ROOTDIR," \
+    -e "s,BINDIR=\".\",BINDIR=$BINDIR," \
+    imunes > $ROOTDIR/$BINDIR/imunes
+chmod 755  $ROOTDIR/$BINDIR/imunes
+
+
+lib_files="editor.tcl exec.tcl filemgmt.tcl nodecfg.tcl linkcfg.tcl help.tcl \
+          initgui.tcl quagga.tcl xorp.tcl static.tcl pc.tcl host.tcl \
+          quaggaboot.sh" 
+
+tiny_icons="delete.gif hub.gif frswitch.gif host.gif \
+           lanswitch.gif link.gif pc.gif rj45.gif router.gif select.gif"
+
+normal_icons="hub.gif frswitch.gif host.gif lanswitch.gif pc.gif \
+             rj45.gif router.gif"
+
+
+for file in ${lib_files}; do
+        cp $file $ROOTDIR/$LIBDIR/
+done
+
+for file in ${tiny_icons}; do 
+        cp icons/tiny/$file $ROOTDIR/$LIBDIR/icons/tiny/
+done
+
+for file in ${normal_icons}; do  
+        cp icons/normal/$file $ROOTDIR/$LIBDIR/icons/normal/
+done
+
+echo Done!
+