Webserver+3d print
Embed:
(wiki syntax)
Show/hide line numbers
mib_common.h
Go to the documentation of this file.
00001 /** 00002 * @file mib_common.h 00003 * @brief Common definitions for MIB modules 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 _MIB_COMMON_H 00030 #define _MIB_COMMON_H 00031 00032 //Dependencies 00033 #include "core/net.h" 00034 00035 //Maximum OID size 00036 #ifndef MIB_MAX_OID_SIZE 00037 #define MIB_MAX_OID_SIZE 16 00038 #elif (MIB_MAX_OID_SIZE < 1) 00039 #error MIB_MAX_OID_SIZE parameter is not valid 00040 #endif 00041 00042 //Forward declaration of MibObject structure 00043 struct _MibObject; 00044 #define MibObject struct _MibObject 00045 00046 00047 /** 00048 * @brief MIB object types 00049 **/ 00050 00051 typedef enum 00052 { 00053 MIB_TYPE_IP_ADDRESS = 0, 00054 MIB_TYPE_COUNTER32 = 1, 00055 MIB_TYPE_GAUGE32 = 2, 00056 MIB_TYPE_UNSIGNED32 = 2, 00057 MIB_TYPE_TIME_TICKS = 3, 00058 MIB_TYPE_OPAQUE = 4, 00059 MIB_TYPE_COUNTER64 = 6 00060 } MibType; 00061 00062 00063 /** 00064 * @brief Access modes 00065 **/ 00066 00067 typedef enum 00068 { 00069 MIB_ACCESS_NONE = 0, 00070 MIB_ACCESS_READ_ONLY = 1, 00071 MIB_ACCESS_WRITE_ONLY = 2, 00072 MIB_ACCESS_READ_WRITE = 3 00073 } MibAccess; 00074 00075 00076 //CodeWarrior or Win32 compiler? 00077 #if defined(__CWCC__) || defined(_WIN32) 00078 #pragma pack(push, 1) 00079 #endif 00080 00081 00082 /** 00083 * @brief Variant data type 00084 **/ 00085 00086 typedef __start_packed struct 00087 { 00088 __start_packed union 00089 { 00090 int32_t integer; 00091 uint8_t octetString[1]; 00092 uint8_t oid[1]; 00093 uint8_t ipAddr[4]; 00094 uint32_t counter32; 00095 uint32_t gauge32; 00096 uint32_t timeTicks; 00097 uint64_t counter64; 00098 }; 00099 } __end_packed MibVariant; 00100 00101 00102 //CodeWarrior or Win32 compiler? 00103 #if defined(__CWCC__) || defined(_WIN32) 00104 #pragma pack(pop) 00105 #endif 00106 00107 00108 /** 00109 * @brief Set object value 00110 **/ 00111 00112 typedef error_t (*MibSetValue)(const MibObject *object, const uint8_t *oid, 00113 size_t oidLen, const MibVariant *value, size_t valueLen); 00114 00115 00116 /** 00117 * @brief Get object value 00118 **/ 00119 00120 typedef error_t (*MibGetValue)(const MibObject *object, const uint8_t *oid, 00121 size_t oidLen, MibVariant *value, size_t *valueLen); 00122 00123 00124 /** 00125 * @brief Get next object 00126 **/ 00127 00128 typedef error_t (*MibGetNext)(const MibObject *object, const uint8_t *oid, 00129 size_t oidLen, uint8_t *nextOid, size_t *nextOidLen); 00130 00131 00132 /** 00133 * @brief MIB object descriptor 00134 **/ 00135 00136 struct _MibObject 00137 { 00138 const char_t *name; 00139 uint8_t oid[MIB_MAX_OID_SIZE]; 00140 size_t oidLen; 00141 uint_t objClass; 00142 uint_t objType; 00143 MibAccess access; 00144 void *value; 00145 size_t *valueLen; 00146 size_t valueSize; 00147 MibSetValue setValue; 00148 MibGetValue getValue; 00149 MibGetNext getNext; 00150 }; 00151 00152 00153 /** 00154 * @brief MIB initialization 00155 **/ 00156 00157 typedef error_t (*MibInit)(void); 00158 00159 00160 /** 00161 * @brief Lock MIB 00162 **/ 00163 00164 typedef void (*MibLock)(void); 00165 00166 00167 /** 00168 * @brief Unlock MIB 00169 **/ 00170 00171 typedef void (*MibUnlock)(void); 00172 00173 00174 /** 00175 * @brief MIB module 00176 **/ 00177 00178 typedef struct 00179 { 00180 const MibObject *objects; 00181 uint_t numObjects; 00182 MibInit init; 00183 MibLock lock; 00184 MibUnlock unlock; 00185 } MibModule; 00186 00187 00188 //MIB related functions 00189 error_t mibEncodeIndex(uint8_t *oid, size_t maxOidLen, size_t *pos, uint_t index); 00190 error_t mibDecodeIndex(const uint8_t *oid, size_t oidLen, size_t *pos, uint_t *index); 00191 00192 error_t mibEncodeIpv4Addr(uint8_t *oid, size_t maxOidLen, size_t *pos, Ipv4Addr ipAddr); 00193 error_t mibDecodeIpv4Addr(const uint8_t *oid, size_t oidLen, size_t *pos, Ipv4Addr *ipAddr); 00194 00195 error_t mibEncodePort(uint8_t *oid, size_t maxOidLen, size_t *pos, uint16_t port); 00196 error_t mibDecodePort(const uint8_t *oid, size_t oidLen, size_t *pos, uint16_t *port); 00197 00198 #endif 00199
Generated on Tue Jul 12 2022 17:10:14 by
