mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-04-10 06:44:18 +00:00
Completely decouple SNMP stack from lwIP core by using private memory pools;
Move SNMP stack to apps; API breaking change: Users need to call snmp_init() now!
This commit is contained in:
parent
92a241a29e
commit
5f642eb3e3
@ -34,11 +34,11 @@
|
||||
* Author: Christiaan Simons <christiaan.simons@axon.tv>
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/snmp_asn1.h"
|
||||
#include "lwip/apps/snmp_asn1.h"
|
||||
|
||||
/**
|
||||
* Retrieves type field from incoming pbuf chain.
|
@ -34,11 +34,11 @@
|
||||
* Author: Christiaan Simons <christiaan.simons@axon.tv>
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/snmp_asn1.h"
|
||||
#include "lwip/apps/snmp_asn1.h"
|
||||
|
||||
/**
|
||||
* Returns octet count for length.
|
@ -35,11 +35,11 @@
|
||||
* Author: Christiaan Simons <christiaan.simons@axon.tv>
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/apps/snmp.h"
|
||||
#include "lwip/snmp_mib2.h"
|
||||
|
||||
#if !LWIP_MIB2_CALLBACKS
|
||||
@ -58,8 +58,8 @@
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/priv/tcp_priv.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/snmp_asn1.h"
|
||||
#include "lwip/snmp_structs.h"
|
||||
#include "lwip/apps/snmp_asn1.h"
|
||||
#include "lwip/apps/snmp_structs.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "netif/etharp.h"
|
||||
#include "lwip/stats.h"
|
@ -32,14 +32,17 @@
|
||||
* Author: Christiaan Simons <christiaan.simons@axon.tv>
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/snmp_structs.h"
|
||||
#include "lwip/apps/snmp_structs.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
LWIP_MEMPOOL_DECLARE(SNMP_ROOTNODE, SNMP_NUM_ROOTNODE, sizeof(struct mib_list_rootnode), "SNMP_ROOTNODE")
|
||||
LWIP_MEMPOOL_DECLARE(SNMP_NODE, SNMP_NUM_NODE, sizeof(struct mib_list_node), "SNMP_NODE")
|
||||
|
||||
/** .iso.org.dod.internet address prefix, @see snmp_iso_*() */
|
||||
const s32_t prefix[4] = {1, 3, 6, 1};
|
||||
|
||||
@ -154,7 +157,7 @@ snmp_mib_ln_alloc(s32_t id)
|
||||
{
|
||||
struct mib_list_node *ln;
|
||||
|
||||
ln = (struct mib_list_node *)memp_malloc(MEMP_SNMP_NODE);
|
||||
ln = (struct mib_list_node *)LWIP_MEMPOOL_ALLOC(SNMP_NODE);
|
||||
if (ln != NULL) {
|
||||
ln->prev = NULL;
|
||||
ln->next = NULL;
|
||||
@ -167,7 +170,7 @@ snmp_mib_ln_alloc(s32_t id)
|
||||
void
|
||||
snmp_mib_ln_free(struct mib_list_node *ln)
|
||||
{
|
||||
memp_free(MEMP_SNMP_NODE, ln);
|
||||
LWIP_MEMPOOL_FREE(SNMP_NODE, ln);
|
||||
}
|
||||
|
||||
struct mib_list_rootnode *
|
||||
@ -175,7 +178,7 @@ snmp_mib_lrn_alloc(void)
|
||||
{
|
||||
struct mib_list_rootnode *lrn;
|
||||
|
||||
lrn = (struct mib_list_rootnode*)memp_malloc(MEMP_SNMP_ROOTNODE);
|
||||
lrn = (struct mib_list_rootnode*)LWIP_MEMPOOL_ALLOC(SNMP_ROOTNODE);
|
||||
if (lrn != NULL) {
|
||||
lrn->scalar.get_object_def = noleafs_get_object_def;
|
||||
lrn->scalar.get_value = noleafs_get_value;
|
||||
@ -192,7 +195,7 @@ snmp_mib_lrn_alloc(void)
|
||||
void
|
||||
snmp_mib_lrn_free(struct mib_list_rootnode *lrn)
|
||||
{
|
||||
memp_free(MEMP_SNMP_ROOTNODE, lrn);
|
||||
LWIP_MEMPOOL_FREE(SNMP_ROOTNODE, lrn);
|
||||
}
|
||||
|
||||
/**
|
@ -32,14 +32,24 @@
|
||||
* Author: Christiaan Simons <christiaan.simons@axon.tv>
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/snmp_asn1.h"
|
||||
#include "lwip/snmp_msg.h"
|
||||
#include "lwip/snmp_structs.h"
|
||||
#if (!LWIP_UDP && LWIP_SNMP)
|
||||
#error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_SNMP && (SNMP_CONCURRENT_REQUESTS<=0))
|
||||
#error "If you want to use SNMP, you have to define SNMP_CONCURRENT_REQUESTS>=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_SNMP && (SNMP_TRAP_DESTINATIONS<=0))
|
||||
#error "If you want to use SNMP, you have to define SNMP_TRAP_DESTINATIONS>=1 in your lwipopts.h"
|
||||
#endif
|
||||
|
||||
#include "lwip/apps/snmp.h"
|
||||
#include "lwip/apps/snmp_asn1.h"
|
||||
#include "snmp_msg.h"
|
||||
#include "lwip/apps/snmp_structs.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/udp.h"
|
||||
@ -47,6 +57,9 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
LWIP_MEMPOOL_DECLARE(SNMP_VARBIND, SNMP_NUM_VARBIND, sizeof(struct snmp_varbind), "SNMP_VARBIND")
|
||||
LWIP_MEMPOOL_DECLARE(SNMP_VALUE, SNMP_NUM_VALUE, SNMP_MAX_VALUE_SIZE, "SNMP_VALUE")
|
||||
|
||||
/* public (non-static) constants */
|
||||
/** SNMP v1 == 0 */
|
||||
const s32_t snmp_version = 0;
|
||||
@ -79,6 +92,11 @@ snmp_init(void)
|
||||
struct snmp_msg_pstat *msg_ps;
|
||||
u8_t i;
|
||||
|
||||
LWIP_MEMPOOL_INIT(SNMP_VARBIND);
|
||||
LWIP_MEMPOOL_INIT(SNMP_VALUE);
|
||||
LWIP_MEMPOOL_INIT(SNMP_ROOTNODE);
|
||||
LWIP_MEMPOOL_INIT(SNMP_NODE);
|
||||
|
||||
snmp1_pcb = udp_new();
|
||||
if (snmp1_pcb != NULL) {
|
||||
udp_recv(snmp1_pcb, snmp_recv, (void *)SNMP_IN_PORT);
|
||||
@ -190,7 +208,7 @@ snmp_error_response(struct snmp_msg_pstat *msg_ps, u8_t error)
|
||||
for (v = 0; v < msg_ps->vb_idx; v++) {
|
||||
if (vbi->ident != NULL) {
|
||||
/* free previously allocated value before overwriting the pointer */
|
||||
memp_free(MEMP_SNMP_VALUE, vbi->ident);
|
||||
LWIP_MEMPOOL_FREE(SNMP_VALUE, vbi->ident);
|
||||
}
|
||||
vbi->ident_len = vbo->ident_len;
|
||||
vbo->ident_len = 0;
|
||||
@ -268,7 +286,7 @@ snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
en = msg_ps->ext_mib_node;
|
||||
|
||||
/* allocate output varbind */
|
||||
vb = (struct snmp_varbind *)memp_malloc(MEMP_SNMP_VARBIND);
|
||||
vb = (struct snmp_varbind *)LWIP_MEMPOOL_ALLOC(SNMP_VARBIND);
|
||||
if (vb != NULL) {
|
||||
vb->next = NULL;
|
||||
vb->prev = NULL;
|
||||
@ -282,13 +300,13 @@ snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
|
||||
vb->value_type = msg_ps->ext_object_def.asn_type;
|
||||
|
||||
vb->value = memp_malloc(MEMP_SNMP_VALUE);
|
||||
vb->value = LWIP_MEMPOOL_ALLOC(SNMP_VALUE);
|
||||
if (vb->value != NULL) {
|
||||
vb->value_len = en->get_value_a(request_id, &msg_ps->ext_object_def, vb->value);
|
||||
LWIP_ASSERT("SNMP_MAX_VALUE_SIZE is configured too low", vb->value_len <= SNMP_MAX_VALUE_SIZE);
|
||||
if (vb->value_len == 0)
|
||||
{
|
||||
memp_free(MEMP_SNMP_VALUE, vb->value);
|
||||
LWIP_MEMPOOL_FREE(SNMP_VALUE, vb->value);
|
||||
vb->value = NULL;
|
||||
}
|
||||
snmp_varbind_tail_add(&msg_ps->outvb, vb);
|
||||
@ -300,7 +318,7 @@ snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_msg_event: no variable space\n"));
|
||||
msg_ps->vb_ptr->ident = vb->ident;
|
||||
msg_ps->vb_ptr->ident_len = vb->ident_len;
|
||||
memp_free(MEMP_SNMP_VARBIND, vb);
|
||||
LWIP_MEMPOOL_FREE(SNMP_VARBIND, vb);
|
||||
snmp_error_response(msg_ps,SNMP_ES_TOOBIG);
|
||||
}
|
||||
} else {
|
||||
@ -350,7 +368,7 @@ snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
|
||||
msg_ps->state = SNMP_MSG_INTERNAL_GET_VALUE;
|
||||
/* allocate output varbind */
|
||||
vb = (struct snmp_varbind *)memp_malloc(MEMP_SNMP_VARBIND);
|
||||
vb = (struct snmp_varbind *)LWIP_MEMPOOL_ALLOC(SNMP_VARBIND);
|
||||
if (vb != NULL) {
|
||||
vb->next = NULL;
|
||||
vb->prev = NULL;
|
||||
@ -364,12 +382,12 @@ snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
|
||||
vb->value_type = object_def.asn_type;
|
||||
|
||||
vb->value = memp_malloc(MEMP_SNMP_VALUE);
|
||||
vb->value = LWIP_MEMPOOL_ALLOC(SNMP_VALUE);
|
||||
if (vb->value != NULL) {
|
||||
vb->value_len = msn->get_value(&object_def, vb->value);
|
||||
LWIP_ASSERT("SNMP_MAX_OCTET_STRING_LEN is configured too low", vb->value_len <= SNMP_MAX_VALUE_SIZE);
|
||||
if (vb->value_len == 0) {
|
||||
memp_free(MEMP_SNMP_VALUE, vb->value);
|
||||
LWIP_MEMPOOL_FREE(SNMP_VALUE, vb->value);
|
||||
vb->value = NULL;
|
||||
}
|
||||
snmp_varbind_tail_add(&msg_ps->outvb, vb);
|
||||
@ -381,7 +399,7 @@ snmp_msg_get_event(u8_t request_id, struct snmp_msg_pstat *msg_ps)
|
||||
msg_ps->vb_ptr->ident_len = vb->ident_len;
|
||||
vb->ident = NULL;
|
||||
vb->ident_len = 0;
|
||||
memp_free(MEMP_SNMP_VARBIND, vb);
|
||||
LWIP_MEMPOOL_FREE(SNMP_VARBIND, vb);
|
||||
snmp_error_response(msg_ps,SNMP_ES_TOOBIG);
|
||||
}
|
||||
} else {
|
||||
@ -1216,7 +1234,7 @@ snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u16_t len)
|
||||
{
|
||||
struct snmp_varbind *vb;
|
||||
|
||||
vb = (struct snmp_varbind *)memp_malloc(MEMP_SNMP_VARBIND);
|
||||
vb = (struct snmp_varbind *)LWIP_MEMPOOL_ALLOC(SNMP_VARBIND);
|
||||
if (vb != NULL) {
|
||||
u8_t i;
|
||||
|
||||
@ -1227,7 +1245,7 @@ snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u16_t len)
|
||||
if (i > 0) {
|
||||
if (i <= SNMP_MAX_TREE_DEPTH) {
|
||||
/* allocate array of s32_t for our object identifier */
|
||||
vb->ident = (s32_t*)memp_malloc(MEMP_SNMP_VALUE);
|
||||
vb->ident = (s32_t*)LWIP_MEMPOOL_ALLOC(SNMP_VALUE);
|
||||
if (vb->ident == NULL) {
|
||||
LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_varbind_alloc: couldn't allocate ident value space\n"));
|
||||
}
|
||||
@ -1236,7 +1254,7 @@ snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u16_t len)
|
||||
vb->ident = NULL;
|
||||
}
|
||||
if (vb->ident == NULL) {
|
||||
memp_free(MEMP_SNMP_VARBIND, vb);
|
||||
LWIP_MEMPOOL_FREE(SNMP_VARBIND, vb);
|
||||
return NULL;
|
||||
}
|
||||
while (i > 0) {
|
||||
@ -1252,7 +1270,7 @@ snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u16_t len)
|
||||
if (len > 0) {
|
||||
if (vb->value_len <= SNMP_MAX_VALUE_SIZE) {
|
||||
/* allocate raw bytes for our object value */
|
||||
vb->value = memp_malloc(MEMP_SNMP_VALUE);
|
||||
vb->value = LWIP_MEMPOOL_ALLOC(SNMP_VALUE);
|
||||
if (vb->value == NULL) {
|
||||
LWIP_DEBUGF(SNMP_MSG_DEBUG, ("snmp_varbind_alloc: couldn't allocate value space\n"));
|
||||
}
|
||||
@ -1262,9 +1280,9 @@ snmp_varbind_alloc(struct snmp_obj_id *oid, u8_t type, u16_t len)
|
||||
}
|
||||
if (vb->value == NULL) {
|
||||
if (vb->ident != NULL) {
|
||||
memp_free(MEMP_SNMP_VALUE, vb->ident);
|
||||
LWIP_MEMPOOL_FREE(SNMP_VALUE, vb->ident);
|
||||
}
|
||||
memp_free(MEMP_SNMP_VARBIND, vb);
|
||||
LWIP_MEMPOOL_FREE(SNMP_VARBIND, vb);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
@ -1281,12 +1299,12 @@ void
|
||||
snmp_varbind_free(struct snmp_varbind *vb)
|
||||
{
|
||||
if (vb->value != NULL) {
|
||||
memp_free(MEMP_SNMP_VALUE, vb->value);
|
||||
LWIP_MEMPOOL_FREE(SNMP_VALUE, vb->value);
|
||||
}
|
||||
if (vb->ident != NULL) {
|
||||
memp_free(MEMP_SNMP_VALUE, vb->ident);
|
||||
LWIP_MEMPOOL_FREE(SNMP_VALUE, vb->ident);
|
||||
}
|
||||
memp_free(MEMP_SNMP_VARBIND, vb);
|
||||
LWIP_MEMPOOL_FREE(SNMP_VARBIND, vb);
|
||||
}
|
||||
|
||||
void
|
@ -42,16 +42,16 @@
|
||||
* Author: Christiaan Simons <christiaan.simons@axon.tv>
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/apps/snmp.h"
|
||||
#include "lwip/snmp_mib2.h"
|
||||
#include "lwip/snmp_asn1.h"
|
||||
#include "lwip/snmp_msg.h"
|
||||
#include "lwip/apps/snmp_asn1.h"
|
||||
#include "snmp_msg.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
#include <string.h>
|
@ -35,9 +35,9 @@
|
||||
#ifndef LWIP_HDR_SNMP_MSG_H
|
||||
#define LWIP_HDR_SNMP_MSG_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/snmp_structs.h"
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
#include "lwip/apps/snmp.h"
|
||||
#include "lwip/apps/snmp_structs.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/err.h"
|
||||
|
@ -50,7 +50,6 @@
|
||||
#include "lwip/raw.h"
|
||||
#include "lwip/udp.h"
|
||||
#include "lwip/priv/tcp_priv.h"
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/autoip.h"
|
||||
#include "lwip/igmp.h"
|
||||
#include "lwip/dns.h"
|
||||
@ -80,9 +79,6 @@
|
||||
#if (!LWIP_UDP && LWIP_MULTICAST_TX_OPTIONS)
|
||||
#error "If you want to use IGMP/LWIP_MULTICAST_TX_OPTIONS, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (!LWIP_UDP && LWIP_SNMP)
|
||||
#error "If you want to use SNMP, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (!LWIP_UDP && LWIP_DNS)
|
||||
#error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h"
|
||||
#endif
|
||||
@ -173,12 +169,6 @@
|
||||
#if (!LWIP_ARP && LWIP_AUTOIP)
|
||||
#error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_SNMP && (SNMP_CONCURRENT_REQUESTS<=0))
|
||||
#error "If you want to use SNMP, you have to define SNMP_CONCURRENT_REQUESTS>=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_SNMP && (SNMP_TRAP_DESTINATIONS<=0))
|
||||
#error "If you want to use SNMP, you have to define SNMP_TRAP_DESTINATIONS>=1 in your lwipopts.h"
|
||||
#endif
|
||||
#if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API)))
|
||||
#error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h"
|
||||
#endif
|
||||
@ -343,9 +333,6 @@ lwip_init(void)
|
||||
#if LWIP_TCP
|
||||
tcp_init();
|
||||
#endif /* LWIP_TCP */
|
||||
#if LWIP_SNMP
|
||||
snmp_init();
|
||||
#endif /* LWIP_SNMP */
|
||||
#if LWIP_AUTOIP
|
||||
autoip_init();
|
||||
#endif /* LWIP_AUTOIP */
|
||||
|
@ -53,8 +53,6 @@
|
||||
#include "lwip/stats.h"
|
||||
#include "netif/etharp.h"
|
||||
#include "lwip/ip_frag.h"
|
||||
#include "lwip/snmp_structs.h"
|
||||
#include "lwip/snmp_msg.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "netif/ppp/ppp.h"
|
||||
|
@ -33,8 +33,7 @@
|
||||
#ifndef LWIP_HDR_SNMP_H
|
||||
#define LWIP_HDR_SNMP_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/snmp_mib2.h"
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -42,6 +41,8 @@ extern "C" {
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/ip.h"
|
||||
|
||||
/** fixed maximum length for object identifier type */
|
||||
#define LWIP_SNMP_OBJ_ID_LEN 32
|
||||
|
@ -35,10 +35,10 @@
|
||||
#ifndef LWIP_HDR_SNMP_ASN1_H
|
||||
#define LWIP_HDR_SNMP_ASN1_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/apps/snmp_opts.h"
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/apps/snmp.h"
|
||||
|
||||
#if LWIP_SNMP
|
||||
|
195
src/include/lwip/apps/snmp_opts.h
Normal file
195
src/include/lwip/apps/snmp_opts.h
Normal file
@ -0,0 +1,195 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Dirk Ziegelmeier
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
* Author: Dirk Ziegelmeier
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LWIP_HDR_SNMP_OPTS_H
|
||||
#define LWIP_HDR_SNMP_OPTS_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
/*
|
||||
----------------------------------
|
||||
---------- SNMP options ----------
|
||||
----------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_SNMP==1: This enables the lwIP SNMP agent. UDP must be available
|
||||
* for SNMP transport.
|
||||
* If you want to use your own SNMP agent, leave this disabled.
|
||||
* To integrate MIB2 of an external agent, you need to enable
|
||||
* LWIP_MIB2_CALLBACKS and MIB2_STATS. This will give you the callbacks
|
||||
* and statistics counters you need to get MIB2 working.
|
||||
*/
|
||||
#ifndef LWIP_SNMP
|
||||
#define LWIP_SNMP 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_CONCURRENT_REQUESTS: Number of concurrent requests the module will
|
||||
* allow. At least one request buffer is required.
|
||||
* Does not have to be changed unless external MIBs answer request asynchronously
|
||||
*/
|
||||
#ifndef SNMP_CONCURRENT_REQUESTS
|
||||
#define SNMP_CONCURRENT_REQUESTS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_TRAP_DESTINATIONS: Number of trap destinations. At least one trap
|
||||
* destination is required
|
||||
*/
|
||||
#ifndef SNMP_TRAP_DESTINATIONS
|
||||
#define SNMP_TRAP_DESTINATIONS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_PRIVATE_MIB:
|
||||
* When using a private MIB, you have to create a file 'private_mib.h' that contains
|
||||
* a 'struct mib_array_node mib_private' which contains your MIB.
|
||||
*/
|
||||
#ifndef SNMP_PRIVATE_MIB
|
||||
#define SNMP_PRIVATE_MIB 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Only allow SNMP write actions that are 'safe' (e.g. disabling netifs is not
|
||||
* a safe action and disabled when SNMP_SAFE_REQUESTS = 1).
|
||||
* Unsafe requests are disabled by default!
|
||||
*/
|
||||
#ifndef SNMP_SAFE_REQUESTS
|
||||
#define SNMP_SAFE_REQUESTS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum length of strings used. This affects the size of
|
||||
* MEMP_SNMP_VALUE elements.
|
||||
*/
|
||||
#ifndef SNMP_MAX_OCTET_STRING_LEN
|
||||
#define SNMP_MAX_OCTET_STRING_LEN 127
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum depth of the SNMP tree.
|
||||
* With private MIBs enabled, this depends on your MIB!
|
||||
* This affects the size of MEMP_SNMP_VALUE elements.
|
||||
*/
|
||||
#ifndef SNMP_MAX_TREE_DEPTH
|
||||
#define SNMP_MAX_TREE_DEPTH 15
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The size of the MEMP_SNMP_VALUE elements, normally calculated from
|
||||
* SNMP_MAX_OCTET_STRING_LEN and SNMP_MAX_TREE_DEPTH.
|
||||
*/
|
||||
#ifndef SNMP_MAX_VALUE_SIZE
|
||||
#define SNMP_MAX_VALUE_SIZE LWIP_MAX((SNMP_MAX_OCTET_STRING_LEN)+1, sizeof(s32_t)*(SNMP_MAX_TREE_DEPTH))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The snmp read-access community. Used for write-access and traps, too
|
||||
* unless SNMP_COMMUNITY_WRITE or SNMP_COMMUNITY_TRAP are enabled, respectively.
|
||||
*/
|
||||
#ifndef SNMP_COMMUNITY
|
||||
#define SNMP_COMMUNITY "public"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set this to 1 to enable support for dedicated write-access and trap communities.
|
||||
*/
|
||||
#ifndef SNMP_COMMUNITY_EXT
|
||||
#define SNMP_COMMUNITY_EXT 0
|
||||
#endif
|
||||
|
||||
#if SNMP_COMMUNITY_EXT
|
||||
/**
|
||||
* The snmp write-access community.
|
||||
*/
|
||||
#ifndef SNMP_COMMUNITY_WRITE
|
||||
#define SNMP_COMMUNITY_WRITE "private"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The snmp community used for sending traps.
|
||||
*/
|
||||
#ifndef SNMP_COMMUNITY_TRAP
|
||||
#define SNMP_COMMUNITY_TRAP "public"
|
||||
#endif
|
||||
#endif /* SNMP_COMMUNITY_EXT */
|
||||
|
||||
/**
|
||||
* SNMP_NUM_NODE: the number of leafs in the SNMP tree.
|
||||
*/
|
||||
#ifndef SNMP_NUM_NODE
|
||||
#define SNMP_NUM_NODE 50
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_NUM_ROOTNODE: the number of branches in the SNMP tree.
|
||||
* Every branch has one leaf (MEMP_NUM_SNMP_NODE) at least!
|
||||
*/
|
||||
#ifndef SNMP_NUM_ROOTNODE
|
||||
#define SNMP_NUM_ROOTNODE 30
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_NUM_VARBIND: influences the number of concurrent requests:
|
||||
* 2 of these are used per request (1 for input, 1 for output), so this needs
|
||||
* to be increased only if you want to support concurrent requests or multiple
|
||||
* variables per request/response.
|
||||
*/
|
||||
#ifndef SNMP_NUM_VARBIND
|
||||
#define SNMP_NUM_VARBIND 2
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_NUM_VALUE: the number of OID or values concurrently used
|
||||
* (does not have to be changed normally) - >=3 of these are used per request
|
||||
* (1 for the value read and 2 for OIDs - input and output on getnext, or more
|
||||
* if you want to support multiple varibles per request/response)
|
||||
*/
|
||||
#ifndef SNMP_NUM_VALUE
|
||||
#define SNMP_NUM_VALUE 3
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_MSG_DEBUG: Enable debugging for SNMP messages.
|
||||
*/
|
||||
#ifndef SNMP_MSG_DEBUG
|
||||
#define SNMP_MSG_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_MIB_DEBUG: Enable debugging for SNMP MIBs.
|
||||
*/
|
||||
#ifndef SNMP_MIB_DEBUG
|
||||
#define SNMP_MIB_DEBUG LWIP_DBG_OFF
|
||||
#endif
|
||||
|
||||
#endif /* LWIP_HDR_SNMP_OPTS_H */
|
@ -41,7 +41,11 @@
|
||||
|
||||
#if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/apps/snmp.h"
|
||||
#include "lwip/memp.h"
|
||||
|
||||
LWIP_MEMPOOL_PROTOTYPE(SNMP_ROOTNODE);
|
||||
LWIP_MEMPOOL_PROTOTYPE(SNMP_NODE);
|
||||
|
||||
#if SNMP_PRIVATE_MIB
|
||||
/* When using a private MIB, you have to create a file 'private_mib.h' that contains
|
@ -64,7 +64,7 @@ typedef enum {
|
||||
|
||||
extern const struct memp_desc *memp_pools[MEMP_MAX];
|
||||
|
||||
#define LWIP_MEMPOOL_PROTOTYPE(name) extern const struct memp_desc *memp_ ## name
|
||||
#define LWIP_MEMPOOL_PROTOTYPE(name) extern const struct memp_desc memp_ ## name
|
||||
|
||||
#if MEMP_MEM_MALLOC
|
||||
|
||||
|
@ -350,41 +350,6 @@
|
||||
#define MEMP_NUM_TCPIP_MSG_INPKT 8
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_SNMP_NODE: the number of leafs in the SNMP tree.
|
||||
*/
|
||||
#ifndef MEMP_NUM_SNMP_NODE
|
||||
#define MEMP_NUM_SNMP_NODE 50
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_SNMP_ROOTNODE: the number of branches in the SNMP tree.
|
||||
* Every branch has one leaf (MEMP_NUM_SNMP_NODE) at least!
|
||||
*/
|
||||
#ifndef MEMP_NUM_SNMP_ROOTNODE
|
||||
#define MEMP_NUM_SNMP_ROOTNODE 30
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_SNMP_VARBIND: influences the number of concurrent requests:
|
||||
* 2 of these are used per request (1 for input, 1 for output), so this needs
|
||||
* to be increased only if you want to support concurrent requests or multiple
|
||||
* variables per request/response.
|
||||
*/
|
||||
#ifndef MEMP_NUM_SNMP_VARBIND
|
||||
#define MEMP_NUM_SNMP_VARBIND 2
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_SNMP_VALUE: the number of OID or values concurrently used
|
||||
* (does not have to be changed normally) - >=3 of these are used per request
|
||||
* (1 for the value read and 2 for OIDs - input and output on getnext, or more
|
||||
* if you want to support multiple varibles per request/response)
|
||||
*/
|
||||
#ifndef MEMP_NUM_SNMP_VALUE
|
||||
#define MEMP_NUM_SNMP_VALUE 3
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MEMP_NUM_NETDB: the number of concurrently running lwip_addrinfo() calls
|
||||
* (before freeing the corresponding memory using lwip_freeaddrinfo()).
|
||||
@ -850,123 +815,15 @@
|
||||
#define LWIP_DHCP_AUTOIP_COOP_TRIES 9
|
||||
#endif
|
||||
|
||||
/*
|
||||
----------------------------------
|
||||
---------- SNMP options ----------
|
||||
----------------------------------
|
||||
*/
|
||||
/**
|
||||
* LWIP_SNMP==1: This enables the lwIP SNMP agent. UDP must be available
|
||||
* for SNMP transport.
|
||||
* If you want to use your own SNMP agent, leave this disabled.
|
||||
* To integrate MIB2 of an external agent, you need to enable
|
||||
* LWIP_MIB2_CALLBACKS and MIB2_STATS. This will give you the callbacks
|
||||
* and statistics counters you need to get MIB2 working.
|
||||
*/
|
||||
#ifndef LWIP_SNMP
|
||||
#define LWIP_SNMP 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_MIB2_CALLBACKS==1: Turn on SNMP MIB2 callbacks.
|
||||
* Turn this on to get callbacks needed to implement MIB2.
|
||||
* Usually MIB2_STATS should be enabled, too.
|
||||
*/
|
||||
#ifndef LWIP_MIB2_CALLBACKS
|
||||
#define LWIP_MIB2_CALLBACKS LWIP_SNMP
|
||||
#define LWIP_MIB2_CALLBACKS 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_CONCURRENT_REQUESTS: Number of concurrent requests the module will
|
||||
* allow. At least one request buffer is required.
|
||||
* Does not have to be changed unless external MIBs answer request asynchronously
|
||||
*/
|
||||
#ifndef SNMP_CONCURRENT_REQUESTS
|
||||
#define SNMP_CONCURRENT_REQUESTS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_TRAP_DESTINATIONS: Number of trap destinations. At least one trap
|
||||
* destination is required
|
||||
*/
|
||||
#ifndef SNMP_TRAP_DESTINATIONS
|
||||
#define SNMP_TRAP_DESTINATIONS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* SNMP_PRIVATE_MIB:
|
||||
* When using a private MIB, you have to create a file 'private_mib.h' that contains
|
||||
* a 'struct mib_array_node mib_private' which contains your MIB.
|
||||
*/
|
||||
#ifndef SNMP_PRIVATE_MIB
|
||||
#define SNMP_PRIVATE_MIB 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Only allow SNMP write actions that are 'safe' (e.g. disabling netifs is not
|
||||
* a safe action and disabled when SNMP_SAFE_REQUESTS = 1).
|
||||
* Unsafe requests are disabled by default!
|
||||
*/
|
||||
#ifndef SNMP_SAFE_REQUESTS
|
||||
#define SNMP_SAFE_REQUESTS 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum length of strings used. This affects the size of
|
||||
* MEMP_SNMP_VALUE elements.
|
||||
*/
|
||||
#ifndef SNMP_MAX_OCTET_STRING_LEN
|
||||
#define SNMP_MAX_OCTET_STRING_LEN 127
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The maximum depth of the SNMP tree.
|
||||
* With private MIBs enabled, this depends on your MIB!
|
||||
* This affects the size of MEMP_SNMP_VALUE elements.
|
||||
*/
|
||||
#ifndef SNMP_MAX_TREE_DEPTH
|
||||
#define SNMP_MAX_TREE_DEPTH 15
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The size of the MEMP_SNMP_VALUE elements, normally calculated from
|
||||
* SNMP_MAX_OCTET_STRING_LEN and SNMP_MAX_TREE_DEPTH.
|
||||
*/
|
||||
#ifndef SNMP_MAX_VALUE_SIZE
|
||||
#define SNMP_MAX_VALUE_SIZE LWIP_MAX((SNMP_MAX_OCTET_STRING_LEN)+1, sizeof(s32_t)*(SNMP_MAX_TREE_DEPTH))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The snmp read-access community. Used for write-access and traps, too
|
||||
* unless SNMP_COMMUNITY_WRITE or SNMP_COMMUNITY_TRAP are enabled, respectively.
|
||||
*/
|
||||
#ifndef SNMP_COMMUNITY
|
||||
#define SNMP_COMMUNITY "public"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set this to 1 to enable support for dedicated write-access and trap communities.
|
||||
*/
|
||||
#ifndef SNMP_COMMUNITY_EXT
|
||||
#define SNMP_COMMUNITY_EXT 0
|
||||
#endif
|
||||
|
||||
#if SNMP_COMMUNITY_EXT
|
||||
/**
|
||||
* The snmp write-access community.
|
||||
*/
|
||||
#ifndef SNMP_COMMUNITY_WRITE
|
||||
#define SNMP_COMMUNITY_WRITE "private"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The snmp community used for sending traps.
|
||||
*/
|
||||
#ifndef SNMP_COMMUNITY_TRAP
|
||||
#define SNMP_COMMUNITY_TRAP "public"
|
||||
#endif
|
||||
#endif /* SNMP_COMMUNITY_EXT */
|
||||
|
||||
/*
|
||||
----------------------------------
|
||||
----- Multicast/IGMP options -----
|
||||
@ -1926,7 +1783,7 @@
|
||||
* MIB2_STATS==1: Stats for SNMP MIB2.
|
||||
*/
|
||||
#ifndef MIB2_STATS
|
||||
#define MIB2_STATS (LWIP_SNMP)
|
||||
#define MIB2_STATS 0
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
@ -87,12 +87,6 @@ LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group)
|
||||
LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT")
|
||||
#endif /* LWIP_TIMERS */
|
||||
|
||||
#if LWIP_SNMP
|
||||
LWIP_MEMPOOL(SNMP_ROOTNODE, MEMP_NUM_SNMP_ROOTNODE, sizeof(struct mib_list_rootnode), "SNMP_ROOTNODE")
|
||||
LWIP_MEMPOOL(SNMP_NODE, MEMP_NUM_SNMP_NODE, sizeof(struct mib_list_node), "SNMP_NODE")
|
||||
LWIP_MEMPOOL(SNMP_VARBIND, MEMP_NUM_SNMP_VARBIND, sizeof(struct snmp_varbind), "SNMP_VARBIND")
|
||||
LWIP_MEMPOOL(SNMP_VALUE, MEMP_NUM_SNMP_VALUE, SNMP_MAX_VALUE_SIZE, "SNMP_VALUE")
|
||||
#endif /* LWIP_SNMP */
|
||||
#if LWIP_DNS && LWIP_SOCKET
|
||||
LWIP_MEMPOOL(NETDB, MEMP_NUM_NETDB, NETDB_ELEM_SIZE, "NETDB")
|
||||
#endif /* LWIP_DNS && LWIP_SOCKET */
|
||||
|
Loading…
x
Reference in New Issue
Block a user