if_mib_module.c
Go to the documentation of this file.
1 /**
2  * @file if_mib_module.c
3  * @brief Interfaces Group MIB module
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneTCP Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @section Description
26  *
27  * The IF-MIB describes managed objects used for managing network
28  * interfaces. Refer to the following RFCs for complete details:
29  * - RFC 2233: The Interfaces Group MIB using SMIv2
30  * - RFC 2863: The Interfaces Group MIB
31  *
32  * @author Oryx Embedded SARL (www.oryx-embedded.com)
33  * @version 1.9.0
34  **/
35 
36 //Switch to the appropriate trace level
37 #define TRACE_LEVEL SNMP_TRACE_LEVEL
38 
39 //Dependencies
40 #include "core/net.h"
41 #include "mibs/mib_common.h"
42 #include "mibs/if_mib_module.h"
43 #include "mibs/if_mib_impl.h"
44 #include "core/crypto.h"
45 #include "encoding/asn1.h"
46 #include "encoding/oid.h"
47 #include "debug.h"
48 
49 //Check TCP/IP stack configuration
50 #if (IF_MIB_SUPPORT == ENABLED)
51 
52 
53 /**
54  * @brief Interfaces Group MIB base
55  **/
56 
58 
59 
60 /**
61  * @brief Interfaces Group MIB objects
62  **/
63 
65 {
66  //ifNumber object (1.3.6.1.2.1.2.1)
67  {
68  "ifNumber",
69  {43, 6, 1, 2, 1, 2, 1},
70  7,
75  NULL,
76  sizeof(int32_t),
77  NULL,
78  NULL,
79  NULL
80  },
81  //ifIndex object (1.3.6.1.2.1.2.2.1.1)
82  {
83  "ifIndex",
84  {43, 6, 1, 2, 1, 2, 2, 1, 1},
85  9,
89  NULL,
90  NULL,
91  sizeof(int32_t),
92  NULL,
95  },
96  //ifDescr object (1.3.6.1.2.1.2.2.1.2)
97  {
98  "ifDescr",
99  {43, 6, 1, 2, 1, 2, 2, 1, 2},
100  9,
104  NULL,
105  NULL,
106  0,
107  NULL,
110  },
111  //ifType object (1.3.6.1.2.1.2.2.1.3)
112  {
113  "ifType",
114  {43, 6, 1, 2, 1, 2, 2, 1, 3},
115  9,
119  NULL,
120  NULL,
121  sizeof(int32_t),
122  NULL,
125  },
126  //ifMtu object (1.3.6.1.2.1.2.2.1.4)
127  {
128  "ifMtu",
129  {43, 6, 1, 2, 1, 2, 2, 1, 4},
130  9,
134  NULL,
135  NULL,
136  sizeof(int32_t),
137  NULL,
140  },
141  //ifSpeed object (1.3.6.1.2.1.2.2.1.5)
142  {
143  "ifSpeed",
144  {43, 6, 1, 2, 1, 2, 2, 1, 5},
145  9,
149  NULL,
150  NULL,
151  sizeof(uint32_t),
152  NULL,
155  },
156  //ifPhysAddress object (1.3.6.1.2.1.2.2.1.6)
157  {
158  "ifPhysAddress",
159  {43, 6, 1, 2, 1, 2, 2, 1, 6},
160  9,
164  NULL,
165  NULL,
166  0,
167  NULL,
170  },
171  //ifAdminStatus object (1.3.6.1.2.1.2.2.1.7)
172  {
173  "ifAdminStatus",
174  {43, 6, 1, 2, 1, 2, 2, 1, 7},
175  9,
179  NULL,
180  NULL,
181  sizeof(int32_t),
185  },
186  //ifOperStatus object (1.3.6.1.2.1.2.2.1.8)
187  {
188  "ifOperStatus",
189  {43, 6, 1, 2, 1, 2, 2, 1, 8},
190  9,
194  NULL,
195  NULL,
196  sizeof(int32_t),
197  NULL,
200  },
201  //ifLastChange object (1.3.6.1.2.1.2.2.1.9)
202  {
203  "ifLastChange",
204  {43, 6, 1, 2, 1, 2, 2, 1, 9},
205  9,
209  NULL,
210  NULL,
211  sizeof(uint32_t),
212  NULL,
215  },
216  //ifInOctets object (1.3.6.1.2.1.2.2.1.10)
217  {
218  "ifInOctets",
219  {43, 6, 1, 2, 1, 2, 2, 1, 10},
220  9,
224  NULL,
225  NULL,
226  sizeof(uint32_t),
227  NULL,
230  },
231  //ifInUcastPkts object (1.3.6.1.2.1.2.2.1.11)
232  {
233  "ifInUcastPkts",
234  {43, 6, 1, 2, 1, 2, 2, 1, 11},
235  9,
239  NULL,
240  NULL,
241  sizeof(uint32_t),
242  NULL,
245  },
246  //ifInDiscards object (1.3.6.1.2.1.2.2.1.13)
247  {
248  "ifInDiscards",
249  {43, 6, 1, 2, 1, 2, 2, 1, 13},
250  9,
254  NULL,
255  NULL,
256  sizeof(uint32_t),
257  NULL,
260  },
261  //ifInErrors object (1.3.6.1.2.1.2.2.1.14)
262  {
263  "ifInErrors",
264  {43, 6, 1, 2, 1, 2, 2, 1, 14},
265  9,
269  NULL,
270  NULL,
271  sizeof(uint32_t),
272  NULL,
275  },
276  //ifInUnknownProtos object (1.3.6.1.2.1.2.2.1.15)
277  {
278  "ifInUnknownProtos",
279  {43, 6, 1, 2, 1, 2, 2, 1, 15},
280  9,
284  NULL,
285  NULL,
286  sizeof(uint32_t),
287  NULL,
290  },
291  //ifOutOctets object (1.3.6.1.2.1.2.2.1.16)
292  {
293  "ifOutOctets",
294  {43, 6, 1, 2, 1, 2, 2, 1, 16},
295  9,
299  NULL,
300  NULL,
301  sizeof(uint32_t),
302  NULL,
305  },
306  //ifOutUcastPkts object (1.3.6.1.2.1.2.2.1.17)
307  {
308  "ifOutUcastPkts",
309  {43, 6, 1, 2, 1, 2, 2, 1, 17},
310  9,
314  NULL,
315  NULL,
316  sizeof(uint32_t),
317  NULL,
320  },
321  //ifOutDiscards object (1.3.6.1.2.1.2.2.1.19)
322  {
323  "ifOutDiscards",
324  {43, 6, 1, 2, 1, 2, 2, 1, 19},
325  9,
329  NULL,
330  NULL,
331  sizeof(uint32_t),
332  NULL,
335  },
336  //ifOutErrors object (1.3.6.1.2.1.2.2.1.20)
337  {
338  "ifOutErrors",
339  {43, 6, 1, 2, 1, 2, 2, 1, 20},
340  9,
344  NULL,
345  NULL,
346  sizeof(uint32_t),
347  NULL,
350  },
351  //ifName object (1.3.6.1.2.1.31.1.1.1.1)
352  {
353  "ifName",
354  {43, 6, 1, 2, 1, 31, 1, 1, 1, 1},
355  10,
359  NULL,
360  NULL,
361  0,
362  NULL,
365  },
366  //ifInMulticastPkts object (1.3.6.1.2.1.31.1.1.1.2)
367  {
368  "ifInMulticastPkts",
369  {43, 6, 1, 2, 1, 31, 1, 1, 1, 2},
370  10,
374  NULL,
375  NULL,
376  sizeof(uint32_t),
377  NULL,
380  },
381  //ifInBroadcastPkts object (1.3.6.1.2.1.31.1.1.1.3)
382  {
383  "ifInBroadcastPkts",
384  {43, 6, 1, 2, 1, 31, 1, 1, 1, 3},
385  10,
389  NULL,
390  NULL,
391  sizeof(uint32_t),
392  NULL,
395  },
396  //ifOutMulticastPkts object (1.3.6.1.2.1.31.1.1.1.4)
397  {
398  "ifOutMulticastPkts",
399  {43, 6, 1, 2, 1, 31, 1, 1, 1, 4},
400  10,
404  NULL,
405  NULL,
406  sizeof(uint32_t),
407  NULL,
410  },
411  //ifOutBroadcastPkts object (1.3.6.1.2.1.31.1.1.1.5)
412  {
413  "ifOutBroadcastPkts",
414  {43, 6, 1, 2, 1, 31, 1, 1, 1, 5},
415  10,
419  NULL,
420  NULL,
421  sizeof(uint32_t),
422  NULL,
425  },
426  //ifHCInOctets object (1.3.6.1.2.1.31.1.1.1.6)
427  {
428  "ifHCInOctets",
429  {43, 6, 1, 2, 1, 31, 1, 1, 1, 6},
430  10,
434  NULL,
435  NULL,
436  sizeof(uint64_t),
437  NULL,
440  },
441  //ifHCInUcastPkts object (1.3.6.1.2.1.31.1.1.1.7)
442  {
443  "ifHCInUcastPkts",
444  {43, 6, 1, 2, 1, 31, 1, 1, 1, 7},
445  10,
449  NULL,
450  NULL,
451  sizeof(uint64_t),
452  NULL,
455  },
456  //ifHCInMulticastPkts object (1.3.6.1.2.1.31.1.1.1.8)
457  {
458  "ifHCInMulticastPkts",
459  {43, 6, 1, 2, 1, 31, 1, 1, 1, 8},
460  10,
464  NULL,
465  NULL,
466  sizeof(uint64_t),
467  NULL,
470  },
471  //ifHCInBroadcastPkts object (1.3.6.1.2.1.31.1.1.1.9)
472  {
473  "ifHCInBroadcastPkts",
474  {43, 6, 1, 2, 1, 31, 1, 1, 1, 9},
475  10,
479  NULL,
480  NULL,
481  sizeof(uint64_t),
482  NULL,
485  },
486  //ifHCOutOctets object (1.3.6.1.2.1.31.1.1.1.10)
487  {
488  "ifHCOutOctets",
489  {43, 6, 1, 2, 1, 31, 1, 1, 1, 10},
490  10,
494  NULL,
495  NULL,
496  sizeof(uint64_t),
497  NULL,
500  },
501  //ifHCOutUcastPkts object (1.3.6.1.2.1.31.1.1.1.11)
502  {
503  "ifHCOutUcastPkts",
504  {43, 6, 1, 2, 1, 31, 1, 1, 1, 11},
505  10,
509  NULL,
510  NULL,
511  sizeof(uint64_t),
512  NULL,
515  },
516  //ifHCOutMulticastPkts object (1.3.6.1.2.1.31.1.1.1.12)
517  {
518  "ifHCOutMulticastPkts",
519  {43, 6, 1, 2, 1, 31, 1, 1, 1, 12},
520  10,
524  NULL,
525  NULL,
526  sizeof(uint64_t),
527  NULL,
530  },
531  //ifHCOutBroadcastPkts object (1.3.6.1.2.1.31.1.1.1.13)
532  {
533  "ifHCOutBroadcastPkts",
534  {43, 6, 1, 2, 1, 31, 1, 1, 1, 13},
535  10,
539  NULL,
540  NULL,
541  sizeof(uint64_t),
542  NULL,
545  },
546  //ifLinkUpDownTrapEnable object (1.3.6.1.2.1.31.1.1.1.14)
547  {
548  "ifLinkUpDownTrapEnable",
549  {43, 6, 1, 2, 1, 31, 1, 1, 1, 14},
550  10,
554  NULL,
555  NULL,
556  sizeof(int32_t),
560  },
561  //ifHighSpeed object (1.3.6.1.2.1.31.1.1.1.15)
562  {
563  "ifHighSpeed",
564  {43, 6, 1, 2, 1, 31, 1, 1, 1, 15},
565  10,
569  NULL,
570  NULL,
571  sizeof(uint32_t),
572  NULL,
575  },
576  //ifPromiscuousMode object (1.3.6.1.2.1.31.1.1.1.16)
577  {
578  "ifPromiscuousMode",
579  {43, 6, 1, 2, 1, 31, 1, 1, 1, 16},
580  10,
584  NULL,
585  NULL,
586  sizeof(int32_t),
590  },
591  //ifConnectorPresent object (1.3.6.1.2.1.31.1.1.1.17)
592  {
593  "ifConnectorPresent",
594  {43, 6, 1, 2, 1, 31, 1, 1, 1, 17},
595  10,
599  NULL,
600  NULL,
601  sizeof(int32_t),
602  NULL,
605  },
606  //ifAlias object (1.3.6.1.2.1.31.1.1.1.18)
607  {
608  "ifAlias",
609  {43, 6, 1, 2, 1, 31, 1, 1, 1, 18},
610  10,
614  NULL,
615  NULL,
616  0,
620  },
621  //ifCounterDiscontinuityTime object (1.3.6.1.2.1.31.1.1.1.19)
622  {
623  "ifCounterDiscontinuityTime",
624  {43, 6, 1, 2, 1, 31, 1, 1, 1, 19},
625  10,
629  NULL,
630  NULL,
631  sizeof(uint32_t),
632  NULL,
635  },
636  //ifStackStatus object (1.3.6.1.2.1.31.1.2.1.3)
637  {
638  "ifStackStatus",
639  {43, 6, 1, 2, 1, 31, 1, 2, 1, 3},
640  10,
644  NULL,
645  NULL,
646  sizeof(int32_t),
650  },
651  //ifRcvAddressStatus object (1.3.6.1.2.1.31.1.4.1.2)
652  {
653  "ifRcvAddressStatus",
654  {43, 6, 1, 2, 1, 31, 1, 4, 1, 2},
655  10,
659  NULL,
660  NULL,
661  sizeof(int32_t),
665  },
666  //ifRcvAddressType object (1.3.6.1.2.1.31.1.4.1.3)
667  {
668  "ifRcvAddressType",
669  {43, 6, 1, 2, 1, 31, 1, 4, 1, 3},
670  10,
674  NULL,
675  NULL,
676  sizeof(int32_t),
680  },
681  //ifTableLastChange object (1.3.6.1.2.1.31.1.5)
682  {
683  "ifTableLastChange",
684  {43, 6, 1, 2, 1, 31, 1, 5},
685  8,
690  NULL,
691  sizeof(uint32_t),
692  NULL,
693  NULL,
694  NULL
695  },
696  //ifStackLastChange object (1.3.6.1.2.1.31.1.6)
697  {
698  "ifStackLastChange",
699  {43, 6, 1, 2, 1, 31, 1, 6},
700  8,
705  NULL,
706  sizeof(uint32_t),
707  NULL,
708  NULL,
709  NULL
710  }
711 };
712 
713 
714 /**
715  * @brief Interfaces Group MIB module
716  **/
717 
719 {
720  "IF-MIB",
721  {43, 6, 1, 2, 1, 31},
722  6,
723  ifMibObjects,
725  ifMibInit,
726  NULL,
727  NULL,
728  NULL,
729  NULL
730 };
731 
732 #endif
Interfaces Group MIB base.
error_t ifMibGetNextIfEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, uint8_t *nextOid, size_t *nextOidLen)
Get next ifEntry object.
Definition: if_mib_impl.c:350
error_t ifMibInit(void)
Interfaces Group MIB module initialization.
Definition: if_mib_impl.c:51
Interfaces Group MIB module.
error_t ifMibGetNextIfStackEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, uint8_t *nextOid, size_t *nextOidLen)
Get next ifStackEntry object.
Definition: if_mib_impl.c:748
IfMibBase ifMibBase
Interfaces Group MIB base.
Definition: if_mib_module.c:57
TCP/IP stack core.
Debugging facilities.
error_t ifMibSetIfEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
Set ifEntry object value.
Definition: if_mib_impl.c:92
#define MibObject
Definition: mib_common.h:44
General definitions for cryptographic algorithms.
OID (Object Identifier)
error_t ifMibGetIfRcvAddressEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get ifRcvAddressEntry object value.
Definition: if_mib_impl.c:847
uint32_t ifTableLastChange
Interfaces Group MIB module implementation.
#define arraysize(a)
Definition: os_port.h:68
ASN.1 (Abstract Syntax Notation One)
#define ASN1_CLASS_APPLICATION
Definition: asn1.h:46
const MibObject ifMibObjects[]
Interfaces Group MIB objects.
Definition: if_mib_module.c:64
const MibModule ifMibModule
Interfaces Group MIB module.
error_t ifMibGetIfXEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get ifXEntry object value.
Definition: if_mib_impl.c:423
uint32_t ifStackLastChange
error_t ifMibGetNextIfRcvAddressEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, uint8_t *nextOid, size_t *nextOidLen)
Get next ifRcvAddressEntry object.
Definition: if_mib_impl.c:968
error_t ifMibSetIfStackEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
Set ifStackEntry object value.
Definition: if_mib_impl.c:660
Common definitions for MIB modules.
error_t ifMibGetIfEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get ifEntry object value.
Definition: if_mib_impl.c:110
#define ASN1_CLASS_UNIVERSAL
Definition: asn1.h:45
int32_t ifNumber
MIB module.
Definition: mib_common.h:285
error_t ifMibGetNextIfXEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, uint8_t *nextOid, size_t *nextOidLen)
Get next ifXEntry object.
Definition: if_mib_impl.c:605
error_t ifMibSetIfRcvAddressEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
Set ifRcvAddressEntry object value.
Definition: if_mib_impl.c:829
error_t ifMibSetIfXEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, const MibVariant *value, size_t valueLen, bool_t commit)
Set ifXEntry object value.
Definition: if_mib_impl.c:405
error_t ifMibGetIfStackEntry(const MibObject *object, const uint8_t *oid, size_t oidLen, MibVariant *value, size_t *valueLen)
Get ifStackEntry object value.
Definition: if_mib_impl.c:678