hi all,

      I did the following settings for authpriv user from program. (Iam
sending the code also) when iam compiling and running the following code iam
getting the error like snmpget: Unsupported security level. Please help me why
this error is coming. Iam not getting how to debug it.




if(securityLevel == AUTHPRIV)
        {
                auth_Pass_Phrase = authUserPasswd.c_str();
                priv_Pass_Phrase = privUserPasswd.c_str();
                //Initialize the SNMP library
                init_snmp("snmpget");
    
                //Initialize a "session" that defines who we're going to talk to
                snmp_sess_init( &session );

                //set the SNMPv3 user name */
                session.securityName = (char*)authUserName.c_str();
                session.securityNameLen = strlen(session.securityName);

                /* set the security level to authenticated, but not encrypted */
                session.securityLevel = SNMP_SEC_LEVEL_AUTHPRIV;

                session.contextName = (char*)contextName.c_str();
                session.contextNameLen = strlen(session.contextName);

                session.contextEngineID = (u_char*)contextId.c_str();
                session.contextEngineIDLen = 
strlen((char*)session.contextEngineID);

                /* set the authentication method to MD5 */
                if(authProtocol == MD5)
                {
                        session.securityAuthProto = usmHMACMD5AuthProtocol;
                }
                session.securityAuthProtoLen = 
sizeof(usmHMACMD5AuthProtocol)/sizeof(oid);
                session.securityAuthKeyLen = USM_AUTH_KU_LEN;

                if(privProtocol == DES)
                {
                        session.securityPrivProto = usmDESPrivProtocol;
                }
                session.securityPrivProtoLen =
USM_PRIV_PROTO_DES_LEN;//sizeof(usmAESPrivProtocol)/sizeof(oid);
                session.securityPrivKeyLen = USM_AUTH_KU_LEN;
                size_t privPasswdLen = strlen(priv_Pass_Phrase);

                /* set the authentication key to a MD5 hashed version of our
                passphrase "The Net-SNMP Demo Password" (which must be at least 
8
                characters long) */
                if (generate_Ku(session.securityAuthProto, 
session.securityAuthProtoLen,
(u_char *) auth_Pass_Phrase, strlen(auth_Pass_Phrase),
session.securityAuthKey, &session.securityAuthKeyLen) != SNMPERR_SUCCESS)
                {
                        snmp_perror("snmpGet");
                        snmp_log(LOG_ERR, "Error generating Ku from 
authentication pass
phrase. \n");
                        logger->log(NORMAL,"SnmpError: Error generating Ku from 
authentication pass
phrase.");
                        exit(1);
                }
                if (generate_Ku(session.securityAuthProto, 
session.securityAuthProtoLen,
(u_char *) priv_Pass_Phrase, strlen(priv_Pass_Phrase),
                session.securityPrivKey, &session.securityPrivKeyLen) != 
SNMPERR_SUCCESS)
                {
                        snmp_perror("snmpGet");
                        snmp_log(LOG_ERR, "Error generating Ku from 
authentication pass
phrase. \n");
                        logger->log(NORMAL,"SnmpError: Error generating Ku from 
authentication pass
phrase.");
                        exit(1);
                }


--
With Regards,
Ravi Kumar K.
Research Engineer,
NMS Group,
C-DOT, Bangalore-100.



------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to