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  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2019 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @section Description
28  *
29  * The IF-MIB describes managed objects used for managing network
30  * interfaces. Refer to the following RFCs for complete details:
31  * - RFC 2233: The Interfaces Group MIB using SMIv2
32  * - RFC 2863: The Interfaces Group MIB
33  *
34  * @author Oryx Embedded SARL (www.oryx-embedded.com)
35  * @version 1.9.6
36  **/
37 
38 //Switch to the appropriate trace level
39 #define TRACE_LEVEL SNMP_TRACE_LEVEL
40 
41 //Dependencies
42 #include "core/net.h"
43 #include "mibs/mib_common.h"
44 #include "mibs/if_mib_module.h"
45 #include "mibs/if_mib_impl.h"
46 #include "core/crypto.h"
47 #include "encoding/asn1.h"
48 #include "encoding/oid.h"
49 #include "debug.h"
50 
51 //Check TCP/IP stack configuration
52 #if (IF_MIB_SUPPORT == ENABLED)
53 
54 
55 /**
56  * @brief Interfaces Group MIB base
57  **/
58 
60 
61 
62 /**
63  * @brief Interfaces Group MIB objects
64  **/
65 
67 {
68  //ifNumber object (1.3.6.1.2.1.2.1)
69  {
70  "ifNumber",
71  {43, 6, 1, 2, 1, 2, 1},
72  7,
77  NULL,
78  sizeof(int32_t),
79  NULL,
80  NULL,
81  NULL
82  },
83  //ifIndex object (1.3.6.1.2.1.2.2.1.1)
84  {
85  "ifIndex",
86  {43, 6, 1, 2, 1, 2, 2, 1, 1},
87  9,
91  NULL,
92  NULL,
93  sizeof(int32_t),
94  NULL,
97  },
98  //ifDescr object (1.3.6.1.2.1.2.2.1.2)
99  {
100  "ifDescr",
101  {43, 6, 1, 2, 1, 2, 2, 1, 2},
102  9,
106  NULL,
107  NULL,
108  0,
109  NULL,
112  },
113  //ifType object (1.3.6.1.2.1.2.2.1.3)
114  {
115  "ifType",
116  {43, 6, 1, 2, 1, 2, 2, 1, 3},
117  9,
121  NULL,
122  NULL,
123  sizeof(int32_t),
124  NULL,
127  },
128  //ifMtu object (1.3.6.1.2.1.2.2.1.4)
129  {
130  "ifMtu",
131  {43, 6, 1, 2, 1, 2, 2, 1, 4},
132  9,
136  NULL,
137  NULL,
138  sizeof(int32_t),
139  NULL,
142  },
143  //ifSpeed object (1.3.6.1.2.1.2.2.1.5)
144  {
145  "ifSpeed",
146  {43, 6, 1, 2, 1, 2, 2, 1, 5},
147  9,
151  NULL,
152  NULL,
153  sizeof(uint32_t),
154  NULL,
157  },
158  //ifPhysAddress object (1.3.6.1.2.1.2.2.1.6)
159  {
160  "ifPhysAddress",
161  {43, 6, 1, 2, 1, 2, 2, 1, 6},
162  9,
166  NULL,
167  NULL,
168  0,
169  NULL,
172  },
173  //ifAdminStatus object (1.3.6.1.2.1.2.2.1.7)
174  {
175  "ifAdminStatus",
176  {43, 6, 1, 2, 1, 2, 2, 1, 7},
177  9,
181  NULL,
182  NULL,
183  sizeof(int32_t),
187  },
188  //ifOperStatus object (1.3.6.1.2.1.2.2.1.8)
189  {
190  "ifOperStatus",
191  {43, 6, 1, 2, 1, 2, 2, 1, 8},
192  9,
196  NULL,
197  NULL,
198  sizeof(int32_t),
199  NULL,
202  },
203  //ifLastChange object (1.3.6.1.2.1.2.2.1.9)
204  {
205  "ifLastChange",
206  {43, 6, 1, 2, 1, 2, 2, 1, 9},
207  9,
211  NULL,
212  NULL,
213  sizeof(uint32_t),
214  NULL,
217  },
218  //ifInOctets object (1.3.6.1.2.1.2.2.1.10)
219  {
220  "ifInOctets",
221  {43, 6, 1, 2, 1, 2, 2, 1, 10},
222  9,
226  NULL,
227  NULL,
228  sizeof(uint32_t),
229  NULL,
232  },
233  //ifInUcastPkts object (1.3.6.1.2.1.2.2.1.11)
234  {
235  "ifInUcastPkts",
236  {43, 6, 1, 2, 1, 2, 2, 1, 11},
237  9,
241  NULL,
242  NULL,
243  sizeof(uint32_t),
244  NULL,
247  },
248  //ifInDiscards object (1.3.6.1.2.1.2.2.1.13)
249  {
250  "ifInDiscards",
251  {43, 6, 1, 2, 1, 2, 2, 1, 13},
252  9,
256  NULL,
257  NULL,
258  sizeof(uint32_t),
259  NULL,
262  },
263  //ifInErrors object (1.3.6.1.2.1.2.2.1.14)
264  {
265  "ifInErrors",
266  {43, 6, 1, 2, 1, 2, 2, 1, 14},
267  9,
271  NULL,
272  NULL,
273  sizeof(uint32_t),
274  NULL,
277  },
278  //ifInUnknownProtos object (1.3.6.1.2.1.2.2.1.15)
279  {
280  "ifInUnknownProtos",
281  {43, 6, 1, 2, 1, 2, 2, 1, 15},
282  9,
286  NULL,
287  NULL,
288  sizeof(uint32_t),
289  NULL,
292  },
293  //ifOutOctets object (1.3.6.1.2.1.2.2.1.16)
294  {
295  "ifOutOctets",
296  {43, 6, 1, 2, 1, 2, 2, 1, 16},
297  9,
301  NULL,
302  NULL,
303  sizeof(uint32_t),
304  NULL,
307  },
308  //ifOutUcastPkts object (1.3.6.1.2.1.2.2.1.17)
309  {
310  "ifOutUcastPkts",
311  {43, 6, 1, 2, 1, 2, 2, 1, 17},
312  9,
316  NULL,
317  NULL,
318  sizeof(uint32_t),
319  NULL,
322  },
323  //ifOutDiscards object (1.3.6.1.2.1.2.2.1.19)
324  {
325  "ifOutDiscards",
326  {43, 6, 1, 2, 1, 2, 2, 1, 19},
327  9,
331  NULL,
332  NULL,
333  sizeof(uint32_t),
334  NULL,
337  },
338  //ifOutErrors object (1.3.6.1.2.1.2.2.1.20)
339  {
340  "ifOutErrors",
341  {43, 6, 1, 2, 1, 2, 2, 1, 20},
342  9,
346  NULL,
347  NULL,
348  sizeof(uint32_t),
349  NULL,
352  },
353  //ifName object (1.3.6.1.2.1.31.1.1.1.1)
354  {
355  "ifName",
356  {43, 6, 1, 2, 1, 31, 1, 1, 1, 1},
357  10,
361  NULL,
362  NULL,
363  0,
364  NULL,
367  },
368  //ifInMulticastPkts object (1.3.6.1.2.1.31.1.1.1.2)
369  {
370  "ifInMulticastPkts",
371  {43, 6, 1, 2, 1, 31, 1, 1, 1, 2},
372  10,
376  NULL,
377  NULL,
378  sizeof(uint32_t),
379  NULL,
382  },
383  //ifInBroadcastPkts object (1.3.6.1.2.1.31.1.1.1.3)
384  {
385  "ifInBroadcastPkts",
386  {43, 6, 1, 2, 1, 31, 1, 1, 1, 3},
387  10,
391  NULL,
392  NULL,
393  sizeof(uint32_t),
394  NULL,
397  },
398  //ifOutMulticastPkts object (1.3.6.1.2.1.31.1.1.1.4)
399  {
400  "ifOutMulticastPkts",
401  {43, 6, 1, 2, 1, 31, 1, 1, 1, 4},
402  10,
406  NULL,
407  NULL,
408  sizeof(uint32_t),
409  NULL,
412  },
413  //ifOutBroadcastPkts object (1.3.6.1.2.1.31.1.1.1.5)
414  {
415  "ifOutBroadcastPkts",
416  {43, 6, 1, 2, 1, 31, 1, 1, 1, 5},
417  10,
421  NULL,
422  NULL,
423  sizeof(uint32_t),
424  NULL,
427  },
428  //ifHCInOctets object (1.3.6.1.2.1.31.1.1.1.6)
429  {
430  "ifHCInOctets",
431  {43, 6, 1, 2, 1, 31, 1, 1, 1, 6},
432  10,
436  NULL,
437  NULL,
438  sizeof(uint64_t),
439  NULL,
442  },
443  //ifHCInUcastPkts object (1.3.6.1.2.1.31.1.1.1.7)
444  {
445  "ifHCInUcastPkts",
446  {43, 6, 1, 2, 1, 31, 1, 1, 1, 7},
447  10,
451  NULL,
452  NULL,
453  sizeof(uint64_t),
454  NULL,
457  },
458  //ifHCInMulticastPkts object (1.3.6.1.2.1.31.1.1.1.8)
459  {
460  "ifHCInMulticastPkts",
461  {43, 6, 1, 2, 1, 31, 1, 1, 1, 8},
462  10,
466  NULL,
467  NULL,
468  sizeof(uint64_t),
469  NULL,
472  },
473  //ifHCInBroadcastPkts object (1.3.6.1.2.1.31.1.1.1.9)
474  {
475  "ifHCInBroadcastPkts",
476  {43, 6, 1, 2, 1, 31, 1, 1, 1, 9},
477  10,
481  NULL,
482  NULL,
483  sizeof(uint64_t),
484  NULL,
487  },
488  //ifHCOutOctets object (1.3.6.1.2.1.31.1.1.1.10)
489  {
490  "ifHCOutOctets",
491  {43, 6, 1, 2, 1, 31, 1, 1, 1, 10},
492  10,
496  NULL,
497  NULL,
498  sizeof(uint64_t),
499  NULL,
502  },
503  //ifHCOutUcastPkts object (1.3.6.1.2.1.31.1.1.1.11)
504  {
505  "ifHCOutUcastPkts",
506  {43, 6, 1, 2, 1, 31, 1, 1, 1, 11},
507  10,
511  NULL,
512  NULL,
513  sizeof(uint64_t),
514  NULL,
517  },
518  //ifHCOutMulticastPkts object (1.3.6.1.2.1.31.1.1.1.12)
519  {
520  "ifHCOutMulticastPkts",
521  {43, 6, 1, 2, 1, 31, 1, 1, 1, 12},
522  10,
526  NULL,
527  NULL,
528  sizeof(uint64_t),
529  NULL,
532  },
533  //ifHCOutBroadcastPkts object (1.3.6.1.2.1.31.1.1.1.13)
534  {
535  "ifHCOutBroadcastPkts",
536  {43, 6, 1, 2, 1, 31, 1, 1, 1, 13},
537  10,
541  NULL,
542  NULL,
543  sizeof(uint64_t),
544  NULL,
547  },
548  //ifLinkUpDownTrapEnable object (1.3.6.1.2.1.31.1.1.1.14)
549  {
550  "ifLinkUpDownTrapEnable",
551  {43, 6, 1, 2, 1, 31, 1, 1, 1, 14},
552  10,
556  NULL,
557  NULL,
558  sizeof(int32_t),
562  },
563  //ifHighSpeed object (1.3.6.1.2.1.31.1.1.1.15)
564  {
565  "ifHighSpeed",
566  {43, 6, 1, 2, 1, 31, 1, 1, 1, 15},
567  10,
571  NULL,
572  NULL,
573  sizeof(uint32_t),
574  NULL,
577  },
578  //ifPromiscuousMode object (1.3.6.1.2.1.31.1.1.1.16)
579  {
580  "ifPromiscuousMode",
581  {43, 6, 1, 2, 1, 31, 1, 1, 1, 16},
582  10,
586  NULL,
587  NULL,
588  sizeof(int32_t),
592  },
593  //ifConnectorPresent object (1.3.6.1.2.1.31.1.1.1.17)
594  {
595  "ifConnectorPresent",
596  {43, 6, 1, 2, 1, 31, 1, 1, 1, 17},
597  10,
601  NULL,
602  NULL,
603  sizeof(int32_t),
604  NULL,
607  },
608  //ifAlias object (1.3.6.1.2.1.31.1.1.1.18)
609  {
610  "ifAlias",
611  {43, 6, 1, 2, 1, 31, 1, 1, 1, 18},
612  10,
616  NULL,
617  NULL,
618  0,
622  },
623  //ifCounterDiscontinuityTime object (1.3.6.1.2.1.31.1.1.1.19)
624  {
625  "ifCounterDiscontinuityTime",
626  {43, 6, 1, 2, 1, 31, 1, 1, 1, 19},
627  10,
631  NULL,
632  NULL,
633  sizeof(uint32_t),
634  NULL,
637  },
638  //ifStackStatus object (1.3.6.1.2.1.31.1.2.1.3)
639  {
640  "ifStackStatus",
641  {43, 6, 1, 2, 1, 31, 1, 2, 1, 3},
642  10,
646  NULL,
647  NULL,
648  sizeof(int32_t),
652  },
653  //ifRcvAddressStatus object (1.3.6.1.2.1.31.1.4.1.2)
654  {
655  "ifRcvAddressStatus",
656  {43, 6, 1, 2, 1, 31, 1, 4, 1, 2},
657  10,
661  NULL,
662  NULL,
663  sizeof(int32_t),
667  },
668  //ifRcvAddressType object (1.3.6.1.2.1.31.1.4.1.3)
669  {
670  "ifRcvAddressType",
671  {43, 6, 1, 2, 1, 31, 1, 4, 1, 3},
672  10,
676  NULL,
677  NULL,
678  sizeof(int32_t),
682  },
683  //ifTableLastChange object (1.3.6.1.2.1.31.1.5)
684  {
685  "ifTableLastChange",
686  {43, 6, 1, 2, 1, 31, 1, 5},
687  8,
692  NULL,
693  sizeof(uint32_t),
694  NULL,
695  NULL,
696  NULL
697  },
698  //ifStackLastChange object (1.3.6.1.2.1.31.1.6)
699  {
700  "ifStackLastChange",
701  {43, 6, 1, 2, 1, 31, 1, 6},
702  8,
707  NULL,
708  sizeof(uint32_t),
709  NULL,
710  NULL,
711  NULL
712  }
713 };
714 
715 
716 /**
717  * @brief Interfaces Group MIB module
718  **/
719 
721 {
722  "IF-MIB",
723  {43, 6, 1, 2, 1, 31},
724  6,
725  ifMibObjects,
727  ifMibInit,
728  NULL,
729  NULL,
730  NULL,
731  NULL
732 };
733 
734 #endif
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:662
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:112
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:607
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:831
OID (Object Identifier)
int32_t ifNumber
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:407
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:680
@ MIB_ACCESS_READ_ONLY
Definition: mib_common.h:79
IfMibBase ifMibBase
Interfaces Group MIB base.
Definition: if_mib_module.c:59
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:750
Interfaces Group MIB module implementation.
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:352
error_t ifMibInit(void)
Interfaces Group MIB module initialization.
Definition: if_mib_impl.c:53
@ MIB_ACCESS_READ_WRITE
Definition: mib_common.h:80
@ MIB_TYPE_COUNTER32
Definition: mib_common.h:61
@ MIB_TYPE_GAUGE32
Definition: mib_common.h:62
uint32_t ifTableLastChange
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:94
#define ASN1_CLASS_UNIVERSAL
Definition: asn1.h:48
General definitions for cryptographic algorithms.
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:849
Interfaces Group MIB module.
MIB module.
Definition: mib_common.h:287
@ ASN1_TYPE_OCTET_STRING
Definition: asn1.h:68
@ ASN1_TYPE_INTEGER
Definition: asn1.h:66
uint32_t ifStackLastChange
@ MIB_TYPE_TIME_TICKS
Definition: mib_common.h:64
Common definitions for MIB modules.
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:425
#define MibObject
Definition: mib_common.h:46
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:970
@ MIB_TYPE_COUNTER64
Definition: mib_common.h:66
TCP/IP stack core.
const MibModule ifMibModule
Interfaces Group MIB module.
#define ASN1_CLASS_APPLICATION
Definition: asn1.h:49
Interfaces Group MIB base.
@ MIB_ACCESS_READ_CREATE
Definition: mib_common.h:81
Debugging facilities.
ASN.1 (Abstract Syntax Notation One)
const MibObject ifMibObjects[]
Interfaces Group MIB objects.
Definition: if_mib_module.c:66
#define arraysize(a)
Definition: os_port.h:70