lwIP 2.1.3 Lightweight IP stack

Modules
SNMPv2c/v3 agent
Applications

## Modules
| Core
| Traps
| MIB2
| Options

## Detailed Description

SNMPv2c and SNMPv3 compatible agent
There is also a MIB compiler and a MIB viewer in lwIP contrib repository (lwip-contrib/apps/LwipMibCompiler).
The agent implements the most important MIB2 MIBs including IPv6 support (interfaces, UDP, TCP, SNMP, ICMP, SYSTEM). IP MIB is an older version without IPv6 statistics (TODO).
Rewritten by Martin Hentschel info@.nosp@m.cl-s.nosp@m.oft.d.nosp@m.e and Dirk Ziegelmeier dzieg.nosp@m.el@g.nosp@m.mx.de

# 0 Agent Capabilities

## Features:

- SNMPv2c support.
- SNMPv3 support (a port to ARM mbedtls is provided, LWIP_SNMP_V3_MBEDTLS option).
- Low RAM usage - no memory pools, stack only.
- MIB2 implementation is separated from SNMP stack.
- Support for multiple MIBs (snmp_set_mibs() call) - e.g. for private MIB.
- Simple and generic API for MIB implementation.
- Comfortable node types and helper functions for scalar arrays and tables.
- Counter64, bit and truthvalue datatype support.
- Callbacks for SNMP writes e.g. to implement persistency.
- Runs on two APIs: RAW and netconn.
- Async API is gone - the stack now supports netconn API instead, so blocking operations can be done in MIB calls. SNMP runs in a worker thread when netconn API is used.
- Simplified thread sync support for MIBs - useful when MIBs need to access variables shared with other threads where no locking is possible. Used in MIB2 to access lwIP stats from lwIP thread.

## MIB compiler (code generator):

- Provided in lwIP contrib repository.
- Written in C#. MIB viewer used Windows Forms.
- Developed on Windows with Visual Studio 2010.
- Can be compiled and used on all platforms with http://www.monodevelop.com/.
- Based on a heavily modified version of of SharpSnmpLib (a4bd05c6afb4) (https://sharpsnmplib.codeplex.com/SourceControl/network/forks/Nemo157/MIBParserUpdate).
- MIB parser, C file generation framework and LWIP code generation are cleanly separated, which means the code may be useful as a base for code generation of other SNMP agents.

## Notes:

- Stack and MIB compiler were used to implement a Profinet device. Compiled/implemented MIBs: LLDP-MIB, LLDP-EXT-DOT3-MIB, LLDP-EXT-PNO-MIB.

## SNMPv1 per RFC1157 and SNMPv2c per RFC 3416

Note the S in SNMP stands for "Simple". Note that "Simple" is relative. SNMP is simple compared to the complex ISO network management protocols CMIP (Common Management Information Protocol) and CMOT (CMip Over Tcp).

## SNMPv3

When SNMPv3 is used, several functions from snmpv3.h must be implemented by the user. This is mainly user management and persistence handling. The sample provided in lwip-contrib is insecure, don't use it in production systems, especially the missing persistence for engine boots variable simplifies replay attacks.

## MIB II

The standard lwIP stack management information base. This is a required MIB, so this is always enabled. The groups EGP, CMOT and transmission are disabled by default.

Most mib-2 objects are not writable except: sysName, sysLocation, sysContact, snmpEnableAuthenTraps. Writing to or changing the ARP and IP address and route tables is not possible.

Note lwIP has a very limited notion of IP routing. It currently doen't have a route table and doesn't have a notion of the U,G,H flags. Instead lwIP uses the interface list with only one default interface acting as a single gateway interface (G) for the default route.

The agent returns a "virtual table" with the default route 0.0.0.0 for the default interface and network routes (no H) for each network interface in the netif_list. All routes are considered to be up (U).

## Loading additional MIBs

MIBs can only be added in compile-time, not in run-time.

# 1 Building the Agent

First of all you'll need to add the following define to your local lwipopts.h: #define LWIP_SNMP 1

and add the source files your makefile.

Note you'll might need to adapt you network driver to update the mib2 variables for your interface.

# 2 Running the Agent

The following function calls must be made in your program to actually get the SNMP agent running.

Before starting the agent you should supply pointers for sysContact, sysLocation, and snmpEnableAuthenTraps. You can do this by calling

- snmp_mib2_set_syscontact()
- snmp_mib2_set_syslocation()
- snmp_set_auth_traps_enabled()

You can register a callback which is called on successful write access: snmp_set_write_callback().

Additionally you may want to set

- snmp_mib2_set_sysdescr()
- snmp_set_device_enterprise_oid()
- snmp_mib2_set_sysname()

Also before starting the agent you need to setup one or more trap destinations using these calls:

- snmp_trap_dst_enable()
- snmp_trap_dst_ip_set()

If you need more than MIB2, set the MIBs you want to use by snmp_set_mibs().

Finally, enable the agent by calling snmp_init()