# 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
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" \
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;
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;
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;
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;
netconfInsertSection $node [list "router rip" \
" redistribute static" \
" redistribute connected" \
+ " redistribute ospf" \
" network 0.0.0.0/0" \
! ]
} else {
netconfInsertSection $node [list "router ripng" \
" redistribute static" \
" redistribute connected" \
+ " redistribute ospf6" \
" network ::/0" \
! ]
} else {
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"
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"
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 } {
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
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
}
}