Re: string index on bind callback

Juergen Schoenwaelder (schoenw@gaertner.de)
Wed, 11 Jun 1997 15:54:33 +0200

bernd@finow.snafu.de (Bernd Hentig) said:

Bernd> When binding a table/entry oid to a "get" callback, I can read the
Bernd> index of the child snmp node with the %i substitution variable:
Bernd> $session bind $table-oid get [list my-callback %V %i]

Bernd> In this case the index originally is an octet string like "idn" which
Bernd> will be converted to "105.100.110" on the "get" callback.
Bernd> Unfortunately I need to know the "real" string, but converting decimal
Bernd> number strings to "real" strings seems to be rather complicated in tcl.
Bernd> I tried
Bernd> mib format table-index $i
Bernd> (where $i is the replaced %i variable)
Bernd> but (as I expected) this doesn't work.

Bernd> Certainly there is some easy method to get at the index name ?

There is currently no automatic interpretation of INDEX definitions.
You have to write a small proc to do the trick. There are lots of
possible solutions. Below is a straight forward and a slightly faster,
cryptic solution.

proc foo {i} {
set x ""
foreach n [split $i .] {
append x [format %c $n]
}
return $x
}

proc bar {i} {
regsub -all {\.[0-9]+} ".$i" {%c} f
eval format $f [split $i .]
}

I know, the Tnm extension should provide better support for INDEX
interpretation and conversion, but this will probably not happen too
soon.
Juergen

-- 
Juergen Schoenwaelder     <schoenw@gaertner.de>     (Tel: +49-531-23873-0)
Gaertner Datensysteme, Hamburger Strasse 273a, 38114 Braunschweig, Germany
--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.