]> git.entuzijast.net Git - imunes.git/commitdiff
Initial revision
authormarko <marko>
Mon, 4 Jul 2005 18:14:36 +0000 (18:14 +0000)
committermarko <marko>
Mon, 4 Jul 2005 18:14:36 +0000 (18:14 +0000)
host.tcl [new file with mode: 0755]
pc.tcl [new file with mode: 0755]
quagga.tcl [new file with mode: 0755]
static.tcl [new file with mode: 0755]
xorp.tcl [new file with mode: 0755]

diff --git a/host.tcl b/host.tcl
new file mode 100755 (executable)
index 0000000..ec52116
--- /dev/null
+++ b/host.tcl
@@ -0,0 +1,72 @@
+#
+# 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 host.cfggen { node } {
+    global $node
+
+    set cfg {}
+
+    foreach ifc [ifcList $node] {
+       lappend cfg "ifconfig $ifc inet [getIfcIPaddr $node $ifc]"
+    }
+    lappend cfg ""
+
+    foreach statrte [getStatIProutes $node] {
+       lappend cfg "route add $statrte"
+    }
+
+    lappend cfg "portmap"
+    lappend cfg "inetd"
+
+    return $cfg
+}
+
+
+proc host.bootcmd { node } {
+    return "/bin/sh"
+}
+
+
+proc host.instantiate { eid node } {
+    l3node.instantiate $eid $node
+    return
+}
+
+
+proc host.nghook { eid node ifc } {
+    return [l3node.nghook $eid $node $ifc]
+}
+
diff --git a/pc.tcl b/pc.tcl
new file mode 100755 (executable)
index 0000000..840f95a
--- /dev/null
+++ b/pc.tcl
@@ -0,0 +1,69 @@
+#
+# 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 pc.cfggen { node } {
+    global $node
+
+    set cfg {}
+
+    foreach ifc [ifcList $node] {
+       lappend cfg "ifconfig $ifc inet [getIfcIPaddr $node $ifc]"
+    }
+    lappend cfg ""
+
+    foreach statrte [getStatIProutes $node] {
+       lappend cfg "route add $statrte"
+    }
+
+    return $cfg
+}
+
+
+proc pc.bootcmd { node } {
+    return "/bin/sh"
+}
+
+
+proc pc.instantiate { eid node } {
+    l3node.instantiate $eid $node
+    return
+}
+
+
+proc pc.nghook { eid node ifc } {
+    return [l3node.nghook $eid $node $ifc]
+}
+
diff --git a/quagga.tcl b/quagga.tcl
new file mode 100755 (executable)
index 0000000..84a1aba
--- /dev/null
@@ -0,0 +1,87 @@
+#
+# 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 router.quagga.cfggen { node } {
+    global $node
+
+    set cfg {}
+
+    foreach ifc [ifcList $node] {
+       lappend cfg "interface $ifc"
+       lappend cfg " ip address [getIfcIPaddr $node $ifc]"
+       if { [getIfcOperState $node $ifc] == "down" } {
+           lappend cfg " shutdown"
+       }
+       lappend cfg "!"
+#exec vimage $node ifconfig $ifc [getIfcOperState $node $ifc] # XXX!!!
+    }
+
+    foreach proto { rip ospf bgp } {
+       set protocfg [netconfFetchSection $node "router $proto"]
+       if { $protocfg != "" } {
+           lappend cfg "router $proto"
+           foreach line $protocfg {
+               lappend cfg "$line"
+           }
+       }
+    }
+
+    foreach statrte [getStatIProutes $node] {
+       lappend cfg "ip route $statrte"
+    }
+
+    return $cfg
+}
+
+
+proc router.quagga.bootcmd { node } {
+    global ROOTDIR LIBDIR
+    return "$ROOTDIR/$LIBDIR/quaggaboot.sh"
+}
+
+
+proc router.quagga.instantiate { eid node } {
+    set node_id "$eid\_$node"
+    l3node.instantiate $eid $node
+    exec vimage $node_id sysctl net.inet.ip.forwarding=1
+    return
+}
+
+
+proc router.quagga.nghook { eid node ifc } {
+    return [l3node.nghook $eid $node $ifc]
+}
+
diff --git a/static.tcl b/static.tcl
new file mode 100755 (executable)
index 0000000..19c9976
--- /dev/null
@@ -0,0 +1,71 @@
+#
+# 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 router.static.cfggen { node } {
+    global $node
+
+    set cfg {}
+
+    foreach ifc [ifcList $node] {
+       lappend cfg "ifconfig $ifc inet [getIfcIPaddr $node $ifc]"
+    }
+    lappend cfg ""
+
+    foreach statrte [getStatIProutes $node] {
+       lappend cfg "route add $statrte"
+    }
+
+    return $cfg
+}
+
+
+proc router.static.bootcmd { node } {
+    return "/bin/sh"
+}
+
+
+proc router.static.instantiate { eid node } {
+    set node_id "$eid\_$node"
+    l3node.instantiate $eid $node
+    exec vimage $node_id sysctl net.inet.ip.forwarding=1
+    return
+}
+
+
+proc router.static.nghook { eid node ifc } {
+    return [l3node.nghook $eid $node $ifc]
+}
+
diff --git a/xorp.tcl b/xorp.tcl
new file mode 100755 (executable)
index 0000000..fb8c5eb
--- /dev/null
+++ b/xorp.tcl
@@ -0,0 +1,122 @@
+#
+# 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 router.xorp.cfggen { node } {
+    global $node
+
+    set cfg {}
+
+    lappend cfg "interfaces {"
+    foreach ifc [ifcList $node] {
+       set ipaddr "[lindex [split [getIfcIPaddr $node $ifc] /] 0]"
+       set ipmask "[lindex [split [getIfcIPaddr $node $ifc] /] 1]"
+       lappend cfg "    interface $ifc {"
+       lappend cfg "      vif $ifc {"
+       lappend cfg "          address $ipaddr {"
+       lappend cfg "              prefix-length: $ipmask"
+       lappend cfg "          }"
+       lappend cfg "      }"
+       lappend cfg "    }"
+    }
+    lappend cfg "}"
+    lappend cfg ""
+
+    lappend cfg "fea {"
+    lappend cfg "}"
+    lappend cfg ""
+
+    set statrtes [getStatIProutes $node]
+    if { $statrtes != "" } {
+       lappend cfg "protocols {"
+       lappend cfg "    static {"
+       foreach rte $statrtes {
+           set dest [lindex $rte 0]
+           set gw [lindex $rte 1]
+           lappend cfg "       route4 $dest {"
+           lappend cfg "           next-hop: $gw"
+           lappend cfg "           metric: 0"
+           lappend cfg "       }"
+       }
+       lappend cfg "    }"
+       lappend cfg "}"
+       lappend cfg ""
+    }
+
+    if { [netconfFetchSection $node "router rip"] != "" } {
+       lappend cfg "protocols {"
+       lappend cfg "    rip {"
+       lappend cfg "   export static {"
+       lappend cfg "       metric: 1"
+       lappend cfg "       tag: 0"
+       lappend cfg "   }"
+       lappend cfg ""
+       foreach ifc [ifcList $node] {
+           set ipaddr "[lindex [split [getIfcIPaddr $node $ifc] /] 0]"
+           set ipmask "[lindex [split [getIfcIPaddr $node $ifc] /] 1]"
+           lappend cfg "       interface $ifc {"
+           lappend cfg "           vif $ifc {"
+           lappend cfg "               address $ipaddr {"
+           lappend cfg "                   advertise-default-route: true"
+           lappend cfg "                   accept-default-route: true"
+           lappend cfg "               }"
+           lappend cfg "           }"
+           lappend cfg "       }"
+       }
+       lappend cfg "    }"
+       lappend cfg "}"
+    }
+
+    return $cfg
+}
+
+
+proc router.xorp.bootcmd { node } {
+    return "/usr/local/xorp/bin/xorp_rtrmgr -b"
+}
+
+
+proc router.xorp.instantiate { eid node } {
+    set node_id "$eid\_$node"
+    l3node.instantiate $eid $node
+    exec vimage $node_id sysctl net.inet.ip.forwarding=1
+    return
+}
+
+
+proc router.xorp.nghook { eid node ifc } {
+    return [l3node.nghook $eid $node $ifc]
+}
+