|
The Agent Compiler generates a set of 'c' source files for each Module of the MIB file. This section gives a basic understanding on how the methods in the handler files/other files are invoked by the agent API when a request is made by the manager to the agent.
Get/Get-next request
Set Request (Atomicity)
Processing a GET/GET-NEXT Request
When a get/get-next request is made
A get/get-next request is made by the manager to the agent. This request may contain a group of OIDs. The agent API will call the method <module>ProcessRequests() from the handler file < module name >hdlr.c. for each request with the received pduType, varBind vector, errStatus, and errIndex.Here, user can do the validation or extra processing over the received varBinds.
Next, the agent API calls the get method for the requested variable from the instrument file < module name >instru.c for each OID.
The get method in the instrument file returns the variable value to the Agent API which creates a get-response message.
The Update<module name>() method is called to update the original or external application's data.
For processing a set request, the AdventNet Agent Toolkit C Edition has implemented the atomic set as follows:
A set request is made for a group of OIDs by the Manager to the Agent. The Agent API will call the method < module name >ProcessRequests() from the handler file < module name >hdlr.c. for each request with the received pduType, varBind vector, errStatus, and errIndex. The set request can be divided into three processes:
Process for validation
For each received varbind, the agent will call < module name > ProcessRequests() method with status as VALIDATE and value as received value of the varbind. For example, if three varbinds are received, which belong to different groups (modules) this method will be called thrice. This method in turn calls its set method from the *instru.c file with status as VALIDATE and with column value. The method < module name >ProcessRequests() will process the set request with status="validate" for each OID one by one.
This in turn calls the set method in the instrument file which validates the data for each OID and returns the current value to the Agent API.
If status="validate" fails for any OID in the set method of instru.c file, the validation process is stopped. It will return NULL with appropriate SNMP error status to the agent. The agent will stop the validation and return SNMP response message with error status and error index.
If validate is success, then the set method of *insru.c file will return the current value of the column to the agent.
Process to set the value
If status = "validate" is success for all the OIDs, control passes to the Agent API which calls the <module name>ProcessRequests() method with status="Modify" for each OID one by one and value as received value of the varbind.
This in turn calls the set method in the Instrument file with status=modify. The set method will modify (commit) the local variable with the received data for this column (varbind).
If status="modify" is success for all the OIDs the Update<module name>() method is called for each group(table/scalar) which will update the changes.
The Agent API will send a response message to the manager with the set values.
Process if set fails
If status = "modify" fails for any OID,the modification process is stopped. The < module name >ProcessRequests() method is called with status="Modify" for each OID one by one untill the OID for which set failed. For example, if there are three OIDs and set fails for the 3rd OID, this method is called for the 1st and 2nd OID.
This in turn calls the set method in the Instrument file which will reset the old value of the OID to the Agent API.
The Agent API will send an SNMP error message to the manager.
In this phase, if set is failed then Agent API will send undo failed error to the manager.
|