I find the simplest way is to 1. Write the notification MIB with the varbinds defined 2. run mib2c with mib2c.notify.conf, this builds the varbind list automatically 3. link the code generated into the snmpd application 4. send the trap from snmpd
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ajran ajran Sent: Friday, April 20, 2007 12:17 PM To: Net-snmp-coders@lists.sourceforge.net Subject: how to include "ASN_OBJECT_ID" in a trap with net-snmp hi, all, I am new in this area I would apprciate any help with the following issue. Bellow is the skeleton that has been generated by mib2c, what am I experiencing problem with is the third the snmp_varlist_add_variable statement handling the attribute "alarmActiveResourceId" suppose there is some struct defined like: typedef struct { u_char* moduleName; long long int *dateAndTime; int* activeAlarmInedx; } ResourceId; my question is: What do I need to do in order to include these data into the trap? What do I choose as index in all oid's? ..... static oid snmptrap_oid[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 }; static int snmptrap_oid_LEN = OID_LENGTH(snmptrap_oid); int send_snfAlarmActiveState_trap(void) { netsnmp_variable_list *var_list = NULL; oid snfAlarmActiveState_oid[] = { 1, 3, 6, 1, 4, 1, 193, 110, 2, 10, 2, 0, 1 }; int snfAlarmActiveState_oid_LEN = OID_LENGTH(snfAlarmActiveState_oid); oid alarmModelDescription_oid[] = { 1, 3, 6, 1, 2, 1, 118, 1, 1, 2, 1, 6, /* insert index here */ }; oid alarmActiveResourceId_oid[] = { 1, 3, 6, 1, 2, 1, 118, 1, 2, 2, 1, 10, /* insert index here */ }; oid alarmActiveDescription_oid[] = { 1, 3, 6, 1, 2, 1, 118, 1, 2, 2, 1, 11, /* insert index here */ }; oid ituAlarmEventType_oid[] = { 1, 3, 6, 1, 2, 1, 121, 1, 1, 1, 1, 2, /* insert index here */ }; oid ituAlarmProbableCause_oid[] = { 1, 3, 6, 1, 2, 1, 121, 1, 1, 1, 1, 3, /* insert index here */ }; /* * Set the snmpTrapOid.0 value */ snmp_varlist_add_variable(&var_list, snmptrap_oid, snmptrap_oid_LEN, ASN_OBJECT_ID, (u_char *)snfAlarmActiveState_oid, snfAlarmActiveState_oid_LEN); /* * Add any objects from the trap definition */ snmp_varlist_add_variable(&var_list, alarmModelDescription_oid, OID_LENGTH(alarmModelDescription_oid), ASN_OCTET_STR, /* * Set an appropriate value for alarmModelDescription */ NULL, 0); snmp_varlist_add_variable(&var_list, alarmActiveResourceId_oid, OID_LENGTH(alarmActiveResourceId_oid), ASN_OBJECT_ID, /* * Set an appropriate value for alarmActiveResourceId */ NULL, 0); snmp_varlist_add_variable(&var_list, alarmActiveDescription_oid, OID_LENGTH(alarmActiveDescription_oid), ASN_OCTET_STR, /* * Set an appropriate value for alarmActiveDescription */ NULL, 0); snmp_varlist_add_variable(&var_list, ituAlarmEventType_oid, OID_LENGTH(ituAlarmEventType_oid), ASN_INTEGER, /* * Set an appropriate value for ituAlarmEventType */ NULL, 0); snmp_varlist_add_variable(&var_list, ituAlarmProbableCause_oid, OID_LENGTH(ituAlarmProbableCause_oid), ASN_INTEGER, /* * Set an appropriate value for ituAlarmProbableCause */ NULL, 0); /* * Add any extra (optional) objects here */ /* * Send the trap to the list of configured destinations * and clean up */ send_v2trap(var_list); snmp_free_varbind(var_list); return SNMP_ERR_NOERROR; } _________________________________________________________________ Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/ ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders The information contained in this electronic mail transmission may be privileged and confidential, and therefore, protected from disclosure. If you have received this communication in error, please notify us immediately by replying to this message and deleting it from your computer without copying or disclosing it. ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders