net-snmp session.securityName

81 views Asked by At

I just need to know which user name to add here.

Suitable values for variable session.securityName to use it on the function snmp_open

below is my piece of code.

My tries

I have used my snmp installed machines user name ip. created SNMP user and used the same.

#ifdef DEMO_USE_SNMP_VERSION_3

    printf("SNMP v3 demo version\n");

    /* Use SNMPv3 to talk to the experimental server */

    /* set the SNMP version number */
    session.version=SNMP_VERSION_3;

    /* set the SNMPv3 user name */
    **session.securityName = strdup("testuser");**
    session.securityNameLen = strlen(session.securityName);

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

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

    /* 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 *) our_v3_passphrase, strlen(our_v3_passphrase),
                    session.securityAuthKey,
                    &session.securityAuthKeyLen) != SNMPERR_SUCCESS) {
        snmp_perror(argv[0]);
        snmp_log(LOG_ERR,
                 "Error generating Ku from authentication pass phrase. \n");
        printf("generate ku\n");
        exit(1);
    }
#else

    /* set the SNMP version number */
    session.version = SNMP_VERSION_1;

    /* set the SNMPv1 community name used for authentication */
    session.community = "public";
    session.community_len = strlen(session.community);
#endif
    printf("generate ku\n");

    SOCK_STARTUP;
    ss = snmp_open(&session);                     /* establish the session */
snmp_session
    if (!ss) {
printf("fail - 1\n");
      snmp_sess_perror("ack", &session);
      SOCK_CLEANUP;
      exit(1);
0

There are 0 answers