Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
mib2_module.h
00001 /** 00002 * @file mib2_module.h 00003 * @brief MIB-II module 00004 * 00005 * @section License 00006 * 00007 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. 00008 * 00009 * This file is part of CycloneTCP Open. 00010 * 00011 * This program is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU General Public License 00013 * as published by the Free Software Foundation; either version 2 00014 * of the License, or (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software Foundation, 00023 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00024 * 00025 * @author Oryx Embedded SARL (www.oryx-embedded.com) 00026 * @version 1.7.6 00027 **/ 00028 00029 #ifndef _MIB2_MODULE_H 00030 #define _MIB2_MODULE_H 00031 00032 //Dependencies 00033 #include "core/net.h" 00034 #include "core/udp.h" 00035 #include "core/tcp.h" 00036 #include "ipv4/ipv4.h" 00037 #include "mibs/mib_common.h" 00038 00039 //MIB-II module support 00040 #ifndef MIB2_SUPPORT 00041 #define MIB2_SUPPORT DISABLED 00042 #elif (MIB2_SUPPORT != ENABLED && MIB2_SUPPORT != DISABLED) 00043 #error MIB2_SUPPORT parameter is not valid 00044 #endif 00045 00046 //Size of sysDescr object 00047 #ifndef MIB2_SYS_DESCR_SIZE 00048 #define MIB2_SYS_DESCR_SIZE 16 00049 #elif (MIB2_SYS_DESCR_SIZE < 0) 00050 #error MIB2_SYS_DESCR_SIZE parameter is not valid 00051 #endif 00052 00053 //Size of sysObjectID object 00054 #ifndef MIB2_SYS_OBJECT_ID_SIZE 00055 #define MIB2_SYS_OBJECT_ID_SIZE 16 00056 #elif (MIB2_SYS_OBJECT_ID_SIZE < 0) 00057 #error MIB2_SYS_OBJECT_ID_SIZE parameter is not valid 00058 #endif 00059 00060 //Size of sysContact object 00061 #ifndef MIB2_SYS_CONTACT_SIZE 00062 #define MIB2_SYS_CONTACT_SIZE 16 00063 #elif (MIB2_SYS_CONTACT_SIZE < 0) 00064 #error MIB2_SYS_CONTACT_SIZE parameter is not valid 00065 #endif 00066 00067 //Size of sysName object 00068 #ifndef MIB2_SYS_NAME_SIZE 00069 #define MIB2_SYS_NAME_SIZE 16 00070 #elif (MIB2_SYS_NAME_SIZE < 0) 00071 #error MIB2_SYS_NAME_SIZE parameter is not valid 00072 #endif 00073 00074 //Size of sysLocation object 00075 #ifndef MIB2_SYS_LOCATION_SIZE 00076 #define MIB2_SYS_LOCATION_SIZE 16 00077 #elif (MIB2_SYS_LOCATION_SIZE < 0) 00078 #error MIB2_SYS_LOCATION_SIZE parameter is not valid 00079 #endif 00080 00081 //Size of ifDescr object 00082 #ifndef MIB2_IF_DESCR_SIZE 00083 #define MIB2_IF_DESCR_SIZE 16 00084 #elif (MIB2_IF_DESCR_SIZE < 1) 00085 #error MIB2_IF_DESCR_SIZE parameter is not valid 00086 #endif 00087 00088 //Size of ifSpecific object 00089 #ifndef MIB2_IF_SPECIFIC_SIZE 00090 #define MIB2_IF_SPECIFIC_SIZE 16 00091 #elif (MIB2_IF_SPECIFIC_SIZE < 1) 00092 #error MIB2_IF_SPECIFIC_SIZE parameter is not valid 00093 #endif 00094 00095 //Size of PhysAddress data type 00096 #ifndef MIB2_PHYS_ADDRESS_SIZE 00097 #define MIB2_PHYS_ADDRESS_SIZE 6 00098 #elif (MIB2_PHYS_ADDRESS_SIZE < 6) 00099 #error MIB2_PHYS_ADDRESS_SIZE parameter is not valid 00100 #endif 00101 00102 //Size of IpAddress data type 00103 #ifndef MIB2_IP_ADDRESS_SIZE 00104 #define MIB2_IP_ADDRESS_SIZE 4 00105 #elif (MIB2_IP_ADDRESS_SIZE != 4) 00106 #error MIB2_IP_ADDRESS_SIZE parameter is not valid 00107 #endif 00108 00109 //Macro definitions 00110 #if (MIB2_SUPPORT == ENABLED) 00111 #define MIB2_SET_INTEGER(name, value) name = value 00112 #define MIB2_SET_GAUGE32(name, value) name = value 00113 #define MIB2_SET_TIME_TICKS(name, value) name = value 00114 #define MIB2_SET_OCTET_STRING(name, value, length) memcpy(name, value, length) 00115 #define MIB2_SET_OCTET_STRING_LEN(name, length) name = length 00116 #define MIB2_INC_COUNTER32(name, value) name += value 00117 #define MIB2_INC_COUNTER64(name, value) name += value 00118 #else 00119 #define MIB2_SET_INTEGER(name, value) 00120 #define MIB2_SET_GAUGE32(name, value) 00121 #define MIB2_SET_TIME_TICKS(name, value) 00122 #define MIB2_SET_OCTET_STRING(name, value, length) 00123 #define MIB2_SET_OCTET_STRING_LEN(name, length) 00124 #define MIB2_INC_COUNTER32(name, value) 00125 #define MIB2_INC_COUNTER64(name, value) 00126 #endif 00127 00128 00129 /** 00130 * @brief System services 00131 **/ 00132 00133 typedef enum 00134 { 00135 MIB2_SYS_SERVICE_PHYSICAL = 0x01, 00136 MIB2_SYS_SERVICE_DATALINK = 0x02, 00137 MIB2_SYS_SERVICE_INTERNET = 0x04, 00138 MIB2_SYS_SERVICE_END_TO_END = 0x08, 00139 MIB2_SYS_SERVICE_APPLICATIONS = 0x40 00140 } Mib2SysService; 00141 00142 00143 /** 00144 * @brief Interface types 00145 **/ 00146 00147 typedef enum 00148 { 00149 MIB2_IF_TYPE_OTHER = 1, 00150 MIB2_IF_TYPE_ETHERNET_CSMACD = 6, 00151 MIB2_IF_TYPE_PROP_PTP_SERIAL = 22, 00152 MIB2_IF_TYPE_PPP = 23, 00153 MIB2_IF_TYPE_SOFT_LOOPBACK = 24, 00154 MIB2_IF_TYPE_SLIP = 28, 00155 MIB2_IF_TYPE_RS232 = 33, 00156 MIB2_IF_TYPE_PARA = 34, 00157 MIB2_IF_TYPE_USB = 160, 00158 MIB2_IF_TYPE_IEEE_802_15_4 = 259 00159 } Mib2IfType; 00160 00161 00162 /** 00163 * @brief The desired state of the interface 00164 **/ 00165 00166 typedef enum 00167 { 00168 MIB2_IF_ADMIN_STATUS_UP = 1, 00169 MIB2_IF_ADMIN_STATUS_DOWN = 2, 00170 MIB2_IF_ADMIN_STATUS_TESTING = 3 00171 } Mib2IfAdminStatus; 00172 00173 00174 /** 00175 * @brief The operational state of the interface 00176 **/ 00177 00178 typedef enum 00179 { 00180 MIB2_IF_OPER_STATUS_UP = 1, 00181 MIB2_IF_OPER_STATUS_DOWN = 2, 00182 MIB2_IF_OPER_STATUS_TESTING = 3 00183 } Mib2IfOperStatus; 00184 00185 00186 /** 00187 * @brief IP forwarding state 00188 **/ 00189 00190 typedef enum 00191 { 00192 MIB2_IP_FORWARDING_ENABLED = 1, 00193 MIB2_IP_FORWARDING_DISABLED = 2 00194 } Mib2IpForwarding; 00195 00196 00197 /** 00198 * @brief Type of mapping 00199 **/ 00200 00201 typedef enum 00202 { 00203 MIB2_IP_NET_TO_MEDIA_TYPE_OTHER = 1, 00204 MIB2_IP_NET_TO_MEDIA_TYPE_INVALID = 2, 00205 MIB2_IP_NET_TO_MEDIA_TYPE_DYNAMIC = 3, 00206 MIB2_IP_NET_TO_MEDIA_TYPE_STATIC = 4 00207 } Mib2IpNetToMediaType; 00208 00209 00210 /** 00211 * @brief RTO calculation algorithm 00212 **/ 00213 00214 typedef enum 00215 { 00216 MIB2_TCP_RTO_ALGORITHM_OTHER = 1, 00217 MIB2_TCP_RTO_ALGORITHM_CONSTANT = 2, 00218 MIB2_TCP_RTO_ALGORITHM_RSRE = 3, 00219 MIB2_TCP_RTO_ALGORITHM_VANJ = 4 00220 } Mib2TcpRtoAlgorithm; 00221 00222 00223 /** 00224 * @brief TCP connection states 00225 **/ 00226 00227 typedef enum 00228 { 00229 MIB2_TCP_CONN_STATE_CLOSED = 1, 00230 MIB2_TCP_CONN_STATE_LISTEN = 2, 00231 MIB2_TCP_CONN_STATE_SYN_SENT = 3, 00232 MIB2_TCP_CONN_STATE_SYN_RECEIVED = 4, 00233 MIB2_TCP_CONN_STATE_ESTABLISHED = 5, 00234 MIB2_TCP_CONN_STATE_FIN_WAIT_1 = 6, 00235 MIB2_TCP_CONN_STATE_FIN_WAIT_2 = 7, 00236 MIB2_TCP_CONN_STATE_CLOSE_WAIT = 8, 00237 MIB2_TCP_CONN_STATE_LAST_ACK = 9, 00238 MIB2_TCP_CONN_STATE_CLOSING = 10, 00239 MIB2_TCP_CONN_STATE_TIME_WAIT = 11, 00240 MIB2_TCP_CONN_STATE_DELETE_TCB = 12 00241 } Mib2TcpConnState; 00242 00243 00244 /** 00245 * @brief System group 00246 **/ 00247 00248 typedef struct 00249 { 00250 #if (MIB2_SYS_DESCR_SIZE > 0) 00251 char_t sysDescr[MIB2_SYS_DESCR_SIZE]; 00252 size_t sysDescrLen; 00253 #endif 00254 #if (MIB2_SYS_OBJECT_ID_SIZE > 0) 00255 uint8_t sysObjectID[MIB2_SYS_OBJECT_ID_SIZE]; 00256 size_t sysObjectIDLen; 00257 #endif 00258 uint32_t sysUpTime; 00259 #if (MIB2_SYS_CONTACT_SIZE > 0) 00260 char_t sysContact[MIB2_SYS_CONTACT_SIZE]; 00261 size_t sysContactLen; 00262 #endif 00263 #if (MIB2_SYS_NAME_SIZE > 0) 00264 char_t sysName[MIB2_SYS_NAME_SIZE]; 00265 size_t sysNameLen; 00266 #endif 00267 #if (MIB2_SYS_LOCATION_SIZE > 0) 00268 char_t sysLocation[MIB2_SYS_LOCATION_SIZE]; 00269 size_t sysLocationLen; 00270 #endif 00271 int32_t sysServices; 00272 } Mib2SysGroup; 00273 00274 00275 /** 00276 * @brief Interfaces table entry 00277 **/ 00278 00279 typedef struct 00280 { 00281 int32_t ifIndex; 00282 char_t ifDescr[MIB2_IF_DESCR_SIZE]; 00283 size_t ifDescrLen; 00284 int32_t ifType; 00285 int32_t ifMtu; 00286 uint32_t ifSpeed; 00287 uint8_t ifPhysAddress[MIB2_PHYS_ADDRESS_SIZE]; 00288 size_t ifPhysAddressLen; 00289 int32_t ifAdminStatus; 00290 int32_t ifOperStatus; 00291 uint32_t ifLastChange; 00292 uint32_t ifInOctets; 00293 uint32_t ifInUcastPkts; 00294 uint32_t ifInNUcastPkts; 00295 uint32_t ifInDiscards; 00296 uint32_t ifInErrors; 00297 uint32_t ifInUnknownProtos; 00298 uint32_t ifOutOctets; 00299 uint32_t ifOutUcastPkts; 00300 uint32_t ifOutNUcastPkts; 00301 uint32_t ifOutDiscards; 00302 uint32_t ifOutErrors; 00303 uint32_t ifOutQLen; 00304 uint8_t ifSpecific[MIB2_IF_SPECIFIC_SIZE]; 00305 size_t ifSpecificLen; 00306 } Mib2IfEntry; 00307 00308 00309 /** 00310 * @brief Interfaces group 00311 **/ 00312 00313 typedef struct 00314 { 00315 int32_t ifNumber; 00316 Mib2IfEntry ifTable[NET_INTERFACE_COUNT]; 00317 } Mib2IfGroup; 00318 00319 00320 /** 00321 * @brief IP group 00322 **/ 00323 00324 typedef struct 00325 { 00326 int32_t ipForwarding; 00327 int32_t ipDefaultTTL; 00328 uint32_t ipInReceives; 00329 uint32_t ipInHdrErrors; 00330 uint32_t ipInAddrErrors; 00331 uint32_t ipForwDatagrams; 00332 uint32_t ipInUnknownProtos; 00333 uint32_t ipInDiscards; 00334 uint32_t ipInDelivers; 00335 uint32_t ipOutRequests; 00336 uint32_t ipOutDiscards; 00337 uint32_t ipOutNoRoutes; 00338 int32_t ipReasmTimeout; 00339 uint32_t ipReasmReqds; 00340 uint32_t ipReasmOKs; 00341 uint32_t ipReasmFails; 00342 uint32_t ipFragOKs; 00343 uint32_t ipFragFails; 00344 uint32_t ipFragCreates; 00345 uint32_t ipRoutingDiscards; 00346 } Mib2IpGroup; 00347 00348 00349 /** 00350 * @brief ICMP group 00351 **/ 00352 00353 typedef struct 00354 { 00355 uint32_t icmpInMsgs; 00356 uint32_t icmpInErrors; 00357 uint32_t icmpInDestUnreachs; 00358 uint32_t icmpInTimeExcds; 00359 uint32_t icmpInParmProbs; 00360 uint32_t icmpInSrcQuenchs; 00361 uint32_t icmpInRedirects; 00362 uint32_t icmpInEchos; 00363 uint32_t icmpInEchoReps; 00364 uint32_t icmpInTimestamps; 00365 uint32_t icmpInTimestampReps; 00366 uint32_t icmpInAddrMasks; 00367 uint32_t icmpInAddrMaskReps; 00368 uint32_t icmpOutMsgs; 00369 uint32_t icmpOutErrors; 00370 uint32_t icmpOutDestUnreachs; 00371 uint32_t icmpOutTimeExcds; 00372 uint32_t icmpOutParmProbs; 00373 uint32_t icmpOutSrcQuenchs; 00374 uint32_t icmpOutRedirects; 00375 uint32_t icmpOutEchos; 00376 uint32_t icmpOutEchoReps; 00377 uint32_t icmpOutTimestamps; 00378 uint32_t icmpOutTimestampReps; 00379 uint32_t icmpOutAddrMasks; 00380 uint32_t icmpOutAddrMaskReps; 00381 } Mib2IcmpGroup; 00382 00383 00384 /** 00385 * @brief TCP group 00386 **/ 00387 00388 typedef struct 00389 { 00390 int32_t tcpRtoAlgorithm; 00391 int32_t tcpRtoMin; 00392 int32_t tcpRtoMax; 00393 int32_t tcpMaxConn; 00394 uint32_t tcpActiveOpens; 00395 uint32_t tcpPassiveOpens; 00396 uint32_t tcpAttemptFails; 00397 uint32_t tcpEstabResets; 00398 uint32_t tcpCurrEstab; 00399 uint32_t tcpInSegs; 00400 uint32_t tcpOutSegs; 00401 uint32_t tcpRetransSegs; 00402 uint32_t tcpInErrs; 00403 uint32_t tcpOutRsts; 00404 uint64_t tcpHCInSegs; 00405 uint64_t tcpHCOutSegs; 00406 } Mib2TcpGroup; 00407 00408 00409 /** 00410 * @brief UDP group 00411 **/ 00412 00413 typedef struct 00414 { 00415 uint32_t udpInDatagrams; 00416 uint32_t udpNoPorts; 00417 uint32_t udpInErrors; 00418 uint32_t udpOutDatagrams; 00419 uint64_t udpHCInDatagrams; 00420 uint64_t udpHCOutDatagrams; 00421 } Mib2UdpGroup; 00422 00423 00424 /** 00425 * @brief SNMP group 00426 **/ 00427 00428 typedef struct 00429 { 00430 uint32_t snmpInPkts; 00431 uint32_t snmpOutPkts; 00432 uint32_t snmpInBadVersions; 00433 uint32_t snmpInBadCommunityNames; 00434 uint32_t snmpInBadCommunityUses; 00435 uint32_t snmpInASNParseErrs; 00436 uint32_t snmpInTooBigs; 00437 uint32_t snmpInNoSuchNames; 00438 uint32_t snmpInBadValues; 00439 uint32_t snmpInReadOnlys; 00440 uint32_t snmpInGenErrs; 00441 uint32_t snmpInTotalReqVars; 00442 uint32_t snmpInTotalSetVars; 00443 uint32_t snmpInGetRequests; 00444 uint32_t snmpInGetNexts; 00445 uint32_t snmpInSetRequests; 00446 uint32_t snmpInGetResponses; 00447 uint32_t snmpInTraps; 00448 uint32_t snmpOutTooBigs; 00449 uint32_t snmpOutNoSuchNames; 00450 uint32_t snmpOutBadValues; 00451 uint32_t snmpOutGenErrs; 00452 uint32_t snmpOutGetRequests; 00453 uint32_t snmpOutGetNexts; 00454 uint32_t snmpOutSetRequests; 00455 uint32_t snmpOutGetResponses; 00456 uint32_t snmpOutTraps; 00457 int32_t snmpEnableAuthenTraps; 00458 } Mib2SnmpGroup; 00459 00460 00461 /** 00462 * @brief MIB-II base 00463 **/ 00464 00465 typedef struct 00466 { 00467 Mib2SysGroup sysGroup; 00468 Mib2IfGroup ifGroup; 00469 #if (IPV4_SUPPORT == ENABLED) 00470 Mib2IpGroup ipGroup; 00471 Mib2IcmpGroup icmpGroup; 00472 #endif 00473 #if (TCP_SUPPORT == ENABLED) 00474 Mib2TcpGroup tcpGroup; 00475 #endif 00476 #if (UDP_SUPPORT == ENABLED) 00477 Mib2UdpGroup udpGroup; 00478 #endif 00479 Mib2SnmpGroup snmpGroup; 00480 } Mib2Base; 00481 00482 00483 //MIB-II related constants 00484 extern Mib2Base mib2Base; 00485 extern const MibObject mib2Objects[]; 00486 extern const MibModule mib2Module; 00487 00488 #endif 00489
Generated on Tue Jul 12 2022 17:10:14 by
1.7.2