Net-SNMP extension with Tcl - SNMP

This is a discussion on Net-SNMP extension with Tcl - SNMP ; Hi All
My Problem is specifically related to building a snmp manager extension for Tcl using the net-snmp provided apis.
I am quite new to net-snmp &amp; do not have much insight in the code so I apologize in advance ...

Net-SNMP extension with Tcl

Hi All

My Problem is specifically related to building a snmp manager extension for Tcl using the net-snmp provided apis.
I am quite new to net-snmp & do not have much insight in the code so I apologize in advance if this issue has cropped up before in this list.

I am trying to write a Tcl extension module using the common APIs of net-snmp for creating some snmp sessions & operations.

SNMP Sessions contain all the netsnmp_session parameters which can be set or accessed

Operations involve the usual SNMP operations like get, set, getbulk etc.. which operate on the sessions.

Earlier I tried the usual examples provided in the net-snmp wiki pages and successfully created small programs but now when I converted those program to Tcl extensions
I face the following problem which is specific to snmp V3.

the problem is as follows
1) I create two snmp sessions snmp0 & snmp1.
2) I configure snmp0 with version 3 and all the mandatory related parameters like security name, securitylevel, protocol, passwords, peername etc.
3) I also configure snmp1 with version 3 and same parameters except a different peername. ( both peernames are setup and tested with snmpget commands )
4) I have defined a status command which does a get on the sysName MIB and returns the value as a indication of wheather the remote peer is alive or not
5) when i invoke status command with snmp0 i get the response but for snmp1 i get the following error "no such security service available :0 snmp_build, unknown failure "

I am aware that this problem comes if we do not call init_snmp( ) function at the start but, in my Tcl extension I call this function inside my module initialization code ,before I do any netsnmp related operation.

After several reruns I noticed that this happens with all the sessions except for the one which was configured first. i.e in my case it happens with snmp1 since snmp1 was configured ( with version 3 specific data ) after snmp0. If I restart the application and configure snmp1 before snmp0 then snmp0 will have this problem.

After putting init_snmp( ) at several places I get the same result . I even tried adding the init_snmp( ) call to TCL initilaization source and recompiling the TCL binary but by doing that nothing works and for every session I get the same error.

I am sure that this happens due to some initialization problem ( something related to the registering of security services at startup ) but it works fine in a application written in C even with multiple V3 sessions. And the same C code used as Tcl extension does not work.

I would like to know if anyone has faced similar problem or if there can be a workaround to this problem.