From: marko Date: Thu, 23 Oct 2008 14:19:14 +0000 (+0000) Subject: Simplify mechanisms for router config generation introduced in X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=87477ba1f8db17712f3ad66ec4c34d8ac85fa91e;p=imunes.git Simplify mechanisms for router config generation introduced in last commit; fix the syntax for quagga ospf2 / ospf3 configuration; and inject route redistribution statements to / from rip / ospf and ripng / ospf3. Bug found by: Submitted by: Reviewed by: Approved by: Obtained from: --- diff --git a/nodecfg.tcl b/nodecfg.tcl index f97e959..64e10d4 100755 --- a/nodecfg.tcl +++ b/nodecfg.tcl @@ -26,7 +26,7 @@ # and Technology through the research contract #IP-2003-143. # -# $Id: nodecfg.tcl,v 1.23 2008/10/23 12:04:20 marko Exp $ +# $Id: nodecfg.tcl,v 1.24 2008/10/23 14:19:14 marko Exp $ #****h* imunes/nodecfg.tcl @@ -1589,38 +1589,10 @@ proc newNode { type } { set nconfig [list \ "hostname $node" \ ! ] - if { $ripEnable == 1 } { - lappend nconfig \ - "router rip" \ - " redistribute static" \ - " redistribute connected" \ - " network 0.0.0.0/0" \ - ! - } - if { $ripngEnable == 1 } { - lappend nconfig \ - "router ripng" \ - " redistribute static" \ - " redistribute connected" \ - " network ::/0" \ - ! - } - if { $ospfEnable == 1 } { - lappend nconfig \ - "router ospf" \ - " redistribute static" \ - " redistribute connected" \ - " network 0.0.0.0/0" \ - ! - } - if { $ospf6Enable == 1 } { - lappend nconfig \ - "router ospf6" \ - " redistribute static" \ - " redistribute connected" \ - " network ::/0" \ - ! - } + setNodeProtocolRip $node $ripEnable + setNodeProtocolRipng $node $ripngEnable + setNodeProtocolOspfv2 $node $ospfEnable + setNodeProtocolOspfv3 $node $ospf6Enable } elseif {$type == "rj45"} { set nconfig [list \ "hostname UNASSIGNED" \ @@ -1697,7 +1669,7 @@ proc setNodeMirror { node value } { proc getNodeProtocolRip { node } { upvar 0 ::cf::[set ::curcfg]::$node $node - if { [netconfFetchSection $node "router rip"] == "{ redistribute static} { redistribute connected} { network 0.0.0.0/0}" } { + if { [netconfFetchSection $node "router rip"] != "" } { return 1; } else { return 0; @@ -1718,7 +1690,7 @@ proc getNodeProtocolRip { node } { proc getNodeProtocolRipng { node } { upvar 0 ::cf::[set ::curcfg]::$node $node - if { [netconfFetchSection $node "router ripng"] == "{ redistribute static} { redistribute connected} { network ::/0}" } { + if { [netconfFetchSection $node "router ripng"] != "" } { return 1; } else { return 0; @@ -1739,7 +1711,7 @@ proc getNodeProtocolRipng { node } { proc getNodeProtocolOspfv2 { node } { upvar 0 ::cf::[set ::curcfg]::$node $node - if { [netconfFetchSection $node "router ospf"] == "{ redistribute static} { redistribute connected} { network 0.0.0.0/0}"} { + if { [netconfFetchSection $node "router ospf"] != ""} { return 1; } else { return 0; @@ -1760,7 +1732,7 @@ proc getNodeProtocolOspfv2 { node } { proc getNodeProtocolOspfv3 { node } { upvar 0 ::cf::[set ::curcfg]::$node $node - if { [netconfFetchSection $node "router ospf6"] == "{ redistribute static} { redistribute connected} { network ::/0}"} { + if { [netconfFetchSection $node "router ospf6"] != ""} { return 1; } else { return 0; @@ -1786,6 +1758,7 @@ proc setNodeProtocolRip { node ripEnable} { netconfInsertSection $node [list "router rip" \ " redistribute static" \ " redistribute connected" \ + " redistribute ospf" \ " network 0.0.0.0/0" \ ! ] } else { @@ -1812,6 +1785,7 @@ proc setNodeProtocolRipng { node ripngEnable} { netconfInsertSection $node [list "router ripng" \ " redistribute static" \ " redistribute connected" \ + " redistribute ospf6" \ " network ::/0" \ ! ] } else { @@ -1838,7 +1812,8 @@ proc setNodeProtocolOspfv2 { node ospfEnable} { netconfInsertSection $node [list "router ospf" \ " redistribute static" \ " redistribute connected" \ - " network 0.0.0.0/0" \ + " redistribute rip" \ + " network 0.0.0.0/0 area 0.0.0.0" \ ! ] } else { netconfClearSection $node "router ospf" @@ -1864,7 +1839,8 @@ proc setNodeProtocolOspfv3 { node ospf6Enable} { netconfInsertSection $node [list "router ospf6" \ " redistribute static" \ " redistribute connected" \ - " network ::/0" \ + " redistribute ripng" \ + " network ::/0 area 0.0.0.0" \ ! ] } else { netconfClearSection $node "router ospf6" @@ -1886,6 +1862,7 @@ proc setNodeProtocolOspfv3 { node ospf6Enable} { proc setNodeType { node newtype } { upvar 0 ::cf::[set ::curcfg]::$node $node + global ripEnable ripngEnable ospfEnable ospf6Enable set oldtype [nodeType $node] if { [lsearch "rj45 hub lanswitch" $newtype] >= 0 } { @@ -1894,14 +1871,15 @@ proc setNodeType { node newtype } { if { [lsearch "rj45 hub lanswitch" $oldtype] >= 0 } { return } - if { $oldtype == "router" && \ - [lsearch "pc host" $newtype] >= 0 } { + if { $oldtype == "router" && [lsearch "pc host" $newtype] >= 0 } { setType $node $newtype set i [lsearch [set $node] "model *"] set $node [lreplace [set $node] $i $i] setNodeName $node $newtype[string range $node 1 end] - netconfClearSection $node "router rip" - netconfClearSection $node "router ripng" + setNodeProtocolRip $node 0 + setNodeProtocolRipng $node 0 + setNodeProtocolOspfv2 $node 0 + setNodeProtocolOspfv3 $node 0 set interfaces [ifcList $node] foreach ifc $interfaces { autoIPv4addr $node $ifc @@ -1914,16 +1892,10 @@ proc setNodeType { node newtype } { setNodeName $node $newtype[string range $node 1 end] netconfClearSection $node "ip route *" netconfClearSection $node "ipv6 route *" - netconfInsertSection $node [list "router rip" \ - " redistribute static" \ - " redistribute connected" \ - " network 0.0.0.0/0" \ - ! ] - netconfInsertSection $node [list "router ripng" \ - " redistribute static" \ - " redistribute connected" \ - " network ::/0" \ - ! ] + setNodeProtocolRip $node $ripEnable + setNodeProtocolRipng $node $ripngEnable + setNodeProtocolOspfv2 $node $ospfEnable + setNodeProtocolOspfv3 $node $ospf6Enable } }