mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-28 09:19:53 +00:00
SNMP: Correctly name a global variable
This commit is contained in:
parent
54a2c13b2e
commit
e5eba61cf0
@ -141,7 +141,7 @@ extern const char *snmp_community;
|
||||
/** Agent community string for write access */
|
||||
extern const char *snmp_community_write;
|
||||
/** handle for sending traps */
|
||||
extern void* traps_handle;
|
||||
extern void* snmp_traps_handle;
|
||||
|
||||
void snmp_receive(void *handle, struct pbuf *p, const ip_addr_t *source_ip, u16_t port);
|
||||
err_t snmp_sendto(void *handle, struct pbuf *p, const ip_addr_t *dst, u16_t port);
|
||||
|
@ -54,7 +54,7 @@ snmp_netconn_thread(void *arg)
|
||||
conn = netconn_new(NETCONN_UDP);
|
||||
LWIP_ERROR("snmp_netconn: invalid conn", (conn != NULL), return;);
|
||||
|
||||
traps_handle = conn;
|
||||
snmp_traps_handle = conn;
|
||||
|
||||
/* Bind to SNMP port with default IP address */
|
||||
netconn_bind(conn, IP_ADDR_ANY, SNMP_IN_PORT);
|
||||
@ -94,7 +94,7 @@ snmp_get_local_ip_for_dst(void* handle, const ip_addr_t *dst, ip_addr_t *result)
|
||||
|
||||
LWIP_UNUSED_ARG(conn); /* unused in case of IPV4 only configuration */
|
||||
|
||||
ip_route_get_local_ip(IP_IS_V6(&conn->pcb.udp->local_ip), &conn->pcb.udp->local_ip, dst, dst_if, dst_ip);
|
||||
ip_route_get_local_ip(IP_IS_V6_VAL(conn->pcb.udp->local_ip), &conn->pcb.udp->local_ip, dst, dst_if, dst_ip);
|
||||
|
||||
if((dst_if != NULL) && (dst_ip != NULL)) {
|
||||
ip_addr_copy(*result, *dst_ip);
|
||||
|
@ -33,6 +33,7 @@
|
||||
*/
|
||||
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#if LWIP_SNMP && SNMP_USE_RAW
|
||||
|
||||
@ -54,8 +55,7 @@ snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
|
||||
err_t
|
||||
snmp_sendto(void *handle, struct pbuf *p, const ip_addr_t *dst, u16_t port)
|
||||
{
|
||||
err_t result = udp_sendto((struct udp_pcb*)handle, p, dst, port);
|
||||
return result;
|
||||
return udp_sendto((struct udp_pcb*)handle, p, dst, port);
|
||||
}
|
||||
|
||||
u8_t
|
||||
@ -67,7 +67,7 @@ snmp_get_local_ip_for_dst(void* handle, const ip_addr_t *dst, ip_addr_t *result)
|
||||
|
||||
LWIP_UNUSED_ARG(udp_pcb); /* unused in case of IPV4 only configuration */
|
||||
|
||||
ip_route_get_local_ip(IP_IS_V6(&udp_pcb->local_ip), &udp_pcb->local_ip, dst, dst_if, dst_ip);
|
||||
ip_route_get_local_ip(IP_IS_V6_VAL(udp_pcb->local_ip), &udp_pcb->local_ip, dst, dst_if, dst_ip);
|
||||
|
||||
if((dst_if != NULL) && (dst_ip != NULL)) {
|
||||
ip_addr_copy(*result, *dst_ip);
|
||||
@ -85,13 +85,12 @@ void
|
||||
snmp_init(void)
|
||||
{
|
||||
struct udp_pcb *snmp_pcb = udp_new();
|
||||
LWIP_ERROR("snmp_raw: no PCB", (snmp_pcb != NULL), return;);
|
||||
|
||||
if (snmp_pcb != NULL) {
|
||||
traps_handle = snmp_pcb;
|
||||
snmp_traps_handle = snmp_pcb;
|
||||
|
||||
udp_recv(snmp_pcb, snmp_recv, (void *)SNMP_IN_PORT);
|
||||
udp_bind(snmp_pcb, IP_ADDR_ANY, SNMP_IN_PORT);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* LWIP_SNMP && SNMP_USE_RAW */
|
||||
|
@ -72,7 +72,7 @@ static void snmp_trap_header_enc(struct snmp_msg_trap *trap, struct snmp_pbuf_st
|
||||
/** Agent community string for sending traps */
|
||||
extern const char *snmp_community_trap;
|
||||
|
||||
void* traps_handle;
|
||||
void* snmp_traps_handle;
|
||||
|
||||
struct snmp_trap_dst
|
||||
{
|
||||
@ -85,9 +85,6 @@ static struct snmp_trap_dst trap_dst[SNMP_TRAP_DESTINATIONS];
|
||||
|
||||
static u8_t snmp_auth_traps_enabled = 0;
|
||||
|
||||
/** TRAP message structure */
|
||||
/*struct snmp_msg_trap trap_msg;*/
|
||||
|
||||
/**
|
||||
* Sets enable switch for this trap destination.
|
||||
* @param dst_idx index in 0 .. SNMP_TRAP_DESTINATIONS-1
|
||||
@ -135,7 +132,6 @@ snmp_get_auth_traps_enabled(void)
|
||||
* @param specific_trap used for enterprise traps when generic_trap == 6
|
||||
* @return ERR_OK when success, ERR_MEM if we're out of memory
|
||||
*
|
||||
* @note the caller is responsible for filling in outvb in the trap_msg
|
||||
* @note the use of the enterprise identifier field
|
||||
* is per RFC1215.
|
||||
* Use .iso.org.dod.internet.mgmt.mib-2.snmp for generic traps
|
||||
@ -156,7 +152,7 @@ snmp_send_trap(const struct snmp_obj_id *device_enterprise_oid, s32_t generic_tr
|
||||
for (i = 0, td = &trap_dst[0]; i < SNMP_TRAP_DESTINATIONS; i++, td++) {
|
||||
if ((td->enable != 0) && !ip_addr_isany(&td->dip)) {
|
||||
/* lookup current source address for this dst */
|
||||
if (snmp_get_local_ip_for_dst(traps_handle, &td->dip, &trap_msg.sip)) {
|
||||
if (snmp_get_local_ip_for_dst(snmp_traps_handle, &td->dip, &trap_msg.sip)) {
|
||||
if (device_enterprise_oid == NULL) {
|
||||
trap_msg.enterprise = snmp_get_device_enterprise_oid();
|
||||
} else {
|
||||
@ -188,7 +184,7 @@ snmp_send_trap(const struct snmp_obj_id *device_enterprise_oid, s32_t generic_tr
|
||||
snmp_stats.outpkts++;
|
||||
|
||||
/** send to the TRAP destination */
|
||||
snmp_sendto(traps_handle, p, &td->dip, SNMP_TRAP_PORT);
|
||||
snmp_sendto(snmp_traps_handle, p, &td->dip, SNMP_TRAP_PORT);
|
||||
} else {
|
||||
err = ERR_MEM;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user