OverView Index Help                                                                WebNMS Agent Toolkit C Edition 6 

snmpv3.c
Handler file for SNMPV3 message processing model.

See Also :snmpv3.h
Return Type Method Summary
CHAR CreateSnmpV3MsgErrorVarBind(U_CHAR *outPkt, INT32 *outPktLen, CHAR error, SnmpMsgFieldPtrs *ptrs)
             It will create a error var bind depending upon the error like unknown engineId, time synch fail, etc.
CHAR CreateSnmpV3MsgHeaders(U_CHAR *outPkt, INT32 *outPktLen, SnmpPdu *pdu, SnmpMsgFieldPtrs *ptrs)
             This function will create SNMPV3 message headers for the outgoing response message.
CHAR CreateSnmpV3MsgScopedPdu(U_CHAR *outPkt, INT32 *outPktLen, SnmpPdu *pdu, SnmpMsgFieldPtrs *ptrs)
             This function will create SNMPV3 security parameters as part of the out going message.
CHAR CreateSnmpV3MsgSecurityParams(U_CHAR *outPkt, INT32 *outPktLen, SnmpPdu *pdu, SecParamsReference *secParamsRef, SnmpMsgFieldPtrs *ptrs, CHAR error)
             This function will create SNMPV3 security parameters for the out going response message or trap.
CHAR CreateSnmpV3MsgVarBinds(U_CHAR *outPkt, INT32 *outPktLen, CHAR error, SnmpPdu *pdu, SnmpMsgFieldPtrs *ptrs)
             If any error like discovery, time synch etc occured when processing the received message then corresponding counter will be incremented and error message will be returned.
U_CHAR* CreateSnmpV3ResponseMsg(U_CHAR *outPkt, INT32 *outPktLen, CHAR error, SnmpPdu *pdu, SecParamsReference *secParamsRef, U_CHAR errMsgFlag, SnmpMsgFieldPtrs *ptrs)
             Function will do necessary checking to confirm the received request for discovery.
void FreeSnmpPduAndUsmSecParams(SnmpPdu *pdu, SecParamsReference *secParamsRef)
             Free the allocated resource of SnmpPdu and SecParamsReference.
CHAR GenerateEngineId()
             Used to generate a engine Id based on the agent address and port number.
LONG GetSnmpMsgVersion(U_CHAR *inPkt, INT32 len)
             This function will find the received SNMP v3 message version.
CHAR InitSnmpV3Params()
             Do the ininitialization process of v3 agent related variables.
CHAR ParseScopedPdu(U_CHAR *inPkt, INT32 *inPktLen, SnmpPdu *pdu, U_CHAR flag, SnmpMsgFieldPtrs *ptrs)
             It will parse the scoped pdu in the case of discovery and time synch request.
CHAR ParseSnmpV3Msg(U_CHAR *inPkt, INT32 *inPktLen, U_CHAR **outPkt, INT32 *outPktLen, SnmpPdu *pdu, SecParamsReference *secParamsRef, SnmpMsgFieldPtrs *ptrs)
             This function will process the received SNMP v3 message headers, security parameters and scoped pdu related parameters.
CHAR ParseSnmpV3MsgHeaders(U_CHAR *inPkt, INT32 *inPktLen, SnmpPdu *pdu, SnmpMsgFieldPtrs *ptrs)
             This function will parse the SNMP v3 message headers like msgFlags, maxResponseSize, securityModel etc.
CHAR ParseSnmpV3MsgSecurityParams(U_CHAR *inPkt, INT32 *inPktLen, U_CHAR **outPkt, INT32 *outPktLen, SnmpPdu *pdu, SecParamsReference *secParamsRef, SnmpMsgFieldPtrs *ptrs)
             This function parse the SNMP v3 security parameters.
void ReadFromSnmpV3File()
             Reads from the text file and updates the engine boot count.
void UpdateSecurityParams()
             Used to update the v3 security and access control related parameters based on the security model and access control model implemented.
   
Method Details

CreateSnmpV3MsgErrorVarBind()

CHAR CreateSnmpV3MsgErrorVarBind(U_CHAR *outPkt, INT32 *outPktLen, CHAR error, SnmpMsgFieldPtrs *ptrs)

It will create a error var bind depending upon the error like unknown engineId, time synch fail, etc.

Arguments:
1. Response message (OUT).
2. Response message length (IN/OUT).
3. Error number (IN).
4. Pointer to the SnmpMsgFieldPtrs (IN/OUT).
Return type:
SUCCESS if everything goes ok, otherwise FAILURE will be returned.
Bugs:
null

CreateSnmpV3MsgHeaders()

CHAR CreateSnmpV3MsgHeaders(U_CHAR *outPkt, INT32 *outPktLen, SnmpPdu *pdu,SnmpMsgFieldPtrs *ptrs)

This function will create SNMPV3 message headers for the outgoing response message.

Arguments:
1. Response message (OUT).
2. Response message length (IN/OUT).
3. Snmp PDU parameters (IN).
4. Pointer to the SnmpMsgFieldPtrs (IN/OUT).
Return type:
SUCCESS if everything goes ok, otherwise FAILURE will be returned.
Bugs:
null

CreateSnmpV3MsgScopedPdu()

CHAR CreateSnmpV3MsgScopedPdu(U_CHAR *outPkt, INT32 *outPktLen, SnmpPdu *pdu, SnmpMsgFieldPtrs *ptrs)

This function will create SNMPV3 security parameters as part of the out going message.

Arguments:
1. Response message (OUT).
2. Response message length (IN/OUT).
3. Snmp PDU parameters (IN).
4. Security parameters (IN).
5. Pointer to the SnmpMsgFieldPtrs(IN/OUT).
Return type:
SUCCESS if everything goes ok, otherwise FAILURE will be returned.
Bugs:
null

CreateSnmpV3MsgSecurityParams()

CHAR CreateSnmpV3MsgSecurityParams(U_CHAR *outPkt, INT32 *outPktLen, SnmpPdu *pdu, SecParamsReference *secParamsRef, SnmpMsgFieldPtrs *ptrs, CHAR error)

This function will create SNMPV3 security parameters for the out going response message or trap. The security parameters will be created based on the security model, by default it will do for USM, but an interface is provided for other security models also.

Arguments:
1. Response message (OUT).
2. Response message length (IN/OUT).
3. Snmp PDU parameters (IN).
4. Security parameters (IN).
5. Pointer to the SnmpMsgFieldPtrs (IN/OUT).
6. Error number (IN).
Return type:
SUCCESS if everything goes ok, otherwise FAILURE will be returned.
Bugs:
null

CreateSnmpV3MsgVarBinds()

CHAR CreateSnmpV3MsgVarBinds(U_CHAR *outPkt, INT32 *outPktLen, CHAR error, SnmpPdu *pdu, SnmpMsgFieldPtrs *ptrs)

If any error like discovery, time synch etc occured when processing the received message then corresponding counter will be incremented and error message will be returned. This funciton is used to creatae those error varbinds and error status and index.

Arguments:
1. Response message (OUT).
2. Response message length(IN/OUT).
3. Error number (IN).
4. Pointer to the SnmpMsgFieldPtrs(IN/OUT).
Return type:
SUCCESS if everything goes ok, otherwise FAILURE will be returned.
Bugs:
null

CreateSnmpV3ResponseMsg()

U_CHAR* CreateSnmpV3ResponseMsg(U_CHAR *outPkt, INT32 *outPktLen, CHAR error, SnmpPdu *pdu, SecParamsReference *secParamsRef, U_CHAR errMsgFlag, SnmpMsgFieldPtrs *ptrs)

Function will do necessary checking to confirm the received request for discovery.

Arguments:
1. Response message (OUT).
2. Response message length (IN/OUT).
3. Error number (IN).
4. Snmp PDU parameters (IN).
5. Security parameters (IN).
6. Message flag (IN).
7. Pointer to the SnmpMsgFieldPtrs (IN/OUT).
Return type:
SUCCESS if everything goes ok, otherwise FAILURE will be returned.
Bugs:
null

FreeSnmpPduAndUsmSecParams()

void FreeSnmpPduAndUsmSecParams(SnmpPdu *pdu, SecParamsReference *secParamsRef)

Free the allocated resource of SnmpPdu and SecParamsReference.

Arguments:
Nothing.
Return type:
1. Reference to snmp pdu(IN/OUT). 2. Reference to usm security parameters(IN/OUT).
Bugs:
null

GenerateEngineId()

CHAR GenerateEngineId()

Used to generate a engine Id based on the agent address and port number.

Arguments:
Nothing
Return type:
SUCCESS or FAILURE.
Bugs:
null

GetSnmpMsgVersion()

LONG GetSnmpMsgVersion(U_CHAR *inPkt, INT32 len)

This function will find the received SNMP v3 message version.

Arguments:
1. The received v3 message (IN).
2. The length of the received message (IN).
Return type:
The received SNMP version number if valid packet is received otherwise SNMP_BADVERSION.
Bugs:
null

InitSnmpV3Params()

CHAR InitSnmpV3Params()

Do the ininitialization process of v3 agent related variables.

Arguments:
Nothing
Return type:
SUCCESS or FAILURE.
Bugs:
null

ParseScopedPdu()

CHAR ParseScopedPdu(U_CHAR *inPkt, INT32 *inPktLen, SnmpPdu *pdu, U_CHAR flag, SnmpMsgFieldPtrs *ptrs)

It will parse the scoped pdu in the case of discovery and time synch request.

Arguments:
1. Received message (OUT).
2. Received message length(IN/OUT).
3. Snmp PDU parameters(IN).
4. Flag(IN).
5. Pointer to the SnmpMsgFieldPtrs(IN/OUT).
Return type:
SUCCESS if everything goes ok, otherwise FAILURE will be returned.
Bugs:
null

ParseSnmpV3Msg()

CHAR ParseSnmpV3Msg(U_CHAR *inPkt, INT32 *inPktLen, U_CHAR **outPkt, INT32 *outPktLen, SnmpPdu *pdu, SecParamsReference *secParamsRef, SnmpMsgFieldPtrs *ptrs)

This function will process the received SNMP v3 message headers, security parameters and scoped pdu related parameters. When processing the security related parameters it will check for the security model By default the security model is USM. If the request for the Discovery, time sync or any SNMP error then this function will create appropriate response message return back to the called function.

Arguments:
1. The received v3 message (IN).
2. The length of the received message (IN/OUT).
3. The response packet (OUT).
4. The response packet length (IN/OUT).
5. The snmp pdu reference (OUT).
6. SecParams Reference to cache (OUT).
7. SnmpMsgFieldPtrs to create response (OUT).
Return type:
SUCCESS or FAILURE based the status of the operation.
Bugs:
null

ParseSnmpV3MsgHeaders()

CHAR ParseSnmpV3MsgHeaders(U_CHAR *inPkt, INT32 *inPktLen, SnmpPdu *pdu, SnmpMsgFieldPtrs *ptrs)

This function will parse the SNMP v3 message headers like msgFlags, maxResponseSize, securityModel etc. Some of the information will be cached in the pdu for further processing and to create response message.

Arguments:
1. The received v3 message (IN).
2. The length of the received message (IN/OUT).
3. The snmp pdu reference (OUT).
4. SnmpMsgFieldPtrs to create response (OUT).
Return type:
SUCCESS or ERR_NUM based on the operation status.
Bugs:
null

ParseSnmpV3MsgSecurityParams()

CHAR ParseSnmpV3MsgSecurityParams(U_CHAR *inPkt, INT32 *inPktLen, U_CHAR **outPkt, INT32 *outPktLen, SnmpPdu *pdu, SecParamsReference *secParamsRef, SnmpMsgFieldPtrs *ptrs)

This function parse the SNMP v3 security parameters. If the security model is USM then the following parameters userName, engineId, engineBoot, engineTime, authKey, privKey, contextName etc. will be processed according to RFC 3414. It also providing a interface to handle the other security model related parameters.

Arguments:
1. The received v3 message (OUT).
2. The length of the received message (IN/OUT).
3. The response message (IN/OUT).
4. The response message length (IN/OUT).
5. Snmp PDU reference (IN).
6. Security Parameters Reference (IN).
7. Pointer to the SnmpMsgFieldPtrs (IN/OUT).
Return type:
SUCCESS or FAILURE based on the status of the operation.
Bugs:
null

ReadFromSnmpV3File()

void ReadFromSnmpV3File()

Reads from the text file and updates the engine boot count.

Arguments:
Nothing.
Return type:
Nothing.
Bugs:
null

UpdateSecurityParams()

void UpdateSecurityParams()

Used to update the v3 security and access control related parameters based on the security model and access control model implemented. It will be called each time from the base loop.

Arguments:
Nothing
Return type:
Nothing
Bugs:
null


OverView Index Help                                                                WebNMS Agent Toolkit C Edition 6 

Copyright (c) 2009 ZOHO Corp. All Rights Reserved.