Hello all,
I have an applicaiton that sends a few SNMP traps right at power up.
After initializing web server and telnet server, I initialize SNMP by calling this:
error = SNMP_init_with_traps("SNMP", 7, 2500, my_trap_list);
Then I make a few calls to send some traps out (just like SNMP demo provided with MQX 3.8).
What I found is that if trap destination IP address diesn't exist on the network (or if ethernet cable is unplugged), the trap sending function never returns. I happens for all generic trap functions: SNMP_trap_coldStart(), SNMP_trap_linkUp(), etc.
I traced it down to this call inside these functions (highlighted in red):
for (i = 0; i < SNMPCFG_MAX_TRAP_RECEIVERS; i++) { if (snmpcfg->trap_receiver_list[i] != 0) { ipaddr = snmpcfg->trap_receiver_list[i]; ipsrc=IP_route_find(ipaddr, 0); htonl(ipsrcp, ipsrc); addr.sin_addr.s_addr = ipaddr; sendto(snmpcfg->trapsock, snmp.outbuf, traplen, 0, &addr, sizeof(addr)); } /* Endif */ } /* Endfor */
This function never returns and it looks like it keeps sending ARP queries without ever timing out.
Has anyone encountered this issue or maybe even found a solution?
Thanks,
Boris
解決済! 解決策の投稿を見る。
Hi,
Try using the socket option send_nowait on the tx socket.
Regards,
Mohsin455
This seems to resolve the problem.
Thank you!