Re: Q:about enum snmp types

Juergen Schoenwaelder (schoenw@cs.utwente.nl)
Thu, 31 Oct 1996 12:36:48 +0100

Damien WETZEL <frs0139@trt-philips.fr> said:

Damien> Did anybody write a tkined or scwish scripts which would permit
Damien> to do SET SNMP on enum variables, showing the different choices for
Damien> that variables like that you dont have to remember the names or the
Damien> values for that variable as for the SNMP-BROWSER in tkined.
Damien> bye.

Below is a patch against scotty 2.1.5 which implements this feature
for the mibtree script (aka SNMP-TREE), but not for the
snmp_browser.tcl (aka SNMP-BROWSER) script. This patch will likely
work with other versions since I did not touch this code for quite
some time.
Juergen

*** tnm/library/snmp.tcl.orig Wed Aug 7 18:59:41 1996
--- tnm/library/snmp.tcl Thu Oct 31 12:27:34 1996
***************
*** 306,312 ****

# SNMP_SetValue --
#
! # Set a value of a MIB variable.
#
# Arguments:
# s - The SNMP session to use.
--- 306,313 ----

# SNMP_SetValue --
#
! # Set a value of a MIB variable. A check is made if the MIB variable
! # is an enumeration. If yes
#
# Arguments:
# s - The SNMP session to use.
***************
*** 331,342 ****
set name [lindex $res 1]
}
if {$name == ""} return
if {$w != ""} {
! set res [Dialog_Request $w.r questhead \
! "Enter new value for $name:" $value($name) "ok cancel"]
} else {
! set res [ined request "Enter new value for $name:" \
! [list [list $name $value($name) entry 20]] "ok cancel"]
}
if {[lindex $res 0] != "ok"} return
set new [lindex $res 1]
--- 332,362 ----
set name [lindex $res 1]
}
if {$name == ""} return
+
+ set enums ""
+ catch {
+ foreach {label number} [join [lindex [mib tc $name] 3]] {
+ lappend enums $label
+ }
+ }
+
if {$w != ""} {
! if {$enums != ""} {
! set res [Dialog_Select $w.l questhead \
! "Select a value (current = $value($name)):" \
! $enums "ok cancel"]
! } else {
! set res [Dialog_Request $w.r questhead \
! "Enter new value for $name:" $value($name) "ok cancel"]
! }
} else {
! if {$enums != ""} {
! set res [ined list "Select a value (current = $value($name)):" \
! $enums "ok cancel"]
! } else {
! set res [ined request "Enter new value for $name:" \
! [list [list $name $value($name) entry 20]] "ok cancel"]
! }
}
if {[lindex $res 0] != "ok"} return
set new [lindex $res 1]