Hi all,

Is there any net-snmp windows expert out there that can help me with this problem?

thanks,
mauricio

----------- message ------------

Hi all,

I work with microsoft windows. I am trying to use the snmpdemoapp.c in the tutorial. but can't make it work. the snmpd.conf file is ok. The weird thing is that ir worked on linux, the same code but there is something wrong in windows.
I am trying to use authentication and enryption using snmp v3. the user i created like this:


snmpusm  -v 3  -u initial -n "" -l authPriv -a MD5 -A setup_passphrase -x
DES -X setup_passphrase -l authPriv localhost create testusr initial
User successfully created.

snmpusm -v 3 -u testusr -n "" -l authPriv -a MD5 -A setup_passphrase -x D
ES -X setup_passphrase localhost passwd setup_passphrase testthispass
SNMPv3 Key(s) successfully changed.

a snmpget works well:

snmpget -v 3 -u testusr -n "" -l authPriv -a MD5 -A testthispass -x DES -X testthispass localhost system.sysContact.0

but when i use the code below i get: Why it says it doesn't support encryption, if it works above? the agent was compiled with openssl

No log handling enabled - turning on stderr logging
Encryption support not enabled.
snmpget: USM encryption error

thanks,
mauricio

i have done this:

#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <string.h>

const char *pass="testthispass";

int main(int argc, char ** argv)
{
struct snmp_session session, *ss;
struct snmp_pdu *pdu;
struct snmp_pdu *response;

oid anOID[MAX_OID_LEN];
size_t anOID_len = MAX_OID_LEN;

struct variable_list *vars;
int status;
int count=1;

init_snmp("snmpapp");

snmp_sess_init( &session );
session.peername = strdup("127.0.0.1");

session.version=SNMP_VERSION_3;
session.securityName = strdup("testusr");
session.securityNameLen = strlen(session.securityName);
session.securityLevel = SNMP_SEC_LEVEL_AUTHPRIV;
session.securityAuthProto = usmHMACMD5AuthProtocol;
session.securityAuthProtoLen = sizeof(usmHMACMD5AuthProtocol)/sizeof(oid);
session.securityAuthKeyLen = USM_AUTH_KU_LEN;
session.securityPrivProto = usmDESPrivProtocol;
session.securityPrivProtoLen = USM_PRIV_PROTO_DES_LEN;
session.securityPrivKeyLen = USM_PRIV_KU_LEN;

if (generate_Ku(session.securityAuthProto,
                session.securityAuthProtoLen,
                (u_char *) pass, strlen(pass),
                session.securityAuthKey,
                &session.securityAuthKeyLen) != SNMPERR_SUCCESS) {
    snmp_perror(argv[0]);
    snmp_log(LOG_ERR,
             "Error generating Ku from authentication pass phrase. \n");
    exit(1);
}

if (generate_Ku(session.securityAuthProto,
                session.securityAuthProtoLen,
                (u_char *) pass, strlen(pass),
                session.securityPrivKey,
                &session.securityPrivKeyLen) != SNMPERR_SUCCESS) {
    snmp_perror(argv[0]);
    snmp_log(LOG_ERR,
             "Error generating Ku from authentication pass phrase. \n");
    exit(1);
}

SOCK_STARTUP;
ss = snmp_open(&session);

if (!ss)
{
    snmp_perror("ack");
    snmp_log(LOG_ERR, "something horrible happened!!!\n");
    exit(2);
}

pdu = snmp_pdu_create(SNMP_MSG_GET);
read_objid(".1.3.6.1.2.1.1.4.0", anOID, &anOID_len);

snmp_add_null_var(pdu, anOID, anOID_len);

status = snmp_synch_response(ss, pdu, &response);

if (status == STAT_SUCCESS && response->errstat == SNMP_ERR_NOERROR)
{

  for(vars = response->variables; vars; vars = vars->next_variable)
    print_variable(vars->name, vars->name_length, vars);

for(vars = response->variables; vars; vars = vars->next_variable)
{
if (vars->type == ASN_OCTET_STR)
{
char *sp = (char *)malloc(1 + vars->val_len);
memcpy(sp, vars->val.string, vars->val_len);
sp[vars->val_len] = '\0';
printf("value #%d is a string: %s\n", count++, sp);
free(sp);
}
else
printf("value #%d is NOT a string! Ack!\n", count++);
}
}
else
{
if (status == STAT_SUCCESS)
fprintf(stderr, "Error in packet\nReason: %s\n",snmp_errstring(response->errstat));
else
snmp_sess_perror("snmpget", ss);
}


if (response)
  snmp_free_pdu(response);
snmp_close(ss);

SOCK_CLEANUP;
return (0);
}

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
Net-snmp-users mailing list
[EMAIL PROTECTED]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to