FreeRTOS
[armadillo_firmware.git] / FreeRTOS / Common / ethernet / lwIP_130 / doc / snmp_agent.txt
blob54c278ab37a4e62a10f0a7a2e66ed6e01a316232
1 SNMPv1 agent for lwIP\r
2 \r
3 Author: Christiaan Simons\r
4 \r
5 This is a brief introduction how to use and configure the SNMP agent.\r
6 Note the agent uses the raw-API UDP interface so you may also want to\r
7 read rawapi.txt to gain a better understanding of the SNMP message handling.\r
8 \r
9 0 Agent Capabilities\r
10 ====================\r
12 SNMPv1 per RFC1157\r
13   This is an old(er) standard but is still widely supported.\r
14   For SNMPv2c and v3 have a greater complexity and need many\r
15   more lines of code. IMHO this breaks the idea of "lightweight IP".\r
17   Note the S in SNMP stands for "Simple". Note that "Simple" is\r
18   relative. SNMP is simple compared to the complex ISO network\r
19   management protocols CMIP (Common Management Information Protocol)\r
20   and CMOT (CMip Over Tcp).\r
22 MIB II per RFC1213\r
23   The standard lwIP stack management information base.\r
24   This is a required MIB, so this is always enabled.\r
25   When builing lwIP without TCP, the mib-2.tcp group is omitted.\r
26   The groups EGP, CMOT and transmission are disabled by default.\r
27   \r
28   Most mib-2 objects are not writable except:\r
29   sysName, sysLocation, sysContact, snmpEnableAuthenTraps.\r
30   Writing to or changing the ARP and IP address and route\r
31   tables is not possible.\r
32  \r
33   Note lwIP has a very limited notion of IP routing. It currently\r
34   doen't have a route table and doesn't have a notion of the U,G,H flags.\r
35   Instead lwIP uses the interface list with only one default interface\r
36   acting as a single gateway interface (G) for the default route.\r
38   The agent returns a "virtual table" with the default route 0.0.0.0\r
39   for the default interface and network routes (no H) for each\r
40   network interface in the netif_list.\r
41   All routes are considered to be up (U).\r
43 Loading additional MIBs\r
44   MIBs can only be added in compile-time, not in run-time.\r
45   There is no MIB compiler thus additional MIBs must be hand coded.\r
47 Large SNMP message support\r
48   The packet decoding and encoding routines are designed\r
49   to use pbuf-chains. Larger payloads then the minimum\r
50   SNMP requirement of 484 octets are supported if the \r
51   PBUF_POOL_SIZE and IP_REASS_BUFSIZE are set to match your\r
52   local requirement.\r
54 1 Building the Agent\r
55 ====================\r
57 First of all you'll need to add the following define\r
58 to your local lwipopts.h:\r
60 #define LWIP_SNMP               1\r
62 and add the source files in lwip/src/core/snmp\r
63 and some snmp headers in lwip/src/include/lwip to your makefile.\r
65 Note you'll might need to adapt you network driver to update\r
66 the mib2 variables for your interface.\r
68 2 Running the Agent\r
69 ===================\r
71 The following function calls must be made in your program to\r
72 actually get the SNMP agent running.\r
74 Before starting the agent you should supply pointers\r
75 to non-volatile memory for sysContact, sysLocation,\r
76 and snmpEnableAuthenTraps. You can do this by calling\r
78 snmp_set_syscontact()\r
79 snmp_set_syslocation()\r
80 snmp_set_snmpenableauthentraps()\r
82 Additionally you may want to set\r
84 snmp_set_sysdescr()\r
85 snmp_set_sysobjid() (if you have a private MIB)\r
86 snmp_set_sysname()\r
88 Also before starting the agent you need to setup\r
89 one or more trap destinations using these calls:\r
91 snmp_trap_dst_enable();\r
92 snmp_trap_dst_ip_set();\r
94 In the lwIP initialisation sequence call snmp_init() just after\r
95 the call to udp_init().\r
97 Exactly every 10 msec the SNMP uptime timestamp must be updated with\r
98 snmp_inc_sysuptime(). You should call this from a timer interrupt\r
99 or a timer signal handler depending on your runtime environment.\r
101 An alternative way to update the SNMP uptime timestamp is to do a call like\r
102 snmp_add_sysuptime(100) each 1000ms (which is bigger "step", but call to\r
103 a lower frequency). Another one is to not call snmp_inc_sysuptime() or\r
104 snmp_add_sysuptime(), and to define the SNMP_GET_SYSUPTIME(sysuptime) macro.\r
105 This one is undefined by default in mib2.c. SNMP_GET_SYSUPTIME is called inside\r
106 snmp_get_sysuptime(u32_t *value), and enable to change "sysuptime" value only\r
107 when it's queried (any function which need "sysuptime" have to call\r
108 snmp_get_sysuptime).\r
111 3 Private MIBs\r
112 ==============\r
114 If want to extend the agent with your own private MIB you'll need to\r
115 add the following define to your local lwipopts.h:\r
117 #define SNMP_PRIVATE_MIB        1\r
119 You must provide the private_mib.h and associated files yourself.\r
120 Note we don't have a "MIB compiler" that generates C source from a MIB,\r
121 so you're required to do some serious coding if you enable this!\r
123 Note the lwIP enterprise ID (26381) is assigned to the lwIP project,\r
124 ALL OBJECT IDENTIFIERS LIVING UNDER THIS ID ARE ASSIGNED BY THE lwIP\r
125 MAINTAINERS!\r
127 If you need to create your own private MIB you'll need\r
128 to apply for your own enterprise ID with IANA: http://www.iana.org/numbers.html \r
130 You can set it by passing a struct snmp_obj_id to the agent\r
131 using snmp_set_sysobjid(&my_object_id), just before snmp_init().\r
133 Note the object identifiers for thes MIB-2 and your private MIB\r
134 tree must be kept in sorted ascending (lexicographical) order.\r
135 This to ensure correct getnext operation.\r
137 An example for a private MIB is part of the "minimal Unix" project:\r
138 contrib/ports/unix/proj/minimal/lwip_prvmib.c\r
140 The next chapter gives a more detailed description of the\r
141 MIB-2 tree and the optional private MIB.\r
143 4 The Gory Details\r
144 ==================\r
146 4.0 Object identifiers and the MIB tree.\r
148 We have three distinct parts for all object identifiers:\r
150 The prefix\r
151   .iso.org.dod.internet\r
153 the middle part \r
154   .mgmt.mib-2.ip.ipNetToMediaTable.ipNetToMediaEntry.ipNetToMediaPhysAddress\r
156 and the index part\r
157   .1.192.168.0.1\r
159 Objects located above the .internet hierarchy aren't supported.\r
160 Currently only the .mgmt sub-tree is available and\r
161 when the SNMP_PRIVATE_MIB is enabled the .private tree\r
162 becomes available too.\r
164 Object identifiers from incoming requests are checked\r
165 for a matching prefix, middle part and index part\r
166 or are expanded(*) for GetNext requests with short\r
167 or inexisting names in the request.\r
168 (* we call this "expansion" but this also\r
169 resembles the "auto-completion" operation)\r
171 The middle part is usually located in ROM (const)\r
172 to preserve precious RAM on small microcontrollers.\r
173 However RAM location is possible for an dynamically\r
174 changing private tree.\r
176 The index part is handled by functions which in\r
177 turn use dynamically allocated index trees from RAM.\r
178 These trees are updated by e.g. the etharp code\r
179 when new entries are made or removed form the ARP cache.\r
181 /** @todo more gory details */\r