mib2_module.h
Go to the documentation of this file.
1 /**
2  * @file mib2_module.h
3  * @brief MIB-II 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  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _MIB2_MODULE_H
30 #define _MIB2_MODULE_H
31 
32 //Dependencies
33 #include "core/net.h"
34 #include "core/udp.h"
35 #include "core/tcp.h"
36 #include "ipv4/ipv4.h"
37 #include "mibs/mib_common.h"
38 
39 //MIB-II module support
40 #ifndef MIB2_SUPPORT
41  #define MIB2_SUPPORT DISABLED
42 #elif (MIB2_SUPPORT != ENABLED && MIB2_SUPPORT != DISABLED)
43  #error MIB2_SUPPORT parameter is not valid
44 #endif
45 
46 //System group support
47 #ifndef MIB2_SYS_GROUP_SUPPORT
48  #define MIB2_SYS_GROUP_SUPPORT ENABLED
49 #elif (MIB2_SYS_GROUP_SUPPORT != ENABLED && MIB2_SYS_GROUP_SUPPORT != DISABLED)
50  #error MIB2_SYS_GROUP_SUPPORT parameter is not valid
51 #endif
52 
53 //Interface group support
54 #ifndef MIB2_IF_GROUP_SUPPORT
55  #define MIB2_IF_GROUP_SUPPORT ENABLED
56 #elif (MIB2_IF_GROUP_SUPPORT != ENABLED && MIB2_IF_GROUP_SUPPORT != DISABLED)
57  #error MIB2_IF_GROUP_SUPPORT parameter is not valid
58 #endif
59 
60 //IP group support
61 #ifndef MIB2_IP_GROUP_SUPPORT
62  #define MIB2_IP_GROUP_SUPPORT ENABLED
63 #elif (MIB2_IP_GROUP_SUPPORT != ENABLED && MIB2_IP_GROUP_SUPPORT != DISABLED)
64  #error MIB2_IP_GROUP_SUPPORT parameter is not valid
65 #endif
66 
67 //ICMP group support
68 #ifndef MIB2_ICMP_GROUP_SUPPORT
69  #define MIB2_ICMP_GROUP_SUPPORT ENABLED
70 #elif (MIB2_ICMP_GROUP_SUPPORT != ENABLED && MIB2_ICMP_GROUP_SUPPORT != DISABLED)
71  #errorMIB2_ICMP_GROUP_SUPPORT parameter is not valid
72 #endif
73 
74 //TCP group support
75 #ifndef MIB2_TCP_GROUP_SUPPORT
76  #define MIB2_TCP_GROUP_SUPPORT ENABLED
77 #elif (MIB2_TCP_GROUP_SUPPORT != ENABLED && MIB2_TCP_GROUP_SUPPORT != DISABLED)
78  #error MIB2_TCP_GROUP_SUPPORT parameter is not valid
79 #endif
80 
81 //UDP group support
82 #ifndef MIB2_UDP_GROUP_SUPPORT
83  #define MIB2_UDP_GROUP_SUPPORT ENABLED
84 #elif (MIB2_UDP_GROUP_SUPPORT != ENABLED && MIB2_UDP_GROUP_SUPPORT != DISABLED)
85  #error MIB2_UDP_GROUP_SUPPORT parameter is not valid
86 #endif
87 
88 //SNMP group support
89 #ifndef MIB2_SNMP_GROUP_SUPPORT
90  #define MIB2_SNMP_GROUP_SUPPORT ENABLED
91 #elif (MIB2_SNMP_GROUP_SUPPORT != ENABLED && MIB2_SNMP_GROUP_SUPPORT != DISABLED)
92  #error MIB2_SNMP_GROUP_SUPPORT parameter is not valid
93 #endif
94 
95 //Size of sysDescr object
96 #ifndef MIB2_SYS_DESCR_SIZE
97  #define MIB2_SYS_DESCR_SIZE 16
98 #elif (MIB2_SYS_DESCR_SIZE < 0)
99  #error MIB2_SYS_DESCR_SIZE parameter is not valid
100 #endif
101 
102 //Size of sysObjectID object
103 #ifndef MIB2_SYS_OBJECT_ID_SIZE
104  #define MIB2_SYS_OBJECT_ID_SIZE 16
105 #elif (MIB2_SYS_OBJECT_ID_SIZE < 0)
106  #error MIB2_SYS_OBJECT_ID_SIZE parameter is not valid
107 #endif
108 
109 //Size of sysContact object
110 #ifndef MIB2_SYS_CONTACT_SIZE
111  #define MIB2_SYS_CONTACT_SIZE 16
112 #elif (MIB2_SYS_CONTACT_SIZE < 0)
113  #error MIB2_SYS_CONTACT_SIZE parameter is not valid
114 #endif
115 
116 //Size of sysName object
117 #ifndef MIB2_SYS_NAME_SIZE
118  #define MIB2_SYS_NAME_SIZE 16
119 #elif (MIB2_SYS_NAME_SIZE < 0)
120  #error MIB2_SYS_NAME_SIZE parameter is not valid
121 #endif
122 
123 //Size of sysLocation object
124 #ifndef MIB2_SYS_LOCATION_SIZE
125  #define MIB2_SYS_LOCATION_SIZE 16
126 #elif (MIB2_SYS_LOCATION_SIZE < 0)
127  #error MIB2_SYS_LOCATION_SIZE parameter is not valid
128 #endif
129 
130 //Size of ifSpecific object
131 #ifndef MIB2_IF_SPECIFIC_SIZE
132  #define MIB2_IF_SPECIFIC_SIZE 16
133 #elif (MIB2_IF_SPECIFIC_SIZE < 1)
134  #error MIB2_IF_SPECIFIC_SIZE parameter is not valid
135 #endif
136 
137 //Size of PhysAddress data type
138 #ifndef MIB2_PHYS_ADDRESS_SIZE
139  #define MIB2_PHYS_ADDRESS_SIZE 6
140 #elif (MIB2_PHYS_ADDRESS_SIZE < 6)
141  #error MIB2_PHYS_ADDRESS_SIZE parameter is not valid
142 #endif
143 
144 //Size of IpAddress data type
145 #ifndef MIB2_IP_ADDRESS_SIZE
146  #define MIB2_IP_ADDRESS_SIZE 4
147 #elif (MIB2_IP_ADDRESS_SIZE != 4)
148  #error MIB2_IP_ADDRESS_SIZE parameter is not valid
149 #endif
150 
151 //Macro definitions
152 #if (MIB2_SUPPORT == ENABLED)
153  #define MIB2_SET_TIME_TICKS(name, value) mib2Base.name = value
154  #define MIB2_INC_COUNTER32(name, value) mib2Base.name += value
155 #else
156  #define MIB2_SET_TIME_TICKS(name, value)
157  #define MIB2_INC_COUNTER32(name, value)
158 #endif
159 
160 //C++ guard
161 #ifdef __cplusplus
162  extern "C" {
163 #endif
164 
165 
166 /**
167  * @brief System services
168  **/
169 
170 typedef enum
171 {
178 
179 
180 /**
181  * @brief Interface types
182  **/
183 
184 typedef enum
185 {
197 } Mib2IfType;
198 
199 
200 /**
201  * @brief The desired state of the interface
202  **/
203 
204 typedef enum
205 {
210 
211 
212 /**
213  * @brief The operational state of the interface
214  **/
215 
216 typedef enum
217 {
222 
223 
224 /**
225  * @brief IP forwarding state
226  **/
227 
228 typedef enum
229 {
233 
234 
235 /**
236  * @brief Type of mapping
237  **/
238 
239 typedef enum
240 {
246 
247 
248 /**
249  * @brief RTO calculation algorithm
250  **/
251 
252 typedef enum
253 {
259 
260 
261 /**
262  * @brief TCP connection states
263  **/
264 
265 typedef enum
266 {
280 
281 
282 /**
283  * @brief System group
284  **/
285 
286 typedef struct
287 {
288 #if (MIB2_SYS_DESCR_SIZE > 0)
290  size_t sysDescrLen;
291 #endif
292 #if (MIB2_SYS_OBJECT_ID_SIZE > 0)
293  uint8_t sysObjectID[MIB2_SYS_OBJECT_ID_SIZE];
295 #endif
296  uint32_t sysUpTime;
297 #if (MIB2_SYS_CONTACT_SIZE > 0)
300 #endif
301 #if (MIB2_SYS_NAME_SIZE > 0)
303  size_t sysNameLen;
304 #endif
305 #if (MIB2_SYS_LOCATION_SIZE > 0)
308 #endif
309  int32_t sysServices;
310 } Mib2SysGroup;
311 
312 
313 /**
314  * @brief Interfaces table entry
315  **/
316 
317 typedef struct
318 {
319  uint32_t ifLastChange;
320  uint32_t ifInOctets;
321  uint32_t ifInUcastPkts;
322  uint32_t ifInNUcastPkts;
323  uint32_t ifInDiscards;
324  uint32_t ifInErrors;
326  uint32_t ifOutOctets;
327  uint32_t ifOutUcastPkts;
328  uint32_t ifOutNUcastPkts;
329  uint32_t ifOutDiscards;
330  uint32_t ifOutErrors;
331  uint32_t ifOutQLen;
332  uint8_t ifSpecific[MIB2_IF_SPECIFIC_SIZE];
334 } Mib2IfEntry;
335 
336 
337 /**
338  * @brief Interfaces group
339  **/
340 
341 typedef struct
342 {
343  int32_t ifNumber;
345 } Mib2IfGroup;
346 
347 
348 /**
349  * @brief IP group
350  **/
351 
352 typedef struct
353 {
354  int32_t ipForwarding;
355  int32_t ipDefaultTTL;
356  uint32_t ipInReceives;
357  uint32_t ipInHdrErrors;
358  uint32_t ipInAddrErrors;
359  uint32_t ipForwDatagrams;
361  uint32_t ipInDiscards;
362  uint32_t ipInDelivers;
363  uint32_t ipOutRequests;
364  uint32_t ipOutDiscards;
365  uint32_t ipOutNoRoutes;
366  int32_t ipReasmTimeout;
367  uint32_t ipReasmReqds;
368  uint32_t ipReasmOKs;
369  uint32_t ipReasmFails;
370  uint32_t ipFragOKs;
371  uint32_t ipFragFails;
372  uint32_t ipFragCreates;
374 } Mib2IpGroup;
375 
376 
377 /**
378  * @brief ICMP group
379  **/
380 
381 typedef struct
382 {
383  uint32_t icmpInMsgs;
384  uint32_t icmpInErrors;
386  uint32_t icmpInTimeExcds;
387  uint32_t icmpInParmProbs;
389  uint32_t icmpInRedirects;
390  uint32_t icmpInEchos;
391  uint32_t icmpInEchoReps;
394  uint32_t icmpInAddrMasks;
396  uint32_t icmpOutMsgs;
397  uint32_t icmpOutErrors;
403  uint32_t icmpOutEchos;
404  uint32_t icmpOutEchoReps;
409 } Mib2IcmpGroup;
410 
411 
412 /**
413  * @brief TCP group
414  **/
415 
416 typedef struct
417 {
419  int32_t tcpRtoMin;
420  int32_t tcpRtoMax;
421  int32_t tcpMaxConn;
422  uint32_t tcpActiveOpens;
423  uint32_t tcpPassiveOpens;
424  uint32_t tcpAttemptFails;
425  uint32_t tcpEstabResets;
426  uint32_t tcpInSegs;
427  uint32_t tcpOutSegs;
428  uint32_t tcpRetransSegs;
429  uint32_t tcpInErrs;
430  uint32_t tcpOutRsts;
431 } Mib2TcpGroup;
432 
433 
434 /**
435  * @brief UDP group
436  **/
437 
438 typedef struct
439 {
440  uint32_t udpInDatagrams;
441  uint32_t udpNoPorts;
442  uint32_t udpInErrors;
443  uint32_t udpOutDatagrams;
444 } Mib2UdpGroup;
445 
446 
447 /**
448  * @brief SNMP group
449  **/
450 
451 typedef struct
452 {
453  uint32_t snmpInPkts;
454  uint32_t snmpOutPkts;
459  uint32_t snmpInTooBigs;
461  uint32_t snmpInBadValues;
462  uint32_t snmpInReadOnlys;
463  uint32_t snmpInGenErrs;
467  uint32_t snmpInGetNexts;
470  uint32_t snmpInTraps;
471  uint32_t snmpOutTooBigs;
474  uint32_t snmpOutGenErrs;
476  uint32_t snmpOutGetNexts;
479  uint32_t snmpOutTraps;
481 } Mib2SnmpGroup;
482 
483 
484 /**
485  * @brief MIB-II base
486  **/
487 
488 typedef struct
489 {
492 #if (IPV4_SUPPORT == ENABLED)
495 #endif
496 #if (TCP_SUPPORT == ENABLED)
498 #endif
499 #if (UDP_SUPPORT == ENABLED)
501 #endif
503 } Mib2Base;
504 
505 
506 //MIB-II related constants
507 extern Mib2Base mib2Base;
508 extern const MibObject mib2Objects[];
509 extern const MibModule mib2Module;
510 
511 //C++ guard
512 #ifdef __cplusplus
513  }
514 #endif
515 
516 #endif
uint32_t snmpInTooBigs
Definition: mib2_module.h:459
TCP group.
Definition: mib2_module.h:416
uint32_t sysUpTime
Definition: mib2_module.h:296
uint32_t snmpInBadVersions
Definition: mib2_module.h:455
Mib2TcpConnState
TCP connection states.
Definition: mib2_module.h:265
uint32_t icmpOutErrors
Definition: mib2_module.h:397
int32_t tcpRtoMax
Definition: mib2_module.h:420
char char_t
Definition: compiler_port.h:41
uint32_t tcpInSegs
Definition: mib2_module.h:426
uint32_t icmpInMsgs
Definition: mib2_module.h:383
size_t sysLocationLen
Definition: mib2_module.h:307
Mib2IfOperStatus
The operational state of the interface.
Definition: mib2_module.h:216
uint32_t icmpOutTimestampReps
Definition: mib2_module.h:406
uint32_t ipFragFails
Definition: mib2_module.h:371
TCP/IP stack core.
uint32_t icmpOutAddrMasks
Definition: mib2_module.h:407
uint32_t ipOutRequests
Definition: mib2_module.h:363
uint32_t snmpOutPkts
Definition: mib2_module.h:454
uint32_t icmpInEchos
Definition: mib2_module.h:390
uint32_t snmpOutGetNexts
Definition: mib2_module.h:476
uint32_t ifOutDiscards
Definition: mib2_module.h:329
int32_t ipReasmTimeout
Definition: mib2_module.h:366
int32_t snmpEnableAuthenTraps
Definition: mib2_module.h:480
uint32_t ipInUnknownProtos
Definition: mib2_module.h:360
uint32_t snmpInTotalReqVars
Definition: mib2_module.h:464
uint32_t tcpInErrs
Definition: mib2_module.h:429
uint32_t udpInErrors
Definition: mib2_module.h:442
uint32_t ipReasmReqds
Definition: mib2_module.h:367
uint32_t snmpInGetResponses
Definition: mib2_module.h:469
#define MibObject
Definition: mib_common.h:44
uint32_t ipInDelivers
Definition: mib2_module.h:362
uint32_t ifInUnknownProtos
Definition: mib2_module.h:325
uint32_t ipInHdrErrors
Definition: mib2_module.h:357
uint32_t snmpInPkts
Definition: mib2_module.h:453
uint32_t ipInAddrErrors
Definition: mib2_module.h:358
uint32_t ifInDiscards
Definition: mib2_module.h:323
int32_t tcpMaxConn
Definition: mib2_module.h:421
uint32_t icmpInRedirects
Definition: mib2_module.h:389
uint32_t icmpInTimestamps
Definition: mib2_module.h:392
uint32_t icmpOutTimeExcds
Definition: mib2_module.h:399
const MibModule mib2Module
MIB-II module.
Definition: mib2_module.c:2201
uint32_t snmpInASNParseErrs
Definition: mib2_module.h:458
uint32_t snmpInTotalSetVars
Definition: mib2_module.h:465
Mib2IpNetToMediaType
Type of mapping.
Definition: mib2_module.h:239
uint32_t ipForwDatagrams
Definition: mib2_module.h:359
Mib2IcmpGroup icmpGroup
Definition: mib2_module.h:494
#define MIB2_SYS_OBJECT_ID_SIZE
Definition: mib2_module.h:104
size_t sysNameLen
Definition: mib2_module.h:303
uint32_t icmpOutAddrMaskReps
Definition: mib2_module.h:408
#define MIB2_IF_SPECIFIC_SIZE
Definition: mib2_module.h:132
size_t sysDescrLen
Definition: mib2_module.h:290
Mib2TcpRtoAlgorithm
RTO calculation algorithm.
Definition: mib2_module.h:252
uint32_t ifInErrors
Definition: mib2_module.h:324
uint32_t snmpOutSetRequests
Definition: mib2_module.h:477
uint32_t snmpInBadValues
Definition: mib2_module.h:461
uint32_t ifOutNUcastPkts
Definition: mib2_module.h:328
uint32_t snmpInNoSuchNames
Definition: mib2_module.h:460
Mib2TcpGroup tcpGroup
Definition: mib2_module.h:497
uint32_t icmpOutDestUnreachs
Definition: mib2_module.h:398
int32_t tcpRtoAlgorithm
Definition: mib2_module.h:418
uint32_t icmpInEchoReps
Definition: mib2_module.h:391
ICMP group.
Definition: mib2_module.h:381
int32_t ifNumber
Definition: mib2_module.h:343
Mib2UdpGroup udpGroup
Definition: mib2_module.h:500
Mib2SysService
System services.
Definition: mib2_module.h:170
uint32_t icmpInErrors
Definition: mib2_module.h:384
const MibObject mib2Objects[]
MIB-II objects.
Definition: mib2_module.c:63
Mib2IfGroup ifGroup
Definition: mib2_module.h:491
uint32_t icmpInTimestampReps
Definition: mib2_module.h:393
uint32_t icmpInSrcQuenchs
Definition: mib2_module.h:388
uint32_t ifOutQLen
Definition: mib2_module.h:331
uint32_t tcpActiveOpens
Definition: mib2_module.h:422
uint32_t ipOutDiscards
Definition: mib2_module.h:364
uint32_t icmpInTimeExcds
Definition: mib2_module.h:386
size_t ifSpecificLen
Definition: mib2_module.h:333
#define NET_INTERFACE_COUNT
Definition: net.h:108
uint32_t icmpOutTimestamps
Definition: mib2_module.h:405
uint32_t snmpOutTooBigs
Definition: mib2_module.h:471
IPv4 (Internet Protocol Version 4)
Mib2IfAdminStatus
The desired state of the interface.
Definition: mib2_module.h:204
#define MIB2_SYS_LOCATION_SIZE
Definition: mib2_module.h:125
uint32_t tcpPassiveOpens
Definition: mib2_module.h:423
uint32_t ifLastChange
Definition: mib2_module.h:319
uint32_t udpNoPorts
Definition: mib2_module.h:441
UDP group.
Definition: mib2_module.h:438
int32_t sysServices
Definition: mib2_module.h:309
uint32_t snmpInGetNexts
Definition: mib2_module.h:467
uint32_t snmpInBadCommunityUses
Definition: mib2_module.h:457
System group.
Definition: mib2_module.h:286
#define MIB2_SYS_DESCR_SIZE
Definition: mib2_module.h:97
uint32_t snmpOutNoSuchNames
Definition: mib2_module.h:472
uint32_t icmpInAddrMasks
Definition: mib2_module.h:394
#define MIB2_SYS_NAME_SIZE
Definition: mib2_module.h:118
uint32_t snmpOutGetRequests
Definition: mib2_module.h:475
uint32_t ipInReceives
Definition: mib2_module.h:356
uint32_t ifInUcastPkts
Definition: mib2_module.h:321
uint32_t icmpOutMsgs
Definition: mib2_module.h:396
uint32_t icmpOutRedirects
Definition: mib2_module.h:402
uint32_t ifInNUcastPkts
Definition: mib2_module.h:322
uint32_t udpOutDatagrams
Definition: mib2_module.h:443
int32_t tcpRtoMin
Definition: mib2_module.h:419
Mib2IpGroup ipGroup
Definition: mib2_module.h:493
uint32_t icmpInAddrMaskReps
Definition: mib2_module.h:395
uint32_t ifOutOctets
Definition: mib2_module.h:326
Mib2IfType
Interface types.
Definition: mib2_module.h:184
uint32_t ipOutNoRoutes
Definition: mib2_module.h:365
MIB-II base.
Definition: mib2_module.h:488
uint32_t snmpOutGetResponses
Definition: mib2_module.h:478
Mib2IpForwarding
IP forwarding state.
Definition: mib2_module.h:228
uint32_t tcpOutSegs
Definition: mib2_module.h:427
uint32_t icmpOutParmProbs
Definition: mib2_module.h:400
uint32_t snmpInGenErrs
Definition: mib2_module.h:463
uint32_t ipRoutingDiscards
Definition: mib2_module.h:373
IP group.
Definition: mib2_module.h:352
uint32_t icmpOutSrcQuenchs
Definition: mib2_module.h:401
uint32_t snmpInTraps
Definition: mib2_module.h:470
uint32_t ifInOctets
Definition: mib2_module.h:320
Common definitions for MIB modules.
SNMP group.
Definition: mib2_module.h:451
int32_t ipForwarding
Definition: mib2_module.h:354
uint32_t ipReasmFails
Definition: mib2_module.h:369
uint32_t ipInDiscards
Definition: mib2_module.h:361
uint32_t ipReasmOKs
Definition: mib2_module.h:368
MIB module.
Definition: mib_common.h:285
uint32_t ipFragCreates
Definition: mib2_module.h:372
uint32_t ifOutErrors
Definition: mib2_module.h:330
uint32_t ipFragOKs
Definition: mib2_module.h:370
uint32_t snmpOutGenErrs
Definition: mib2_module.h:474
uint32_t snmpInGetRequests
Definition: mib2_module.h:466
uint32_t tcpOutRsts
Definition: mib2_module.h:430
#define MIB2_SYS_CONTACT_SIZE
Definition: mib2_module.h:111
size_t sysObjectIDLen
Definition: mib2_module.h:294
uint32_t snmpInSetRequests
Definition: mib2_module.h:468
uint32_t tcpAttemptFails
Definition: mib2_module.h:424
Mib2Base mib2Base
MIB-II base.
Definition: mib2_module.c:56
uint32_t snmpInReadOnlys
Definition: mib2_module.h:462
uint32_t icmpInParmProbs
Definition: mib2_module.h:387
TCP (Transmission Control Protocol)
uint32_t snmpOutTraps
Definition: mib2_module.h:479
uint32_t icmpOutEchos
Definition: mib2_module.h:403
int32_t ipDefaultTTL
Definition: mib2_module.h:355
Mib2SysGroup sysGroup
Definition: mib2_module.h:490
Mib2SnmpGroup snmpGroup
Definition: mib2_module.h:502
uint32_t snmpInBadCommunityNames
Definition: mib2_module.h:456
size_t sysContactLen
Definition: mib2_module.h:299
uint32_t tcpRetransSegs
Definition: mib2_module.h:428
UDP (User Datagram Protocol)
uint32_t tcpEstabResets
Definition: mib2_module.h:425
uint32_t snmpOutBadValues
Definition: mib2_module.h:473
uint32_t ifOutUcastPkts
Definition: mib2_module.h:327
Interfaces group.
Definition: mib2_module.h:341
Interfaces table entry.
Definition: mib2_module.h:317
uint32_t icmpInDestUnreachs
Definition: mib2_module.h:385
uint32_t icmpOutEchoReps
Definition: mib2_module.h:404
uint32_t udpInDatagrams
Definition: mib2_module.h:440