ucd-snmp:why not send trap by send_v2trap()
ye_cl <[email protected]>
| Newsgroups | gmane.network.net-snmp.user,gmane.linux.uclinux.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,I have a question.
In my snmpd agent, the trap2sink ip address will be changed sometimes,but in my embedded uClinux,the filesystem is read-only(romfs), so I can't change the trap2sink directive in file "snmpd.conf" which is in filesystem.
Now,I delete all lines of trap2sink in snmpd.conf, and use the ucd-snmp API functions to implement it,but by using API functions, I find the UDP trap packages can't be sent out.My source code as follows,which is produced be mib2c and is style of ucd-snmp. Is there any mistake for using the API functions? In my application,there will be ten destinatio ip addresses to receive traps,then how to implement this?
.....#define SNMP_TRAP_PORT 162
#define SNMP_TRAP_COMMUNITY "public"
....oid scomcenter_variables_oid[] = { 1,3,6,1,4,1,19176 };....void init_scomcenter(void) {
unsigned char trap_dest1[20] = "200.162.162.55";
REGISTER_MIB("scomcenter", scomcenter_variables, variable7,
scomcenter_variables_oid); if(create_trap_session ((char *)trap_dest1, SNMP_TRAP_PORT,SNMP_TRAP_COMMUNITY,
SNMP_VERSION_2c,SNMP_MSG_TRAP2) == 0)
printf("create_trap_session 1 err\n");
snmp_alarm_register(5, /* seconds */
SA_REPEAT, /* repeat (every 30 seconds). */
check_encoder_statu, /* our callback */
NULL /* no callback data needed */
);
}void check_encoder_statu()
{
send_demo_trap();
return;
}void send_demo_trap()
{
char example_str[] = "no video source";
long my_value = 0;
oid objid_snmptrap[] = { 1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0 };
size_t objid_snmptrap_len = OID_LENGTH(objid_snmptrap);
oid notifying_oid[] = { 1, 3, 6, 1, 4, 1, 19176, 1, 1, 20, 0, 8 };
oid tsoveripstatus_oid[] = { 1, 3, 6, 1, 4, 1, 19176, 1, 1, 20, 1, 0, 0 };
struct variable_list var_trap,var_obj;
var_trap.next_variable = &var_obj;
var_trap.name = objid_snmptrap; // snmpTrapOID.0
var_trap.name_length = sizeof(objid_snmptrap)/sizeof(oid);
var_trap.type = ASN_OBJECT_ID;
var_trap.val.objid = notifying_oid; //
var_trap.val_len = sizeof(notifying_oid);
var_obj.next_variable = NULL;
var_obj.name = tsoveripstatus_oid;
var_obj.name_length = sizeof(tsoveripstatus_oid)/sizeof(oid);
var_obj.type = ASN_INTEGER;
var_obj.val.integer = &my_value;
var_obj.val_len = sizeof(my_value);
send_v2trap(&var_trap);}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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