You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've mostly worked this out, but I keep running into areas where I want to be able to extend the functionality in the various modules without having to go to C land, to avoid the problems that come with keeping my own fork of tnm. I will try and put together an actual pull request, but just for anyone interested in how I'm doing this today, here is the bones of a solution.
mib-init.tcl
package require Tnm
rename ::Tnm::mib ::mib
interp hide {} mib
namespace eval ::Tnm::mib {
set ns [namespace current]
set builtins [list {*}{
access children compare defval description displayhint
enums exists file format index info label length load
macro member module name oid pack parent range scan size
split status subtree syntax type unpack variables walk
}]
foreach builtin $builtins {
# export the builtinnamespace export $builtin# create alias to invoke hidden ::Tnm::mib commandinterp alias {} ${ns}::$builtin {} interp invokehidden {} mib $builtin
}
namespace ensemble create -command ::Tnm::mib
# alternative implementation for slective dispatch between c-side sub-commands and# and interp subcommandsif 0 {
procensembleUnknown {command args} {
variable builtins
if {$command in $builtins} {
tailcall [namespace current]::mib {*}$args
}
set badoptionerr {bad option "%s": must be %s, or %s}
set options [dict get keys [namespace ensemble configure -map]]
set optionsString [join [lrange$options 0 end-1] ", "]
set message [format$badoptionerr$optionsString [lindex$options end]]
return -code error $message
}
namespace ensemble create -command ::Tnm::mib -unknown ensembleUnknown
}
}
# ::Tnm::mib ensemble extensionsnamespace eval ::Tnm::mib {
namespace export tables
proctables {root} {
set tables {}
mib walk OID $root {
if {[mib type $OID] == {SEQUENCE OF}} {
lappend tables [mib type $OID] $OID
}
}
return$tables
}
}
The text was updated successfully, but these errors were encountered:
I've mostly worked this out, but I keep running into areas where I want to be able to extend the functionality in the various modules without having to go to C land, to avoid the problems that come with keeping my own fork of tnm. I will try and put together an actual pull request, but just for anyone interested in how I'm doing this today, here is the bones of a solution.
mib-init.tcl
The text was updated successfully, but these errors were encountered: