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-2024 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 2.4.0
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 #if (ETH_SUPPORT == ENABLED)
159  //ifPhysAddress object (1.3.6.1.2.1.2.2.1.6)
160  {
161  "ifPhysAddress",
162  {43, 6, 1, 2, 1, 2, 2, 1, 6},
163  9,
167  NULL,
168  NULL,
169  0,
170  NULL,
173  },
174 #endif
175  //ifAdminStatus object (1.3.6.1.2.1.2.2.1.7)
176  {
177  "ifAdminStatus",
178  {43, 6, 1, 2, 1, 2, 2, 1, 7},
179  9,
183  NULL,
184  NULL,
185  sizeof(int32_t),
189  },
190  //ifOperStatus object (1.3.6.1.2.1.2.2.1.8)
191  {
192  "ifOperStatus",
193  {43, 6, 1, 2, 1, 2, 2, 1, 8},
194  9,
198  NULL,
199  NULL,
200  sizeof(int32_t),
201  NULL,
204  },
205  //ifLastChange object (1.3.6.1.2.1.2.2.1.9)
206  {
207  "ifLastChange",
208  {43, 6, 1, 2, 1, 2, 2, 1, 9},
209  9,
213  NULL,
214  NULL,
215  sizeof(uint32_t),
216  NULL,
219  },
220  //ifInOctets object (1.3.6.1.2.1.2.2.1.10)
221  {
222  "ifInOctets",
223  {43, 6, 1, 2, 1, 2, 2, 1, 10},
224  9,
228  NULL,
229  NULL,
230  sizeof(uint32_t),
231  NULL,
234  },
235  //ifInUcastPkts object (1.3.6.1.2.1.2.2.1.11)
236  {
237  "ifInUcastPkts",
238  {43, 6, 1, 2, 1, 2, 2, 1, 11},
239  9,
243  NULL,
244  NULL,
245  sizeof(uint32_t),
246  NULL,
249  },
250  //ifInDiscards object (1.3.6.1.2.1.2.2.1.13)
251  {
252  "ifInDiscards",
253  {43, 6, 1, 2, 1, 2, 2, 1, 13},
254  9,
258  NULL,
259  NULL,
260  sizeof(uint32_t),
261  NULL,
264  },
265  //ifInErrors object (1.3.6.1.2.1.2.2.1.14)
266  {
267  "ifInErrors",
268  {43, 6, 1, 2, 1, 2, 2, 1, 14},
269  9,
273  NULL,
274  NULL,
275  sizeof(uint32_t),
276  NULL,
279  },
280  //ifInUnknownProtos object (1.3.6.1.2.1.2.2.1.15)
281  {
282  "ifInUnknownProtos",
283  {43, 6, 1, 2, 1, 2, 2, 1, 15},
284  9,
288  NULL,
289  NULL,
290  sizeof(uint32_t),
291  NULL,
294  },
295  //ifOutOctets object (1.3.6.1.2.1.2.2.1.16)
296  {
297  "ifOutOctets",
298  {43, 6, 1, 2, 1, 2, 2, 1, 16},
299  9,
303  NULL,
304  NULL,
305  sizeof(uint32_t),
306  NULL,
309  },
310  //ifOutUcastPkts object (1.3.6.1.2.1.2.2.1.17)
311  {
312  "ifOutUcastPkts",
313  {43, 6, 1, 2, 1, 2, 2, 1, 17},
314  9,
318  NULL,
319  NULL,
320  sizeof(uint32_t),
321  NULL,
324  },
325  //ifOutDiscards object (1.3.6.1.2.1.2.2.1.19)
326  {
327  "ifOutDiscards",
328  {43, 6, 1, 2, 1, 2, 2, 1, 19},
329  9,
333  NULL,
334  NULL,
335  sizeof(uint32_t),
336  NULL,
339  },
340  //ifOutErrors object (1.3.6.1.2.1.2.2.1.20)
341  {
342  "ifOutErrors",
343  {43, 6, 1, 2, 1, 2, 2, 1, 20},
344  9,
348  NULL,
349  NULL,
350  sizeof(uint32_t),
351  NULL,
354  },
355  //ifName object (1.3.6.1.2.1.31.1.1.1.1)
356  {
357  "ifName",
358  {43, 6, 1, 2, 1, 31, 1, 1, 1, 1},
359  10,
363  NULL,
364  NULL,
365  0,
366  NULL,
369  },
370  //ifInMulticastPkts object (1.3.6.1.2.1.31.1.1.1.2)
371  {
372  "ifInMulticastPkts",
373  {43, 6, 1, 2, 1, 31, 1, 1, 1, 2},
374  10,
378  NULL,
379  NULL,
380  sizeof(uint32_t),
381  NULL,
384  },
385  //ifInBroadcastPkts object (1.3.6.1.2.1.31.1.1.1.3)
386  {
387  "ifInBroadcastPkts",
388  {43, 6, 1, 2, 1, 31, 1, 1, 1, 3},
389  10,
393  NULL,
394  NULL,
395  sizeof(uint32_t),
396  NULL,
399  },
400  //ifOutMulticastPkts object (1.3.6.1.2.1.31.1.1.1.4)
401  {
402  "ifOutMulticastPkts",
403  {43, 6, 1, 2, 1, 31, 1, 1, 1, 4},
404  10,
408  NULL,
409  NULL,
410  sizeof(uint32_t),
411  NULL,
414  },
415  //ifOutBroadcastPkts object (1.3.6.1.2.1.31.1.1.1.5)
416  {
417  "ifOutBroadcastPkts",
418  {43, 6, 1, 2, 1, 31, 1, 1, 1, 5},
419  10,
423  NULL,
424  NULL,
425  sizeof(uint32_t),
426  NULL,
429  },
430  //ifHCInOctets object (1.3.6.1.2.1.31.1.1.1.6)
431  {
432  "ifHCInOctets",
433  {43, 6, 1, 2, 1, 31, 1, 1, 1, 6},
434  10,
438  NULL,
439  NULL,
440  sizeof(uint64_t),
441  NULL,
444  },
445  //ifHCInUcastPkts object (1.3.6.1.2.1.31.1.1.1.7)
446  {
447  "ifHCInUcastPkts",
448  {43, 6, 1, 2, 1, 31, 1, 1, 1, 7},
449  10,
453  NULL,
454  NULL,
455  sizeof(uint64_t),
456  NULL,
459  },
460  //ifHCInMulticastPkts object (1.3.6.1.2.1.31.1.1.1.8)
461  {
462  "ifHCInMulticastPkts",
463  {43, 6, 1, 2, 1, 31, 1, 1, 1, 8},
464  10,
468  NULL,
469  NULL,
470  sizeof(uint64_t),
471  NULL,
474  },
475  //ifHCInBroadcastPkts object (1.3.6.1.2.1.31.1.1.1.9)
476  {
477  "ifHCInBroadcastPkts",
478  {43, 6, 1, 2, 1, 31, 1, 1, 1, 9},
479  10,
483  NULL,
484  NULL,
485  sizeof(uint64_t),
486  NULL,
489  },
490  //ifHCOutOctets object (1.3.6.1.2.1.31.1.1.1.10)
491  {
492  "ifHCOutOctets",
493  {43, 6, 1, 2, 1, 31, 1, 1, 1, 10},
494  10,
498  NULL,
499  NULL,
500  sizeof(uint64_t),
501  NULL,
504  },
505  //ifHCOutUcastPkts object (1.3.6.1.2.1.31.1.1.1.11)
506  {
507  "ifHCOutUcastPkts",
508  {43, 6, 1, 2, 1, 31, 1, 1, 1, 11},
509  10,
513  NULL,
514  NULL,
515  sizeof(uint64_t),
516  NULL,
519  },
520  //ifHCOutMulticastPkts object (1.3.6.1.2.1.31.1.1.1.12)
521  {
522  "ifHCOutMulticastPkts",
523  {43, 6, 1, 2, 1, 31, 1, 1, 1, 12},
524  10,
528  NULL,
529  NULL,
530  sizeof(uint64_t),
531  NULL,
534  },
535  //ifHCOutBroadcastPkts object (1.3.6.1.2.1.31.1.1.1.13)
536  {
537  "ifHCOutBroadcastPkts",
538  {43, 6, 1, 2, 1, 31, 1, 1, 1, 13},
539  10,
543  NULL,
544  NULL,
545  sizeof(uint64_t),
546  NULL,
549  },
550  //ifLinkUpDownTrapEnable object (1.3.6.1.2.1.31.1.1.1.14)
551  {
552  "ifLinkUpDownTrapEnable",
553  {43, 6, 1, 2, 1, 31, 1, 1, 1, 14},
554  10,
558  NULL,
559  NULL,
560  sizeof(int32_t),
564  },
565  //ifHighSpeed object (1.3.6.1.2.1.31.1.1.1.15)
566  {
567  "ifHighSpeed",
568  {43, 6, 1, 2, 1, 31, 1, 1, 1, 15},
569  10,
573  NULL,
574  NULL,
575  sizeof(uint32_t),
576  NULL,
579  },
580  //ifPromiscuousMode object (1.3.6.1.2.1.31.1.1.1.16)
581  {
582  "ifPromiscuousMode",
583  {43, 6, 1, 2, 1, 31, 1, 1, 1, 16},
584  10,
588  NULL,
589  NULL,
590  sizeof(int32_t),
594  },
595  //ifConnectorPresent object (1.3.6.1.2.1.31.1.1.1.17)
596  {
597  "ifConnectorPresent",
598  {43, 6, 1, 2, 1, 31, 1, 1, 1, 17},
599  10,
603  NULL,
604  NULL,
605  sizeof(int32_t),
606  NULL,
609  },
610  //ifAlias object (1.3.6.1.2.1.31.1.1.1.18)
611  {
612  "ifAlias",
613  {43, 6, 1, 2, 1, 31, 1, 1, 1, 18},
614  10,
618  NULL,
619  NULL,
620  0,
624  },
625  //ifCounterDiscontinuityTime object (1.3.6.1.2.1.31.1.1.1.19)
626  {
627  "ifCounterDiscontinuityTime",
628  {43, 6, 1, 2, 1, 31, 1, 1, 1, 19},
629  10,
633  NULL,
634  NULL,
635  sizeof(uint32_t),
636  NULL,
639  },
640  //ifStackStatus object (1.3.6.1.2.1.31.1.2.1.3)
641  {
642  "ifStackStatus",
643  {43, 6, 1, 2, 1, 31, 1, 2, 1, 3},
644  10,
648  NULL,
649  NULL,
650  sizeof(int32_t),
654  },
655  //ifRcvAddressStatus object (1.3.6.1.2.1.31.1.4.1.2)
656  {
657  "ifRcvAddressStatus",
658  {43, 6, 1, 2, 1, 31, 1, 4, 1, 2},
659  10,
663  NULL,
664  NULL,
665  sizeof(int32_t),
669  },
670  //ifRcvAddressType object (1.3.6.1.2.1.31.1.4.1.3)
671  {
672  "ifRcvAddressType",
673  {43, 6, 1, 2, 1, 31, 1, 4, 1, 3},
674  10,
678  NULL,
679  NULL,
680  sizeof(int32_t),
684  },
685  //ifTableLastChange object (1.3.6.1.2.1.31.1.5)
686  {
687  "ifTableLastChange",
688  {43, 6, 1, 2, 1, 31, 1, 5},
689  8,
694  NULL,
695  sizeof(uint32_t),
696  NULL,
697  NULL,
698  NULL
699  },
700  //ifStackLastChange object (1.3.6.1.2.1.31.1.6)
701  {
702  "ifStackLastChange",
703  {43, 6, 1, 2, 1, 31, 1, 6},
704  8,
709  NULL,
710  sizeof(uint32_t),
711  NULL,
712  NULL,
713  NULL
714  }
715 };
716 
717 
718 /**
719  * @brief Interfaces Group MIB module
720  **/
721 
723 {
724  "IF-MIB",
725  {43, 6, 1, 2, 1, 31},
726  6,
727  ifMibObjects,
729  ifMibInit,
730  NULL,
731  NULL,
732  NULL,
733  NULL
734 };
735 
736 #endif
ASN.1 (Abstract Syntax Notation One)
@ ASN1_TYPE_OCTET_STRING
Definition: asn1.h:72
@ ASN1_TYPE_INTEGER
Definition: asn1.h:70
#define ASN1_CLASS_APPLICATION
Definition: asn1.h:53
#define ASN1_CLASS_UNIVERSAL
Definition: asn1.h:52
General definitions for cryptographic algorithms.
Debugging facilities.
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:423
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:851
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:678
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:995
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 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:770
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:696
error_t ifMibInit(void)
Interfaces Group MIB module initialization.
Definition: if_mib_impl.c:53
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:368
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:623
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:441
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:869
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
Interfaces Group MIB module implementation.
IfMibBase ifMibBase
Interfaces Group MIB base.
Definition: if_mib_module.c:59
const MibModule ifMibModule
Interfaces Group MIB module.
const MibObject ifMibObjects[]
Interfaces Group MIB objects.
Definition: if_mib_module.c:66
Interfaces Group MIB module.
Common definitions for MIB modules.
#define MibObject
Definition: mib_common.h:46
@ MIB_ACCESS_READ_ONLY
Definition: mib_common.h:79
@ MIB_ACCESS_READ_CREATE
Definition: mib_common.h:81
@ MIB_ACCESS_READ_WRITE
Definition: mib_common.h:80
@ MIB_TYPE_TIME_TICKS
Definition: mib_common.h:64
@ MIB_TYPE_COUNTER32
Definition: mib_common.h:61
@ MIB_TYPE_COUNTER64
Definition: mib_common.h:66
@ MIB_TYPE_GAUGE32
Definition: mib_common.h:62
TCP/IP stack core.
OID (Object Identifier)
#define arraysize(a)
Definition: os_port.h:71
Interfaces Group MIB base.
uint32_t ifTableLastChange
uint32_t ifStackLastChange
int32_t ifNumber
MIB module.
Definition: mib_common.h:292