[AGENT++] How to change community at run-time

Luca Cossaro lcossaro at solari.it
Fri Oct 1 11:51:08 CEST 2010


Hi,

 

I wanna change community string at run-time for both SNMPv1/2 and SNMPv3
(even if I'm planning to use it in a SNMP1/2 application environment). 

I'm using snmp_community_mib and I turned on 'SNMPv3'.

Here is the code I used in a SET REQUEST method (as an example):

 

int communityNameAdmin::commit_set_request(Request* req, int ind)

{

OctetStr SecurityName, NewSecurityName;

         OctetStr Context;

         int SecurityModel;

 

         // retrieve the new and the old community string

         

req->get_security_name(SecurityName);

         Context = req->get_context();

         SecurityModel = req->get_security_model();

         Vbx vb = req->get_value(ind);

         int res = vb.get_value(NewSecurityName);

 

 

Mib *myMib = Mib::instance;

         RequestList *reqList=myMib->requestList;

 

         Vacm* vacm = new Vacm();

         vacm = reqList->get_vacm();

 

         // SNMPv3

// add the new one

         vacm->addNewGroup(SecurityModel, NewSecurityName,

                             "v1v2AdminGroup", storageType_volatile);

// delete the old one

vacm->deleteGroup(SecurityModel, SecurityName);

 

         // SNMPv1/2

// add the new one

         MibTableRow* rowAdmin =
snmpCommunityEntry::instance->add_row(Oidx::from_string(NewSecurityName,
FALSE));

         OctetStr tagAdmin("v1v2PermittedManagers");

         snmpCommunityEntry::instance->set_row(rowAdmin, NewSecurityName,
NewSecurityName, reqList->get_v3mp()->get_local_engine_id(),

                   "",tagAdmin,3,1);

// delete the old one

 
snmpCommunityEntry::instance->remove_row(Oidx::from_string(SecurityName,
FALSE));

 

         int status = MibLeaf::commit_set_request(req, ind);

         return status;

}

 

After this code execution (which runs without run-time errors), I'm not able
to perform any GET/SET REQUEST using the old Security Name (that's makes
sense because I've just deleted it) but neither the new one is working. 

Do I misunderstood something? Is that the right way to do it?

 

Thanks in advance,

 

Best Regards

Luca


Luca Cossaro
Sviluppo Software Prodotti
lcossaro at solari.it

Solari di Udine Spa - via Gino Pieri, 29 - 33100 - Udine
Centralino: +39 0432 4971 - Fax +39 0432 480 160

 




More information about the AGENTPP mailing list