lwIP中的snmp

1. 概述

lwIP官网介绍snmp
lwip-SNMP移植
LwIP的SNMP学习笔记
RT论坛上的“LWIP下的SNMP协议”
lwip下SNMP的移植实现,表的获取问题
How to make lwip SNMP work【转载】
snmp数据类型及读写函数

2.添加mib2

S2700 V100R006C05 MIB参考

2.1 步骤

1、在你的 lwipopts.h中定义使用snmp

#define LWIP_SNMP 1

2、使用mib2,初始化snmp

//必须----
snmp_mib2_set_syscontact()				//设置联系人节点指针
snmp_mib2_set_syslocation()				//设置结点物理位置的指针
snmp_set_auth_traps_enabled()			//使能发送验证失败报告
snmp_set_write_callback()				//设置写回调函数
//不是必须--
snmp_mib2_set_sysdescr()
snmp_set_device_enterprise_oid()
snmp_mib2_set_sysname()
//设置trap目的地址
snmp_trap_dst_enable()
snmp_trap_dst_ip_set()
//设置mib、初始化snmp----
snmp_set_mibs()							//设置mib
snmp_init()								//snmp初始化

2.2 core模块

2.3 Traps模块

2.4 MIB2模块

2.5 Options模块

#define LWIP_SNMP   0
#define SNMP_COMMUNITY   "public"
#define SNMP_COMMUNITY_TRAP   "public"
#define SNMP_COMMUNITY_WRITE   "private"
#define SNMP_DEBUG   LWIP_DBG_OFF
#define SNMP_DEVICE_ENTERPRISE_OID   {1, 3, 6, 1, 4, 1, SNMP_LWIP_ENTERPRISE_OID}
#define SNMP_DEVICE_ENTERPRISE_OID_LEN   7
#define SNMP_LWIP_ENTERPRISE_OID   26381
#define SNMP_LWIP_GETBULK_MAX_REPETITIONS   0
#define SNMP_LWIP_MIB2   LWIP_SNMP
#define SNMP_LWIP_MIB2_SYSCONTACT   ""
#define SNMP_LWIP_MIB2_SYSDESC   "lwIP"
#define SNMP_LWIP_MIB2_SYSLOCATION   ""
#define SNMP_LWIP_MIB2_SYSNAME   "FQDN-unk"
#define SNMP_MAX_COMMUNITY_STR_LEN   LWIP_MAX(LWIP_MAX(sizeof(SNMP_COMMUNITY), sizeof(SNMP_COMMUNITY_WRITE)), sizeof(SNMP_COMMUNITY_TRAP))
#define SNMP_MAX_OBJ_ID_LEN   50
#define SNMP_MAX_OCTET_STRING_LEN   127
#define SNMP_MAX_VALUE_SIZE   LWIP_MAX(LWIP_MAX((SNMP_MAX_OCTET_STRING_LEN), sizeof(u32_t)*(SNMP_MAX_OBJ_ID_LEN)), SNMP_MIN_VALUE_SIZE)
#define SNMP_MIB_DEBUG   LWIP_DBG_OFF
#define SNMP_MIN_VALUE_SIZE   (2 * sizeof(u32_t*))	 /* size required to store the basic types (8 bytes for counter64) */
#define SNMP_SAFE_REQUESTS   1
#define SNMP_STACK_SIZE   DEFAULT_THREAD_STACKSIZE
#define SNMP_THREAD_PRIO   DEFAULT_THREAD_PRIO
#define SNMP_TRAP_DESTINATIONS   1
#define SNMP_USE_NETCONN   0
#define SNMP_USE_RAW   1
  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
INTRODUCTION lwIP is a small independent implementation of the TCP/IP protocol suite. The focus of the lwIP TCP/IP implementation is to reduce the RAM usage while still having a full scale TCP. This making lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40 kilobytes of code ROM. lwIP was originally developed by Adam Dunkels at the Computer and Networks Architectures (CNA) lab at the Swedish Institute of Computer Science (SICS) and is now developed and maintained by a worldwide network of developers. FEATURES * IP (Internet Protocol, IPv4 and IPv6) including packet forwarding over multiple network interfaces * ICMP (Internet Control Message Protocol) for network maintenance and debugging * IGMP (Internet Group Management Protocol) for multicast traffic management * MLD (Multicast listener discovery for IPv6). Aims to be compliant with RFC 2710. No support for MLDv2 * ND (Neighbor discovery and stateless address autoconfiguration for IPv6). Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862 (Address autoconfiguration) * DHCP, AutoIP/APIPA (Zeroconf), ACD (Address Conflict Detection) and (stateless) DHCPv6 * UDP (User Datagram Protocol) including experimental UDP-lite extensions * TCP (Transmission Control Protocol) with congestion control, RTT estimation fast recovery/fast retransmit and sending SACKs * raw/native API for enhanced performance * Optional Berkeley-like socket API * TLS: optional layered TCP ("altcp") for nearly transparent TLS for any TCP-based protocol (ported to mbedTLS) (see changelog for more info) * PPPoS and PPPoE (Point-to-point protocol over Serial/Ethernet) * DNS (Domain name resolver incl. mDNS) * 6LoWPAN (via IEEE 802.15.4, BLE or ZEP) APPLICATIONS * HTTP server with SSI and CGI (HTTPS via altcp) * SNMPv2c agent with MIB compiler (Simple Network Management Protocol), v3 via altcp * SNTP (Simple network time protocol) * NetBIOS name service responder * MDNS (Multicast DNS) responder * iPerf server implementation * MQTT client (TLS support via altcp) LICENSE lwIP is freely available under a BSD license. DEVELOPMENT lwIP has grown into an excellent TCP/IP stack for embedded devices, and developers using the stack often submit bug fixes, improvements, and additions to the stack to further increase its usefulness. Development of lwIP is hosted on Savannah, a central point for software development, maintenance and distribution. Everyone can help improve lwIP by use of Savannah's interface, Git and the mailing list. A core team of developers will commit changes to the Git source tree. The lwIP TCP/IP stack is maintained in the 'lwip' Git module and contributions (such as platform ports) are in the 'contrib' Git module. See doc/savannah.txt for details on Git server access for users and developers. The current Git trees are web-browsable: http://git.savannah.gnu.org/cgit/lwip.git http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git Submit patches and bugs via the lwIP project page: http://savannah.nongnu.org/projects/lwip/ Continuous integration builds (GCC, clang): https://travis-ci.org/lwip-tcpip/lwip DOCUMENTATION Self documentation of the source code is regularly extracted from the current Git sources and is available from this web page: http://www.nongnu.org/lwip/ Also, there are mailing lists you can subscribe at http://savannah.nongnu.org/mail/?group=lwip plus searchable archives: http://lists.nongnu.org/archive/html/lwip-users/ http://lists.nongnu.org/archive/html/lwip-devel/ There is a wiki about lwIP at http://lwip.wikia.com/wiki/LwIP_Wiki You might get questions answered there, but unfortunately, it is not as well maintained as it should be. lwIP was originally written by Adam Dunkels: http://dunkels.com/adam/ Reading Adam's papers, the files in docs/, browsing the source code documentation and browsing the mailing list archives is a good way to become familiar with the design of lwIP. Adam Dunkels Leon Woestenberg
lwIP是一个轻量级的嵌入式TCP/IP协议栈,它提供了一些功能强大的功能,其包括对SNMP(Simple Network Management Protocol,简单网络管理协议)的支持。下面是lwIP SNMP的使用教程: 1. 首先,确保你已经正确地集成了lwIP协议栈到你的嵌入式设备。你可以参考lwIP官方文档来进行集成。 2. 设置SNMP功能的相关参数。在lwIPSNMP的参数定义在“lwip/src/include/lwip/snmp.h”头文件。你可以根据你的需求修改其的参数,例如SNMP_COMMUNITY(SNMP社区字符串)、SNMP_MAX_BULKREPS(SNMP最大批量回复数)等。 3. 配置lwIP内核的选项。在使用SNMP之前,你需要在lwIP的内核选项启用SNMP功能。你可以在“lwip/src/include/lwip/opt.h”头文件找到关于SNMP的配置选项,确保SNMP功能已经启用。 4. 实现SNMP协议的逻辑。在lwIP,你可以通过注册回调函数来处理SNMP的相关操作。具体来说,你可以注册一个函数来处理SNMP查询请求(SNMP GET、GETNEXT等)以及设置请求(SNMP SET)。在这些回调函数,你可以根据你的需求进行相关的处理操作。 5. 配置SNMP代理。如果你希望你的设备作为SNMP代理来处理SNMP查询的请求,你需要在lwIP配置选项启用SNMP代理功能,并设置代理的相关参数(例如SNMP_TRAP_DESTINATIONS和SNMP_LWIP_TRAP_BIND_IDX)。 6. 编译和调试。完成上述步骤后,你可以将你的工程进行编译,并将生成的可执行文件烧录到你的嵌入式设备上。你可以通过SNMP管理工具(例如SNMP MIB Browser)来测试你的SNMP功能是否正常。 总结来说,使用lwIP实现SNMP功能需要进行lwIP的集成、配置SNMP参数、实现SNMP协议逻辑以及进行编译和调试等步骤。具体的操作细节可以根据你的具体需求和系统架构来进行调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值