]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/blob - src/core/snmp/mib2.c
MIB-2 object values near to completion, just committing for keeping the flame alive.
[pes-rpp/rpp-lwip.git] / src / core / snmp / mib2.c
1 /**
2  * @file
3  * [EXPERIMENTAL] Management Information Base II (RFC1213) objects and functions
4  */
5
6 /*
7  * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without modification,
11  * are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  *    this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  *    this list of conditions and the following disclaimer in the documentation
17  *    and/or other materials provided with the distribution.
18  * 3. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30  * OF SUCH DAMAGE.
31  *
32  * Author: Christiaan Simons <christiaan.simons@axon.tv>
33  */
34
35 #include "arch/cc.h"
36 #include "lwip/opt.h"
37 #include "lwip/snmp.h"
38 #include "lwip/netif.h"
39 #include "netif/etharp.h"
40 #include "lwip/ip.h"
41 #include "lwip/ip_frag.h"
42 #include "lwip/udp.h"
43 #include "lwip/snmp_asn1.h"
44 #include "lwip/snmp_structs.h"
45
46 #if LWIP_SNMP
47
48 /** 
49  * IANA assigned enterprise ID for lwIP is 26381
50  * @see http://www.iana.org/assignments/enterprise-numbers
51  *
52  * @note this enterprise ID is assigned to the lwIP project,
53  * all object identifiers living under this ID are assigned
54  * by the lwIP maintainers (contact Christiaan Simons)!
55  * @note don't change this define, use snmp_set_sysobjid()
56  *
57  * If you need to create your own private MIB you'll need
58  * to apply for your own enterprise ID with IANA:
59  * http://www.iana.org/numbers.html 
60  */
61 #define SNMP_ENTERPRISE_ID 26381
62 #define SNMP_SYSOBJID_LEN 7
63 #define SNMP_SYSOBJID {1, 3, 6, 1, 4, 1, SNMP_ENTERPRISE_ID}
64
65 #ifndef SNMP_SYSSERVICES
66 #define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2))
67 #endif
68
69 /** @todo export this in snmp_structs.h (for use in private mib) */
70 void noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
71 void noleafs_get_value(struct obj_def *od, u16_t len, void *value);
72
73 static void system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
74 static void system_get_value(struct obj_def *od, u16_t len, void *value);
75 static void interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
76 static void interfaces_get_value(struct obj_def *od, u16_t len, void *value);
77 static void ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
78 static void ifentry_get_value(struct obj_def *od, u16_t len, void *value);
79 static void atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
80 static void atentry_get_value(struct obj_def *od, u16_t len, void *value);
81 static void ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
82 static void ip_get_value(struct obj_def *od, u16_t len, void *value);
83 static void ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
84 static void ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value);
85 static void ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
86 static void ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value);
87 static void ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
88 static void ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value);
89 static void icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
90 static void icmp_get_value(struct obj_def *od, u16_t len, void *value);
91 #if LWIP_TCP
92 static void tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
93 static void tcp_get_value(struct obj_def *od, u16_t len, void *value);
94 static void tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
95 static void tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value);
96 #endif
97 static void udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
98 static void udp_get_value(struct obj_def *od, u16_t len, void *value);
99 static void udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
100 static void udpentry_get_value(struct obj_def *od, u16_t len, void *value);
101 static void snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
102 static void snmp_get_value(struct obj_def *od, u16_t len, void *value);
103
104 /* snmp .1.3.6.1.2.1.11 */
105 const s32_t snmp_ids[28] = {
106   1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16,
107   17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30
108 };
109 struct mib_node* const snmp_nodes[28] = {
110   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
111   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
112 };
113 const struct mib_array_node snmp = {
114   &snmp_get_object_def,
115   &snmp_get_value,
116   MIB_NODE_AR,
117   28,
118   snmp_ids,
119   snmp_nodes 
120 };
121
122 /* dot3 and EtherLike MIB not planned. (transmission .1.3.6.1.2.1.10) */
123 /* historical (some say hysterical). (cmot .1.3.6.1.2.1.9) */
124 /* lwIP has no EGP, thus may not implement it. (egp .1.3.6.1.2.1.8) */
125
126 /* udp .1.3.6.1.2.1.7 */
127 const s32_t udpentry_ids[2] = { 1, 2 };
128 struct mib_node* const udpentry_nodes[2] = {
129   NULL, NULL,
130 };
131 const struct mib_array_node udpentry = {
132   &udpentry_get_object_def,
133   &udpentry_get_value,
134   MIB_NODE_AR,
135   2,
136   udpentry_ids,
137   udpentry_nodes
138 };
139
140 const s32_t udptable_id = 1;
141 struct mib_node* const udptable_node = (struct mib_node* const)&udpentry;
142 const struct mib_array_node udptable = {
143   &noleafs_get_object_def,
144   &noleafs_get_value,
145   MIB_NODE_AR,
146   1,
147   &udptable_id,
148   &udptable_node
149 };
150
151 const s32_t udp_ids[5] = { 1, 2, 3, 4, 5 };
152 struct mib_node* const udp_nodes[5] = {
153   NULL, NULL, NULL, NULL, (struct mib_node* const)&udptable
154 };
155 const struct mib_array_node udp = {
156   &udp_get_object_def,
157   &udp_get_value,
158   MIB_NODE_AR,
159   5,
160   udp_ids,
161   udp_nodes
162 };
163
164 /* tcp .1.3.6.1.2.1.6 */
165 #if LWIP_TCP
166 /* only if the TCP protocol is available may implement this group */
167 const s32_t tcpconnentry_ids[5] = { 1, 2, 3, 4, 5 };
168 struct mib_node* const tcpconnentry_nodes[5] = {
169   NULL, NULL, NULL, NULL, NULL
170 };
171 const struct mib_array_node tcpconnentry = {
172   &tcpconnentry_get_object_def,
173   &tcpconnentry_get_value,
174   MIB_NODE_AR,
175   5,
176   tcpconnentry_ids,
177   tcpconnentry_nodes
178 };
179
180 const s32_t tcpconntable_id = 1;
181 struct mib_node* const tcpconntable_node = (struct mib_node* const)&tcpconnentry;
182 const struct mib_array_node tcpconntable = {
183   &noleafs_get_object_def,
184   &noleafs_get_value,
185   MIB_NODE_AR,
186   1,
187   &tcpconntable_id,
188   &tcpconntable_node
189 };
190
191 const s32_t tcp_ids[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
192 struct mib_node* const tcp_nodes[15] = {
193   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
194   (struct mib_node* const)&tcpconntable, NULL, NULL
195 };
196 const struct mib_array_node tcp = {
197   &tcp_get_object_def,
198   &tcp_get_value,
199   MIB_NODE_AR,
200   15,
201   tcp_ids,
202   tcp_nodes
203 };
204 #endif
205
206 /* icmp .1.3.6.1.2.1.5 */
207 const s32_t icmp_ids[26] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 };
208 struct mib_node* const icmp_nodes[26] = {
209   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
210   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
211 };
212 const struct mib_array_node icmp = {
213   &icmp_get_object_def,
214   &icmp_get_value,
215   MIB_NODE_AR,
216   26,
217   icmp_ids,
218   icmp_nodes
219 };
220
221 const s32_t ipntomentry_ids[4] = { 1, 2, 3, 4 };
222 struct mib_node* const ipntomentry_nodes[4] = {
223   NULL, NULL, NULL, NULL
224 };
225 const struct mib_array_node ipntomentry = {
226   &ip_ntomentry_get_object_def,
227   &ip_ntomentry_get_value,
228   MIB_NODE_AR,
229   4,
230   ipntomentry_ids,
231   ipntomentry_nodes
232 };
233
234 const s32_t ipntomtable_id = 1;
235 struct mib_node* const ipntomtable_node = (struct mib_node* const)&ipntomentry;
236 const struct mib_array_node ipntomtable = {
237   &noleafs_get_object_def,
238   &noleafs_get_value,
239   MIB_NODE_AR,
240   1,
241   &ipntomtable_id,
242   &ipntomtable_node
243 };
244
245 const s32_t iprteentry_ids[13] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
246 struct mib_node* const iprteentry_nodes[13] = {
247   NULL, NULL, NULL, NULL, NULL, NULL, NULL,
248   NULL, NULL, NULL, NULL, NULL, NULL
249 };
250 const struct mib_array_node iprteentry = {
251   &ip_rteentry_get_object_def,
252   &ip_rteentry_get_value,
253   MIB_NODE_AR,
254   13,
255   iprteentry_ids,
256   iprteentry_nodes
257 };
258
259 const s32_t iprtetable_id = 1;
260 struct mib_node* const iprtetable_node = (struct mib_node* const)&iprteentry;
261 const struct mib_array_node iprtetable = {
262   &noleafs_get_object_def,
263   &noleafs_get_value,
264   MIB_NODE_AR,
265   1,
266   &iprtetable_id,
267   &iprtetable_node
268 };
269
270 const s32_t ipaddrentry_ids[5] = { 1, 2, 3, 4, 5 };
271 struct mib_node* const ipaddrentry_nodes[5] = {
272   NULL, NULL, NULL, NULL, NULL
273 };
274 const struct mib_array_node ipaddrentry = {
275   &ip_addrentry_get_object_def,
276   &ip_addrentry_get_value,
277   MIB_NODE_AR,
278   5,
279   ipaddrentry_ids,
280   ipaddrentry_nodes
281 };
282
283 const s32_t ipaddrtable_id = 1;
284 struct mib_node* const ipaddrtable_node = (struct mib_node* const)&ipaddrentry;
285 const struct mib_array_node ipaddrtable = {
286   &noleafs_get_object_def,
287   &noleafs_get_value,
288   MIB_NODE_AR,
289   1,
290   &ipaddrtable_id,
291   &ipaddrtable_node
292 };
293
294 /* ip .1.3.6.1.2.1.4 */
295 const s32_t ip_ids[23] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
296 struct mib_node* const ip_nodes[23] = {
297   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
298   NULL, NULL, NULL, NULL, NULL, NULL, NULL, (struct mib_node* const)&ipaddrtable,
299   (struct mib_node* const)&iprtetable, (struct mib_node* const)&ipntomtable, NULL
300 };
301 const struct mib_array_node ip = {
302   &ip_get_object_def,
303   &ip_get_value,
304   MIB_NODE_AR,
305   23,
306   ip_ids,
307   ip_nodes
308 };
309
310 const s32_t atentry_ids[3] = { 1, 2, 3 };
311 struct mib_node* const atentry_nodes[3] = {
312   NULL, NULL, NULL
313 };
314 const struct mib_array_node atentry = {
315   &atentry_get_object_def,
316   &atentry_get_value,
317   MIB_NODE_AR,
318   3,
319   atentry_ids,
320   atentry_nodes
321 };
322
323 const s32_t attable_id = 1;
324 struct mib_node* const attable_node = (struct mib_node* const)&atentry;
325 const struct mib_array_node attable = {
326   &noleafs_get_object_def,
327   &noleafs_get_value,
328   MIB_NODE_AR,
329   1,
330   &attable_id,
331   &attable_node
332 };
333
334 /* at .1.3.6.1.2.1.3 */
335 const s32_t at_id = 1;
336 struct mib_node* const at_node = (struct mib_node* const)&attable;
337 const struct mib_array_node at = {
338   &noleafs_get_object_def,
339   &noleafs_get_value,
340   MIB_NODE_AR,
341   1,
342   &at_id,
343   &at_node
344 };
345
346 const s32_t ifentry_ids[22] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 };
347 struct mib_node* const ifentry_nodes[22] = {
348   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
349   NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
350 };
351 const struct mib_array_node ifentry = {
352   &ifentry_get_object_def,
353   &ifentry_get_value,
354   MIB_NODE_AR,
355   22,
356   ifentry_ids,
357   ifentry_nodes
358 };
359
360 const s32_t iftable_id = 1;
361 struct mib_node* const iftable_node = (struct mib_node* const)&ifentry;
362 const struct mib_array_node iftable = {
363   &noleafs_get_object_def,
364   &noleafs_get_value,
365   MIB_NODE_AR,
366   1,
367   &iftable_id,
368   &iftable_node
369 };
370
371 /* interfaces .1.3.6.1.2.1.2 */
372 const s32_t interfaces_ids[2] = { 1, 2 };
373 struct mib_node* const interfaces_nodes[2] = { NULL, (struct mib_node* const)&iftable };
374 const struct mib_array_node interfaces = {
375   &interfaces_get_object_def,
376   &interfaces_get_value,
377   MIB_NODE_AR,
378   2,
379   interfaces_ids,
380   interfaces_nodes
381 };
382
383 /*             0 1 2 3 4 5 6 */
384 /* system .1.3.6.1.2.1.1 */
385 const s32_t sys_tem_ids[7] = { 1, 2, 3, 4, 5, 6, 7 };
386 struct mib_node* const sys_tem_nodes[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
387 /* work around name issue with 'sys_tem', some compiler(s?) seem to reserve 'system' */
388 const struct mib_array_node sys_tem = {
389   &system_get_object_def,
390   &system_get_value,
391   MIB_NODE_AR,
392   7,
393   sys_tem_ids,
394   sys_tem_nodes
395 };
396
397 /* mib-2 .1.3.6.1.2.1 */
398 #if LWIP_TCP
399 #define MIB2_GROUPS 8
400 #else
401 #define MIB2_GROUPS 7
402 #endif
403 const s32_t mib2_ids[MIB2_GROUPS] =
404
405   1,
406   2,
407   3,
408   4,
409   5,
410 #if LWIP_TCP
411   6,
412 #endif
413   7,
414   11
415 };
416 struct mib_node* const mib2_nodes[MIB2_GROUPS] = {
417   (struct mib_node* const)&sys_tem,
418   (struct mib_node* const)&interfaces,
419   (struct mib_node* const)&at,
420   (struct mib_node* const)&ip,
421   (struct mib_node* const)&icmp,
422 #if LWIP_TCP
423   (struct mib_node* const)&tcp,
424 #endif
425   (struct mib_node* const)&udp,
426   (struct mib_node* const)&snmp
427 };
428
429 const struct mib_array_node mib2 = {
430   &noleafs_get_object_def,
431   &noleafs_get_value,
432   MIB_NODE_AR,
433   MIB2_GROUPS,
434   mib2_ids,
435   mib2_nodes
436 };
437
438 /* mgmt .1.3.6.1.2 */
439 const s32_t mgmt_ids[1] = { 1 };
440 struct mib_node* const mgmt_nodes[1] = { (struct mib_node* const)&mib2 };
441 const struct mib_array_node mgmt = {
442   &noleafs_get_object_def,
443   &noleafs_get_value,
444   MIB_NODE_AR,
445   1,
446   mgmt_ids,
447   mgmt_nodes
448 };
449
450 /* internet .1.3.6.1 */
451 #if SNMP_PRIVATE_MIB
452 s32_t internet_ids[2] = { 2, 4 };
453 struct mib_node* const internet_nodes[2] = { (struct mib_node* const)&mgmt, (struct mib_node* const)&private };
454 const struct mib_array_node internet = {
455   &noleafs_get_object_def,
456   &noleafs_get_value,
457   MIB_NODE_AR,
458   2,
459   internet_ids,
460   internet_nodes
461 };
462 #else
463 const s32_t internet_ids[1] = { 2 };
464 struct mib_node* const internet_nodes[1] = { (struct mib_node* const)&mgmt };
465 const struct mib_array_node internet = {
466   &noleafs_get_object_def,
467   &noleafs_get_value,
468   MIB_NODE_AR,
469   1,
470   internet_ids,
471   internet_nodes
472 };
473 #endif
474
475 /** mib-2.system.sysObjectID  */
476 static struct snmp_obj_id sysobjid = {SNMP_SYSOBJID_LEN, SNMP_SYSOBJID};
477 /** enterprise ID for generic TRAPs, .iso.org.dod.internet.mgmt.mib-2.snmp */
478 static struct snmp_obj_id snmpgrp_id = {7,{1,3,6,1,2,1,11}};
479 /** mib-2.system.sysServices */
480 static const s32_t sysservices = SNMP_SYSSERVICES;
481
482 /** mib-2.system.sysDescr */
483 static const u8_t sysdescr_len_default = 4;
484 static const u8_t sysdescr_default[] = "lwIP";
485 static u8_t* sysdescr_len_ptr = (u8_t*)&sysdescr_len_default;
486 static u8_t* sysdescr_ptr = (u8_t*)&sysdescr_default[0];
487 /** mib-2.system.sysContact */
488 static const u8_t syscontact_len_default = 0;
489 static const u8_t syscontact_default[] = "";
490 static u8_t* syscontact_len_ptr = (u8_t*)&syscontact_len_default;
491 static u8_t* syscontact_ptr = (u8_t*)&syscontact_default[0];
492 /** mib-2.system.sysName */
493 static const u8_t sysname_len_default = 8;
494 static const u8_t sysname_default[] = "FQDN-unk";
495 static u8_t* sysname_len_ptr = (u8_t*)&sysname_len_default;
496 static u8_t* sysname_ptr = (u8_t*)&sysname_default[0];
497 /** mib-2.system.sysLocation */
498 static const u8_t syslocation_len_default = 0;
499 static const u8_t syslocation_default[] = "";
500 static u8_t* syslocation_len_ptr = (u8_t*)&syslocation_len_default;
501 static u8_t* syslocation_ptr = (u8_t*)&syslocation_default[0];
502 /** mib-2.snmp.snmpEnableAuthenTraps */
503 static const u8_t snmpenableauthentraps_default = 2; /* disabled */
504 static u8_t* snmpenableauthentraps_ptr = (u8_t*)&snmpenableauthentraps_default;
505
506 /** mib-2.interfaces.ifTable.ifEntry.ifSpecific (zeroDotZero) */
507 static const struct snmp_obj_id ifspecific = {2, {0, 0}};
508 /** mib-2.ip.ipRouteTable.ipRouteEntry.ipRouteInfo (zeroDotZero) */
509 static const struct snmp_obj_id iprouteinfo = {2, {0, 0}};
510 /** mib-2.snmp.snmpEnableAuthenTraps 1 = enabled 2 = disabled */
511
512 /* mib-2.system counter(s) */
513 static u32_t sysuptime = 0;
514
515 /* mib-2.ip counter(s) */
516 static u32_t ipinreceives = 0,
517              ipinhdrerrors = 0,
518              ipinaddrerrors = 0,
519              ipforwdatagrams = 0,
520              ipinunknownprotos = 0,
521              ipindiscards = 0,
522              ipindelivers = 0,
523              ipoutrequests = 0,
524              ipoutdiscards = 0,
525              ipoutnoroutes = 0,
526              ipreasmreqds = 0,
527              ipreasmoks = 0,
528              ipreasmfails = 0,
529              ipfragoks = 0,
530              ipfragfails = 0,
531              ipfragcreates = 0,
532              iproutingdiscards = 0;
533 /* mib-2.icmp counter(s) */
534 static u32_t icmpinmsgs = 0,
535              icmpinerrors = 0,
536              icmpindestunreachs = 0,
537              icmpintimeexcds = 0,
538              icmpinparmprobs = 0,
539              icmpinsrcquenchs = 0,
540              icmpinredirects = 0,
541              icmpinechos = 0,
542              icmpinechoreps = 0,
543              icmpintimestamps = 0,
544              icmpintimestampreps = 0,
545              icmpinaddrmasks = 0,
546              icmpinaddrmaskreps = 0,
547              icmpoutmsgs = 0,
548              icmpouterrors = 0,
549              icmpoutdestunreachs = 0,
550              icmpouttimeexcds = 0,
551              icmpoutparmprobs = 0,
552              icmpoutsrcquenchs = 0,
553              icmpoutredirects = 0,
554              icmpoutechos = 0,
555              icmpoutechoreps = 0,
556              icmpouttimestamps = 0,
557              icmpouttimestampreps = 0,
558              icmpoutaddrmasks = 0,
559              icmpoutaddrmaskreps = 0;
560 /* mib-2.tcp counter(s) */
561 static u32_t tcpactiveopens = 0,
562              tcppassiveopens = 0,
563              tcpattemptfails = 0,
564              tcpestabresets = 0,
565              tcpcurrestab = 0,
566              tcpinsegs = 0,
567              tcpoutsegs = 0,
568              tcpretranssegs = 0,
569              tcpinerrs = 0,
570              tcpoutrsts = 0;
571 /* mib-2.udp counter(s) */
572 static u32_t udpindatagrams = 0,
573              udpnoports = 0,
574              udpinerrors = 0,
575              udpoutdatagrams = 0;
576 /* mib-2.snmp counter(s) */             
577 static u32_t snmpinpkts = 0,
578              snmpoutpkts = 0,
579              snmpinbadversions = 0,
580              snmpinbadcommunitynames = 0,
581              snmpinbadcommunityuses = 0,
582              snmpinasnparseerrs = 0,
583              snmpintoobigs = 0,
584              snmpinnosuchnames = 0,
585              snmpinbadvalues = 0,
586              snmpinreadonlys = 0,
587              snmpingenerrs = 0,
588              snmpintotalreqvars = 0,
589              snmpintotalsetvars = 0,
590              snmpingetrequests = 0,
591              snmpingetnexts = 0,
592              snmpinsetrequests = 0,
593              snmpingetresponses = 0,
594              snmpintraps = 0,
595              snmpouttoobigs = 0,
596              snmpoutnosuchnames = 0,
597              snmpoutbadvalues = 0,
598              snmpoutgenerrs = 0,
599              snmpoutgetrequests = 0,
600              snmpoutgetnexts = 0,
601              snmpoutsetrequests = 0,
602              snmpoutgetresponses = 0,
603              snmpouttraps = 0;
604
605
606
607 /* prototypes of the following functions are in lwip/src/include/lwip/snmp.h */
608 /**
609  * Copy octet string.
610  *
611  * @param dst points to destination
612  * @param src points to source
613  * @param n number of octets to copy.
614  */
615 void ocstrncpy(u8_t *dst, u8_t *src, u8_t n)
616 {
617   while (n > 0)
618   {
619     n--;
620     *dst++ = *src++;
621   }
622 }
623
624 /**
625  * Copy object identifier (s32_t) array.
626  *
627  * @param dst points to destination
628  * @param src points to source
629  * @param n number of sub identifiers to copy.
630  */
631 void objectidncpy(s32_t *dst, s32_t *src, u8_t n)
632 {
633   while(n > 0)
634   {
635     n--;
636     *dst++ = *src++;
637   }
638 }
639
640 /**
641  * Initializes sysDescr pointers.
642  *
643  * @param str if non-NULL then copy str pointer
644  * @param strlen points to string length, excluding zero terminator
645  */
646 void snmp_set_sysdesr(u8_t *str, u8_t *strlen)
647 {
648   if (str != NULL)
649   {
650     sysdescr_ptr = str;
651     sysdescr_len_ptr = strlen;
652   }
653 }
654
655 void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid)
656 {
657   *oid = &sysobjid;
658 }
659
660 /**
661  * Initializes sysObjectID value.
662  *
663  * @param oid points to stuct snmp_obj_id to copy
664  */
665 void snmp_set_sysobjid(struct snmp_obj_id *oid)
666 {
667   sysobjid = *oid;
668 }
669
670 /**
671  * Must be called at regular 10 msec interval from a timer interrupt
672  * or signal handler depending on your runtime environment.
673  */
674 void snmp_inc_sysuptime(void)
675 {
676   sysuptime++;
677 }
678
679 void snmp_get_sysuptime(u32_t *value)
680 {
681   *value = sysuptime;
682 }
683
684 /**
685  * Initializes sysContact pointers,
686  * e.g. ptrs to non-volatile memory external to lwIP.
687  *
688  * @param str if non-NULL then copy str pointer
689  * @param strlen points to string length, excluding zero terminator
690  */
691 void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen)
692 {
693   if (ocstr != NULL)
694   {
695     syscontact_ptr = ocstr;
696     syscontact_len_ptr = ocstrlen;
697   }
698 }
699
700 /**
701  * Initializes sysName pointers,
702  * e.g. ptrs to non-volatile memory external to lwIP.
703  *
704  * @param str if non-NULL then copy str pointer
705  * @param strlen points to string length, excluding zero terminator
706  */
707 void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen)
708 {
709   if (ocstr != NULL)
710   {
711     sysname_ptr = ocstr;
712     sysname_len_ptr = ocstrlen;
713   }
714 }
715
716 /**
717  * Initializes sysLocation pointers,
718  * e.g. ptrs to non-volatile memory external to lwIP.
719  *
720  * @param str if non-NULL then copy str pointer
721  * @param strlen points to string length, excluding zero terminator
722  */
723 void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen)
724 {
725   if (ocstr != NULL)
726   {
727     syslocation_ptr = ocstr;
728     syslocation_len_ptr = ocstrlen;
729   }
730 }
731
732
733 void snmp_add_ifinoctets(struct netif *ni, u32_t value)
734 {
735   ni->ifinoctets += value;  
736 }
737
738 void snmp_inc_ifinucastpkts(struct netif *ni)
739 {
740   (ni->ifinucastpkts)++;
741 }
742
743 void snmp_inc_ifinnucastpkts(struct netif *ni)
744 {
745   (ni->ifinnucastpkts)++;
746 }
747
748 void snmp_inc_ifindiscards(struct netif *ni)
749 {
750   (ni->ifindiscards)++;
751 }
752
753 void snmp_add_ifoutoctets(struct netif *ni, u32_t value)
754 {
755   ni->ifoutoctets += value;  
756 }
757
758 void snmp_inc_ifoutucastpkts(struct netif *ni)
759 {
760   (ni->ifoutucastpkts)++;
761 }
762
763 void snmp_inc_ifoutnucastpkts(struct netif *ni)
764 {
765   (ni->ifoutnucastpkts)++;
766 }
767
768 void snmp_inc_ifoutdiscards(struct netif *ni)
769 {
770   (ni->ifoutdiscards)++;
771 }
772
773 void snmp_inc_ipinreceives(void)
774 {
775   ipinreceives++;
776 }
777
778 void snmp_inc_ipinhdrerrors(void)
779 {
780   ipinhdrerrors++;
781 }
782
783 void snmp_inc_ipinaddrerrors(void)
784 {
785   ipinaddrerrors++;
786 }
787
788 void snmp_inc_ipforwdatagrams(void)
789 {
790   ipforwdatagrams++;
791 }
792
793 void snmp_inc_ipinunknownprotos(void)
794 {
795   ipinunknownprotos++;
796 }
797
798 void snmp_inc_ipindiscards(void)
799 {
800   ipindiscards++;
801 }
802
803 void snmp_inc_ipindelivers(void)
804 {
805   ipindelivers++;
806 }
807
808 void snmp_inc_ipoutrequests(void)
809 {
810   ipoutrequests++;
811 }
812
813 void snmp_inc_ipoutdiscards(void)
814 {
815   ipoutdiscards++;
816 }
817
818 void snmp_inc_ipoutnoroutes(void)
819 {
820   ipoutnoroutes++;
821 }
822
823 void snmp_inc_ipreasmreqds(void)
824 {
825   ipreasmreqds++;
826 }
827
828 void snmp_inc_ipreasmoks(void)
829 {
830   ipreasmoks++;
831 }
832
833 void snmp_inc_ipreasmfails(void)
834 {
835   ipreasmfails++;
836 }
837
838 void snmp_inc_ipfragoks(void)
839 {
840   ipfragoks++;
841 }
842
843 void snmp_inc_ipfragfails(void)
844 {
845   ipfragfails++;
846 }
847
848 void snmp_inc_ipfragcreates(void)
849 {
850   ipfragcreates++;
851 }
852
853 void snmp_inc_iproutingdiscards(void)
854 {
855   iproutingdiscards++;
856 }
857
858
859 void snmp_inc_icmpinmsgs(void)
860 {
861   icmpinmsgs++;
862 }
863
864 void snmp_inc_icmpinerrors(void)
865 {
866   icmpinerrors++;
867 }
868
869 void snmp_inc_icmpindestunreachs(void)
870 {
871   icmpindestunreachs++;
872 }
873
874 void snmp_inc_icmpintimeexcds(void)
875 {
876   icmpintimeexcds++;
877 }
878
879 void snmp_inc_icmpinparmprobs(void)
880 {
881   icmpinparmprobs++;
882 }
883
884 void snmp_inc_icmpinsrcquenchs(void)
885 {
886   icmpinsrcquenchs++;
887 }
888
889 void snmp_inc_icmpinredirects(void)
890 {
891   icmpinredirects++;
892 }
893
894 void snmp_inc_icmpinechos(void)
895 {
896   icmpinechos++;
897 }
898
899 void snmp_inc_icmpinechoreps(void)
900
901   icmpinechoreps++;
902 }
903
904 void snmp_inc_icmpintimestamps(void)
905 {
906   icmpintimestamps++;
907 }
908
909 void snmp_inc_icmpintimestampreps(void)
910 {
911   icmpintimestampreps++;
912 }
913
914 void snmp_inc_icmpinaddrmasks(void)
915 {
916   icmpinaddrmasks++;
917
918
919 void snmp_inc_icmpinaddrmaskreps(void)
920 {
921   icmpinaddrmaskreps++;
922
923
924 void snmp_inc_icmpoutmsgs(void)
925 {
926   icmpoutmsgs++;
927 }
928
929 void snmp_inc_icmpouterrors(void)
930 {
931   icmpouterrors++;
932 }
933
934 void snmp_inc_icmpoutdestunreachs(void)
935 {
936   icmpoutdestunreachs++;
937
938
939 void snmp_inc_icmpouttimeexcds(void)
940 {
941   icmpouttimeexcds++;
942 }
943
944 void snmp_inc_icmpoutparmprobs(void)
945 {
946   icmpoutparmprobs++;
947 }
948
949 void snmp_inc_icmpoutsrcquenchs(void)
950 {
951   icmpoutsrcquenchs++;
952 }
953
954 void snmp_inc_icmpoutredirects(void)
955 {
956   icmpoutredirects++;
957
958
959 void snmp_inc_icmpoutechos(void)
960 {
961   icmpoutechos++;
962 }
963
964 void snmp_inc_icmpoutechoreps(void)
965 {
966   icmpoutechoreps++;
967 }
968
969 void snmp_inc_icmpouttimestamps(void)
970 {
971   icmpouttimestamps++;
972 }
973
974 void snmp_inc_icmpouttimestampreps(void)
975 {
976   icmpouttimestampreps++;
977 }
978
979 void snmp_inc_icmpoutaddrmasks(void)
980 {
981   icmpoutaddrmasks++;
982 }
983
984 void snmp_inc_icmpoutaddrmaskreps(void)
985 {
986   icmpoutaddrmaskreps++;
987 }
988
989 void snmp_inc_tcpactiveopens(void)
990 {
991   tcpactiveopens++;
992 }
993
994 void snmp_inc_tcppassiveopens(void)
995 {
996   tcppassiveopens++;
997 }
998
999 void snmp_inc_tcpattemptfails(void)
1000 {
1001   tcpattemptfails++;
1002 }
1003
1004 void snmp_inc_tcpestabresets(void)
1005 {
1006   tcpestabresets++;
1007
1008
1009 void snmp_inc_tcpcurrestab(void)
1010 {
1011   tcpcurrestab++; 
1012 }
1013
1014 void snmp_inc_tcpinsegs(void)
1015 {
1016   tcpinsegs++;
1017 }
1018
1019 void snmp_inc_tcpoutsegs(void)
1020 {
1021   tcpoutsegs++;
1022 }
1023
1024 void snmp_inc_tcpretranssegs(void)
1025 {
1026   tcpretranssegs++;
1027 }
1028
1029 void snmp_inc_tcpinerrs(void)
1030 {
1031   tcpinerrs++;
1032 }
1033
1034 void snmp_inc_tcpoutrsts(void)
1035 {
1036   tcpoutrsts++;
1037 }
1038
1039 void snmp_inc_udpindatagrams(void)
1040 {
1041   udpindatagrams++;
1042 }
1043
1044 void snmp_inc_udpnoports(void)
1045 {
1046   udpnoports++;
1047 }
1048
1049 void snmp_inc_udpinerrors(void)
1050 {
1051   udpinerrors++;
1052 }
1053
1054 void snmp_inc_udpoutdatagrams(void)
1055 {
1056   udpoutdatagrams++;
1057 }
1058
1059 void snmp_inc_snmpinpkts(void)
1060 {
1061   snmpinpkts++;
1062 }
1063
1064 void snmp_inc_snmpoutpkts(void)
1065 {
1066   snmpoutpkts++;
1067 }
1068
1069 void snmp_inc_snmpinbadversions(void)
1070 {
1071   snmpinbadversions++;
1072 }
1073
1074 void snmp_inc_snmpinbadcommunitynames(void)
1075 {
1076   snmpinbadcommunitynames++;
1077 }
1078
1079 void snmp_inc_snmpinbadcommunityuses(void)
1080 {
1081   snmpinbadcommunityuses++;
1082 }
1083
1084 void snmp_inc_snmpinasnparseerrs(void)
1085 {
1086   snmpinasnparseerrs++;
1087 }
1088
1089 void snmp_inc_snmpintoobigs(void)
1090 {
1091   snmpintoobigs++;
1092 }
1093
1094 void snmp_inc_snmpinnosuchnames(void)
1095 {
1096   snmpinnosuchnames++;
1097 }
1098
1099 void snmp_inc_snmpinbadvalues(void)
1100 {
1101   snmpinbadvalues++;
1102 }
1103
1104 void snmp_inc_snmpinreadonlys(void)
1105 {
1106   snmpinreadonlys++;
1107 }
1108
1109 void snmp_inc_snmpingenerrs(void)
1110 {
1111   snmpingenerrs++;
1112 }
1113
1114 void snmp_add_snmpintotalreqvars(u8_t value)
1115 {
1116   snmpintotalreqvars += value;
1117 }
1118
1119 void snmp_add_snmpintotalsetvars(u8_t value)
1120 {
1121   snmpintotalsetvars += value;
1122 }
1123
1124 void snmp_inc_snmpingetrequests(void)
1125 {
1126   snmpingetrequests++;
1127 }
1128
1129 void snmp_inc_snmpingetnexts(void)
1130 {
1131   snmpingetnexts++;
1132 }
1133
1134 void snmp_inc_snmpinsetrequests(void)
1135 {
1136   snmpinsetrequests++;
1137 }
1138
1139 void snmp_inc_snmpingetresponses(void)
1140 {
1141   snmpingetresponses++;
1142 }
1143
1144 void snmp_inc_snmpintraps(void)
1145 {
1146   snmpintraps++;
1147 }
1148
1149 void snmp_inc_snmpouttoobigs(void)
1150 {
1151   snmpouttoobigs++;
1152 }
1153
1154 void snmp_inc_snmpoutnosuchnames(void)
1155 {
1156   snmpoutnosuchnames++;
1157 }
1158
1159 void snmp_inc_snmpoutbadvalues(void)
1160 {
1161   snmpoutbadvalues++;
1162 }
1163
1164 void snmp_inc_snmpoutgenerrs(void)
1165 {
1166   snmpoutgenerrs++;
1167 }
1168
1169 void snmp_inc_snmpoutgetrequests(void)
1170 {
1171   snmpoutgetrequests++;
1172 }
1173
1174 void snmp_inc_snmpoutgetnexts(void)
1175 {
1176   snmpoutgetnexts++;
1177 }
1178
1179 void snmp_inc_snmpoutsetrequests(void)
1180 {
1181   snmpoutsetrequests++;
1182 }
1183
1184 void snmp_inc_snmpoutgetresponses(void)
1185 {
1186   snmpoutgetresponses++;
1187 }
1188
1189 void snmp_inc_snmpouttraps(void)
1190 {
1191   snmpouttraps++;
1192 }
1193
1194 void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid)
1195 {
1196   *oid = &snmpgrp_id;
1197 }
1198
1199 void snmp_set_snmpenableauthentraps(u8_t *value)
1200 {
1201   if (value != NULL)
1202   {
1203     snmpenableauthentraps_ptr = value;
1204   }
1205 }
1206
1207 void
1208 noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
1209 {
1210   if (ident_len){}
1211   if (ident){}
1212   od->instance = MIB_OBJECT_NONE;
1213 }
1214
1215 void                                                  
1216 noleafs_get_value(struct obj_def *od, u16_t len, void *value)
1217 {
1218   if (od){}
1219   if (len){}
1220   if (value){}
1221 }
1222
1223
1224
1225
1226 /**
1227  * Returns systems object definitions.
1228  *
1229  * @param ident_len the address length (2)
1230  * @param ident points to objectname.0 (object id trailer)
1231  * @param od points to object definition.
1232  */
1233 static void
1234 system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
1235 {
1236   u8_t id;
1237
1238   if ((ident_len == 2) && (ident[1] == 0))
1239   { 
1240     od->id_inst_len = ident_len;
1241     od->id_inst_ptr = ident;
1242     
1243     id = ident[0];
1244     LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def system.%"U16_F".0",(u16_t)id));
1245     switch (id)
1246     {
1247       case 1: /* sysDescr */
1248         od->instance = MIB_OBJECT_SCALAR;
1249         od->access = MIB_OBJECT_READ_ONLY;
1250         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
1251         od->v_len = *sysdescr_len_ptr;
1252         break;
1253       case 2: /* sysObjectID */
1254         od->instance = MIB_OBJECT_SCALAR;
1255         od->access = MIB_OBJECT_READ_ONLY;
1256         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID);
1257         od->v_len = SNMP_SYSOBJID_LEN * sizeof(s32_t);
1258         break;
1259       case 3: /* sysUpTime */
1260         od->instance = MIB_OBJECT_SCALAR;
1261         od->access = MIB_OBJECT_READ_ONLY;
1262         od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS);
1263         od->v_len = sizeof(u32_t);
1264         break;
1265       case 4: /* sysContact */
1266         od->instance = MIB_OBJECT_SCALAR;
1267         od->access = MIB_OBJECT_READ_WRITE;
1268         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
1269         od->v_len = *syscontact_len_ptr;
1270         break;
1271       case 5: /* sysName */
1272         od->instance = MIB_OBJECT_SCALAR;
1273         od->access = MIB_OBJECT_READ_WRITE;
1274         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
1275         od->v_len = *sysname_len_ptr;
1276         break;
1277       case 6: /* sysLocation */
1278         od->instance = MIB_OBJECT_SCALAR;
1279         od->access = MIB_OBJECT_READ_WRITE;
1280         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
1281         od->v_len = *syslocation_len_ptr;
1282         break;
1283       case 7: /* sysServices */
1284         od->instance = MIB_OBJECT_SCALAR;
1285         od->access = MIB_OBJECT_READ_ONLY;
1286         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
1287         od->v_len = sizeof(s32_t);
1288         break;
1289       default:
1290         LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_object_def: no such object"));
1291         od->instance = MIB_OBJECT_NONE;
1292         break;
1293     };
1294   }
1295   else
1296   {
1297     LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_object_def: no scalar"));
1298     od->instance = MIB_OBJECT_NONE;
1299   }
1300 }
1301
1302 /**
1303  * Returns system object value.
1304  *
1305  * @param ident_len the address length (2)
1306  * @param ident points to objectname.0 (object id trailer)
1307  * @param len return value space (in bytes)
1308  * @param value points to (varbind) space to copy value into.
1309  */
1310 static void                                                  
1311 system_get_value(struct obj_def *od, u16_t len, void *value)
1312 {
1313   u8_t id;
1314
1315   id = od->id_inst_ptr[0];
1316   switch (id)
1317   {
1318     case 1: /* sysDescr */
1319       ocstrncpy(value,sysdescr_ptr,len);
1320       break;
1321     case 2: /* sysObjectID */
1322       objectidncpy((s32_t*)value,(s32_t*)sysobjid.id,len / sizeof(s32_t));
1323       break;
1324     case 3: /* sysUpTime */
1325       {
1326         u32_t *uint_ptr = value;
1327         *uint_ptr = sysuptime;
1328       }
1329       break;
1330     case 4: /* sysContact */
1331       ocstrncpy(value,syscontact_ptr,len);
1332       break;
1333     case 5: /* sysName */
1334       ocstrncpy(value,sysname_ptr,len);
1335       break;
1336     case 6: /* sysLocation */
1337       ocstrncpy(value,syslocation_ptr,len);
1338       break;
1339     case 7: /* sysServices */
1340       {
1341         s32_t *sint_ptr = value;
1342         *sint_ptr = sysservices;
1343       }
1344       break;
1345   };
1346 }
1347
1348 /**
1349  * Returns interfaces.ifnumber object definition.
1350  *
1351  * @param ident_len the address length (2)
1352  * @param ident points to objectname.index
1353  * @param od points to object definition.
1354  */
1355 static void
1356 interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
1357 {
1358   if ((ident_len == 2) && (ident[0] == 1) && (ident[1] == 0))
1359   {
1360     od->id_inst_len = ident_len;
1361     od->id_inst_ptr = ident;
1362
1363     od->instance = MIB_OBJECT_SCALAR;
1364     od->access = MIB_OBJECT_READ_ONLY;
1365     od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
1366     od->v_len = sizeof(s32_t);
1367   }
1368   else
1369   {
1370     LWIP_DEBUGF(SNMP_MIB_DEBUG,("interfaces_get_object_def: no scalar"));
1371     od->instance = MIB_OBJECT_NONE;
1372   }
1373 }
1374
1375 /**
1376  * Returns interfaces.ifnumber object value.
1377  *
1378  * @param ident_len the address length (2)
1379  * @param ident points to objectname.0 (object id trailer)
1380  * @param len return value space (in bytes)
1381  * @param value points to (varbind) space to copy value into.
1382  */
1383 static void                                                  
1384 interfaces_get_value(struct obj_def *od, u16_t len, void *value)
1385 {
1386   if (len){}
1387   if (od->id_inst_ptr[0] == 1)
1388   {
1389     s32_t *sint_ptr = value;
1390     *sint_ptr = netif_cnt;
1391   }
1392 }
1393
1394 /**
1395  * Returns ifentry object definitions.
1396  *
1397  * @param ident_len the address length (2)
1398  * @param ident points to objectname.index
1399  * @param od points to object definition.
1400  */
1401 static void
1402 ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
1403 {
1404   u8_t id;
1405
1406   if ((ident_len == 2) && (ident[1] > 0) && (ident[1] <= netif_cnt))
1407   {
1408     od->id_inst_len = ident_len;
1409     od->id_inst_ptr = ident;
1410     
1411     id = ident[0];
1412     LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def ifentry.%"U16_F".",(u16_t)id));
1413     switch (id)
1414     {
1415       case 1: /* ifIndex */
1416         od->instance = MIB_OBJECT_TAB;
1417         od->access = MIB_OBJECT_READ_ONLY;
1418         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
1419         od->v_len = sizeof(s32_t);
1420         break;
1421       case 2: /* ifDescr */
1422         od->instance = MIB_OBJECT_TAB;
1423         od->access = MIB_OBJECT_READ_ONLY;
1424         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
1425         /** @todo this should be some sort of sizeof(struct netif.name) */
1426         od->v_len = 2;
1427         break;
1428       case 3: /* ifType */
1429       case 4: /* ifMtu */
1430       case 8: /* ifOperStatus */
1431         od->instance = MIB_OBJECT_TAB;
1432         od->access = MIB_OBJECT_READ_ONLY;
1433         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
1434         od->v_len = sizeof(s32_t);
1435         break;
1436       case 5: /* ifSpeed */
1437       case 21: /* ifOutQLen */
1438         od->instance = MIB_OBJECT_TAB;
1439         od->access = MIB_OBJECT_READ_ONLY;
1440         od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE);
1441         od->v_len = sizeof(u32_t);
1442         break;
1443       case 6: /* ifPhysAddress */
1444         {
1445           struct netif *netif = netif_list;
1446           u16_t i, ifidx;
1447
1448           ifidx = ident[1] - 1;
1449           i = 0;
1450           while ((netif != NULL) && (i < ifidx))
1451           {
1452             netif = netif->next;
1453             i++;
1454           }
1455           od->instance = MIB_OBJECT_TAB;
1456           od->access = MIB_OBJECT_READ_ONLY;
1457           od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
1458           od->v_len = netif->hwaddr_len;
1459         }
1460         break;
1461       case 7: /* ifAdminStatus */
1462         od->instance = MIB_OBJECT_TAB;
1463         od->access = MIB_OBJECT_READ_WRITE;
1464         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
1465         od->v_len = sizeof(s32_t);
1466         break;
1467       case 9: /* ifLastChange */
1468         od->instance = MIB_OBJECT_TAB;
1469         od->access = MIB_OBJECT_READ_ONLY;
1470         od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS);
1471         od->v_len = sizeof(u32_t);
1472         break;
1473       case 10: /* ifInOctets */
1474       case 11: /* ifInUcastPkts */
1475       case 12: /* ifInNUcastPkts */
1476       case 13: /* ifInDiscarts */
1477       case 14: /* ifInErrors */
1478       case 15: /* ifInUnkownProtos */
1479       case 16: /* ifOutOctets */
1480       case 17: /* ifOutUcastPkts */
1481       case 18: /* ifOutNUcastPkts */
1482       case 19: /* ifOutDiscarts */
1483       case 20: /* ifOutErrors */
1484         od->instance = MIB_OBJECT_TAB;
1485         od->access = MIB_OBJECT_READ_ONLY;
1486         od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
1487         od->v_len = sizeof(u32_t);
1488         break;
1489       case 22: /* ifSpecific */
1490         /** @note returning zeroDotZero (0.0) no media specific MIB support */
1491         od->instance = MIB_OBJECT_TAB;
1492         od->access = MIB_OBJECT_READ_ONLY;
1493         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID);
1494         od->v_len = ifspecific.len * sizeof(s32_t);
1495         break;
1496       default:
1497         LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_object_def: no such object"));
1498         od->instance = MIB_OBJECT_NONE;
1499         break;
1500     };
1501   }
1502   else
1503   {
1504     LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_object_def: no scalar"));
1505     od->instance = MIB_OBJECT_NONE;
1506   }
1507 }
1508
1509 /**
1510  * Returns ifentry object value.
1511  *
1512  * @param ident_len the address length (2)
1513  * @param ident points to objectname.0 (object id trailer)
1514  * @param len return value space (in bytes)
1515  * @param value points to (varbind) space to copy value into.
1516  */
1517 static void                                                  
1518 ifentry_get_value(struct obj_def *od, u16_t len, void *value)
1519 {
1520   struct netif *netif = netif_list;
1521   u16_t i, ifidx;
1522   u8_t id;
1523
1524   ifidx = od->id_inst_ptr[1] - 1;
1525   i = 0;
1526   while ((netif != NULL) && (i < ifidx))
1527   {
1528     netif = netif->next;
1529     i++;
1530   }
1531   id = od->id_inst_ptr[0];
1532   switch (id)
1533   {
1534     case 1: /* ifIndex */
1535       {
1536         s32_t *sint_ptr = value;
1537         *sint_ptr = od->id_inst_ptr[1];
1538       }
1539       break;
1540     case 2: /* ifDescr */
1541       ocstrncpy(value,(u8_t*)netif->name,len);
1542       break;
1543     case 3: /* ifType */
1544       {
1545         s32_t *sint_ptr = value;
1546         *sint_ptr = netif->link_type;
1547       }
1548       break;
1549     case 4: /* ifMtu */
1550       {
1551         s32_t *sint_ptr = value;
1552         *sint_ptr = netif->mtu;
1553       }
1554       break;
1555     case 5: /* ifSpeed */
1556       {
1557         u32_t *uint_ptr = value;
1558         *uint_ptr = netif->link_speed;
1559       }
1560       break;
1561     case 6: /* ifPhysAddress */
1562       ocstrncpy(value,netif->hwaddr,len);
1563       break;
1564     case 7: /* ifAdminStatus */
1565     case 8: /* ifOperStatus */
1566       {
1567         s32_t *sint_ptr = value;
1568         if (netif_is_up(netif))
1569         {
1570           *sint_ptr = 1;
1571         }
1572         else
1573         {
1574           *sint_ptr = 2;
1575         }
1576       }
1577       break;
1578     case 9: /* ifLastChange */
1579       {
1580         u32_t *uint_ptr = value;
1581         *uint_ptr = netif->ts;
1582       }
1583       break;
1584     case 10: /* ifInOctets */
1585       {
1586         u32_t *uint_ptr = value;
1587         *uint_ptr = netif->ifinoctets;
1588       }
1589       break;
1590     case 11: /* ifInUcastPkts */
1591       {
1592         u32_t *uint_ptr = value;
1593         *uint_ptr = netif->ifinucastpkts;
1594       }
1595       break;
1596     case 12: /* ifInNUcastPkts */
1597       {
1598         u32_t *uint_ptr = value;
1599         *uint_ptr = netif->ifinnucastpkts;
1600       }
1601       break;
1602     case 13: /* ifInDiscarts */
1603       {
1604         u32_t *uint_ptr = value;
1605         *uint_ptr = netif->ifindiscards;
1606       }
1607       break;
1608     case 14: /* ifInErrors */
1609     case 15: /* ifInUnkownProtos */
1610       /** @todo add these counters! */
1611       {
1612         u32_t *uint_ptr = value;
1613         *uint_ptr = 0;
1614       }
1615       break;
1616     case 16: /* ifOutOctets */
1617       {
1618         u32_t *uint_ptr = value;
1619         *uint_ptr = netif->ifoutoctets;
1620       }
1621       break;
1622     case 17: /* ifOutUcastPkts */
1623       {
1624         u32_t *uint_ptr = value;
1625         *uint_ptr = netif->ifoutucastpkts;
1626       }
1627       break;
1628     case 18: /* ifOutNUcastPkts */
1629       {
1630         u32_t *uint_ptr = value;
1631         *uint_ptr = netif->ifoutnucastpkts;
1632       }
1633       break;
1634     case 19: /* ifOutDiscarts */
1635       {
1636         u32_t *uint_ptr = value;
1637         *uint_ptr = netif->ifoutdiscards;
1638       }
1639       break;
1640     case 20: /* ifOutErrors */
1641        /** @todo add this counter! */
1642       {
1643         u32_t *uint_ptr = value;
1644         *uint_ptr = 0;
1645       }
1646       break;
1647     case 21: /* ifOutQLen */
1648       /** @todo figure out if this must be 0 (no queue) or 1? */
1649       {
1650         u32_t *uint_ptr = value;
1651         *uint_ptr = 0;
1652       }
1653       break;
1654     case 22: /* ifSpecific */
1655       objectidncpy((s32_t*)value,(s32_t*)ifspecific.id,len / sizeof(s32_t));
1656       break;
1657   };
1658 }
1659
1660 /**
1661  * Returns atentry object definitions.
1662  *
1663  * @param ident_len the address length (6)
1664  * @param ident points to objectname.atifindex.atnetaddress
1665  * @param od points to object definition.
1666  *
1667  * @todo std says objects are writeable, can we ignore it?
1668  */
1669 static void
1670 atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
1671 {
1672   if ((ident_len == 6) && 
1673       (ident[1] > 0) && (ident[1] <= netif_cnt))
1674   {
1675     struct eth_addr* ethaddr_ret;
1676     struct ip_addr* ipaddr_ret;
1677     struct ip_addr ip;
1678     struct netif *netif = netif_list;
1679     u16_t i, ifidx;
1680
1681     ifidx = ident[1] - 1;
1682     i = 0;
1683     while ((netif != NULL) && (i < ifidx))
1684     {
1685       netif = netif->next;
1686       i++;
1687     }
1688     ip.addr = ident[2];
1689     ip.addr <<= 8;
1690     ip.addr |= ident[3];
1691     ip.addr <<= 8;
1692     ip.addr |= ident[4];
1693     ip.addr <<= 8;
1694     ip.addr |= ident[5];
1695     ip.addr = htonl(ip.addr);
1696     
1697     if (etharp_find_addr(netif, &ip, &ethaddr_ret, &ipaddr_ret) > -1)
1698     {
1699       od->id_inst_len = ident_len;
1700       od->id_inst_ptr = ident;
1701
1702       switch (ident[0])
1703       {
1704         case 1: /* atIfIndex */
1705           od->instance = MIB_OBJECT_TAB;
1706           od->access = MIB_OBJECT_READ_WRITE;
1707           od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
1708           od->v_len = sizeof(s32_t);
1709           od->addr = NULL;
1710           break;
1711         case 2: /* atPhysAddress */
1712           od->instance = MIB_OBJECT_TAB;
1713           od->access = MIB_OBJECT_READ_WRITE;
1714           od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
1715           od->v_len = sizeof(struct eth_addr);
1716           od->addr = ethaddr_ret;
1717           break;
1718         case 3: /* atNetAddress */
1719           od->instance = MIB_OBJECT_TAB;
1720           od->access = MIB_OBJECT_READ_WRITE;
1721           od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
1722           od->v_len = 4;
1723           od->addr = ipaddr_ret;
1724           break;
1725         default:
1726           LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no such object"));
1727           od->instance = MIB_OBJECT_NONE;
1728           break;
1729       }
1730     }
1731     else
1732     {
1733       LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no scalar"));
1734       od->instance = MIB_OBJECT_NONE;
1735     }
1736   }
1737   else
1738   {
1739     LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no scalar"));
1740     od->instance = MIB_OBJECT_NONE;
1741   }
1742 }
1743
1744 static void
1745 atentry_get_value(struct obj_def *od, u16_t len, void *value)
1746 {
1747   u8_t id;
1748
1749   if (len) {}
1750   id = od->id_inst_ptr[0];
1751   switch (id)
1752   {
1753     case 1: /* atIfIndex */
1754       {
1755         s32_t *sint_ptr = value;
1756         *sint_ptr = od->id_inst_ptr[1];
1757       }
1758       break;
1759     case 2: /* atPhysAddress */
1760       {
1761         struct eth_addr *dst = value;
1762         struct eth_addr *src = od->addr;
1763
1764         *dst = *src;
1765       }
1766       break;
1767     case 3: /* atNetAddress */
1768       {
1769         struct ip_addr *dst = value;
1770         struct ip_addr *src = od->addr;
1771
1772         *dst = *src;
1773       }
1774       break;
1775   }
1776 }
1777
1778
1779 static void
1780 ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
1781 {
1782   u8_t id;
1783
1784   if ((ident_len == 2) && (ident[1] == 0))
1785   { 
1786     od->id_inst_len = ident_len;
1787     od->id_inst_ptr = ident;
1788     
1789     id = ident[0];
1790     LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def ip.%"U16_F".0",(u16_t)id));
1791     switch (id)
1792     {
1793       case 1: /* ipForwarding */
1794       case 2: /* ipDefaultTTL */
1795         od->instance = MIB_OBJECT_SCALAR;
1796         od->access = MIB_OBJECT_READ_WRITE;
1797         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
1798         od->v_len = sizeof(s32_t);
1799         break;
1800       case 3: /* ipInReceives */
1801       case 4: /* ipInHdrErrors */
1802       case 5: /* ipInAddrErrors */
1803       case 6: /* ipForwDatagrams */
1804       case 7: /* ipInUnknownProtos */
1805       case 8: /* ipInDiscards */
1806       case 9: /* ipInDelivers */
1807       case 10: /* ipOutRequests */
1808       case 11: /* ipOutDiscards */
1809       case 12: /* ipOutNoRoutes */
1810       case 14: /* ipReasmReqds */
1811       case 15: /* ipReasmOKs */
1812       case 16: /* ipReasmFails */
1813       case 17: /* ipFragOKs */
1814       case 18: /* ipFragFails */
1815       case 19: /* ipFragCreates */
1816       case 23: /* ipRoutingDiscards */
1817         od->instance = MIB_OBJECT_SCALAR;
1818         od->access = MIB_OBJECT_READ_ONLY;
1819         od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
1820         od->v_len = sizeof(u32_t);
1821         break;
1822       case 13: /* ipReasmTimeout */
1823         od->instance = MIB_OBJECT_SCALAR;
1824         od->access = MIB_OBJECT_READ_ONLY;
1825         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
1826         od->v_len = sizeof(s32_t);
1827         break;
1828       default:
1829         LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_object_def: no such object"));
1830         od->instance = MIB_OBJECT_NONE;
1831         break;
1832     };
1833   }
1834   else
1835   {
1836     LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_object_def: no scalar"));
1837     od->instance = MIB_OBJECT_NONE;
1838   }
1839 }
1840
1841 /** @todo ipForwarding is writeable, but we may return badValue,
1842           in lwIP this is a compile-time switch
1843           we will also return a badvalue for wring a default TTL
1844           which differs from our compile time default */
1845 static void
1846 ip_get_value(struct obj_def *od, u16_t len, void *value)
1847 {
1848   u8_t id;
1849
1850   if (len) {}
1851   id = od->id_inst_ptr[0];
1852   switch (id)
1853   {
1854     case 1: /* ipForwarding */
1855       {
1856         s32_t *sint_ptr = value;
1857 #if IP_FORWARD
1858         /* forwarding */
1859         *sint_ptr = 1;
1860 #else
1861         /* not-forwarding */
1862         *sint_ptr = 2;
1863 #endif
1864       }
1865       break;
1866     case 2: /* ipDefaultTTL */
1867       {
1868         s32_t *sint_ptr = value;
1869         *sint_ptr = IP_DEFAULT_TTL;
1870       }
1871       break;
1872     case 3: /* ipInReceives */
1873       {
1874         u32_t *uint_ptr = value;
1875         *uint_ptr = ipinreceives;
1876       }
1877       break;
1878     case 4: /* ipInHdrErrors */
1879       {
1880         u32_t *uint_ptr = value;
1881         *uint_ptr = ipinhdrerrors;
1882       }
1883       break;
1884     case 5: /* ipInAddrErrors */
1885       {
1886         u32_t *uint_ptr = value;
1887         *uint_ptr = ipinaddrerrors;
1888       }
1889       break;
1890     case 6: /* ipForwDatagrams */
1891       {
1892         u32_t *uint_ptr = value;
1893         *uint_ptr = ipforwdatagrams;
1894       }
1895       break;
1896     case 7: /* ipInUnknownProtos */
1897       {
1898         u32_t *uint_ptr = value;
1899         *uint_ptr = ipinunknownprotos;
1900       }
1901       break;
1902     case 8: /* ipInDiscards */
1903       {
1904         u32_t *uint_ptr = value;
1905         *uint_ptr = ipindiscards;
1906       }
1907       break;
1908     case 9: /* ipInDelivers */
1909       {
1910         u32_t *uint_ptr = value;
1911         *uint_ptr = ipindelivers;
1912       }
1913       break;
1914     case 10: /* ipOutRequests */
1915       {
1916         u32_t *uint_ptr = value;
1917         *uint_ptr = ipoutrequests;
1918       }
1919       break;
1920     case 11: /* ipOutDiscards */
1921       {
1922         u32_t *uint_ptr = value;
1923         *uint_ptr = ipoutdiscards;
1924       }
1925       break;
1926     case 12: /* ipOutNoRoutes */
1927       {
1928         u32_t *uint_ptr = value;
1929         *uint_ptr = ipoutnoroutes;
1930       }
1931       break;
1932     case 13: /* ipReasmTimeout */
1933       {
1934         s32_t *sint_ptr = value;
1935 #if IP_REASSEMBLY
1936         *sint_ptr = IP_REASS_MAXAGE;
1937 #else
1938         *sint_ptr = 0;
1939 #endif
1940       }
1941       break;
1942     case 14: /* ipReasmReqds */
1943       {
1944         u32_t *uint_ptr = value;
1945         *uint_ptr = ipreasmreqds;
1946       }
1947       break;
1948     case 15: /* ipReasmOKs */
1949       {
1950         u32_t *uint_ptr = value;
1951         *uint_ptr = ipreasmoks;
1952       }
1953       break;
1954     case 16: /* ipReasmFails */
1955       {
1956         u32_t *uint_ptr = value;
1957         *uint_ptr = ipreasmfails;
1958       }
1959       break;
1960     case 17: /* ipFragOKs */
1961       {
1962         u32_t *uint_ptr = value;
1963         *uint_ptr = ipfragoks;
1964       }
1965       break;
1966     case 18: /* ipFragFails */
1967       {
1968         u32_t *uint_ptr = value;
1969         *uint_ptr = ipfragfails;
1970       }
1971       break;
1972     case 19: /* ipFragCreates */
1973       {
1974         u32_t *uint_ptr = value;
1975         *uint_ptr = ipfragcreates;
1976       }
1977       break;
1978     case 23: /* ipRoutingDiscards */
1979       /** @todo can lwIP discard routes at all?? hardwire this to 0?? */
1980       {
1981         u32_t *uint_ptr = value;
1982         *uint_ptr = iproutingdiscards;
1983       }
1984       break;
1985   };
1986 }
1987
1988 static void
1989 ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
1990 {
1991   if (ident_len == 5)
1992   {
1993     struct ip_addr ip;
1994     struct netif *netif = netif_list;
1995
1996     ip.addr = ident[1];
1997     ip.addr <<= 8;
1998     ip.addr |= ident[2];
1999     ip.addr <<= 8;
2000     ip.addr |= ident[3];
2001     ip.addr <<= 8;
2002     ip.addr |= ident[4];
2003     ip.addr = htonl(ip.addr);
2004
2005     while ((netif != NULL) && !ip_addr_cmp(&ip, &netif->ip_addr))
2006     {
2007       netif = netif->next;
2008     }
2009     
2010     if (netif != NULL)
2011     {
2012       u8_t id;
2013
2014       od->id_inst_len = ident_len;
2015       od->id_inst_ptr = ident;
2016       od->addr = netif;
2017
2018       id = ident[0];
2019       switch (id)
2020       {
2021         case 1: /* ipAdEntAddr */
2022         case 3: /* ipAdEntNetMask */
2023           od->instance = MIB_OBJECT_TAB;
2024           od->access = MIB_OBJECT_READ_ONLY;
2025           od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
2026           od->v_len = 4;
2027           break;
2028         case 2: /* ipAdEntIfIndex */
2029         case 4: /* ipAdEntBcastAddr */
2030         case 5: /* ipAdEntReasmMaxSize */
2031           od->instance = MIB_OBJECT_TAB;
2032           od->access = MIB_OBJECT_READ_ONLY;
2033           od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2034           od->v_len = sizeof(s32_t);
2035           break;
2036         default:
2037           LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no such object"));
2038           od->instance = MIB_OBJECT_NONE;
2039           break;
2040       }
2041     }
2042     else
2043     {
2044       LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no scalar"));
2045       od->instance = MIB_OBJECT_NONE;
2046     }
2047   }
2048   else
2049   {
2050     LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no scalar"));
2051     od->instance = MIB_OBJECT_NONE;
2052   }
2053 }
2054
2055 static void
2056 ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value)
2057 {
2058   u8_t id;
2059
2060   if (len) {}
2061   id = od->id_inst_ptr[0];
2062   switch (id)
2063   {
2064     case 1: /* ipAdEntAddr */
2065       {
2066         struct ip_addr *dst = value;
2067         struct netif *netif;
2068         struct ip_addr *src;
2069
2070         netif = od->addr;
2071         src = &netif->ip_addr;
2072         *dst = *src;
2073       }
2074       break;
2075     case 2: /* ipAdEntIfIndex */
2076       {
2077         s32_t *sint_ptr = value;
2078         struct netif *netif = netif_list;
2079         u16_t i;
2080
2081         i = 0;
2082         while ((netif != NULL) && (netif != od->addr))
2083         {
2084           netif = netif->next;
2085           i++;
2086         }
2087         *sint_ptr = i + 1;
2088       }
2089       break;
2090     case 3: /* ipAdEntNetMask */
2091       {
2092         struct ip_addr *dst = value;
2093         struct netif *netif;
2094         struct ip_addr *src;
2095
2096         netif = od->addr;
2097         src = &netif->netmask;
2098         *dst = *src;
2099       }
2100       break;
2101     case 4: /* ipAdEntBcastAddr */
2102       {
2103         s32_t *sint_ptr = value;      
2104
2105         /* lwIP oddity, there's no broadcast
2106           address in the netif we can rely on */
2107         *sint_ptr = ip_addr_broadcast.addr & 1;
2108       }
2109       break;
2110     case 5: /* ipAdEntReasmMaxSize */
2111       {
2112         s32_t *sint_ptr = value;      
2113 #if IP_REASSEMBLY
2114         *sint_ptr = (IP_HLEN + IP_REASS_BUFSIZE);
2115 #else
2116         /** @todo returning MTU would be a bad thing and
2117            returning a wild guess like '576' isn't good either */
2118         *sint_ptr = 0;
2119 #endif
2120       }
2121       break;
2122   }
2123 }
2124
2125 /** 
2126  * @note
2127  * lwIP IP routing is currently using the network addresses in netif_list.
2128  * if no suitable network IP is found in netif_list, the default_netif is used.
2129  */
2130 static void
2131 ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2132 {
2133   u8_t id;
2134
2135   if (ident_len == 5)
2136   {
2137     struct ip_addr dest;
2138     struct netif *netif;
2139
2140     dest.addr = ident[1];
2141     dest.addr <<= 8;
2142     dest.addr |= ident[2];
2143     dest.addr <<= 8;
2144     dest.addr |= ident[3];
2145     dest.addr <<= 8;
2146     dest.addr |= ident[4];
2147     dest.addr = htonl(dest.addr);
2148
2149     if (dest.addr == 0)
2150     {
2151       /* ip_route() uses default netif for default route */
2152       netif = netif_default;
2153     }
2154     else
2155     {
2156       /* not using ip_route(), need exact match! */
2157       netif = netif_list;
2158       while ((netif != NULL) && 
2159               !ip_addr_netcmp(&dest, &(netif->ip_addr), &(netif->netmask)) )
2160       {      
2161         netif = netif->next;
2162       }
2163     }    
2164     if (netif != NULL)
2165     {
2166       od->id_inst_len = ident_len;
2167       od->id_inst_ptr = ident;
2168       od->addr = netif;
2169
2170       id = ident[0];
2171       switch (id)
2172       {
2173         case 1: /* ipRouteDest */
2174         case 7: /* ipRouteNextHop */
2175         case 11: /* ipRouteMask */
2176           od->instance = MIB_OBJECT_TAB;
2177           od->access = MIB_OBJECT_READ_WRITE;
2178           od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
2179           od->v_len = 4;
2180           break;
2181         case 2: /* ipRouteIfIndex */
2182         case 3: /* ipRouteMetric1 */
2183         case 4: /* ipRouteMetric2 */
2184         case 5: /* ipRouteMetric3 */
2185         case 6: /* ipRouteMetric4 */
2186         case 8: /* ipRouteType */
2187         case 10: /* ipRouteAge */
2188         case 12: /* ipRouteMetric5 */
2189           od->instance = MIB_OBJECT_TAB;
2190           od->access = MIB_OBJECT_READ_WRITE;
2191           od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2192           od->v_len = sizeof(s32_t);
2193           break;
2194         case 9: /* ipRouteProto */
2195           od->instance = MIB_OBJECT_TAB;
2196           od->access = MIB_OBJECT_READ_ONLY;
2197           od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2198           od->v_len = sizeof(s32_t);
2199           break;
2200         case 13: /* ipRouteInfo */
2201           /** @note returning zeroDotZero (0.0) no routing protocol specific MIB */
2202           od->instance = MIB_OBJECT_TAB;
2203           od->access = MIB_OBJECT_READ_ONLY;
2204           od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID);
2205           od->v_len = iprouteinfo.len * sizeof(s32_t);
2206           break;
2207         default:
2208           LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no such object"));
2209           od->instance = MIB_OBJECT_NONE;
2210           break;
2211       }
2212     }
2213     else
2214     {
2215       LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no scalar"));
2216       od->instance = MIB_OBJECT_NONE;
2217     }
2218   }
2219   else
2220   {
2221     LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no scalar"));
2222     od->instance = MIB_OBJECT_NONE;
2223   }
2224 }
2225
2226 static void
2227 ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
2228 {
2229   struct netif *netif;
2230   struct ip_addr dest;
2231   s32_t *ident;
2232   u8_t id;
2233
2234   netif = od->addr;
2235   ident = od->id_inst_ptr;
2236   dest.addr = ident[1];
2237   dest.addr <<= 8;
2238   dest.addr |= ident[2];
2239   dest.addr <<= 8;
2240   dest.addr |= ident[3];
2241   dest.addr <<= 8;
2242   dest.addr |= ident[4];
2243   dest.addr = htonl(dest.addr);
2244
2245   id = ident[0];
2246   switch (id)
2247   {
2248     case 1: /* ipRouteDest */
2249       {
2250         struct ip_addr *dst = value;
2251
2252         if (dest.addr == 0)
2253         {
2254           /* default rte has 0.0.0.0 dest */
2255           dst->addr = 0;
2256         }
2257         else
2258         {
2259           /* netifs have netaddress dest */
2260           dst->addr = netif->ip_addr.addr & netif->netmask.addr;
2261         }
2262       }
2263       break;
2264     case 2: /* ipRouteIfIndex */
2265       {
2266         struct netif *ni = netif_list;
2267         s32_t *sint_ptr = value;
2268         u16_t i;
2269
2270         i = 0;
2271         while ((ni != NULL) && (ni != netif))
2272         {
2273           ni = ni->next;
2274           i++;
2275         }
2276         *sint_ptr = i + 1;
2277       }
2278       break;
2279     case 3: /* ipRouteMetric1 */         
2280       {
2281         s32_t *sint_ptr = value;
2282
2283         if (dest.addr == 0)
2284         {
2285           /* default rte has metric 1 */
2286           *sint_ptr = 1;
2287         }
2288         else
2289         {
2290           /* other rtes have metric 0 */
2291           *sint_ptr = 0;
2292         }
2293       }
2294       break;
2295     case 4: /* ipRouteMetric2 */
2296     case 5: /* ipRouteMetric3 */
2297     case 6: /* ipRouteMetric4 */
2298     case 12: /* ipRouteMetric5 */
2299       {
2300         s32_t *sint_ptr = value;
2301         /* not used */
2302         *sint_ptr = -1;
2303       }
2304       break;
2305     case 7: /* ipRouteNextHop */
2306       {
2307         struct ip_addr *dst = value;
2308
2309         if (dest.addr == 0)
2310         {
2311           /* default rte: gateway */
2312           *dst = netif->gw;
2313         }
2314         else
2315         {
2316           /* other rtes: netif ip_addr  */
2317           *dst = netif->ip_addr;
2318         }
2319       }
2320       break;
2321     case 8: /* ipRouteType */
2322       {
2323         s32_t *sint_ptr = value;
2324
2325         if (dest.addr == 0)
2326         {
2327           /* default rte is indirect */
2328           *sint_ptr = 4;
2329         }
2330         else
2331         {
2332           /* other rtes are direct */
2333           *sint_ptr = 3;
2334         }
2335       }
2336       break;
2337     case 9: /* ipRouteProto */
2338       {
2339         s32_t *sint_ptr = value;
2340         /* locally defined routes */
2341         *sint_ptr = 2;
2342       }
2343       break;
2344     case 10: /* ipRouteAge */
2345       {
2346         s32_t *sint_ptr = value;
2347         /** @todo (sysuptime - timestamp last change) / 100 */
2348         *sint_ptr = 0;
2349       }
2350       break;
2351     case 11: /* ipRouteMask */
2352       {
2353         struct ip_addr *dst = value;
2354
2355         if (dest.addr == 0)
2356         {
2357           /* default rte use 0.0.0.0 mask */
2358           dst->addr = 0;
2359         }
2360         else
2361         {
2362           /* other rtes use netmask */
2363           *dst = netif->netmask;
2364         }
2365       }
2366       break;
2367     case 13: /* ipRouteInfo */
2368       objectidncpy((s32_t*)value,(s32_t*)iprouteinfo.id,len / sizeof(s32_t));
2369       break;
2370   }
2371 }
2372
2373 static void
2374 ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2375 {
2376   if ((ident_len == 6) && 
2377       (ident[1] > 0) && (ident[1] <= netif_cnt))
2378   {
2379     struct eth_addr* ethaddr_ret;
2380     struct ip_addr* ipaddr_ret;
2381     struct ip_addr ip;
2382     struct netif *netif = netif_list;
2383     u16_t i, ifidx;
2384
2385     ifidx = ident[1] - 1;
2386     i = 0;
2387     while ((netif != NULL) && (i < ifidx))
2388     {
2389       netif = netif->next;
2390       i++;
2391     }
2392     ip.addr = ident[2];
2393     ip.addr <<= 8;
2394     ip.addr |= ident[3];
2395     ip.addr <<= 8;
2396     ip.addr |= ident[4];
2397     ip.addr <<= 8;
2398     ip.addr |= ident[5];
2399     ip.addr = htonl(ip.addr);
2400     
2401     if (etharp_find_addr(netif, &ip, &ethaddr_ret, &ipaddr_ret) > -1)
2402     {
2403       u8_t id;
2404
2405       od->id_inst_len = ident_len;
2406       od->id_inst_ptr = ident;
2407
2408       id = ident[0];
2409       switch (id)
2410       {
2411         case 1: /* ipNetToMediaIfIndex */
2412         case 4: /* ipNetToMediaType */
2413           od->instance = MIB_OBJECT_TAB;
2414           od->access = MIB_OBJECT_READ_WRITE;
2415           od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2416           od->v_len = sizeof(s32_t);
2417           od->addr = NULL;
2418           break;
2419         case 2: /* ipNetToMediaPhysAddress */
2420           od->instance = MIB_OBJECT_TAB;
2421           od->access = MIB_OBJECT_READ_WRITE;
2422           od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
2423           od->v_len = sizeof(struct eth_addr);
2424           od->addr = ethaddr_ret;
2425           break;
2426         case 3: /* ipNetToMediaNetAddress */
2427           od->instance = MIB_OBJECT_TAB;
2428           od->access = MIB_OBJECT_READ_WRITE;
2429           od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
2430           od->v_len = 4;
2431           od->addr = ipaddr_ret;
2432           break;
2433         default:
2434           LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no such object"));
2435           od->instance = MIB_OBJECT_NONE;
2436           break;
2437       }
2438     }
2439     else
2440     {
2441       LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no scalar"));
2442       od->instance = MIB_OBJECT_NONE;
2443     }
2444   }
2445   else
2446   {
2447     LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no scalar"));
2448     od->instance = MIB_OBJECT_NONE;
2449   }
2450 }
2451
2452 static void
2453 ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value)
2454 {
2455   u8_t id;
2456
2457   if (len){}
2458   id = od->id_inst_ptr[0];
2459   switch (id)
2460   {
2461     case 1: /* ipNetToMediaIfIndex */
2462       {
2463         s32_t *sint_ptr = value;
2464         *sint_ptr = od->id_inst_ptr[1];
2465       }
2466       break;
2467     case 2: /* ipNetToMediaPhysAddress */
2468       {
2469         struct eth_addr *dst = value;
2470         struct eth_addr *src = od->addr;
2471
2472         *dst = *src;
2473       }
2474       break;
2475     case 3: /* ipNetToMediaNetAddress */
2476       {
2477         struct ip_addr *dst = value;
2478         struct ip_addr *src = od->addr;
2479
2480         *dst = *src;
2481       }
2482       break;
2483     case 4: /* ipNetToMediaType */
2484       {
2485         s32_t *sint_ptr = value;
2486         /* dynamic (?) */
2487         *sint_ptr = 3;
2488       }
2489       break;
2490   }
2491 }
2492
2493 static void
2494 icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2495 {
2496   if ((ident_len == 2) && (ident[1] == 0) &&
2497       (ident[0] > 0) && (ident[0] < 27))
2498   {
2499     od->id_inst_len = ident_len;
2500     od->id_inst_ptr = ident;
2501
2502     od->instance = MIB_OBJECT_SCALAR;
2503     od->access = MIB_OBJECT_READ_ONLY;
2504     od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
2505     od->v_len = sizeof(u32_t);
2506   }
2507   else
2508   {
2509     LWIP_DEBUGF(SNMP_MIB_DEBUG,("icmp_get_object_def: no scalar"));
2510     od->instance = MIB_OBJECT_NONE;
2511   }
2512 }
2513
2514 static void
2515 icmp_get_value(struct obj_def *od, u16_t len, void *value)
2516 {
2517   u32_t *uint_ptr = value;
2518   u8_t id;
2519
2520   if (len){}
2521   id = od->id_inst_ptr[0];
2522   switch (id)
2523   {
2524     case 1: /* icmpInMsgs */
2525       *uint_ptr = icmpinmsgs;
2526       break;
2527     case 2: /* icmpInErrors */
2528       *uint_ptr = icmpinerrors;
2529       break;
2530     case 3: /* icmpInDestUnreachs */
2531       *uint_ptr = icmpindestunreachs;
2532       break;
2533     case 4: /* icmpInTimeExcds */
2534       *uint_ptr = icmpintimeexcds;
2535       break;
2536     case 5: /* icmpInParmProbs */
2537       *uint_ptr = icmpinparmprobs;
2538       break;
2539     case 6: /* icmpInSrcQuenchs */
2540       *uint_ptr = icmpinsrcquenchs;
2541       break;
2542     case 7: /* icmpInRedirects */
2543       *uint_ptr = icmpinredirects;
2544       break;
2545     case 8: /* icmpInEchos */
2546       *uint_ptr = icmpinechos;
2547       break;
2548     case 9: /* icmpInEchoReps */
2549       *uint_ptr = icmpinechoreps;
2550       break;
2551     case 10: /* icmpInTimestamps */
2552       *uint_ptr = icmpintimestamps;
2553       break;
2554     case 11: /* icmpInTimestampReps */
2555       *uint_ptr = icmpintimestampreps;
2556       break;
2557     case 12: /* icmpInAddrMasks */
2558       *uint_ptr = icmpinaddrmasks;
2559       break;
2560     case 13: /* icmpInAddrMaskReps */
2561       *uint_ptr = icmpinaddrmaskreps;
2562       break;
2563     case 14: /* icmpOutMsgs */
2564       *uint_ptr = icmpoutmsgs; 
2565       break;
2566     case 15: /* icmpOutErrors */
2567       *uint_ptr = icmpouterrors;
2568       break;
2569     case 16: /* icmpOutDestUnreachs */
2570       *uint_ptr = icmpoutdestunreachs;
2571       break;
2572     case 17: /* icmpOutTimeExcds */
2573       *uint_ptr = icmpouttimeexcds;
2574       break;
2575     case 18: /* icmpOutParmProbs */
2576       *uint_ptr = icmpoutparmprobs;
2577       break;
2578     case 19: /* icmpOutSrcQuenchs */
2579       *uint_ptr = icmpoutsrcquenchs;
2580       break;
2581     case 20: /* icmpOutRedirects */
2582       *uint_ptr = icmpoutredirects;
2583       break;
2584     case 21: /* icmpOutEchos */
2585       *uint_ptr = icmpoutechos;
2586       break;
2587     case 22: /* icmpOutEchoReps */
2588       *uint_ptr = icmpoutechoreps;
2589       break;
2590     case 23: /* icmpOutTimestamps */
2591       *uint_ptr = icmpouttimestamps;
2592       break;
2593     case 24: /* icmpOutTimestampReps */
2594       *uint_ptr = icmpouttimestampreps;
2595       break;
2596     case 25: /* icmpOutAddrMasks */
2597       *uint_ptr = icmpoutaddrmasks;
2598       break;
2599     case 26: /* icmpOutAddrMaskReps */
2600       *uint_ptr = icmpoutaddrmaskreps;
2601       break;
2602   }
2603 }
2604
2605 #if LWIP_TCP
2606 /** @todo tcp grp */
2607 static void
2608 tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2609 {
2610 }
2611
2612 static void
2613 tcp_get_value(struct obj_def *od, u16_t len, void *value)
2614 {
2615 }
2616
2617 static void
2618 tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2619 {
2620 }
2621
2622 static void
2623 tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value)
2624 {
2625 }
2626 #endif
2627
2628 static void
2629 udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2630 {
2631   if ((ident_len == 2) && (ident[1] == 0) &&
2632       (ident[0] > 0) && (ident[0] < 6))
2633   {
2634     od->id_inst_len = ident_len;
2635     od->id_inst_ptr = ident;
2636
2637     od->instance = MIB_OBJECT_SCALAR;
2638     od->access = MIB_OBJECT_READ_ONLY;
2639     od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
2640     od->v_len = sizeof(u32_t);
2641   }
2642   else
2643   {
2644     LWIP_DEBUGF(SNMP_MIB_DEBUG,("udp_get_object_def: no scalar"));
2645     od->instance = MIB_OBJECT_NONE;
2646   }
2647 }
2648
2649 static void
2650 udp_get_value(struct obj_def *od, u16_t len, void *value)
2651 {
2652   u32_t *uint_ptr = value;
2653   u8_t id;
2654
2655   if (len){}
2656   id = od->id_inst_ptr[0];
2657   switch (id)
2658   {
2659     case 1: /* udpInDatagrams */
2660       *uint_ptr = udpindatagrams;
2661       break;
2662     case 2: /* udpNoPorts */
2663       *uint_ptr = udpnoports;
2664       break;
2665     case 3: /* udpInErrors */
2666       *uint_ptr = udpinerrors;
2667       break;
2668     case 4: /* udpOutDatagrams */
2669       *uint_ptr = udpoutdatagrams;
2670       break;
2671   }
2672 }
2673
2674 static void
2675 udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2676 {
2677   if (ident_len == 6)
2678   {
2679     struct udp_pcb *pcb;
2680     struct ip_addr ip;
2681     u16_t port;
2682
2683     ip.addr = ident[1];
2684     ip.addr <<= 8;
2685     ip.addr |= ident[2];
2686     ip.addr <<= 8;
2687     ip.addr |= ident[3];
2688     ip.addr <<= 8;
2689     ip.addr |= ident[4];
2690     ip.addr = htonl(ip.addr);
2691
2692     port = ident[5];
2693
2694     pcb = udp_pcbs;
2695     while ((pcb != NULL) &&
2696             (pcb->local_ip.addr != ip.addr) &&
2697             (pcb->local_port != port))
2698     {      
2699       pcb = pcb->next;
2700     }
2701     
2702     if (pcb != NULL)
2703     {
2704       od->id_inst_len = ident_len;
2705       od->id_inst_ptr = ident;
2706       od->addr = pcb;
2707
2708       switch (ident[0])
2709       {
2710         case 1: /* udpLocalAddress */
2711           od->instance = MIB_OBJECT_TAB;
2712           od->access = MIB_OBJECT_READ_WRITE;
2713           od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
2714           od->v_len = 4;
2715           break;
2716         case 2: /* udpLocalPort */
2717           od->instance = MIB_OBJECT_TAB;
2718           od->access = MIB_OBJECT_READ_WRITE;
2719           od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2720           od->v_len = sizeof(s32_t);
2721           break;
2722         default:
2723           LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no such object"));
2724           od->instance = MIB_OBJECT_NONE;
2725           break;
2726       }
2727     }
2728     else
2729     {
2730       LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no scalar"));
2731       od->instance = MIB_OBJECT_NONE;
2732     }
2733   }
2734   else
2735   {
2736     LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no scalar"));
2737     od->instance = MIB_OBJECT_NONE;
2738   }
2739 }
2740
2741 static void
2742 udpentry_get_value(struct obj_def *od, u16_t len, void *value)
2743 {
2744   struct udp_pcb *pcb;
2745   u8_t id;
2746
2747   if (len){}
2748   pcb = od->addr;
2749   id = od->id_inst_ptr[0];
2750   switch (id)
2751   {
2752     case 1: /* udpLocalAddress */
2753       {
2754         struct ip_addr *dst = value;
2755         struct ip_addr *src = &pcb->local_ip;
2756         *dst = *src;
2757       }
2758       break;
2759     case 2: /* udpLocalPort */
2760       {
2761         s32_t *sint_ptr = value;
2762         *sint_ptr = pcb->local_port;
2763       }
2764       break;
2765   }
2766 }
2767
2768 static void
2769 snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
2770 {
2771   if ((ident_len == 2) && (ident[1] == 0))
2772   {
2773     u8_t id;
2774
2775     od->id_inst_len = ident_len;
2776     od->id_inst_ptr = ident;
2777
2778     id = ident[0];
2779     switch (id)
2780     {
2781       case 1: /* snmpInPkts */
2782       case 2: /* snmpOutPkts */
2783       case 3: /* snmpInBadVersions */
2784       case 4: /* snmpInBadCommunityNames */
2785       case 5: /* snmpInBadCommunityUses */
2786       case 6: /* snmpInASNParseErrs */
2787       case 8: /* snmpInTooBigs */
2788       case 9: /* snmpInNoSuchNames */
2789       case 10: /* snmpInBadValues */
2790       case 11: /* snmpInReadOnlys */
2791       case 12: /* snmpInGenErrs */
2792       case 13: /* snmpInTotalReqVars */
2793       case 14: /* snmpInTotalSetVars */
2794       case 15: /* snmpInGetRequests */
2795       case 16: /* snmpInGetNexts */
2796       case 17: /* snmpInSetRequests */
2797       case 18: /* snmpInGetResponses */
2798       case 19: /* snmpInTraps */
2799       case 20: /* snmpOutTooBigs */
2800       case 21: /* snmpOutNoSuchNames */
2801       case 22: /* snmpOutBadValues */
2802       case 24: /* snmpOutGenErrs */
2803       case 25: /* snmpOutGetRequests */
2804       case 26: /* snmpOutGetNexts */
2805       case 27: /* snmpOutSetRequests */
2806       case 28: /* snmpOutGetResponses */
2807       case 29: /* snmpOutTraps */
2808         od->instance = MIB_OBJECT_SCALAR;
2809         od->access = MIB_OBJECT_READ_ONLY;
2810         od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
2811         od->v_len = sizeof(u32_t);
2812         break;
2813       case 30: /* snmpEnableAuthenTraps */
2814         od->instance = MIB_OBJECT_SCALAR;
2815         od->access = MIB_OBJECT_READ_WRITE;
2816         od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
2817         od->v_len = sizeof(s32_t);
2818         break;
2819       default:
2820         LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_object_def: no such object"));
2821         od->instance = MIB_OBJECT_NONE;
2822         break;
2823     };
2824   }
2825   else
2826   {
2827     LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_object_def: no scalar"));
2828     od->instance = MIB_OBJECT_NONE;
2829   }
2830 }
2831
2832 static void
2833 snmp_get_value(struct obj_def *od, u16_t len, void *value)
2834 {
2835   u32_t *uint_ptr = value;
2836   u8_t id;
2837
2838   if (len){}
2839   id = od->id_inst_ptr[0];
2840   switch (id)
2841   {
2842       case 1: /* snmpInPkts */
2843         *uint_ptr = snmpinpkts;
2844         break;
2845       case 2: /* snmpOutPkts */
2846         *uint_ptr = snmpoutpkts;
2847         break;
2848       case 3: /* snmpInBadVersions */
2849         *uint_ptr = snmpinbadversions;
2850         break;
2851       case 4: /* snmpInBadCommunityNames */
2852         *uint_ptr = snmpinbadcommunitynames;
2853         break;
2854       case 5: /* snmpInBadCommunityUses */
2855         *uint_ptr = snmpinbadcommunityuses;
2856         break;
2857       case 6: /* snmpInASNParseErrs */
2858         *uint_ptr = snmpinasnparseerrs;
2859         break;
2860       case 8: /* snmpInTooBigs */
2861         *uint_ptr = snmpintoobigs;
2862         break;
2863       case 9: /* snmpInNoSuchNames */
2864         *uint_ptr = snmpinnosuchnames;
2865         break;
2866       case 10: /* snmpInBadValues */
2867         *uint_ptr = snmpinbadvalues;
2868         break;
2869       case 11: /* snmpInReadOnlys */
2870         *uint_ptr = snmpinreadonlys;
2871         break;
2872       case 12: /* snmpInGenErrs */
2873         *uint_ptr = snmpingenerrs;
2874         break;
2875       case 13: /* snmpInTotalReqVars */
2876         *uint_ptr = snmpintotalreqvars;
2877         break;
2878       case 14: /* snmpInTotalSetVars */
2879         *uint_ptr = snmpintotalsetvars;
2880         break;
2881       case 15: /* snmpInGetRequests */
2882         *uint_ptr = snmpingetrequests;
2883         break;
2884       case 16: /* snmpInGetNexts */
2885         *uint_ptr = snmpingetnexts;
2886         break;
2887       case 17: /* snmpInSetRequests */
2888         *uint_ptr = snmpinsetrequests;
2889         break;
2890       case 18: /* snmpInGetResponses */
2891         *uint_ptr = snmpingetresponses;
2892         break;
2893       case 19: /* snmpInTraps */
2894         *uint_ptr = snmpintraps;
2895         break;
2896       case 20: /* snmpOutTooBigs */
2897         *uint_ptr = snmpouttoobigs;
2898         break;
2899       case 21: /* snmpOutNoSuchNames */
2900         *uint_ptr = snmpoutnosuchnames;
2901         break;
2902       case 22: /* snmpOutBadValues */
2903         *uint_ptr = snmpoutbadvalues;
2904         break;
2905       case 24: /* snmpOutGenErrs */
2906         *uint_ptr = snmpoutgenerrs;
2907         break;
2908       case 25: /* snmpOutGetRequests */
2909         *uint_ptr = snmpoutgetrequests;
2910         break;
2911       case 26: /* snmpOutGetNexts */
2912         *uint_ptr = snmpoutgetnexts;
2913         break;
2914       case 27: /* snmpOutSetRequests */
2915         *uint_ptr = snmpoutsetrequests;
2916         break;
2917       case 28: /* snmpOutGetResponses */
2918         *uint_ptr = snmpoutgetresponses;
2919         break;
2920       case 29: /* snmpOutTraps */
2921         *uint_ptr = snmpouttraps;
2922         break;
2923       case 30: /* snmpEnableAuthenTraps */
2924         *uint_ptr = *snmpenableauthentraps_ptr;
2925         break;
2926   };
2927 }
2928
2929 #endif /* LWIP_SNMP */