proc historyControlDataSource.modify {val inst} {return 1.3.6.1.2.1.2.2.1.1.[ddCheckIfIndex $val]}
proc etherStatsDataSource.modify {val inst} {return [historyControlDataSource.modify $val $inst]}
proc rcBridgeFilterPort.modify {val inst} {return [ddCheckIfIndex $val]}
proc rcBridgeStaticPort.modify {val inst} {return [ddCheckIfIndex $val]}
proc ipNetToMediaIfIndex.modify {val inst} {return [ddCheckIfIndex $val]}
proc ipAdEntIfIndex.modify {val inst} {return [ddCheckIfIndex $val]}
proc ipRouteIfIndex.modify {val inst} {return [ddCheckIfIndex $val]}
proc rcMirrorByPortMirrorPort.modify {val inst} {return [ddCheckIfIndex $val]}
proc rcMirrorByPortMirroredPortOne.modify {val inst} {return [ddCheckIfIndex $val]}
proc rcMirrorByPortMirroredPortTwo.modify {val inst} {return [ddCheckIfIndex $val]}
proc rcIpFilterPortIfIndex.modify {val inst} {return [ddCheckIfIndex $val]}
proc rcDiagMirrorByPortMirroredPort.modify {val inst} {return [ddCheckIfIndex $val]}
proc rcDiagMirrorByPortMirroringPort.modify {val inst} {return [ddCheckIfIndex $val]}
proc ddCheckIfIndex {val} {if {[set n [scan $val %d/%d cardNo portNo]] == 2} {incr portNo -1
return [expr ($cardNo<<4) + $portNo]}
return $val}
proc rcVlanColor.modify {val inst} {global Dm_Pref
if {[set color [lsearch $Dm_Pref(colors) $val]] == -1} {return $val}
return $color}
proc rcVlanStaticMembers.modify {val inst} {return [dmsModifyPortBitmap $val]}
proc rcVlanNotAllowToJoin.modify {val inst} {return [dmsModifyPortBitmap $val]}
proc dmsModifyPortBitmap {val} {if {$val == ""} {return 00}
return [port parse $val]}
proc rcPortPerformRouting.modify {val inst} {if {$val == 1} {set nulls [bit print [lindex [lindex [lindex [Sess0 get null rcVlanPortMembers.0] 4] 0] 2]]
if {[lsearch $nulls $inst] == -1} {set ans [dm_Prompt .ask "A routable port can't belong to any VLAN.\nDo you want to move this port to Unassigned?" Yes Cancel]
if {$ans == 1} {error cancelled}}}
return $val}
proc rcIpFilterGlobalListFilterIdList.modify {val inst} {if {$val == ""} {return $val}
return [idList parse $val]}
proc rcIpFilterBaseListFilterIdList.modify {val inst} {return [rcIpFilterGlobalListFilterIdList.modify $val $inst]}
proc rcIpFilterPortFilterList.modify {val inst} {return [rcIpFilterGlobalListFilterIdList.modify $val $inst]}
proc rcMltVlanIds.modify {val inst} {if {$val == ""} {return $val}
return [idList parse $val]}
proc rcIpPolicyAddrListIdList.modify {val inst} {return [idList parse $val]}
proc rcIpPolicyNetListIdList.modify {val inst} {return [idList parse $val]}
proc rcVlanUserDefinedPid.modify {val inst} {if {$val == "{}"} {return $val} else {scan $val "%x" ret
return $ret}}
proc rcDevicePcmciaFileCrc.display {val} {return [rcDeviceFlashFileCrc.display $val]}
proc rcDeviceFlashFileCrc.display {val} {return [format 0x%04x $val]}
proc rcPortOperSpeed.display {val} {return "$val Mbps"}
proc sysUpTime.display {val} {return "[timeticks uptime $val] ([timeticks now $val])"}
proc dot1dStpPortDesignatedRoot.display {val} {global DmsPriv
if {[string compare [string range $val 6 end] $DmsPriv(defaultBridge)] == 0} {return self}
return $val}
proc rcStgPortDesignatedRoot.display {val} {return [dot1dStpPortDesignatedRoot.display $val]}
proc rcStgPortDesignatedBridge.display {val} {return [dot1dStpPortDesignatedRoot.display $val]}
proc rcStgTimeSinceTopologyChange.display {val} {if {$val==0} {return none}
return [timeticks uptime $val]}
proc ifLastChange.display {val} {return [dmsSinceSysUpTime $val]}
proc etherHistoryIntervalStart.display {val} {return [dmsSinceSysUpTime $val]}
proc eventLastTimeSent.display {val} {return [dmsSinceSysUpTime $val]}
proc logTime.display {val} {return [dmsSinceSysUpTime $val]}
proc rcSysLastChange.display {val} {return [dmsSinceSysUpTime $val]}
proc rcSysLastVlanChange.display {val} {return [dmsSinceSysUpTime $val]}
proc rcSysLastStatisticsReset.display {val} {return [dmsSinceSysUpTime $val]}
proc rcSysBufferUtilPeakTime.display {val} {return [dmsSinceSysUpTime $val]}
proc rcSysLastSaveToNVRam.display {val} {return [dmsSinceSysUpTime $val]}
proc rcSysLastSaveToStandbyNVRam.display {val} {return [dmsSinceSysUpTime $val]}
proc rcWebLastChange.display {val} {return [dmsSinceSysUpTime $val]}
proc rcStatOspfLastSpfRun.display {val} {return [dmsSinceSysUpTime $val]}
proc vrrpOperVirtualRouterUpTime.display {val} {return [dmsSinceSysUpTime $val]}
proc s5EnMsTopNmmLstChg.display {val} {return [dmsSinceSysUpTime $val]}
proc rcSysBufferUtil.display {val} {return $val%}
proc rcSysBufferUtilPeak.display {val} {return $val%}
proc rcSysCpuUtil.display {val} {return $val%}
proc rcSysSwitchFabricUtil.display {val} {return $val%}
proc rcSysNVRamSize.display {val} {return "$val K"}
proc rcSysNVRamUsed.display {val} {return "$val K"}
proc ipReasmTimeout.display {val} {return "$val sec"}
proc dmsSinceSysUpTime {val} {if {$val==0} {return none}
global Dm_SysUpTime
if {[set v [expr [timeticks ticks $Dm_SysUpTime]-$val]] < 0} {return "[timeticks uptime $val] ago"}
return [timeticks now $v]}
proc historyControlDataSource.display {val} {if {$val != "0.0"} {return [dmsIfIndex2Port [string range $val 20 end]]}
return $val}
proc etherStatsDataSource.display {val} {return [historyControlDataSource.display $val]}
proc alarmVariable.display {val} {return [dm_GetNameFromOid $val]}
proc rcSysTrapRecvAddress.display {val} {global Dm_Pref
if $Dm_Pref(showDNSName) {return [getIPHost $val]}
return $val}
proc rcCardType.display {val} {set cat .edCard.fCat0
if [winfo exists $cat.v1] {if {$val == 2} {foreach i {1 5} {grid $cat.l$i -row $i -column 0 -sticky e
grid $cat.v$i -row $i -column 1 -sticky w}} else {grid forget $cat.l1 $cat.v1 $cat.l5 $cat.v5}
return $val}
foreach e [snmpinfo mibprop rcCardType enums] {if {[rlindex e 0] == $val} {return [rlindex e 1]}}}
proc rcVlanColor.display {val} {global Dm_Pref
if {[set color [rlindex Dm_Pref(colors) $val]] == 0} {return $val}
return $color}
proc rcMltVlanIds.display {val} {return [rcVlanPortVlanIds.display $val]}
proc rcVlanPortVlanIds.display {val} {set i 0
foreach hex [split $val :] {if [expr $i && ($i%2 == 0)] {append str " "}
append str $hex
incr i}
if [info exists str] {set result ""
foreach hex $str {if {$hex == 0} {append result Unassigned,} elseif {$hex == 1} {append result Default,} else {global DmsPriv
set id [format %d 0x$hex]
if [info exists DmsPriv(vlan.name.$id)] {append result $DmsPriv(vlan.name.$id),} else {append result $id,}}}
return [string trimright $result ,]}
return $val}
proc rcVlanStaticMembers.display {val} {return [port print $val range]}
proc rcVlanNotAllowToJoin.display {val} {return [port print $val range]}
proc rcVlanActiveMembers.display {val} {return [port print $val range]}
proc ipAdEntIfIndex.display {val} {global DmsPriv
if {$val >= 16 && $val < 144} {return [dmsIfIndex2Port $val]} elseif {$val > 256 && $val < 512} {if [info exists DmsPriv(vlan.ifIndex2Id.$val)] {return "$DmsPriv(vlan.name.$DmsPriv(vlan.ifIndex2Id.$val)) (VLAN)"} else {return "$val (VLAN)"}} elseif {$val > 65535} {set port [expr $val >> 16]
set vlanIf [expr $val - ($port<<16)]
if [info exists DmsPriv(vlan.ifIndex2Id.$vlanIf)] {set vlanIf $DmsPriv(vlan.name.$DmsPriv(vlan.ifIndex2Id.$vlanIf))}
return "[dmsIfIndex2Port $port] in $vlanIf (VLAN)"}
return $val}
proc rcIpRouteIfIndex.display {val} {return [ipAdEntIfIndex.display $val]}
proc ipRouteIfIndex.display {val} {return [ipAdEntIfIndex.display $val]}
proc ipNetToMediaIfIndex.display {val} {return [ipAdEntIfIndex.display $val]}
proc dot1dTpFdbPort.display {val} {return [ipAdEntIfIndex.display $val]}
proc rcBridgeFdbPort.display {val} {return [ipAdEntIfIndex.display $val]}
proc rcBridgeStaticPort.display {val} {return [ipAdEntIfIndex.display $val]}
proc rcBridgeFilterPort.display {val} {return [ipAdEntIfIndex.display $val]}
proc rcMirrorByPortMirrorPort.display {val} {return [ipAdEntIfIndex.display $val]}
proc rcMirrorByPortMirroredPortOne.display {val} {return [ipAdEntIfIndex.display $val]}
proc rcMirrorByPortMirroredPortTwo.display {val} {return [ipAdEntIfIndex.display $val]}
proc rcIpFilterPortIfIndex.display {val} {return [ipAdEntIfIndex.display $val]}
proc vrrpOperIfIndex.display {val} {return [ipAdEntIfIndex.display $val]}
proc rcVlanIgmpSnoopQuerierPort.display {val} {if {$val == 0} {return "none"} else {return [ipAdEntIfIndex.display $val]}}
proc rcVlanIgmpSnoopIfIndex.display {val} {if {$val == 0} {return ""} else {return [ipAdEntIfIndex.display $val]}}
proc dot1dTpFdbAddress.display {val} {global Dm_VendorMac
set vendor [string range $val 0 7]
if [info exists Dm_VendorMac($vendor)] {return $Dm_VendorMac($vendor)[string range $val 8 end]}
return $val}
proc rcBridgeFdbAddress.display {val} {return [dot1dTpFdbAddress.display $val]}
proc rcIpRouteDest.display {val} {if {$val == "0.0.0.0"} {return default}
return $val}
proc ipRouteDest.display {val} {if {$val == "0.0.0.0"} {return default}
return $val}
proc rcVlanAgingTime.display {val} {if {$val == 0} {return N/A}
return $val}
proc rcVlanSubnetAddr.display {val} {if {$val == "0.0.0.0"} {return N/A}
return $val}
proc rcVlanSubnetMask.display {val} {return [rcVlanSubnetAddr.display $val]}
proc rcIpFilterGlobalListFilterIdList.display {val} {if {$val == ""} {return $val}
return [idList print $val]}
proc rcIpFilterBaseListFilterIdList.display {val} {return [rcIpFilterGlobalListFilterIdList.display $val]}
proc rcIpFilterPortFilterList.display {val} {return [rcIpFilterGlobalListFilterIdList.display $val]}
proc rcMltVlanIds.display {val} {return [rcIpFilterGlobalListFilterIdList.display $val]}
proc rcIpPolicyAddrAddrListIdList.display {val} {return [idList print $val]}
proc rcIpPolicyNetNetListIdList.display {val} {return [idList print $val]}
proc rcIpPolicyAddrListIdList.display {val} {return [idList print $val]}
proc rcIpPolicyAddrListPolicyIdList.display {val} {return [idList print $val]}
proc rcIpPolicyNetListIdList.display {val} {return [idList print $val]}
proc rcIpPolicyNetListPolicyIdList.display {val} {return [idList print $val]}
proc ospfLsdbSequence.display {val} {return [format "%#x" $val]}
proc ospfLsdbChecksum.display {val} {return [format "%#x" $val]}
proc ospfAreaLSACksumSum.display {val} {return [format "%#x" $val]}
proc rcVlanUserDefinedPid.display {val} {return [format "%#x" $val]}
proc rcVlanPortMembers.display {val} {return [port print $val range]}
proc dmsHotswap {numCards} {global Dm_Pref DmDMS
loop i 0 $numCards {lappend vbl rcCardType.$i}
set DmDMS(hotswapTimerId) [after [expr $Dm_Pref(hotswapFreq)*1000] Sess0 next \"dmsHotswapCB $numCards\" [list $vbl]]}
proc dmsHotswapCB {numCards sess reqid errStat errIndex vbl} {global DmDMS DmsPriv Dm_Pref Dm_Status
if {$errStat == "noError"} {foreach vb $vbl {append val [rlindex vb 0],[rlindex vb 2],}
if {[info exists DmsPriv(lastHotswap)] && $val != $DmsPriv(lastHotswap)} {dm_Rediscover}
set DmsPriv(lastHotswap) $val}
if {$Dm_Pref(hotswapFreq) == 0} {set Dm_Status "Hotswap checking disabled"} else {dmsHotswap $numCards}}
proc dmsTestBuildCB {frm inst sess isTable} {if {$isTable} {$frm.t tag coltag "" 0
$frm.t tag coltag "" 1
return}
global Dm_Radio
grid forget $frm.v0.r0 $frm.v0.r1 $frm.v0.r2 $frm.l1 $frm.v1 $frm.v2 $frm.l3 $frm.v3
button $frm.v0.b1 -text "Internal\nLoopback" -command "dmsTestAction $frm 1"
button $frm.v0.b2 -text "External\nLoopback" -command "dmsTestAction $frm 2"
button $frm.v0.b0 -text "Stop\nTest" -command "dmsTestAction $frm 0"
trace variable Dm_Radio($frm.v0) w dmsTestTraceButtons
$frm.v0 config -relief flat
pack $frm.v0.b2 $frm.v0.b1 $frm.v0.b0 -side left -padx 4
frame $frm.f2
pack $frm.v2 $frm.v3 -in $frm.f2 -side left
raise $frm.v2
raise $frm.v3
grid $frm.f2 -row 2 -column 1 -sticky w
set parent [winfo parent $frm]
$parent.fBtn.cancel config -command "catch {dmsTestStop $frm $inst $sess}; [$parent.fBtn.cancel cget -command]"}
proc dmsTestDiagBuildCB {frm inst sess isTable} {global Dm_Radio
dmsTestBuildCB $frm $sess $inst $isTable
$frm.v0.r1 config -value [snmpinfo mibprop rcTestTypesFabric value]
$frm.v0.r2 config -value [snmpinfo mibprop rcTestTypesArTable value]
$frm.v0.b1 config -text Fabric
$frm.v0.b2 config -text ARtable}
proc dmsTestStop {f inst sess} {global DmsPriv
if {[after info $DmsPriv(ifTestPoll)] != ""} {$sess set null [list "ifTestType.$inst {} 0.0"]}}
proc dmsTestAction {frm testNo} {global Dm_Pref DmsPriv
$frm.v0.r$testNo invoke
$frm.v0.r$testNo config -font $Dm_Pref(changeFont)
$frm.v1 config -font $Dm_Pref(changeFont)
set top [winfo toplevel $frm]
$top.fBtn.apply config -state normal
$top.fBtn.apply invoke
if {$testNo == 0} {$top.fBtn.refresh invoke
catch {after cancel $DmsPriv(ifTestPoll)}} else {if {[$top.status cget -text] == "ok"} {set DmsPriv(ifTestPoll) [after 2000 dmsTestPoll $frm]}}}
proc dmsTestPoll {frm} {global DmsPriv
if [winfo exists $frm] {if [winfo ismapped $frm] {set w [winfo toplevel $frm]
catch {$w.fBtn.refresh invoke}}
set DmsPriv(ifTestPoll) [after 2000 dmsTestPoll $frm]}}
proc dmsTestTraceButtons {name1 w op} {global Dm_Radio
if {$Dm_Radio($w) == 0.0} {$w.b0 config -state disabled
$w.b1 config -state normal
catch {$w.b2 config -state normal}} else {$w.b0 config -state normal
$w.b1 config -state disabled
catch {$w.b2 config -state disabled}}}
global Dm_Vendor
set Dm_Vendor {Bay Networks, Inc}
proc dmsGetCardInst {inst} {return [lindex [split $inst .] 0]}
proc dmsGetPortIfIndex {inst} {scan $inst "%d.%d" cardNo portNo
return [expr ($cardNo<<4) + ($portNo-1)]}
proc dmsIfIndex2Port {inst} {return [expr $inst>>4]/[expr ($inst&15)+1]}
proc dmsIndexPort {inst {display 0}} {if $display {return [dmsIfIndex2Port $inst]}
scan $inst "%d/%d" cardNo portNo
return [expr ($cardNo<<4) + ($portNo-1)]}
proc dmsBitIfIndex2Port {inst} {return [expr $inst>>4]/[expr ($inst&15)+1]}
proc dmsBitIndexPort {inst} {scan $inst "%d/%d" cardNo portNo
return [expr ($cardNo<<4) + ($portNo-1)]}
proc dmsStartIndex {inst sess} {return $inst}
proc dmsStopIndex {inst currInst sess} {return ![string match $inst.* $currInst]}
proc dmsIPAddrInsertTab {ip mask} {$mask delete 0 end
set ip [$ip get]
if {$ip == {0.0.0.0}} {$mask insert 0 0.0.0.0} elseif {[scan $ip %d a] == 1} {if {$a < 128} {$mask insert 0 255.0.0.0} elseif {$a < 192} {$mask insert 0 255.255.0.0} elseif {$a < 256} {$mask insert 0 255.255.255.0}}}
proc dmsDiscoverrcCardType {numCards inst parent sess} {global DmDMS
catch {
		unset DmDMS(Chassis.Card.subClasses)
		unset DmDMS(Chassis.Card.instances)
	}
loop i 0 $numCards {lappend vbl rcCardType.$i}
if [catch {set resp [Sess0 next null $vbl]} err] {dm_Prompt .err "No cards returned. AGENT ERROR: [rlindex err 2]" Continue
return}
set offset [string length [snmpinfo mibprop rcCardType value]]
incr offset
foreach vb [rlindex resp 4] {if {[snmpinfo mibprop [rlindex vb 0] descriptor] != "rcCardType"} break
set card([string range [rlindex vb 0] $offset end]) [rlindex vb 2]}
for {set i 1} {$i <= $numCards} {incr i} {if ![info exists card($i)] {set card($i) 1}
lappend DmDMS(Chassis.Card.subClasses) $card($i)
lappend DmDMS(Chassis.Card.instances) $i}}
proc dmsEndDiscovery {sess} {global DmsPriv Dm_Pref tcl_platform Dm_Path env DmsRmonScript DmDMS
catch {unset DmsPriv(vlanCache)}
if [catch {set r [Sess0 get null dot1dBaseBridgeAddress.0]}] {set DmsPriv(defaultBridge) ""} else {set DmsPriv(defaultBridge) [lindex [lindex [rlindex r 4] 0] 2]}
if {$tcl_platform(platform) == "unix" && [file isdirectory /opt/OV]} {if {[.mBar.help.m type 3] == "separator"} {.mBar.help.m insert 3 command -label "Run HP OpenView Install on Console" -command "exec $Dm_Path/hpov/install &"}}
if {![info exists DmPref(rmonScriptsRead)]  &&  [file readable $env(HOME)/.rmonscript]} {if ![catch {set fd [open $env(HOME)/.rmonscript r]}] {while {[set line [gets $fd]] != ""} {set line [split $line =]
set DmsRmonScript([rlindex line 0]) [rlindex line 1]}
close $fd}
set DmPref(rmonScriptsRead) 1}}
proc dmsSupportRouting {} {global DmsPriv Dm_Status
if ![info exists DmsPriv(rcSysSupportRouting)] {if [catch {set v [lindex [lindex [lindex [Sess0 get null rcSysSupportRouting.0] 4] 0] 2]} err] {set Dm_Status $err
bell
return 1}
if {$v == 2} {set DmsPriv(rcSysSupportRouting) 0} else {set DmsPriv(rcSysSupportRouting) 1}}
return $DmsPriv(rcSysSupportRouting)}
proc dmsCloseDeviceProc {} {global DmsRmonScript env
if [info exists DmsRmonScript] {if ![catch {set fd [open $env(HOME)/.rmonscript w]}] {foreach s [array names DmsRmonScript] {catch {puts $fd $s=$DmsRmonScript($s)}}
catch {close $fd; chmod $env(HOME)/.rmonscript 666}}}
if [catch {set vbl [lindex [Sess0 get null {rcSysLastChange.0 rcSysLastSaveToNVRam.0}] 4]}] {return 0}
set lastChange [lindex [rlindex vbl 0] 2]
set lastSave [lindex [rlindex vbl 1] 2]
if {$lastChange && $lastChange > $lastSave} {if ![winfo ismapped .] {wm deiconify .}
set ans [dm_Prompt .ask "Some changes have not been saved to NVRAM\nsince [ifLastChange.display $lastChange].\n\nDo you wish to save them now?" No Yes Cancel]
if {$ans == 0} {return 0}
if {$ans == 2} {return -1}
dm_DoAction Sess0 {{rcSysAction.0 {} 4}}}
return 0}
proc dmsExecVlanMgr {} {global Dm_Path tcl_platform env
if {$tcl_platform(platform) == "unix"} {if {[lsearch [winfo interps] vlmgr.tcl] != -1} {if ![catch {send vlmgr.tcl "wm deiconify .; raise ."}] return}}
if [info exists env(DMOS)] {set bin bin.$env(DMOS)} else {set bin bin}
exec $Dm_Path/$bin/wish42 $Dm_Path/vlmgr.tcl &}
proc dmsToolsFastStart {val} {if [catch {set instList [dm_GetSelInst Port]}] {dm_Prompt .ask "Please select ports" Continue
return}
if {$val == 1} {foreach i $instList {lappend vbl rcVlanPortType.$i}
if [catch {set r [Sess0 get null $vbl]} err] {dm_Prompt .err [dm_SnmpError err] Continue
return}
set offset [string length [snmpinfo mibprop rcVlanPortType value]]
incr offset
foreach vb [rlindex r 4] {if {[rlindex vb 2] == 2} {append msg "[dmsIfIndex2Port [string range [rlindex vb 0] $offset end]] "}}
if [info exists msg] {if {[dm_Prompt .ask "$msg port(s) are trunking.  Continue?" Yes No] == 1} return}}
if [catch {set r [Sess0 get null rcStgNumStgs.0]} err] {dm_Prompt .err [dm_SnmpError err] Continue
return}
Sess0 config -maxrept [lindex [lindex [rlindex r 4] 0] 2]
if [catch {set r [Sess0 bulk null rcStgPortMembers.0]} err] {dm_Prompt .err [dm_SnmpError err] Continue
return}
set offset [string length [snmpinfo mibprop rcStgPortMembers value]]
incr offset
foreach vb [rlindex r 4] {set stgId [string range [rlindex vb 0] $offset end]
foreach p [bit print [rlindex vb 2]] {set stgPort($p) $stgId}}
set vbl ""
foreach i $instList {if ![info exists stgPort($i)] {set stgPort($i) 1}
lappend vbl "rcStgPortFastStart.$i.$stgPort($i) {} $val"}
if [catch {Sess0 set null $vbl} err] {dm_Prompt .err [dm_SnmpError err set] Continue} else {global Dm_Status
set Dm_Status ok}}
proc dmsPortSummary {what} {global Dm_Pref Dm_WinInst
if {$what == "Up"} {foreach i [array names Dm_WinInst] {if [string match Port* [rlindex Dm_WinInst($i) 0]] {if {[rlindex Dm_WinInst($i) 0] == "Port::3"} {if [string match *dual*U*.gif [.chassis itemcget $i -image]] {lappend instList [rlindex Dm_WinInst($i) 1]}} elseif [string match *-1.gif [.chassis itemcget $i -image]] {lappend instList [rlindex Dm_WinInst($i) 1]}}}
if ![info exists instList] {dm_Prompt .err "No ports are up" Continue
return}
set instList [lsort -integer $instList]} else {if [catch {set instList [dm_GetSelInst Port]}] {dm_Prompt .ask "Please select ports to graph" Continue
return}}
set w .grportSummary
set numPorts [llength $instList]
if {$numPorts > 1} {append w T}
if [winfo exists $w] {raise $w} else {dm_Dialog graph portSummary $instList
if {$numPorts == 1} {wm title $w "($Dm_Pref(devName)) - $what Ports Performance Summary [dmsIfIndex2Port $instList]"}}}
proc dmsChassisBuildCB {frm inst sess isTable} {global DmDMS
set fanNo [dm_GetFieldNo rcChasFanOperStatus.1 $frm]
set psNo [dm_GetFieldNo rcChasPowerSupplyOperStatus.1 $frm]
for {set i 1; set l $fanNo} {$i <= 3} {incr i; incr l} {$frm.l$l config -text "Fan #$i OperStatus:"}
for {set i 1; set l $psNo} {$i <= 2} {incr i; incr l} {$frm.l$l config -text "PowerSupply #$i OperStatus:"}
if {$DmDMS(sysObjectId) == "1.3.6.1.4.1.2272.6"} {incr fanNo
grid forget $frm.l$fanNo $frm.v$fanNo
incr fanNo
grid forget $frm.l$fanNo $frm.v$fanNo
incr psNo
grid forget $frm.l$psNo $frm.v$psNo} elseif {$DmDMS(sysObjectId) == "1.3.6.1.4.1.2272.9"} {incr psNo
grid forget $frm.l$psNo $frm.v$psNo} elseif {$DmDMS(sysObjectId) == "1.3.6.1.4.1.2272.8"} {incr fanNo 2
grid forget $frm.l$fanNo $frm.v$fanNo}}
proc dmsInterfaceGetCB {frm inst sess} {global DmDMS
set autoNegSupported [lindex [lindex [lindex [$sess get null rcPortAutoNegotiationSupported.$inst] 4] 0] 2]
if {$autoNegSupported == 1} {set fNo [dm_GetFieldNo rcPortAutoNegotiate $frm]
$frm.l$fNo config -fg black
dm_enableFrame $frm.v$fNo normal
set fNo [dm_GetFieldNo rcPortAdminDuplex $frm]
$frm.l$fNo config -fg gray
dm_enableFrame $frm.v$fNo disabled
set fNo [dm_GetFieldNo rcPortAdminSpeed $frm]
$frm.l$fNo config -fg gray
dm_enableFrame $frm.v$fNo disabled} else {set fNo [dm_GetFieldNo rcPortAutoNegotiate $frm]
$frm.l$fNo config -fg gray
dm_enableFrame $frm.v$fNo disabled
set fNo [dm_GetFieldNo rcPortAdminDuplex $frm]
$frm.l$fNo config -fg black
dm_enableFrame $frm.v$fNo normal
set fNo [dm_GetFieldNo rcPortAdminSpeed $frm]
$frm.l$fNo config -fg black
dm_enableFrame $frm.v$fNo normal}}
proc dmsARPBuildCB {frm inst sess isTable} {dmsCheckVlanCache $sess}
proc dmsTrapRecvInsertCB {w inst sess} {grid forget $w.f.l3 $w.f.v3}
proc dmsPortVrrpInsertCB {w inst sess} {$w.f.v0 delete 0 end
$w.f.v0 insert 0 $inst
grid forget $w.f.l0 $w.f.f0}
proc dmsPortVrrpAddrInsertCB {w inst sess} {$w.f.v0 delete 0 end
$w.f.v0 insert 0 $inst
grid forget $w.f.l0 $w.f.v0}
proc dmsPortIPAddrInsertCB {w inst sess} {$w.f.v0 delete 0 end
$w.f.v0 insert 0 $inst
grid forget $w.f.l0 $w.f.f0
focus $w.f.v1
bind $w.f.v1 <Tab> "dmsIPAddrInsertTab $w.f.v1 $w.f.v2"}
proc dmsARPInsertCB {w inst sess} {global DmsPriv
$w.f.v0 config -width 10
pack forget $w.f.f0.b
dmsIfIndexInsertCB $w $inst $sess 0
$w.f.f0.mb.m delete 1
$w.f.f0.mb.m add cascade -label "Port in VLAN" -menu $w.f.f0.mb.m.piv
menu $w.f.f0.mb.m.piv
dmsCheckVlanCache $sess
foreach n [lsort [array names DmsPriv vlan.name.*]] {if {[set id [lindex [split $n .] 2]] == 0} continue
$w.f.f0.mb.m.piv add command -label "$DmsPriv($n)..." -command "dmsPortInVlanCB $w $id $sess"}
bind $w.f.v1 <FocusOut> {doCheckIPAddr %W}}
proc dmsPortInVlanCB {w id sess} {global DmsPriv
if [winfo exists .rcPort] {destroy .rcPort}
catch {
		foreach p [bit print [lindex [lindex [lindex [$sess get null rcVlanPortMembers.$id] 4] 0] 2]] {
			lappend membership [dmsIfIndex2Port $p]
		}
		set ifIndex [dmsIndexPort [dmsPromptPort $membership]]
		$w.f.v0 delete 0 end
		$w.f.v0 insert 0 [expr ($ifIndex<<16) + $DmsPriv(vlan.ifIndex.$id)]
	}}
proc dmsRouteInsertCB {w inst sess} {bind $w.f.v0 <Tab> "dmsIPAddrInsertTab $w.f.v0 $w.f.v1"
$w.fb.ok config -command "dmsCheckSubnetMask $w.f.v0 $w.f.v1; [$w.fb.ok cget -command]"}
proc dmsCheckSubnetMask {subnet mask} {scan [$subnet get] %d.%d.%d.%d a b c d
scan [$mask get] %d.%d.%d.%d ma mb mc md
if {$mb == 0} {set b 0}
if {$mc == 0} {set c 0}
if {$md == 0} {set d 0}
$subnet delete 0 end
$subnet insert 0 $a.$b.$c.$d}
proc dmsOspfAreaRangeInsertCB {w inst sess} {bind $w.f.v1 <Tab> "dmsIPAddrInsertTab $w.f.v1 $w.f.v2"
$w.fb.ok config -command "dmsCheckSubnetMask $w.f.v1 $w.f.v2; [$w.fb.ok cget -command]"}
proc dmsIfIndexInsertCB {w inst sess row} {global Dm_Path DmsPriv
menubutton $w.f.f$row.mb -bitmap @$Dm_Path/bitmaps/pulldown.xbm -takefocus 1 -highlightthickness 1 -relief raised -menu $w.f.f$row.mb.m
pack $w.f.f$row.mb -side left
menu $w.f.f$row.mb.m
$w.f.f$row.mb.m add command -label Port... -command "dmsIfIndexInsert $w $row"
$w.f.f$row.mb.m add cascade -label Vlan -menu $w.f.f$row.m.v
menu $w.f.f$row.mb.m.v
dmsCheckVlanCache $sess
foreach n [lsort [array names DmsPriv vlan.name.*]] {if {[set id [lindex [split $n .] 2]] == 0} continue
$w.f.f$row.mb.m.v add command -label $DmsPriv($n) -command "dmsIfIndexInsert $w $row $DmsPriv(vlan.ifIndex.$id)"}}
proc dmsIfIndexInsert {w row {ifIndex ""}} {if ![winfo exists $w] return
if {$ifIndex == ""} {catch {
			set ifIndex [dmsPromptPort]
			$w.f.v$row delete 0 end
			$w.f.v$row insert 0 $ifIndex
		}} else {$w.f.v$row delete 0 end
$w.f.v$row insert 0 $ifIndex}}
proc dmsSelectSTPPort {t sess} {global Dm_Pref
upvar #0 [$t cget -var] tab
set row [$t index active row]
if [catch {set inst $tab($row,-1)}] return
dm_Dialog graph SpanningTree $inst
scan $inst %d.%d ifIndex stgId
wm title .grSpanningTree "($Dm_Pref(devName)) - Graph SpanningTree:  Port [dmsIfIndex2Port $ifIndex], STG $stgId"}
proc dmsIpForwarding {inst sess} {set v [lindex [lindex [lindex [$sess get null ipForwarding.0] 4] 0] 2]
if {$v == 1} {return 1}
return 0}
proc dmsCheckAruMode {inst sess} {set v [lindex [lindex [lindex [$sess get null rcChasAruMode.0] 4] 0] 2]
if {$v == 2} {return 1}
return 0}
proc dmsIpForwardOspfEnable {inst sess} {set vbl "{rcIpConfOspfEnable.$inst} {ipForwarding.0}"
set values [lindex [$sess get null $vbl] 4]
set v1 [lindex [lindex $values 0] 2]
set v2 [lindex [lindex $values 1] 2]
if {$v1 == 1 && $v2 == 1} {return 1}
return 0}
proc dmsCreateAlarm {sess} {global DmsPriv Dm_Radio Dm_AlarmIndex
if [catch {dmsRmonCheckEnabled $sess} err] {if {$err != ""} {dm_Prompt .err $err Ok}
return}
set w .alarm
if [winfo exists $w] {wm deiconify $w
raise $w
$w.status config -text ""} else {set DmsPriv(alarmInterval) 10
set Dm_AlarmIndex 1
dm_MakeDlg $w "Insert Alarm" {
			{ComboMenu Variable {}}
			{Radio "Sample Type" {Absolute Delta}}
			{Spin "Sample Interval" 1 DmsPriv(alarmInterval) 3600 "1..3600 (secs)"}
			{Spin Index 1 Dm_AlarmIndex 65535 "1..65535"}}
$w.f.v0 config -width 40
grid config $w.f.f0 -columnspan 2
dmsBuildAlarmMenu $w.f.mb0.m
$w.f.v1.r0 config -value 1
$w.f.v1.r1 config -value 2
set Dm_Radio($w.f.v1) 2
set row 4
foreach lab {"Threshold Type" Value "Event Index" Severity Script} {label $w.f.l$row -text $lab:
grid $w.f.l$row -row $row -column 0 -sticky e
incr row}
loop col 1 3 {set row 4
foreach fType {label entry entry radio entry} {if {$fType == "radio"} {set f [frame $w.f.v$row-$col -class FRadio]
set Dm_Radio($f) 3
loop i 1 6 {pack [radiobutton $f.r$i -text $i -value $i -indicatoron 0 -selectcolor "" -variable Dm_Radio($f)] -side left}} else {$fType $w.f.v$row-$col}
grid $w.f.v$row-$col -row $row -column $col -sticky w -padx 4
incr row}}
$w.f.v4-1 config -text "Rising Value"
$w.f.v4-2 config -text "Falling Value"
$w.f.v6-1 config -width 10
$w.f.v6-1 insert 0 default
$w.f.v6-2 config -width 10
$w.f.v6-2 insert 0 default
$w.fb.ok config -text Insert -command "dmsCreateAlarmCB $w $sess"
button $w.fb.script -text Scripts... -command "dmsRmonAlarmScripts"
pack $w.fb.script -side left -before $w.fb.cancel
$w.fb.cancel config -command "wm withdraw $w"
$w.fb.help config -state normal -command "dm_Help help/rmon.html#createAlarm"}
focus $w.f.v0
update idletasks
if [catch {dmsGetAlarmIndex $sess} err] {$w.status config -text $err}}
proc dmsCreateAlarmCB {w sess} {global Dm_Radio Dm_AlarmIndex DmsRmonScript
set var [$w.f.v0 get]
if [catch {dmsRmonAlarmCheck $var "" $sess} err] {$w.status config -text $err
bell
focus $w.f.v0
return}
set index [$w.f.v3 get]
if ![catch {dmsRmonAlarmCheck alarmIndex $index $sess}] {$w.status config -text "Alarm $index already exists"
focus $w.f.v3
bell
return}
lappend vbl [list alarmStatus.$index {} 2]
set startupAlarm 0
loop t 1 3 {if {[set eventI [$w.f.v6-$t get]] == "default"} {set eventI [expr 60533+$t]}
if {[catch {format "%d" $eventI}] || $eventI < 0 || $eventI > 65535} {$w.status config -text "Event Index must be between 0..65535"
bell
focus $w.f.v6-$t
return}
if $eventI {if [catch {dmsRmonAlarmCheck eventIndex $eventI $sess} err] {$w.status config -text $err
bell
focus $w.f.v6-$t
return}}
set value [$w.f.v5-$t get]
if [catch {format "%d" $value} err] {$w.status config -text $err
bell
focus $w.f.v5-$t
return}
if {$t == 1} {lappend vbl [list alarmRisingThreshold.$index {} $value]
lappend vbl [list alarmRisingEventIndex.$index {} $eventI]} else {lappend vbl [list alarmFallingThreshold.$index {} $value]
lappend vbl [list alarmFallingEventIndex.$index {} $eventI]}
incr startupAlarm $t}
lappend vbl [list alarmVariable.$index {} $var]] [list alarmInterval.$index {} [$w.f.v2 get]] [list alarmSampleType.$index {} $Dm_Radio($w.f.v1)] [list alarmStartupAlarm.$index {} $startupAlarm] [list alarmOwner.$index {} [info hostname]]
if [catch {$sess set null $vbl} err] {$w.status config -text "[dm_SnmpError err] during create&wait"
bell
catch {puts stderr $vbl}} elseif [catch {$sess set null [list [list alarmStatus.$index {} 1]]} err] {$w.status config -text [dm_SnmpError err]
bell} else {$w.status config -text "Created Alarm $index"
if {[set script [$w.f.v8-1 get]] != ""} {set DmsRmonScript(risingAlarm.$index) "$script $Dm_Radio($w.f.v7-1)"}
if {[set script [$w.f.v8-2 get]] != ""} {set DmsRmonScript(fallingAlarm.$index) "$script $Dm_Radio($w.f.v7-2)"}
incr Dm_AlarmIndex}}
proc dmsCreateEvent {sess index desc} {global Dm_Pref
lappend vbl [list eventStatus.$index "" 2] [list eventDescription.$index "" $desc] [list eventType.$index "" 4] [list eventCommunity.$index DisplayString $Dm_Pref(readComm)] [list eventOwner.$index "" [info hostname]]
if [catch {$sess set null $vbl} err] {error "[dm_SnmpError err] event during create&wait"} elseif [catch {$sess set null [list [list eventStatus.$index "" 1]]} err] {error "[dm_SnmpError err] event"}}
proc dmsRmonAlarmCheck {var inst sess} {if {$inst != ""} {append var .$inst}
if [string match noSuch* [lindex [lindex [lindex [$sess get null $var] 4] 0] 2]] {error "$var doesn't exist"}}
proc dmsAlarmMenu {m} {set w .alarm.f.v0
$w delete 0 end
set var [$m entrycget active -label]
if {[string first . $var] == -1} {if [string match etherStats* $var] {catch {append var .[dmsPromptEtherStats]}} else {if {[set port [dmsPromptPort]] != ""} {catch {append var .[dmsIndexPort $port]}}}} elseif [string match *. $var] {.alarm.status config -text "Please add instance to variable"} else {.alarm.status config -text ""}
$w insert 0 $var}
proc dmsPromptPort {{instList ""}} {global DmsAlarmPort Dm_WinInst Dm_Pref
if {$instList == ""} {foreach i [lsort -integer [array names Dm_WinInst]] {if [string match Port* [rlindex Dm_WinInst($i) 0]] {lappend instList [dmsIfIndex2Port [rlindex Dm_WinInst($i) 1]]}}
if {$instList == ""} {return ""}}
set w .rcPort
toplevel $w -highlightthickness 1
wm withdraw $w
wm overrideredirect $w 1
grid [label $w.l -text "Which Port?"] -row 0 -column 1 -columnspan 16 -sticky w
set DmsAlarmPort ""
set slots ""
set i 0
foreach inst $instList {scan $inst %d/%d cardNo portNo
if {[lsearch $slots $cardNo] == -1} {lappend slots $cardNo}
radiobutton $w.r$i -indicatoron 0 -variable DmsAlarmPort -value $inst -text $portNo
grid $w.r$i -row $cardNo -column $portNo
incr i}
foreach s $slots {grid [label $w.l$s -text $s/ -font $Dm_Pref(boldFont)] -row $s -column 0 -sticky e}
bind $w <1> {set DmsAlarmPort [set DmsAlarmPort]}
bind $w <Escape> {set DmsAlarmPort ""}
dm_OnScreen $w
focus $w
grab $w
vwait DmsAlarmPort
grab release $w
destroy $w
return $DmsAlarmPort}
proc dmsPromptEtherStats {} {global DmsPriv
foreach n [array names DmsPriv RmonStatsIndex.*] {lappend instList [dmsIfIndex2Port [lindex [split $n .] 1]]}
if [info exists instList] {set inst [dmsPromptPort $instList]
return $DmsPriv(RmonStatsIndex.[dmsIndexPort $inst])}
return "."}
proc dmsCheckRmonTrap {type alarmIndex} {global DmsRmonScript
if ![info exists DmsRmonScript($type.$alarmIndex)] return
catch {eval exec $DmsRmonScript($type.$alarmIndex) &}}
proc dmsRmonAlarmScripts {} {global DmsRmonScript env
set w .rmonscript
if [dm_MakeDlg $w "Alarm Scripts" {{Label ""} {List ""}}] return
grid forget $w.f.l0 $w.f.l1
pack forget $w.status
$w.f.v0 config -text "Contents of $env(HOME)/.rmonscript"
$w.f.v1 delete 0 end
foreach s [array names DmsRmonScript] {$w.f.v1 insert end "$s   $DmsRmonScript($s)"}
if ![info exists s] {$w.fb.ok config -state disabled}
$w.fb.ok config -text Delete -command "dmsRmonAlarmDeleteScript $w.f.v1"}
proc dmsRmonAlarmDeleteScript {list} {global DmsRmonScript
if {[set sel [$list curselection]] == ""} return
unset DmsRmonScript([lindex [$list get $sel] 0])
$list delete $sel $sel}
proc dmsRmonHistoryBuildCB {table ifIndex sess vars} {global dmsRmonHist
if ![info exists dmsRmonHist(index.$ifIndex)] {error "$sess 0 {Please enable history} 0"}
if [catch {set vb [lindex [$sess next null etherHistoryIntervalStart.$dmsRmonHist(index.$ifIndex)] 4]} err] {if {[rlindex err 2] == "end"} {error "$sess 0 {No history yet recorded} 0"} else {error $err}}
set startTime [lindex [rlindex vb 0] 2]
upvar #0 $table tab
upvar $vars varList
set maxRept $dmsRmonHist(size.$ifIndex)
$sess config -maxrept $maxRept
set oid [snmpinfo mibprop [rlindex varList 0] value].$dmsRmonHist(index.$ifIndex)
set row 0
foreach v $varList {set col 0
foreach vb [lindex [$sess bulk null $v.$dmsRmonHist(index.$ifIndex)] 4] {if {$row == 0 && [string first $oid [rlindex vb 0]] == -1} {set maxRept $col
$sess config -maxrept $maxRept
break}
set tab($row,$col) [rlindex vb 2]
incr col}
if {$col < $maxRept} {append errMsg "$v: [expr $maxRept-$col] intervals truncated\n"
loop c $col $maxRept {set tab($row,$c) N/A}}
incr row}
if [info exists errMsg] {dm_Prompt .err "History Table is too large at $maxRept intervals:\n\n$errMsg" Continue}
if {$tab(1,-1) == "Utilization"} {loop c 0 $maxRept {catch {set tab(1,$c) [format %.2f [expr $tab(1,$c)/100.0]]}}}
set tab(-1,0) [lindex [dmsSinceSysUpTime $startTime] 3]
set i [expr $dmsRmonHist(interval.$ifIndex)*100]
loop c 1 $maxRept {incr startTime $i
set tab(-1,$c) [lindex [dmsSinceSysUpTime $startTime] 3]}
if {$i >= 6000} {loop c 0 $maxRept {set tab(-1,$c) [string range $tab(-1,$c) 0 4]}}
return $maxRept}
proc dmsCheckRmonHistory {ifIndex sess} {global dmsRmonHist Dm_Status Dm_SysUpTime
catch {unset dmsRmonHist}
set dmsRmonHist(lastIndex) 0
if [catch {set tabSize [lindex [lindex [lindex [$sess get null rcTblRmonHistoryControlSize.0] 4] 0] 2]} err] {set Dm_Status [rlindex err 2]
return 0}
if {$tabSize == 0} {return 0}
$sess config -maxrept $tabSize
set ifIndexOffset [expr [string length [snmpinfo mibprop ifIndex value]]+1]
set indexOffset [expr [string length [snmpinfo mibprop historyControlDataSource value]]+1]
set r [$sess bulk null {historyControlDataSource. historyControlBucketsGranted. historyControlInterval.}]
foreach {data buckets interval} [rlindex r 4] {set index [string range [rlindex data 2] $ifIndexOffset end]
set inst [string range [rlindex data 0] $indexOffset end]
set dmsRmonHist(index.$index) $inst
set dmsRmonHist(size.$index) [rlindex buckets 2]
set dmsRmonHist(interval.$index) [rlindex interval 2]}
set dmsRmonHist(lastIndex) $inst
return [info exists dmsRmonHist(index.$ifIndex)]}
proc dmsCvtIfIndex2RmonHistIndex {ifIndex} {global dmsRmonHist
if [info exists dmsRmonHist(index.$ifIndex)] {return $dmsRmonHist(index.$ifIndex)}
return 0}
proc dmsRmonEnableHistory {} {global dmsRmonHist Dm_Status
if [catch {dmsRmonCheckEnabled Sess0} err] {dm_Prompt .err $err Ok
return}
foreach i [dm_GetSelInst Port] {if ![dmsCheckRmonHistory $i Sess0] {if [info exists dmsRmonHist(lastIndex)] {set etherIndex [incr dmsRmonHist(lastIndex)]} else {set etherIndex 1}
if [catch {Sess0 set null [list [list historyControlStatus.$etherIndex "" 2] [list historyControlOwner.$etherIndex "" [info hostname]] [list historyControlDataSource.$etherIndex "" 1.3.6.1.2.1.2.2.1.1.$i]]} err] {dm_Prompt .err [dm_SnmpError err] Ok
return}
if [catch {Sess0 set null [list [list historyControlStatus.$etherIndex "" 1]]} err] {dm_Prompt .err [dm_SnmpError err] Ok
return}}}
set Dm_Status ok}
proc dmsRmonControlBuildCB {f inst sess isTable} {set top [winfo toplevel $f]
$top.fBtn.remove config -command "[$top.fBtn.remove cget -command]; catch {unset dmsRmonHist}"
dmsRmonEtherBuildCB $f $inst $sess $isTable}
proc dmsRmonEtherBuildCB {f inst sess isTable} {if [catch {dmsRmonCheckEnabled $sess} err] {if {$err != ""} {dm_Prompt .err $err Ok}
return}}
proc dmsRmonEnableStat {} {global DmsPriv Dm_Status
if [catch {dmsRmonCheckEnabled Sess0} err] {dm_Prompt .err $err Ok
return}
foreach i [dm_GetSelInst Port] {if ![dmsCheckRmonStats $i Sess0] {set etherIndex [incr DmsPriv(RmonStatsLastIndex)]
if [catch {Sess0 set null [list [list etherStatsStatus.$etherIndex "" 2] [list etherStatsOwner.$etherIndex "" [info hostname]] [list etherStatsDataSource.$etherIndex "" 1.3.6.1.2.1.2.2.1.1.$i]]} err] {dm_Prompt .err [dm_SnmpError err] Ok} elseif [catch {Sess0 set null [list [list etherStatsStatus.$etherIndex "" 1]]} err] {dm_Prompt .err [dm_SnmpError err] Ok}}}
set Dm_Status ok}
proc dmsCheckRmonStats {ifIndex sess} {global DmsPriv
set DmsPriv(RmonStatsLastIndex) 0
foreach n [array names DmsPriv RmonStatsIndex.*] {unset DmsPriv($n)}
if [catch {set r [$sess get null rcTblRmonStatSize.0]}] {return 0}
if {[set tabSize [lindex [lindex [rlindex r 4] 0] 2]] == 0} {return 0}
$sess config -maxrept [lindex [lindex [rlindex r 4] 0] 2]
set indexOffset [expr [string length [snmpinfo mibprop etherStatsDataSource value]]+1]
foreach vb [lindex [$sess bulk null etherStatsDataSource.0] 4] {set inst [string range [rlindex vb 0] $indexOffset end]
set DmsPriv(RmonStatsIndex.[string range [rlindex vb 2] 20 end]) $inst}
set DmsPriv(RmonStatsLastIndex) $inst
return [info exists DmsPriv(RmonStatsIndex.$ifIndex)]}
proc dmsCvtIfIndex2RmonIndex {ifIndex} {global DmsPriv
if [info exists DmsPriv(RmonStatsIndex.$ifIndex)] {return $DmsPriv(RmonStatsIndex.$ifIndex)}
return 9999}
proc dmsTftpBuildCB {frm inst sess isTable} {global Dm_Radio Dm_Path Dm_Pref
set w [winfo toplevel $frm]
grid forget $frm.v0
$frm.v0 config -width 16
set myIPAddr [getIPAddr [info hostname]]
frame $frm.f0
radiobutton $frm.f0.r0 -value 1 -text [info hostname] -variable Dm_Radio($frm.f0) -command "dmsTftpRadioCB $frm 1 $myIPAddr"
radiobutton $frm.f0.r1 -value 0 -text Remote: -variable Dm_Radio($frm.f0) -command "dmsTftpRadioCB $frm 0 $myIPAddr"
pack $frm.f0.r0 $frm.f0.r1 -side left
pack $frm.v0 -in $frm.f0 -side right
raise $frm.v0
grid $frm.f0 -row 0 -column 1 -sticky w
grid forget $frm.v1
frame $frm.f1
button $frm.b1 -bitmap @$Dm_Path/bitmaps/pulldown.xbm
$frm.v1 config -width 50
pack $frm.v1 $frm.b1 -in $frm.f1 -side left
raise $frm.v1
grid $frm.f1 -row 1 -column 1 -sticky w
$frm.b1 config -command "dm_ShowDropList .tftpboot"
raise $frm.f1 $frm.v2
raise $frm.v2
if ![winfo exists .tftpboot] {dm_CreateDropList .tftpboot $frm.v1
bind .tftpboot.l <Map> {
			catch {$Dm_DropListTarget(%W) config -font $Dm_Pref(changeFont)}
		}} else {.tftpboot.l delete 0 end}
catch {
		foreach f [lsort [glob /tftpboot/*]] {
			.tftpboot.l insert 0 $f
		}
	}
if {[$frm.v0 get] == $myIPAddr} {set Dm_Radio($frm.f0) 1
dmsTftpRadioCB $frm $Dm_Radio($frm.f0) $myIPAddr} else {set Dm_Radio($frm.f0) 0
$frm.b1 config -state disabled}
$w.fBtn.apply config -command "dmsCheckTftp $w $frm $sess $myIPAddr; [$w.fBtn.apply cget -command]"}
proc dmsTftpRadioCB {frm local myIPAddr} {global Dm_Pref
if $local {pack forget $frm.v0
$frm.b1 config -state normal
$frm.v0 delete 0 end
$frm.v0 insert 0 $myIPAddr
$frm.v0 config -font $Dm_Pref(changeFont)} else {pack $frm.v0 -in $frm.f0 -side right
$frm.v0 delete 0 end
raise $frm.v0
$frm.b1 config -state disabled}
[winfo toplevel $frm].fBtn.apply config -state normal}
proc dmsCheckTftp {w frm sess myIPAddr} {if {[[string range $w 1 end] cget -CatNo] != 3} return
global Dm_Radio
if {$myIPAddr == [$frm.v0 get]} {set name [$frm.v1 get]
if ![file exists $name] {if {$Dm_Radio($frm.v2) != 3} {dm_Prompt .err "$name not found" Continue
return}
if [catch {close [open $name w]} err] {dm_Prompt .err $err Continue
return}
catch {chmod $name 666}} elseif ![file readable $name] {if [catch {chmod $name 666}] {$w.status config -text "$name: permission denied"
return}}} else {if {[$frm.v1 get] == ""} {dm_Prompt .err "Please supply a filename" Continue
return}}
after 3000 $sess get "\"dmsCheckTftpProgressCB $frm 3\"" rcTftpResult.0}
proc dmsCheckTftpProgressCB {frm secs s reqid err errIndex vbl} {if ![winfo exists $frm] return
set w [winfo toplevel $frm]
if {$err != "noError"} {$w.status config -text $err
bell
return}
$w.status config -text "Transferring...$secs secs..."
set val [lindex [rlindex vbl 0] 2]
dm_SetROEnum $frm.v3 $val
if {$val == 2} {incr secs 3
after 3000 $s get "\"dmsCheckTftpProgressCB $frm $secs\"" rcTftpResult.0} else {$w.status config -text "Transfer ended after $secs secs"
bell}}
proc dmsTrapRegisterProc {sess} {set inst [getIPAddr [info hostname]]
$sess get "dmsTrapRegisterProcCB $inst" rcSysTrapRecvRowStatus.$inst}
proc dmsTrapRegisterProcCB {inst sess reqid err errI vbl} {if {$err != "noError"} {global Dm_Status
set Dm_Status "Trap registration failed: $err"}
if [string match noSuch* [lindex [rlindex vbl 0] 2]] {global Dm_Pref tcl_platform
set devIpAddr [getIPAddr $Dm_Pref(devName)]
set vbl {}
lappend vbl "rcSysTrapRecvRowStatus.$inst {} 4" "rcSysTrapRecvCommunity.$inst {} public"
if {$tcl_platform(platform) == "windows"} {lappend vbl "rcSysTrapRecvVersion.$inst {} 2"}
$sess set dmsTrapRegisterSetProcCB $vbl}}
proc dmsTrapRegisterSetProcCB {s reqid err errI vbl} {if {$err != "noError"} {global Dm_Status
set Dm_Status "Trap registration failed: $err"}}
proc dmsTrapProc {time trap vbl} {if {[string compare 1.3.6.1.2.1.16.1 $trap] == 0} {set trap risingAlarm
dmsCheckRmonTrap $trap [lindex [rlindex vbl 0] 2]} elseif {[string compare 1.3.6.1.2.1.16.2 $trap] == 0} {set trap fallingAlarm
dmsCheckRmonTrap $trap [lindex [rlindex vbl 0] 2]} elseif {[string compare 1.3.6.1.6.3.1.1.4.1.0 $trap] == 0} {set oid [lindex [lindex $vbl end] 0]
if {$oid == "1.3.6.1.2.1.16.3.1.1.7"} {set trap risingAlarm
dmsCheckRmonTrap $trap [lindex [rlindex vbl 0] 2]} elseif {$oid == "1.3.6.1.2.1.16.3.1.1.8"} {set trap fallingAlarm
dmsCheckRmonTrap $trap [lindex [rlindex vbl 0] 2]} elseif {$oid == "1.3.6.1.6.3.1.1.4.3.0"} {set vb [lindex $vbl 2]
if {[snmpinfo mibprop [rlindex vb 0] descriptor] == "ifOperStatus"} {if {[rlindex vb 2] == 1} {set trap linkUp} else {set trap linkDown}}}} else {set trap [snmpinfo mibprop $trap descriptor]}
dm_RecordTrap $time $trap vbl
if [string match link* $trap] {set inst [lindex [rlindex vbl 0] 2]
set val [expr [lindex [rlindex vbl 2] 2]<<3|[lindex [rlindex vbl 1] 2]]
global Dm_WinInst DmDMS
foreach i [array names Dm_WinInst] {set obj [rlindex Dm_WinInst($i) 0]
if {[string match Port* $obj] && [rlindex Dm_WinInst($i) 1] == $inst} {if {$obj == "Port::3"} {set val [expr [lindex [rlindex vbl 4] 2]<<8|[lindex [rlindex vbl 3] 2]<<6|$val]}
.chassis itemconfig $i -image [dm_GetImage [rlindex DmDMS($obj.status==$val) 1]]
return}}} elseif {$trap == "coldStart"} {global Dm_SysUpTime Dm_SysUpTimeOrig
set Dm_SysUpTimeOrig $time
set Dm_SysUpTime [timeticks clock $time]
after 5000 dm_Rediscover} elseif [string match rcCard* $trap] {dm_Rediscover} elseif {$trap == "rcChasPowerSupplyDown" || $trap == "rcChasFanDown"} {dm_Rediscover}}
proc dmsCheckVlanCache {sess} {global DmsPriv Dm_Status
if [catch {set resp [$sess get null {rcSysLastVlanChange.0 rcVlanNumVlans.0}]} err] {set Dm_Status "Can't get VLANs: [rlindex err 0]"
return}
set lastChange [lindex [lindex [rlindex resp 4] 0] 2]
if {![info exists DmsPriv(vlanCache)] || $lastChange != $DmsPriv(vlanCache)} {set DmsPriv(vlanCache) $lastChange
foreach n [array names DmsPriv vlan.name.*] {unset DmsPriv($n)}
set offset [string length [snmpinfo mibprop rcVlanName value]]
incr offset
$sess config -maxrept [lindex [lindex [rlindex resp 4] 1] 2]
foreach {name ports ifIndex} [lindex [$sess bulk null {rcVlanName.0 rcVlanPortMembers.0 rcVlanIfIndex.0}] 4] {set id [string range [rlindex name 0] $offset end]
set DmsPriv(vlan.name.$id) [rlindex name 2]
set DmsPriv(vlan.ports.$id) [bit print [rlindex ports 2]]
set ifIndex [rlindex ifIndex 2]
set DmsPriv(vlan.ifIndex.$id) $ifIndex
set DmsPriv(vlan.ifIndex2Id.$ifIndex) $id}}}
proc dmsIgnoreVlanNull {inst sess} {return 0}
proc dmsCheckUseIPConfig {ifIndex sess} {global DmsPriv Dm_Status
if [catch {set rc [$sess get null rcVlanRoutingEnable.$DmsPriv(vlan.ifIndex2Id.$ifIndex)]} err] {set Dm_Status [dm_SnmpError err]
return 0}
if {[lindex [lindex [rlindex rc 4] 0] 2] == 1} {return 1} else {return 0}}
proc dmsVlanSelectBridge {t sess} {global Dm_Pref DmsPriv
upvar #0 [$t cget -var] tab
set row [$t index active row]
if [catch {set vlanId $tab($row,-1)}] return
set DmsPriv(selectedVLAN) $vlanId
$sess config -rd $Dm_Pref(readComm)@$vlanId -wr $Dm_Pref(writeComm)@$vlanId
set w .edBridge
if [winfo exists $w] {$w.fBtn.refresh invoke
raise $w} else {dm_Dialog edit Bridge 0}
wm title $w "($Dm_Pref(devName)) - edit Bridge ($tab($row,0) VLAN)"
global Dm_VendorMac Dm_Path
catch {source $Dm_Path/dmdb/accelar1k/v120/vendors}}
proc dmsVlanSelectRouting {t sess} {global Dm_Pref DmsPriv
upvar #0 [$t cget -var] tab
set row [$t index active row]
if [catch {set vlanIfIndex $tab($row,11)}] return
if {$tab($row,9) == "N/A"} {catch {unset DmsPriv(vlan.$vlanIfIndex.subnet)}} else {set DmsPriv(vlan.$vlanIfIndex.subnet) $tab($row,9)}
set DmsPriv(vlan.ifIndex2Id.$vlanIfIndex) $tab($row,-1)
set w .edVlan_IP
if [winfo exists $w] {[string range $w 1 end] configure -GlobInst $vlanIfIndex -CatInst $vlanIfIndex
$w.fBtn.refresh invoke
raise $w} else {dm_Dialog edit Vlan_IP $vlanIfIndex}
wm title $w "($Dm_Pref(devName)) - edit Vlan_IP ($tab($row,0) VLAN)"}
proc dmsVlanPortBuildCB {w inst sess isTable} {dmsCheckVlanCache $sess}
proc dmsVlanBuildCB {w inst sess isTable} {set tabObj ::DMedit::[string range $w 1 end]
foreach col {4 6 7} {$w.t tag coltag popup $col
$tabObj setPopupCmd $col "dmsVlanEditMembership $w.t $sess"}
$w.t tag coltag popup 1
$tabObj setPopupCmd 1 "dmsVlanModifyColor $w.t $tabObj"
$w.t config -cols 12}
proc dmsVlanEditMembership {t sess} {global DmsPriv Dm_Pref Dm_Radio
set w .vlanMembers
if [winfo exists $w] {raise $w
set numPorts $Dm_Pref(numPorts)} else {toplevel $w
dm_transient $w [winfo toplevel $t]
wm geom $w "+[winfo pointerx .]+[winfo pointery .]"
wm resizable $w 0 0
set numPorts [dmsCreatePortGrid $w.f button]
set Dm_Pref(numPorts) $numPorts
frame $w.l
set i 1
foreach text {Never Potential Always} color {red yellow green} {
			pack [button $w.l.l$i -text $text -bg $color -font $Dm_Pref(normalFont) -padx 2 -pady 1 -command "dmsVlanChangeColor $w.f $color $numPorts"]
			incr i
		}
pack [label $w.l.l$i -text "Active" -font $Dm_Pref(italicFont) -fg blue -bd 1 -relief sunken]
frame $w.fBtn -class FBtn
button $w.fBtn.ok -text Ok
button $w.fBtn.cancel -text Cancel -command "destroy $w"
pack $w.fBtn.cancel $w.fBtn.ok -side right -pady 5
bind $w <Escape> "$w.fBtn.cancel invoke"
bind $w <Return> "$w.fBtn.ok invoke"
grid $w.l -row 0 -column 0
grid $w.f -row 0 -column 1
grid $w.fBtn -row 1 -column 0 -columnspan 2}
set row [$t index active row]
upvar #0 [$t cget -var] tab
set vlanId $tab($row,-1)
set byPort [expr {$tab($row,2) == "byPort"}]
set DmsPriv($w.f.byPort) $byPort
wm title $w "($Dm_Pref(devName)) - VLAN $tab($row,0)($vlanId) Ports"
$w.fBtn.ok config -command "dmsVlanEditMembershipCB $w $t $row $numPorts $byPort"
if $byPort {pack forget $w.l.l2 $w.l.l4} else {pack $w.l.l2 $w.l.l4}
set bg [$w cget -bg]
loop i 0 $numPorts {set port2Check($Dm_Radio($w.f.c$i)) $w.f.c$i
$w.f.c$i config -bg $bg -fg black -font $Dm_Pref(normalFont)}
if $tab($row,3) {loop i 0 $numPorts {$w.f.c$i config -state disabled}
foreach p [bit print [lindex [lindex [lindex [$sess get null rcStgPortMembers.$tab($row,3)] 4] 0] 2]] {if [info exists port2Check($p)] {$port2Check($p) config -state normal}}}
if $byPort {loop i 0 $numPorts {if {[$w.f.c$i cget -state] == "normal"} {$w.f.c$i config -bg red}}
foreach p [bit print [dmsModifyPortBitmap [list $tab($row,4)]]] {if [info exists port2Check($p)] {$port2Check($p) config -bg green}}} else {if ![catch {set r [$sess get null rcStgNotAllowedPorts.0]} err] {foreach p [bit print [lindex [lindex [rlindex r 4] 0] 2]] {if [info exists port2Check($p)] {$port2Check($p) config -state disabled}}}
loop i 0 $numPorts {if {[$w.f.c$i cget -state] == "normal"} {$w.f.c$i config -bg yellow}}
foreach p [bit print [dmsModifyPortBitmap [list $tab($row,5)]]] {if [info exists port2Check($p)] {$port2Check($p) config -fg blue -font $Dm_Pref(italicFont)}}
foreach p [bit print [dmsModifyPortBitmap [list $tab($row,6)]]] {if [info exists port2Check($p)] {$port2Check($p) config -bg green}}
foreach p [bit print [dmsModifyPortBitmap [list $tab($row,7)]]] {if [info exists port2Check($p)] {if {[$port2Check($p) cget -state] == "normal"} {$port2Check($p) config -bg red}}}}}
proc dmsVlanEditMembershipCB {w t row numPorts byPort} {global Dm_Radio
if ![winfo exists $t] return
upvar #0 [$t cget -var] tab
if $byPort {set ports ""
loop i 0 $numPorts {if {[$w.f.c$i cget -state] == "normal" && [$w.f.c$i cget -bg] == "green"} {lappend ports $Dm_Radio($w.f.c$i)}}
set tab($row,4) [port print [bit parse $ports] range]
set tab($row,6) ""
set tab($row,7) ""
$t tag celltag edited $row,4 $row,6 $row,7} else {set staticPorts ""
set notAllowedPorts ""
set potentialPorts ""
loop i 0 $numPorts {if {[$w.f.c$i cget -state] == "normal"} {set bg [$w.f.c$i cget -bg]
if {$bg == "green"} {lappend staticPorts $Dm_Radio($w.f.c$i)} elseif {$bg == "red"} {lappend notAllowedPorts $Dm_Radio($w.f.c$i)} elseif {$bg == "yellow"} {lappend potentialPorts $Dm_Radio($w.f.c$i)}}}
set tab($row,4) [port print [bit parse [concat $potentialPorts $staticPorts]] range]
set tab($row,6) [port print [bit parse $staticPorts] range]
set tab($row,7) [port print [bit parse $notAllowedPorts] range]
$t tag celltag edited $row,4 $row,6 $row,7}
[winfo toplevel $t].fBtn.apply config -state normal
[winfo toplevel $t].fBtn.apply invoke
destroy $w}
proc dmsVlanModifyColor {t tabObj} {global Dm_Radio
dm_RadioBox .color color
upvar #0 [$t cget -var] tab
set row [$t index active row]
set tab($row,1) $Dm_Radio(.color)
$t tag celltag edited $row,1
$tabObj hide popup
[winfo toplevel $t].fBtn.apply config -state normal}
proc dmsBridgeForwardingBuildCB {w inst sess isTable} {}
proc dmsMac2IPHost {t sess} {upvar #0 [$t cget -var] tab
scan [$t index active] %d,%d row col
if {[dm_GetTYPE [rlindex tab(-2,$col) 0]] == "MacAddress"} {global Dm_VendorMac}}
proc dmsBridgeStaticInsertCB {w inst sess} {$w.f.f1.b config -command "dmsBridgeInsertPort $w $sess"}
proc dmsBridgeInsertPort {w sess} {global DmsPriv
dmsCheckVlanCache $sess
set ports ""
foreach ifIndex $DmsPriv(vlan.ports.$DmsPriv(selectedVLAN)) {lappend ports [dmsIfIndex2Port $ifIndex]}
if [catch {set inst [dmsPromptPort $ports]}] {set inst ""}
$w.f.v1 delete 0 end
$w.f.v1 insert 0 $inst}
proc dmsBridgeFilterInsertCB {w inst sess} {global DmsPriv
dmsCheckVlanCache $sess
set ports ""
foreach ifIndex $DmsPriv(vlan.ports.$DmsPriv(selectedVLAN)) {lappend ports [dmsIfIndex2Port $ifIndex]}
dm_PortSetEnable $w.f.f2 [port parse $ports]}
proc dmsCreatePortGrid {f widget} {global Dm_WinInst Dm_Radio Dm_Pref
set instList ""
foreach i [lsort -integer [array names Dm_WinInst]] {if [string match Port* [rlindex Dm_WinInst($i) 0]] {lappend instList [dmsIfIndex2Port [rlindex Dm_WinInst($i) 1]]}}
frame $f -bd 1 -relief sunken
set numPorts 0
set slots ""
foreach inst $instList {scan $inst %d/%d cardNo portNo
if {[lsearch $slots $cardNo] == -1} {lappend slots $cardNo}
if {$widget == "check"} {set Dm_Radio($f.c$numPorts) 0
checkbutton $f.c$numPorts -indicatoron 0 -onvalue [dmsIndexPort $inst] -text $portNo -selectcolor white -variable Dm_Radio($f.c$numPorts)} else {set Dm_Radio($f.c$numPorts) [dmsIndexPort $inst]
button $f.c$numPorts -font $Dm_Pref(normalFont) -text $portNo -padx 1 -pady 1
bind $f.c$numPorts <1> "dmsVlanTriState %W"
bind $f.c$numPorts <space> "dmsVlanTriState %W"}
grid $f.c$numPorts -row [lindex [split $inst /] 0] -column [lindex [split $inst /] 1]
incr numPorts}
foreach s $slots {label $f.l$s -text $s/ -font $Dm_Pref(boldFont)
grid $f.l$s -row $s -column 0 -sticky e}
return $numPorts}
proc dmsCreatePortGridCB {src target numPorts} {global Dm_Radio
set ports ""
loop i 0 $numPorts {if $Dm_Radio($src.c$i) {lappend ports $Dm_Radio($src.c$i)}}
$target delete 0 end
$target insert 0 [port print [bit parse $ports] range]}
proc dmsVrrpInsertCB {w inst sess} {global DmsPriv
$w.f.v0 delete 0 end
$w.f.v0 insert 0 $inst
grid forget $w.f.l0 $w.f.f0}
proc dmsIPAddrInsertCB {w inst sess} {global DmsPriv
$w.f.v0 delete 0 end
$w.f.v0 insert 0 $inst
grid forget $w.f.l0 $w.f.f0
focus $w.f.v1
if [info exists DmsPriv(vlan.$inst.subnet)] {$w.f.v1 insert 0 $DmsPriv(vlan.$inst.subnet)}
bind $w.f.v1 <Tab> "dmsIPAddrInsertTab $w.f.v1 $w.f.v2"}
proc dmsVlanSelectSnoop {t sess} {global Dm_Pref DmsPriv
upvar #0 [$t cget -var] tab
set row [$t index active row]
set vlanId $tab($row,-1)
global Dm_IgmpVlanId
set Dm_IgmpVlanId $vlanId
set w .edSnoop
if [winfo exists $w] {[string range $w 1 end] configure -GlobInst $vlanId -CatInst $vlanId
$w.fBtn.refresh invoke
raise $w} else {dm_Dialog edit Snoop $vlanId}
wm title $w "($Dm_Pref(devName)) - edit Snoop ($tab($row,0) VLAN)"}
proc dmsVlanIgmpSnoopStart {inst sess} {return $inst}
proc dmsVlanIgmpSnoopStop {inst currInst sess} {return ![string match $inst.* $currInst]}
proc dmsVlanIgmpSnoopStaticInsertCB {w inst sess} {global Dm_IgmpVlanId
puts "vlan id = $Dm_IgmpVlanId"
$w.f.v0 insert 0 $Dm_IgmpVlanId
$w.f.v1 config -width 15
button $w.f.f1.range -text "..." -command "dmsShowIPMAddr $w" -padx 2 -pady 0
pack $w.f.f1.range -side right}
proc dmsShowIPMAddr {w} {if {[set ipAddr [$w.f.v1 get]] == ""} {dm_Prompt .err "Please enter a multicast address first" Continue} else {dm_MakeDlg .ipm "MultiCast" {{Label "" "MultiCast Range:"} {List ""}}
grid forget .ipm.f.l0 .ipm.f.l1
.ipm.f.v1 config -width 16
foreach ip [ipmShowIpAddr $ipAddr] {.ipm.f.v1 insert end $ip}
pack forget .ipm.fb.ok}}
proc dmsVlanInsertCB {w inst sess} {global Dm_Path Dm_Radio Dm_Pref Dm_WinInst DmsVlanMembers DmsPriv
$w.f.v2 insert 0 [rlindex Dm_Pref(colors) [expr [$w.f.v0 get] % 32]]
bind $w.f.v2 <FocusOut> break
$w.f.v2 config -width 20
pack forget $w.f.f2.l
button $w.f.f2.b -bitmap @$Dm_Path/bitmaps/pulldown.xbm -command "dmsVlanInsertColor $w.f.v2"
pack $w.f.f2.b -side left
set Dm_Radio(.color) [$w.f.v2 get]
$w.f.v6 config -state disabled -bg [$w cget -bg]
$w.f.l6 config -text "SpanningTreeGroupId:"
$w.f.f6.l config -text "0..128"
menubutton $w.f.f6.b -bitmap @$Dm_Path/bitmaps/pulldown.xbm -relief raised -bd 1 -menu $w.f.f6.b.m
pack $w.f.f6.b -side left
grid forget $w.f.l5 $w.f.v5
grid forget $w.f.l9 $w.f.v9
grid forget $w.f.l4 $w.f.v4
grid forget $w.f.l15 $w.f.v15
grid forget $w.f.l16 $w.f.v16
grid forget $w.f.l17 $w.f.f17
grid forget $w.f.l18 $w.f.f18
grid forget $w.f.l19 $w.f.f19
grid forget $w.f.l20 $w.f.v20
grid $w.f.v7 -pady 8
$w.f.l7 config -font $Dm_Pref(boldFont)
$w.f.v7.r0 config -command "dmsVlanInsertCBType $w port"
$w.f.v7.r1 config -command "dmsVlanInsertCBType $w subnet"
$w.f.v7.r2 config -command "dmsVlanInsertCBType $w protocol"
destroy $w.f.l10
set i 0
foreach p [winfo children $w.f.v11] {$p config -command "dmVlanInsertCBProto $w $i"
incr i}
set Dm_Radio($w.f.v11) 1
grid forget $w.f.v10 $w.f.v11
set numPorts [dmsCreatePortGrid $w.f.f10 button]
frame $w.f.l10
pack [label $w.f.l10.l0 -text "Dynamic Membership:"]
set i 1
foreach text {Never Potential Always} color {red yellow green} {
		pack [button $w.f.l10.l$i -text $text -bg $color -font $Dm_Pref(normalFont) -padx 2 -pady 1 -command "dmsVlanChangeColor $w.f.f10 $color $numPorts"]
		incr i
	}
$w.fb.ok config -command "dmsVlanInsertApply $w $numPorts; [$w.fb.ok cget -command]"
bind $w.f.v12 <Tab> "dmsIPAddrInsertTab $w.f.v12 $w.f.v13"
dmsVlanStgMenu $w $numPorts [menu $w.f.f6.b.m] $w.f.v6 $sess
catch {$w.f.f6.b.m invoke 1}
set DmsPriv($w.f.f8.byPort) 1
dmsVlanInsertCBType $w port
dmsVlanShowTrunksInStatic $w.f.f10 $sess
set v [lindex [lindex [lindex [$sess get null rcChasAruMode.0] 4] 0] 2]
if {$v != 2} {$w.f.l15 config -fg gray
dm_enableFrame $w.f.v15 disabled}}
proc dmsVlanInsertApply {w numPorts} {global Dm_Radio
if {$Dm_Radio($w.f.v7) == 1} {$w.f.v9 delete 0 end
$w.f.v10 delete 0 end
$w.f.v14 delete 0 end} else {set potentialMembers ""
set staticMembers ""
set notAllowed ""
loop i 0 $numPorts {if {[set color [$w.f.f10.c$i cget -bg]] == "red"} {lappend notAllowed $Dm_Radio($w.f.f10.c$i)} elseif {$color == "green"} {lappend staticMembers $Dm_Radio($w.f.f10.c$i)} elseif {$color == "yellow"} {lappend potentialMembers $Dm_Radio($w.f.f10.c$i)}}
dm_PortSetDisplay $w.f.f8 [bit parse [concat $staticMembers $potentialMembers]]
$w.f.v9 delete 0 end
$w.f.v9 insert 0 [port print [bit parse $staticMembers] range]
$w.f.v10 delete 0 end
$w.f.v10 insert 0 [port print [bit parse $notAllowed] range]
if {[$w.f.v1 get] == ""} {if {$Dm_Radio($w.f.v7) == 2} {$w.f.v1 insert 0 [$w.f.v12 get]} else {foreach e [snmpinfo mibprop rcVlanProtocolId enums] {if {$Dm_Radio($w.f.v11) == [rlindex e 0]} {$w.f.v1 insert 0 [rlindex e 1]
break}}}}}}
proc dmsVlanStgMenu {w numPorts m e sess} {if ![catch {set r [$sess get null rcStgNotAllowedPorts.0]} err] {set notAllowed [lindex [lindex [rlindex r 4] 0] 2]
$m add command -label "0: Any" -command "dmsVlanStgMenuCB $w $numPorts $e 0 $notAllowed"}
set numStgs [lindex [lindex [lindex [$sess get null rcStgNumStgs.0] 4] 0] 2]
$sess config -maxrept $numStgs
set offset [string length [snmpinfo mibprop rcStgPortMembers value]]
incr offset
foreach vb [lindex [$sess bulk null rcStgPortMembers.0] 4] {set id [string range [rlindex vb 0] $offset end]
$m add command -label "$id: [port print [rlindex vb 2] range]" -command "dmsVlanStgMenuCB $w $numPorts $e $id [rlindex vb 2]"}}
proc dmsVlanStgMenuCB {w numPorts e id instList} {global Dm_Radio
$e config -state normal
$e delete 0 end
$e insert 0 $id
$e config -state disabled
set bg [$w cget -bg]
if {$id == 0} {set instList [bit print $instList]
loop i 0 $numPorts {set inst [$w.f.f8.c$i cget -onvalue]
if {[lsearch $instList $inst] != -1} {$w.f.f8.c$i config -state disabled
$w.f.f10.c$i config -state disabled -bg $bg} else {$w.f.f8.c$i config -state normal
$w.f.f10.c$i config -state normal -bg yellow}}
return}
dm_PortSetEnable $w.f.f8 $instList
loop i 0 $numPorts {set port2Btn($Dm_Radio($w.f.f10.c$i)) $w.f.f10.c$i
$w.f.f10.c$i config -state disabled -bg $bg}
foreach p [bit print $instList] {catch {$port2Btn($p) config -state normal -bg yellow}}}
proc dmsVlanTriState {w} {if {[$w cget -state] == "disabled"} return
global DmsPriv
set top [winfo parent $w]
if {[info exists DmsPriv($top.byPort)] && $DmsPriv($top.byPort)} {if {[set color [$w cget -bg]] == "green"} {set nextColor red} else {set nextColor green}} else {if {[set color [$w cget -bg]] == "yellow"} {set nextColor green} elseif {$color == "green"} {set nextColor red} else {set nextColor yellow}}
$w config -bg $nextColor}
proc dmsVlanChangeColor {f color numPorts} {loop i 0 $numPorts {if {[$f.c$i cget -state] != "disabled"} {$f.c$i config -bg $color}}}
proc dmsVlanInsertCBType {w type} {global Dm_Radio
if {$type == "port"} {grid $w.f.l8 -row 8 -column 0 -sticky e
grid $w.f.f8 -row 8 -column 1 -sticky w
foreach i {11 12 13} {grid forget $w.f.l$i $w.f.v$i}
foreach i {10 14 20} {grid forget $w.f.l$i $w.f.f$i}} elseif {$type == "protocol"} {foreach i {10 14} {grid $w.f.l$i -row $i -column 0 -sticky e
grid $w.f.f$i -row $i -column 1 -sticky w}
grid $w.f.l11 -row 11 -column 0 -sticky e
grid $w.f.v11 -row 11 -column 1 -sticky w
dmVlanInsertCBProto $w [expr $Dm_Radio($w.f.v11) - 1]
foreach i {8 12 13} {grid forget $w.f.l$i $w.f.v$i}
grid forget $w.f.f8} else {foreach i {10 14} {grid $w.f.l$i -row $i -column 0 -sticky e
grid $w.f.f$i -row $i -column 1 -sticky w}
foreach i {12 13} {grid $w.f.l$i -row $i -column 0 -sticky e
grid $w.f.v$i -row $i -column 1 -sticky w}
foreach i {8 9 11} {grid forget $w.f.l$i $w.f.v$i}
grid forget $w.f.f8
grid forget $w.f.l20 $w.f.f20}}
proc dmVlanInsertCBProto {w rid} {set rtext [$w.f.v11.r${rid} cget -text]
if {$rtext == "usrDefined"} {grid $w.f.l20 -row 20 -column 0 -sticky e
grid $w.f.f20 -row 20 -column 1 -sticky w} else {grid forget $w.f.l20 $w.f.f20}}
proc dmsVlanInsertColor {e} {global Dm_Radio
dm_RadioBox .color color
$e delete 0 end
$e insert 0 $Dm_Radio(.color)}
proc dmsVlanShowTrunksInStatic {f sess} {global Dm_WinInst
foreach i [lsort -integer [array names Dm_WinInst]] {if [string match Port* [rlindex Dm_WinInst($i) 0]] {lappend vbl rcVlanPortType.[rlindex Dm_WinInst($i) 1]}}
if [info exists vbl] {catch {$sess get "dmsVlanShowTrunksInStaticCB $f" $vbl}}}
proc dmsVlanShowTrunksInStaticCB {f sess reqId err errI vbl} {if {$err != "noError" || ![winfo exists $f]} return
set numPorts 0
foreach vb $vbl {if {[rlindex vb 2] == 2} {$f.c$numPorts config -bg green}
incr numPorts}}
proc dmsStgInsertCB {w inst sess} {catch {$w.f.v2 insert 0 [expr 4000+[$w.f.v0 get]]}
if ![catch {set r [$sess get null rcStgUnassignedPorts.0]} err] {global Dm_Radio Dm_PortPicker
foreach p [bit print [lindex [lindex [rlindex r 4] 0] 2]] {set unassigned($p) 1}
loop i 0 $Dm_PortPicker($w.f.f9.numPorts) {if [info exists unassigned([$w.f.f9.c$i cget -onvalue])] {set Dm_Radio($w.f.f9.c$i) [$w.f.f9.c$i cget -onvalue]}}}
if ![catch {set r [$sess get null rcStgNotAllowedPorts.0]} err] {global Dm_Radio Dm_PortPicker
foreach p [bit print [lindex [lindex [rlindex r 4] 0] 2]] {set notAllowed($p) 1}
loop i 0 $Dm_PortPicker($w.f.f9.numPorts) {if [info exists notAllowed([$w.f.f9.c$i cget -onvalue])] {$w.f.f9.c$i config -state disabled}}}}
proc dmsStgBuildCB {w inst sess isTable} {set tabInstance [string range $w 1 end]
::DMedit::$tabInstance setPopupCmd 8 "dmsStgBuildPromptPort $w.t 8 $sess"}
proc dmsStgBuildPromptPort {t col sess} {global Dm_PortPicker
dm_BuildPromptPort $t $col
if ![catch {set r [$sess get null rcStgNotAllowedPorts.0]} err] {set instList [bit print [lindex [lindex [rlindex r 4] 0] 2]]
loop i 0 $Dm_PortPicker(.pp.f.numPorts) {set inst [.pp.f.c$i cget -onvalue]
if {[lsearch $instList $inst] != -1} {.pp.f.c$i config -state disabled}}}}
proc dmsBootBuildCB {frm inst sess isTable} {if {$isTable} return
global Dm_Path
foreach row {3 5 7 9} {menubutton $frm.mb$row -bitmap @$Dm_Path/bitmaps/pulldown.xbm -takefocus 1 -highlightthickness 1 -relief raised -menu $frm.mb$row.m
grid $frm.mb$row -row $row -column 2 -padx 2
menu $frm.mb$row.m
$frm.mb$row.m add cascade -label Flash -menu $frm.mb$row.m.flash -state disabled
menu $frm.mb$row.m.flash
$frm.mb$row.m add cascade -label Pcmcia -menu $frm.mb$row.m.pcmcia -state disabled
menu $frm.mb$row.m.pcmcia
bind $frm.mb$row <1> "dmsCheckBootFiles $sess $frm $row [expr $row == 9]"}}
proc dmsCheckBootFiles {sess frm row {configOnly 0}} {global Dm_Pref Dm_Status
$frm.mb$row.m.flash delete 0 end
$frm.mb$row.m.pcmcia delete 0 end
if [catch {set result [$sess get null {rcDeviceFlashNumFiles.0 rcDevicePcmciaNumFiles.0}]} err] {set Dm_Status [dm_SnmpError err]
return}
set result [rlindex result 4]
set numFlashFiles [lindex [rlindex result 0] 2]
set numPcmciaFiles [lindex [rlindex result 1] 2]
if {$numFlashFiles > 0} {$sess config -maxrept $numFlashFiles
if [catch {set result [$sess bulk null {rcDeviceFlashFileName.0 rcDeviceFlashFileType.0 rcDeviceFlashFileStatus.0}]} err] {set Dm_Status [dm_SnmpError err]
return}
foreach {name type status} [rlindex result 4] {if {[rlindex status 2] != 1} continue
if {[rlindex type 2] == 4} {lappend flashFiles [rlindex name 2]} elseif {[rlindex type 2] == 1} {lappend flashConfigFiles [rlindex name 2]}}
if ![info exists flashFiles] {set numFlashFiles 0}}
if {$numPcmciaFiles > 0} {$sess config -maxrept $numPcmciaFiles
if [catch {set result [$sess bulk null {rcDevicePcmciaFileName.0 rcDevicePcmciaFileType.0 rcDevicePcmciaFileStatus.0}]} err] {set Dm_Status [dm_SnmpError err]
return}
foreach {name type status} [rlindex result 4] {if {[rlindex status 2] != 1} continue
if {[rlindex type 2] == 4} {lappend pcmciaFile [rlindex name 2]} elseif {[rlindex type 2] == 1} {lappend pcmciaConfigFiles [rlindex name 2]}}
if ![info exists pcmciaFile] {set numPcmciaFiles 0}}
if $configOnly {if {[info exists flashConfigFiles] || [info exists pcmciaConfigFiles]} {if [info exists flashConfigFiles] {foreach name $flashConfigFiles {$frm.mb$row.m entryconfig 0 -state normal
$frm.mb$row.m.flash add command -label $name -command "dmsBootUpdate $frm.v$row $name"}}
if [info exists pcmciaConfigFiles] {foreach name $pcmciaConfigFiles {$frm.mb$row.m entryconfig 1 -state normal
$frm.mb$row.m.pcmcia add command -label $name -command "dmsBootUpdate $frm.v$row $name"}}}} else {if {$numFlashFiles > 0 || $numPcmciaFiles > 0} {if {$numFlashFiles > 0} {$frm.mb$row.m entryconfig 0 -state normal
foreach name $flashFiles {$frm.mb$row.m.flash add command -label $name -command "dmsBootUpdate $frm.v$row $name"}}
if {$numPcmciaFiles > 0} {foreach name $pcmciaFile {$frm.mb$row.m entryconfig 1 -state normal
$frm.mb$row.m.pcmcia add command -label $name -command "dmsBootUpdate $frm.v$row $name"}}}}}
proc dmsBootUpdate {f name} {global Dm_Pref
$f delete 0 end
$f insert 0 $name
$f config -font $Dm_Pref(changeFont)
[winfo toplevel $f].fBtn.apply config -state normal}
proc dmsCreateAgentSimulator {sess} {global Dm_Pref
set types {
		{"Text files" .txt}
		{"All files" *}
	}
set file [tk_getSaveFile -filetypes $types -parent . -title "($Dm_Pref(devName)) - Create Agent Simulator File" -initialfile walk.txt -defaultextension .txt]
if {$file == ""} return
if [catch {set fd [open $file w]} err] {dm_prompt .err $err Continue
return}
$sess next "dmsCreateAgentSimulatorCB $fd" 1.3.6.1.2.1.1.1}
proc dmsCreateAgentSimulatorCB {fd sess reqid errStat errIdx vbl} {if {$errStat != "noError"} {global Dm_Status
puts $fd "# $errStat"
close $fd
set Dm_Status "...completed agent simulator walk."} else {set vb [rlindex vbl 0]
set oid [lindex $vb 0]
set syntax [lindex $vb 1]
if {$syntax == "endOfMibView"} {return [dmsCreateAgentSimulatorCB $fd $sess $reqid $syntax $errIdx vbl]}
switch $syntax {
			Integer32 {set syntax {2 }}
			OctetString {
				set syntax {4 } 
				if {[snmpinfo mibprop $oid type] == "DisplayString"} {
					append syntax {"}
				}
			}
			ObjectId {set syntax {6 }}
			IpAddress {set syntax {64 }}
			Counter32 {set syntax {65 }}
			Gauge32 {set syntax {66 }}
			TimeTicks {set syntax {67 }}
			Counter64 {set syntax {70 0.}}
		}
puts $fd "[lindex $vb 0] $syntax[lindex $vb 2]"
$sess next "dmsCreateAgentSimulatorCB $fd" $oid}}
proc dmsGlobalFilterInsertCB {w inst sess} {dmsFilterSetInsertCB $w $inst $sess 1}
proc dmsNonGlobalFilterInsertCB {w inst sess} {dmsFilterSetInsertCB $w $inst $sess 0}
proc dmsFilterSetInsertCB {w inst sess useGlobal} {global Dm_Radio Dm_Status DmsIdList
if $useGlobal {set varName gFilter} else {set varName ngFilter}
grid forget $w.f.v2
dmBuildIdList $DmsIdList($varName) $w.f.f2
grid $w.f.f2 -row 2 -column 1 -sticky we -padx 2 -pady 2
$w.fb.ok config -command "dmIdListInsertApply $w.f.f2.c $w.f.v2; 
			[$w.fb.ok cget -command]"}
proc dmsInsertFilterPortCB {w inst sess} {global Dm_Radio Dm_Status
set nameIds [dmsGetFilterPortIdList $sess]
grid forget $w.f.v1
dmBuildIdList $nameIds $w.f.f1
grid $w.f.f1 -row 1 -column 1 -sticky we -padx 2 -pady 2
$w.fb.ok config -command "dmIdListInsertApply $w.f.f1.c $w.f.v1; 
			[$w.fb.ok cget -command]"}
proc dmsInsertFilterCB {w inst sess} {bind $w.f.v1 <Tab> "dmsIPAddrInsertTab $w.f.v1 $w.f.v2"
bind $w.f.v3 <Tab> "dmsIPAddrInsertTab $w.f.v3 $w.f.v4"}
proc dmsFilterGlobalSetBuildCB {w inst sess isTable} {global DmsIdList
set tabObj ::DMedit::[string range $w 1 end]
set DmsIdList(gFilter) {}
dmsGetIpFilterIdList gfilter $sess 1
set nameIds [list $DmsIdList(gFilter)]
$w.t tag coltag popup 1
$tabObj setPopupCmd 1 "dmShowIdListWindow .gfilter $w.t $nameIds"}
proc dmsFilterNonGlobalSetBuildCB {w inst sess isTable} {global DmsIdList
set tabObj ::DMedit::[string range $w 1 end]
set DmsIdList(ngFilter) {}
dmsGetIpFilterIdList ngFilter $sess 0
set nameIds [list $DmsIdList(ngFilter)]
$w.t tag coltag popup 1
$tabObj setPopupCmd 1 "dmShowIdListWindow .ngfilter $w.t $nameIds"}
proc dmsFilterPortSetBuildCB {w inst sess isTable} {global DmsIdList
set tabObj ::DMedit::[string range $w 1 end]
set DmsIdList(setFilter) {}
dmsGetIpFilterSetIdList setFilter $sess
set nameIds [list $DmsIdList(setFilter)]
$w.t tag coltag popup 1
$tabObj setPopupCmd 1 "dmShowIdListWindow .setfilter $w.t $nameIds"}
proc dmsGetIpFilterIdList {varName sess useGlobal} {global Dm_Radio Dm_Status DmsWaitIdList DmsIdList
if $useGlobal {set varName gFilter} else {set varName ngFilter}
if [catch {set result [$sess get null rcIpFilterFilterTableSize.0]} err] {set Dm_Status [dm_SnmpError err]
set DmsIdList($varName) {}
return 0}
if {[set maxrept [lindex [lindex [rlindex result 4] 0] 2]] == 0} {set DmsIdList($varName) {}
return 0}
$sess config -version 2 -maxrept $maxrept
$sess bulk "dmsGetIpFilterCB $varName $maxrept " {rcIpFilterType.0 rcIpFilterId.0 rcIpFilterName.0}
vwait DmsWaitIdList
return $maxrept}
proc dmsGetIpFilterCB {varName tot sess reqid errStat errIndex vbl} {global Dm_Status DmsIdList DmsWaitIdList
if {$errStat != "noError"} {set Dm_Status $errStat
set DmsWaitIdList 1
return}
if {$varName == "gFilter"} {set useGlobal 1} else {set useGlobal 0}
set num 0
foreach {type id name} $vbl {if {$name == ""} break
incr num
set firstVar [rlindex type 0]
set secondVar [rlindex id 0]
set thirdVar [rlindex name 0]
set type [rlindex type 2]
if {($type == 1 && !$useGlobal) || ($type != 1 && $useGlobal)} continue
set pair [list [rlindex id 2] [rlindex name 2]]
lappend DmsIdList($varName) $pair}
if {$num == $tot} {set DmsWaitIdList 1
return} else {incr tot -$num
set vbl [list $firstVar $secondVar $thirdVar]
$sess config -maxrept $tot
$sess bulk "dmsGetIpFilterCB $varName $tot" $vbl}}
proc dmsGetIpFilterSetIdList {varName sess } {global Dm_Radio Dm_Status DmsWaitIdList DmsIdList
if [catch {set result [$sess get null {rcIpFilterGlobalListTableSize.0  rcIpFilterBaseListTableSize.0}]} err] {set Dm_Status [dm_SnmpError err]
set DmsIdList($varName) "{}"
return 0}
set numGlobals [lindex [lindex [rlindex result 4] 0] 2]
set numNonGlobals [lindex [lindex [rlindex result 4] 1] 2]
if {[expr $numGlobals+$numNonGlobals] == 0} {set DmsIdList($varName) "{}"
return 0}
if {$numGlobals > 0} {$sess config -version 2 -maxrept $numGlobals
$sess bulk "dmsGetIpFilterSetCB $varName $numGlobals " {
			rcIpFilterGlobalListId.0 rcIpFilterGlobalListName.0}
vwait DmsWaitIdList}
if {$numNonGlobals > 0} {$sess config -version 2 -maxrept $numNonGlobals
$sess bulk "dmsGetIpFilterSetCB $varName $numNonGlobals " {
			rcIpFilterBaseListId.0 rcIpFilterBaseListName.0}
vwait DmsWaitIdList}}
proc dmsGetIpFilterSetCB {varName tot sess reqid errStat errIndex vbl} {global Dm_Status DmsIdList DmsWaitIdList
if {$errStat != "noError"} {set Dm_Status $errStat
set DmsWaitIdList 1
return}
set num 0
foreach {id name} $vbl {if {$name == ""} break
incr num
set firstVar [rlindex id 0]
set secondVar [rlindex name 0]
set pair [list [rlindex id 2] [rlindex name 2]]
lappend DmsIdList($varName) $pair}
if {$num == $tot} {set DmsWaitIdList 1
return} else {incr tot -$num
set vbl [list $firstVar $secondVar]
$sess config -maxrept $tot
$sess bulk "dmsGetIpFilterSetCB $varName $tot " $vbl}}
proc dmsGetFilterPortIdList {sess} {global Dm_Radio Dm_Status
if [catch {set result [$sess get null {rcIpFilterGlobalListTableSize.0 
			rcIpFilterBaseListTableSize.0}]} err] {set Dm_Status [dm_SnmpError err]
return}
set numGlobals [lindex [lindex [rlindex result 4] 0] 2]
set numNonGlobals [lindex [lindex [rlindex result 4] 1] 2]
if {[expr $numGlobals+$numNonGlobals] == 0} return
if {$numGlobals > 0} {$sess config -maxrept $numGlobals
if [catch {set result [$sess bulk null {rcIpFilterGlobalListId.0 
				rcIpFilterGlobalListName.0}]} err] {set Dm_Status [dm_SnmpError err]
return}
foreach {id name} [rlindex result 4] {set pair [list [rlindex id 2] [rlindex name 2]]
lappend nameIds $pair}}
if {$numNonGlobals > 0} {$sess config -maxrept $numNonGlobals
if [catch {set result [$sess bulk null {rcIpFilterBaseListId.0 
				rcIpFilterBaseListName.0}]} err] {set Dm_Status [dm_SnmpError err]
return}
foreach {id name} [rlindex result 4] {set pair [list [rlindex id 2] [rlindex name 2]]
lappend nameIds $pair}}
return $nameIds}
proc dmsFilterRefreshCB {w inst sess} {global DmsIdList DmsWaitIdList
set w0 [string range $w 0 [string last "fCat" $w]]
set cat [[lindex [split $w .] 1] cget -CatNo]
set w ${w0}Cat${cat}
set curActive [$w.t index active]
$w.t activate 0,0
$w.t activate $curActive
set tabObj ::DMedit::[string range $w 1 end]
switch $cat {
	0 {#Filters}
	1 {#Global Set
		# retrieve the gFilter List for insertion and popup list
		set DmsIdList(gFilter) {}
		dmsGetIpFilterIdList gfilter $sess 1
		set nameIds [list $DmsIdList(gFilter)]
		$w.t tag coltag popup 1
		$tabObj setPopupCmd 1 "dmShowIdListWindow .gfilter $w.t $nameIds"
	}
	2 {#Source/Destination Set
		# retrieve the ngFilter List for insertion and popup list
		set DmsIdList(ngFilter) {}
		dmsGetIpFilterIdList ngFilter $sess 0
		set nameIds [list $DmsIdList(ngFilter)]
		$tabObj setPopupCmd 1 "dmShowIdListWindow .ngfilter $w.t $nameIds"
	}
	3 {#Filtered Ports
		# retrieve the filter sets for insertion and popup list
		set DmsIdList(setFilter) {}
		dmsGetIpFilterSetIdList setFilter $sess 
		set nameIds [list $DmsIdList(setFilter)]
		$tabObj setPopupCmd 1 "dmShowIdListWindow .setfilter $w.t $nameIds"
	}
	}}
proc dmsFiltersBuildCB {frm inst sess isTable} {set v [lindex [lindex [lindex [$sess get null rcChasAruMode.0] 4] 0] 2]
if {$v == 2} {set btn [string range $frm 0 [expr [string last "fCat" $frm] - 1]]
set btn ${btn}fBtn.refresh
set oldcmd [$btn cget -command]
set bid [lindex $oldcmd 0]
$btn config -command "dmsFilterRefreshCB $frm $inst $sess; global $bid; eval $oldcmd"
return}
set pw [winfo parent $frm]
$pw.fBtn.insert config -state disabled
$pw.fBtn.remove config -state disabled
$pw.fBtn.refresh config -state disabled
$pw.fBtn.other config -state disabled}
proc dmsMltInsertCB {w inst sess} {global Dm_Radio Dm_Status DmsIdList
grid forget $w.f.v4
dmBuildIdList $DmsIdList(mlt) $w.f.f4
grid $w.f.f4 -row 4 -column 1 -sticky we -padx 2 -pady 2
$w.fb.ok config -command "dmIdListInsertApply $w.f.f4.c $w.f.v4; 
			[$w.fb.ok cget -command]"}
proc dmsGetMltIdList {sess} {global Dm_Radio Dm_Status
set nameIds {}
if [catch {set result [$sess get null rcVlanNumVlans.0]} err] {set Dm_Status [dm_SnmpError err]
return}
if {[set numVlans [lindex [lindex [rlindex result 4] 0] 2]] == 0} return
incr numVlans -1
$sess config -maxrept $numVlans
if [catch {set result [$sess bulk null {rcVlanId.0 rcVlanName.0}]} err] {set Dm_Status [dm_SnmpError err]
return}
foreach {id name} [rlindex result 4] {set pair [list [rlindex id 2] [rlindex name 2]]
lappend nameIds $pair}
return $nameIds}
proc dmsMltRefreshCB {w inst sess} {global DmsIdList DmsWaitIdList
set w0 [string range $w 0 [string last "fCat" $w]]
set cat [[lindex [split $w .] 1] cget -CatNo]
set w ${w0}Cat${cat}
set curActive [$w.t index active]
$w.t activate 0,0
$w.t activate $curActive
set tabObj ::DMedit::[string range $w 1 end]
switch $cat {
	0 {# Mlt
		# retrieve the mlt List for insertion and popup list
		set DmsIdList(mlt) {}
		if {[dmsGetVlanIdList mlt $sess rcVlanNumVlans.0  {rcVlanId.0 rcVlanName.0}] != 0} {
			vwait DmsWaitIdList
		}
		set nameIds [list $DmsIdList(mlt)]
		$tabObj setPopupCmd 3 "dmShowIdListWindow .mlt $w.t $nameIds"
	}
	}}
proc dmsMltBuildCB {w inst sess isTable} {global DmsIdList DmsWaitIdList
set tabObj ::DMedit::[string range $w 1 end]
set DmsIdList(mlt) {}
if {[dmsGetVlanIdList mlt $sess rcVlanNumVlans.0  {rcVlanId.0 rcVlanName.0}] != 0} {vwait DmsWaitIdList}
$w.t tag coltag popup 3
set nameIds [list $DmsIdList(mlt)]
$tabObj setPopupCmd 3 "dmShowIdListWindow .mltId $w.t $nameIds"
set btn [string range $w 0 [expr [string last "fCat" $w] - 1]]
set btn ${btn}fBtn.refresh
set oldcmd [$btn cget -command]
set bid [lindex $oldcmd 0]
$btn config -command "dmsMltRefreshCB $w $inst $sess; global $bid; eval $oldcmd"}
proc dmsGetVlanIdList {varName sess sizeVar colList} {global Dm_Radio Dm_Status DmsWaitIdList DmsIdList
if [catch {set result [$sess get null $sizeVar]} err] {set Dm_Status [dm_SnmpError err]
return 0}
set maxrept [lindex [lindex [rlindex result 4] 0] 2]
incr maxrept -1
if {$maxrept == 0} {set DmsWaitIdList 1
return 0}
$sess config -version 2 -maxrept $maxrept
$sess bulk "dmsGetIdListCB $varName $maxrept " $colList
return $maxrept}
proc dmsRmonCheckEnabled {sess} {if [catch {set resp [$sess get null rcSysRmonEnable.0]}] {set enabled 0} else {set enabled [lindex [lindex [rlindex resp 4] 0] 2]}
if {$enabled != 1} {if [dm_Prompt .ask "RMON is currently disabled\nDo you want to enable it now?" Yes No] {error ""}
if [catch {$sess set null {{rcSysRmonEnable.0 {} 1}}} err] {error [rlindex err 2]}}}
proc dmsGetAlarmIndex {sess} {global Dm_AlarmIndex
set vbl [lindex [$sess get null {rcTblRmonAlarmSize.0
        eventStatus.60534 eventStatus.60535}] 4]
if {[set alarmSize [lindex [rlindex vbl 0] 2]]} {$sess config -maxrept $alarmSize
catch {
            set lastIndex [lindex [lindex [lindex [$sess bulk null alarmIndex.0]
 4] end] 2]
            set Dm_AlarmIndex [incr lastIndex]
        }}
if {[string match noSuch* [lindex [rlindex vbl 1] 2]]} {dmsCreateEvent $sess 60534 "Rising Event"}
if {[string match noSuch* [lindex [rlindex vbl 2] 2]]} {dmsCreateEvent $sess 60535 "Falling Event"}}
proc dmsBuildAlarmMenu {m} {set menuNo 0
foreach mdef {
		{Accelar {
		rcSysCpuUtil.0 rcSysSwitchFabricUtil.0 rcSysBufferUtil.0
		rcSysNVRamUsed.0 - rcTblArNoSpace.0 - rcSysLastChange.0
		rcSysLastVlanChange.0 rcSysLastSaveToNVRam.0 rcSysLastSaveToStandbyNVRam.0 -
		rcCardOperStatus. rcChasPowerSupplyOperStatus.1 
		rcChasPowerSupplyOperStatus.2 rcChasFanOperStatus.1 rcChasFanOperStatus.2}}
		{Bridge {
		rcStgTimeSinceTopologyChange. rcStgTopChanges. rcStgMaxAge. -
		rcStgPortForwardTransitions. rcStgPortInConfigBpdus.
		rcStgPortInTcnBpdus. rcStgPortInBadBpdus.
		rcStgPortOutConfigBpdus. rcStgPortOutTcnBpdus. -
		dot1dTpPortInFrames dot1dTpPortOutFrames dot1dTpPortInDiscards -
		dot1dTpLearnedEntryDiscards.0}}
		{Interface {
		ifInOctets ifInDiscards ifInErrors ifInMulticastPkts
		ifInBroadcastPkts ifInUnknownProtos -
		ifOutOctets ifOutDiscards ifOutErrors
		ifOutMulticastPkts ifOutBroadcastPkts -
		ifOperStatus ifLastChange rcPortActiveConnector}}
		{"Ethernet Errors" {
		dot3StatsAlignmentErrors dot3StatsFCSErrors
		dot3StatsSingleCollisionFrames dot3StatsMultipleCollisionFrames
		dot3StatsSQETestErrors dot3StatsDeferredTransmissions
		dot3StatsLateCollisions dot3StatsExcessiveCollisions
		dot3StatsInternalMacTransmitErrors dot3StatsCarrierSenseErrors
		dot3StatsFrameTooLongs dot3StatsInternalMacReceiveErrors}}
		{"RMON Stats" {
		etherStatsOctets. etherStatsPkts.
		etherStatsBroadcastPkts. etherStatsMulticastPkts.
		etherStatsCRCAlignErrors. etherStatsUndersizePkts.
		etherStatsOversizePkts. etherStatsFragments.
		etherStatsCollisions.}}
		{IP {
		ipInReceives.0 ipInHdrErrors.0 ipInAddrErrors.0
		ipForwDatagrams.0 ipInUnknownProtos.0 ipInDiscards.0
		ipInDelivers.0 ipOutRequests.0 ipOutDiscards.0
		ipOutNoRoutes.0 -
		ipFragOKs.0 ipFragFails.0 ipFragCreates.0 ipReasmReqds.0
		ipReasmOKs.0 ipReasmFails.0 -
		icmpInSrcQuenchs.0 icmpInRedirects.0 icmpInEchos.0
		icmpInEchoReps.0 icmpInTimestamps.0 icmpInTimestampReps.0
		icmpInAddrMasks.0 icmpInAddrMaskReps.0 icmpInParmProbs.0
		icmpInDestUnreachs.0 icmpInTimeExcds.0 -
		icmpOutSrcQuenchs.0 icmpOutRedirects.0 icmpOutEchos.0
		icmpOutEchoReps.0 icmpOutTimestamps.0 icmpOutTimestampReps.0
		icmpOutAddrMasks.0 icmpOutAddrMaskReps.0 icmpOutParmProbs.0
		icmpOutDestUnreachs.0 icmpOutTimeExcds.0}}
		{RIP {rip2GlobalRouteChanges.0 rip2GlobalQueries.0 -
		rip2IfStatRcvBadPackets. rip2IfStatRcvBadRoutes. rip2IfStatSentUpdates.}}
		{OSPF {ospfExternLSACount.0 ospfOriginateNewLSAs.0 ospfRxNewLSAs.0 -
		ospfSpfRuns. ospfAreaBdrRtrCount. ospfASBdrRtrCount. ospfAreaLSACount. -
		ospfIfState. ospfIfEvents. - ospfNbrState. ospfNbrEvents. -
		ospfVirtIfState. ospfVirtIfEvents. - ospfVirtNbrState. ospfVirtNbrEvents.}}
		{SNMP {
		snmpInPkts.0 snmpOutPkts.0 - snmpInBadVersions.0
		snmpInBadCommunityNames.0 snmpInBadCommunityUses.0
		snmpInASNParseErrs.0 snmpInTooBigs.0 snmpInNoSuchNames.0
		snmpInBadValues.0 snmpInReadOnlys.0 snmpInGenErrs.0
		snmpInTotalReqVars.0 snmpInTotalSetVars.0 snmpInGetRequests.0
		snmpInGetNexts.0 snmpInSetRequests.0 snmpInGetResponses.0
		snmpInTraps.0 - snmpOutTooBigs.0 snmpOutNoSuchNames.0
		snmpOutBadValues.0 snmpOutGenErrs.0 snmpOutGetRequests.0
		snmpOutGetNexts.0 snmpOutSetRequests.0 snmpOutGetResponses.0
		snmpOutTraps.0}}
		} {$m add cascade -label [rlindex mdef 0] -menu $m.$menuNo
set mc [menu $m.$menuNo]
incr menuNo
foreach v [rlindex mdef 1] {if {$v == "-"} {$mc add separator} else {$mc add command -label $v -command "dmsAlarmMenu $mc"}}}}
proc dmsIpPolicyRefreshCB {w inst sess} {global DmsIdList DmsWaitIdList
set w0 [string range $w 0 [string last "fCat" $w]]
set cat [[lindex [split $w .] 1] cget -CatNo]
set w ${w0}Cat${cat}
set curActive [$w.t index active]
$w.t activate 0,0
$w.t activate $curActive
set tabObj ::DMedit::[string range $w 1 end]
switch $cat {
	0 {#Addr}
	1 {#AddrList
		# retrieve the addr List for insertion and popup list
		set DmsIdList(addr) {} 
		if {[dmsGetIpPolicyIdList addr $sess rcIpPolicyAddrTableSize.0  {rcIpPolicyAddrId.0 rcIpPolicyAddrIpAddr.0}] != 0} {
			vwait DmsWaitIdList
		}
		set nameIds [list $DmsIdList(addr)]
		$tabObj setPopupCmd 2 "dmShowIdListWindow .addrlist $w.t $nameIds"
	}
	2 {#Net}
	3 {#NetList
		# retrieve the net List for insertion and popup list
		set DmsIdList(net) {} 
		if {[dmsGetIpPolicyIdList2 net $sess rcIpPolicyNetTableSize.0  {rcIpPolicyNetId.0 rcIpPolicyNetAddr.0  rcIpPolicyNetMask.0}] != 0} {
			vwait DmsWaitIdList
		}
		set nameIds [list $DmsIdList(net)]
		$tabObj setPopupCmd 2 "dmShowIdListWindow .netlist $w.t $nameIds"
	}
	4 {#Rip Announce
		dmsIpPolicyRipAnnounceBuildCB $w $inst $sess
	}
	5 {#OSPF Announce
		dmsIpPolicyRipAnnounceBuildCB $w $inst $sess
	}
	6 {#Rip Accept Policy
		dmsIpPolicyRipAnnounceBuildCB $w $inst $sess
	}
	7 {#OSPF Accept Policy
		dmsIpPolicyRipAnnounceBuildCB $w $inst $sess
	}
	}}
proc dmsIpPolicyRipAnnounceBuildCB {w inst sess {isTable 0}} {global DmsIdList DmsWaitIdList
set DmsIdList(addrList) {}
if {[dmsGetIpPolicyIdList addrList $sess rcIpPolicyAddrListTableSize.0  {rcIpPolicyAddrListId.0 rcIpPolicyAddrListName.0}] != 0} {vwait DmsWaitIdList}
set DmsIdList(netList) {}
if {[dmsGetIpPolicyIdList netList $sess rcIpPolicyNetListTableSize.0  {rcIpPolicyNetListId.0 rcIpPolicyNetListName.0}] != 0} {vwait DmsWaitIdList}}
proc dmsIpPolicyAddrBuildCB {w inst sess isTable} {set btn [string range $w 0 [expr [string last "fCat" $w] - 1]]
set btn ${btn}fBtn.refresh
set oldcmd [$btn cget -command]
set bid [lindex $oldcmd 0]
$btn config -command "dmsIpPolicyRefreshCB $w $inst $sess; global $bid; eval $oldcmd"}
proc dmsIpPolicyOspfnnounceBuildCB {w inst sess isTable} {dmsIpPolicyRipAnnounceBuildCB $w $inst $sess}
proc dmsIpPolicyRipAcceptBuildCB {w inst sess isTable} {dmsIpPolicyRipAnnounceBuildCB $w $inst $sess}
proc dmsIpPolicyOspfAcceptBuildCB {w inst sess isTable} {dmsIpPolicyRipAnnounceBuildCB $w $inst $sess}
proc dmsInsertPolicyRipAnnounceCB {w inst sess} {dmsInsertPolicyAnnounceCB $w $sess {3 4 11} {5 6 7 8}}
proc dmsInsertPolicyOspfAnnounceCB {w inst sess} {dmsInsertPolicyAnnounceCB $w $sess {3 4 9} {5 6}}
proc dmsInsertPolicyRipAcceptCB {w inst sess} {dmsInsertPolicyAnnounceCB $w $sess {3 4 9} {5 6}}
proc dmsInsertPolicyOspfAcceptCB {w inst sess} {dmsInsertPolicyAnnounceCB $w $sess {3 4 7} {}}
proc dmsInsertPolicyAnnounceCB {w sess netRows addrRows} {global Dm_Path DmsIdList
foreach row $netRows {if {$DmsIdList(netList) == {}} {$w.f.f$row.mb config -state disabled} else {foreach pair $DmsIdList(netList) {set id [rlindex pair 0]
set val [rlindex pair 1]
$w.f.f$row.mb.m add command -label $val -command "$w.f.v$row delete 0; $w.f.v$row insert 0 $id"}}}
foreach row $addrRows {if {$DmsIdList(addrList) == {}} {$w.f.f$row.mb config -state disabled} else {foreach pair $DmsIdList(addrList) {set id [rlindex pair 0]
set val [rlindex pair 1]
$w.f.f$row.mb.m add command -label $val -command "$w.f.v$row delete 0; $w.f.v$row insert 0 $id"}}}}
proc dmsIpPolicyAddrListBuildCB {w inst sess isTable} {global DmsIdList DmsWaitIdList
set tabObj ::DMedit::[string range $w 1 end]
set DmsIdList(addr) {}
if {[dmsGetIpPolicyIdList addr $sess rcIpPolicyAddrTableSize.0  {rcIpPolicyAddrId.0 rcIpPolicyAddrIpAddr.0}] != 0} {vwait DmsWaitIdList}
$w.t tag coltag popup 2
set nameIds [list $DmsIdList(addr)]
$tabObj setPopupCmd 2 "dmShowIdListWindow .addrlist $w.t $nameIds"}
proc dmsIpPolicyAddrListInsertCB {w inst sess} {global Dm_Radio Dm_Status DmsIdList
grid forget $w.f.v2
dmBuildIdList $DmsIdList(addr) $w.f.f2
grid $w.f.f2 -row 2 -column 1 -sticky we -padx 2 -pady 2
$w.fb.ok config -command "dmIdListInsertApply $w.f.f2.c $w.f.v2; 
			[$w.fb.ok cget -command]"}
proc dmsIpPolicyNetListBuildCB {w inst sess isTable} {global DmsIdList DmsWaitIdList
set tabObj ::DMedit::[string range $w 1 end]
set DmsIdList(net) {}
if {[dmsGetIpPolicyIdList2 net $sess rcIpPolicyNetTableSize.0  {rcIpPolicyNetId.0 rcIpPolicyNetAddr.0  rcIpPolicyNetMask.0}] != 0} {vwait DmsWaitIdList}
$w.t tag coltag popup 2
set nameIds [list $DmsIdList(net)]
$tabObj setPopupCmd 2 "dmShowIdListWindow .netlist $w.t $nameIds"}
proc dmsIpPolicyNetListInsertCB {w inst sess} {global Dm_Radio Dm_Status DmsIdList
grid forget $w.f.v2
dmBuildIdList $DmsIdList(net) $w.f.f2
grid $w.f.f2 -row 2 -column 1 -sticky we -padx 2 -pady 2
$w.fb.ok config -command "dmIdListInsertApply $w.f.f2.c $w.f.v2; 
			[$w.fb.ok cget -command]"}
proc dmsGetIpPolicyIdList {varName sess sizeVar colList} {global Dm_Radio Dm_Status DmsWaitIdList DmsIdList
if [catch {set result [$sess get null $sizeVar]} err] {set Dm_Status [dm_SnmpError err]
return 0}
if {[set maxrept [lindex [lindex [rlindex result 4] 0] 2]] == 0} {set DmsWaitIdList 1
return 0}
$sess config -version 2 -maxrept $maxrept
$sess bulk "dmsGetIdListCB $varName $maxrept " $colList
return $maxrept}
proc dmsGetIdListCB {varName tot sess reqid errStat errIndex vbl} {global Dm_Status DmsIdList DmsWaitIdList
if {$errStat != "noError"} {set Dm_Status $errStat
set DmsWaitIdList 1
return}
set num 0
foreach {id name} $vbl {if {$name == ""} break
set firstVar [rlindex id 0]
set secondVar [rlindex name 0]
set pair [list [rlindex id 2] [rlindex name 2]]
lappend DmsIdList($varName) $pair
incr num}
if {$num == $tot} {set DmsWaitIdList 1
return} else {incr tot -$num
set vbl [list $firstVar $secondVar]
$sess config -maxrept $tot
$sess bulk "dmsGetIdListCB $varName $tot" $vbl}}
proc dmsGetIpPolicyIdList2 {varName sess sizeVar colList} {global Dm_Radio Dm_Status DmsWaitIdList
if [catch {set result [$sess get null $sizeVar]} err] {set Dm_Status [dm_SnmpError err]
return 0}
if {[set maxrept [lindex [lindex [rlindex result 4] 0] 2]] == 0} {set DmsWaitIdList 1
return 0}
$sess config -version 2 -maxrept $maxrept
$sess bulk "dmsGetIdList2CB $varName $maxrept " $colList
return $maxrept}
proc dmsGetIdList2CB {varName tot sess reqid errStat errIndex vbl} {global Dm_Status DmsIdList DmsWaitIdList
if {$errStat != "noError"} {set Dm_Status $errStat
set DmsWaitIdList 1
return}
set num 0
foreach {id name1 name2} $vbl {if {$name2 == ""} break
set firstVar [rlindex id 0]
set secondVar [rlindex name1 0]
set thirdVar [rlindex name2 0]
set names [list [rlindex name1 2] [rlindex name2 2]]
set pair [list [rlindex id 2] $names]
lappend DmsIdList($varName) $pair
incr num}
if {$num == $tot} {set DmsWaitIdList 1
return} else {incr tot -$num
set vbl [list $firstVar $secondVar $thirdVar]
$sess config -maxrept $tot
$sess bulk "dmsGetIdList2CB $varName $tot" $vbl}}
proc dmsInsertPolicyNetCB {w inst sess} {bind $w.f.v0 <Tab> "dmsIPAddrInsertTab $w.f.v0 $w.f.v1"
$w.fb.ok config -command "dmsCheckSubnetMask $w.f.v0 $w.f.v1; [$w.fb.ok cget -command]"}
proc dmsGraphVRRPList {inst sess} {lappend vbl vrrpStatsIfIndex.$inst. vrrpStatsVrId.$inst.
while 1 {if [catch {set resp [$sess next null $vbl]}] break
set ifIndex [lindex [lindex [rlindex resp 4] 0] 2]
if {$ifIndex != $inst} break
set id [lindex [lindex [rlindex resp 4] 1] 2]
lappend instList $inst.$id
set vbl [list vrrpStatsIfIndex.$inst.$id vrrpStatsVrId.$inst.$id]}
if [info exists instList] {return $instList} else {return ""}}
