problem about sending V2 trap
"liuying" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
Dear:
I have a problem about sending V2 trap.
When I use "snmp.c, snmp.so" to send trap,I can recerive it sucessfully.
But when I use:
$ gcc main.c -L -lsnmp …… -I ./include -o main
In the main.c,Iuse:
write_exampletrap2(COMMIT,NULL,0,0,NULL,NULL,0)
to send trap.
In my snmp.c, I use:
var_trap.next_variable = &var_str; /* next variable */
var_trap.name = objid_snmptrap; /* snmpTrapOID.0 */
var_trap.name_length = sizeof(objid_snmptrap) / sizeof(oid); /* number of sub-ids */
var_trap.type = ASN_OBJECT_ID;
var_trap.val.objid = demo_trap; /* demo-trap objid */
var_trap.val_len = sizeof(demo_trap); /* length in bytes (not number of subids!) */
/*
* additional objects
*/
var_str.next_variable = &var_pon; /* next variable*/
var_str.type = ASN_INTEGER; /* type of variable */
var_str.val.integer = &var_default.traptype; /* value */
var_str.val_len = sizeof(var_default.traptype);
var_pon.next_variable = &var_onu; /* next variable */
var_pon.name = var_default.pon_oid;
var_pon.name_length = sizeof(var_default.pon_oid)/ sizeof(oid); /* number of sub-ids */
var_pon.type = ASN_OCTET_STR; /* type of variable */
var_pon.val.string = "PONoid"; /* value */
var_pon.val_len = sizeof("PONoid");
if(var_default.is485==1)
{
var_onu.next_variable = &var_onu485;
}
else
{
var_onu.next_variable = NULL;
}
var_onu.name = var_default.onu_oid;
var_onu.name_length = sizeof(var_default.onu_oid)/ sizeof(oid); /* number of sub-ids */
var_onu.type = ASN_OCTET_STR; /* type of variable */
var_onu.val.string = "ONUoid"; /* value */
var_onu.val_len = sizeof("ONUoid");
var_onu485.next_variable = NULL; /* No more variables after this one */
var_onu485.name = var_default.onu485_oid;
var_onu485.name_length = sizeof(var_default.onu485_oid) / sizeof(oid);/* number of sub-ids */
var_onu485.type = ASN_OCTET_STR; /* type of variable */
var_onu485.val.string = "ONU485oid"; /* value */
var_onu485.val_len = sizeof("ONU485oid");
DEBUGMSGTL(("example", "write_exampletrap2 sending the v2 trap\n"));
send_v2trap(&var_trap);
DEBUGMSGTL(("example", "write_exampletrap2 v2 trap sent\n"));
There are some errors. It returns:
$ No log handling enabled - turning on stderr logging
send_trap: no v2 trapOID varbind provided
What can I do to solve the problem?
Looking forward for your help!Thanks!
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
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