mbed

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Fri Sep 02 15:07:44 2016 +0100
Revision:
144:ef7eb2e8f9f7
Child:
147:30b64687e01f
This updates the lib to the mbed lib v125

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 144:ef7eb2e8f9f7 1 /**
<> 144:ef7eb2e8f9f7 2 ******************************************************************************
<> 144:ef7eb2e8f9f7 3 * @file mib.h
<> 144:ef7eb2e8f9f7 4 * @brief Defines the structure of a Management Information Base (MIB)
<> 144:ef7eb2e8f9f7 5 * @internal
<> 144:ef7eb2e8f9f7 6 * @author ON Semiconductor
<> 144:ef7eb2e8f9f7 7 * $Rev: 2284 $
<> 144:ef7eb2e8f9f7 8 * $Date: 2013-09-12 15:08:22 +0530 (Thu, 12 Sep 2013) $
<> 144:ef7eb2e8f9f7 9 ******************************************************************************
<> 144:ef7eb2e8f9f7 10 * @copyright (c) 2012 ON Semiconductor. All rights reserved.
<> 144:ef7eb2e8f9f7 11 * ON Semiconductor is supplying this software for use with ON Semiconductor
<> 144:ef7eb2e8f9f7 12 * processor based microcontrollers only.
<> 144:ef7eb2e8f9f7 13 *
<> 144:ef7eb2e8f9f7 14 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
<> 144:ef7eb2e8f9f7 15 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
<> 144:ef7eb2e8f9f7 16 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
<> 144:ef7eb2e8f9f7 17 * ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL,
<> 144:ef7eb2e8f9f7 18 * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
<> 144:ef7eb2e8f9f7 19 * @endinternal
<> 144:ef7eb2e8f9f7 20 *
<> 144:ef7eb2e8f9f7 21 * @details
<> 144:ef7eb2e8f9f7 22 * This file defines the structure, as seen from the outside, of any Management
<> 144:ef7eb2e8f9f7 23 * Information Base (MIB) implementation. It does not define the contents of the
<> 144:ef7eb2e8f9f7 24 * MIB.
<> 144:ef7eb2e8f9f7 25 *
<> 144:ef7eb2e8f9f7 26 * A MIB is implemented as a map of parameters, each identified by a unique Object ID.
<> 144:ef7eb2e8f9f7 27 * The contents of the map have to be filled in by the actual MIB implementation, by
<> 144:ef7eb2e8f9f7 28 * assigning to the GlobMibMap variable. The mib_param_t data type defines the format
<> 144:ef7eb2e8f9f7 29 * of each parameter in the map. *NOTE:* The length of the last entry in the map must
<> 144:ef7eb2e8f9f7 30 * be 0.
<> 144:ef7eb2e8f9f7 31 *
<> 144:ef7eb2e8f9f7 32 * One parameter must always be present in the MIB map: the system revision. It has
<> 144:ef7eb2e8f9f7 33 * to be set by assigning a value to the systemRevision variable.
<> 144:ef7eb2e8f9f7 34 *
<> 144:ef7eb2e8f9f7 35 * Parameters can be of any data type, and read / write or read only. To resemble
<> 144:ef7eb2e8f9f7 36 * the hierarchical structure of an SNMP MIB, each Object ID consists of four nibbles
<> 144:ef7eb2e8f9f7 37 * (uint16_t) where the more significant nibbles correspond to a higher level in the
<> 144:ef7eb2e8f9f7 38 * hierarchy.
<> 144:ef7eb2e8f9f7 39 *
<> 144:ef7eb2e8f9f7 40 * The contents of the map can be accessed with the fMibSetBytes() and fMibGetBytes()
<> 144:ef7eb2e8f9f7 41 * functions. The implementation of the MIB may also make its parameters accessible
<> 144:ef7eb2e8f9f7 42 * in a more "direct" way; that is left to the implementation. The fMibSetBytes() and
<> 144:ef7eb2e8f9f7 43 * fMibGetBytes() functions are made available to the user interface (see ui.h). In
<> 144:ef7eb2e8f9f7 44 * order to do so, fMibUiInit() must be called during device initialization.
<> 144:ef7eb2e8f9f7 45 *
<> 144:ef7eb2e8f9f7 46 * Additionally, for parameters that have an array as their value, the individual
<> 144:ef7eb2e8f9f7 47 * elements of the array can be accessed using the fMibIndexedSetBytes() and
<> 144:ef7eb2e8f9f7 48 * fMibIndexedGetBytes() functions. The functions are similar to their non-indexed
<> 144:ef7eb2e8f9f7 49 * variants (fMibSetBytes() and fMibGetBytes()), except that they expect the index of
<> 144:ef7eb2e8f9f7 50 * the element as an argument.
<> 144:ef7eb2e8f9f7 51 *
<> 144:ef7eb2e8f9f7 52 * fMibGetBytes() and fMibSetBytes() will normally copy bytes from the MIB parameter
<> 144:ef7eb2e8f9f7 53 * into a given place in memory, or from memory to the MIB parameter. This behaviour
<> 144:ef7eb2e8f9f7 54 * can be overruled by assigning a function to the setAction and / or getAction
<> 144:ef7eb2e8f9f7 55 * fields of the MIB parameter.
<> 144:ef7eb2e8f9f7 56 *
<> 144:ef7eb2e8f9f7 57 * For parameters that have an array as their value, the length field has a slightly
<> 144:ef7eb2e8f9f7 58 * different meaning: the most significant 16 bits contain the length of the array;
<> 144:ef7eb2e8f9f7 59 * the least significant 16 bits contain the width of the array (i.e. the size in
<> 144:ef7eb2e8f9f7 60 * bytes of the array's elements). This implies that the normal fMibGetBytes() and
<> 144:ef7eb2e8f9f7 61 * fMibSetBytes() cannot be used on these parameters; instead, a get and set action
<> 144:ef7eb2e8f9f7 62 * needs to be provided to interpret the length field in case of a non-indexed get
<> 144:ef7eb2e8f9f7 63 * or set.
<> 144:ef7eb2e8f9f7 64 *
<> 144:ef7eb2e8f9f7 65 * To access the MIB fields over the user interface, the module ID must be equal to
<> 144:ef7eb2e8f9f7 66 * MIB_MODULE_ID or 0x01. The data in the packet must have the following structure:
<> 144:ef7eb2e8f9f7 67 * <table>
<> 144:ef7eb2e8f9f7 68 * <tr>
<> 144:ef7eb2e8f9f7 69 * <th>Get (0x00) / Set (0x01) code</th>
<> 144:ef7eb2e8f9f7 70 * <th>Object ID</th>
<> 144:ef7eb2e8f9f7 71 * <th>Value (only for set)</th>
<> 144:ef7eb2e8f9f7 72 * </tr>
<> 144:ef7eb2e8f9f7 73 * <tr>
<> 144:ef7eb2e8f9f7 74 * <td>1 Byte</td>
<> 144:ef7eb2e8f9f7 75 * <td>2 Bytes</td>
<> 144:ef7eb2e8f9f7 76 * <td>X bytes</td>
<> 144:ef7eb2e8f9f7 77 * </tr>
<> 144:ef7eb2e8f9f7 78 * </table>
<> 144:ef7eb2e8f9f7 79 *
<> 144:ef7eb2e8f9f7 80 * <table>
<> 144:ef7eb2e8f9f7 81 * <tr>
<> 144:ef7eb2e8f9f7 82 * <th>Indexed Get (0x02) / Set (0x03) code</th>
<> 144:ef7eb2e8f9f7 83 * <th>Object ID</th>
<> 144:ef7eb2e8f9f7 84 * <th>Index</th>
<> 144:ef7eb2e8f9f7 85 * <th>Value (only for set)</th>
<> 144:ef7eb2e8f9f7 86 * </tr>
<> 144:ef7eb2e8f9f7 87 * <tr>
<> 144:ef7eb2e8f9f7 88 * <td>1 Byte</td>
<> 144:ef7eb2e8f9f7 89 * <td>2 Bytes</td>
<> 144:ef7eb2e8f9f7 90 * <td>2 Bytes</td>
<> 144:ef7eb2e8f9f7 91 * <td>X bytes</td>
<> 144:ef7eb2e8f9f7 92 * </tr>
<> 144:ef7eb2e8f9f7 93 * </table>
<> 144:ef7eb2e8f9f7 94 *
<> 144:ef7eb2e8f9f7 95 * The reply to this request will have the same structure, with the value always
<> 144:ef7eb2e8f9f7 96 * being present (in case of a Set as well as a Get request).
<> 144:ef7eb2e8f9f7 97 *
<> 144:ef7eb2e8f9f7 98 * In case an error occurs during a Set or Get request, an error is returned by
<> 144:ef7eb2e8f9f7 99 * fMibGetBytes(), fMibSetBytes() or the UI. See the UI Module's documentation for
<> 144:ef7eb2e8f9f7 100 * the format of an error reply. The applicable error codes are:
<> 144:ef7eb2e8f9f7 101 * <table>
<> 144:ef7eb2e8f9f7 102 * <tr><th>0x01</th><td>Trying to set a read-only parameter.</td></tr>
<> 144:ef7eb2e8f9f7 103 * <tr><th>0x02</th><td>Requested value out of range.</td></tr>
<> 144:ef7eb2e8f9f7 104 * <tr><th>0x03</th><td>Object ID is unknown.</td></tr>
<> 144:ef7eb2e8f9f7 105 * <tr><th>0x04</th><td>Provided index is incorrect.</td></tr>
<> 144:ef7eb2e8f9f7 106 * </table>
<> 144:ef7eb2e8f9f7 107 *
<> 144:ef7eb2e8f9f7 108 * @ingroup mib
<> 144:ef7eb2e8f9f7 109 */
<> 144:ef7eb2e8f9f7 110
<> 144:ef7eb2e8f9f7 111 #ifndef MIB_H_
<> 144:ef7eb2e8f9f7 112 #define MIB_H_
<> 144:ef7eb2e8f9f7 113
<> 144:ef7eb2e8f9f7 114
<> 144:ef7eb2e8f9f7 115 #include <stdint.h>
<> 144:ef7eb2e8f9f7 116
<> 144:ef7eb2e8f9f7 117 #include "types.h"
<> 144:ef7eb2e8f9f7 118 #include "error.h"
<> 144:ef7eb2e8f9f7 119
<> 144:ef7eb2e8f9f7 120 /** A structure defining the format of the system revision parameter. */
<> 144:ef7eb2e8f9f7 121 typedef struct mib_systemRevision {
<> 144:ef7eb2e8f9f7 122 uint8_t hardwareRevision;
<> 144:ef7eb2e8f9f7 123 uint8_t patchLevel;
<> 144:ef7eb2e8f9f7 124 uint8_t bugFix;
<> 144:ef7eb2e8f9f7 125 uint8_t featureSet;
<> 144:ef7eb2e8f9f7 126 uint8_t generation;
<> 144:ef7eb2e8f9f7 127 uint8_t release;
<> 144:ef7eb2e8f9f7 128 } mib_systemRevision_t, *mib_systemRevision_pt;
<> 144:ef7eb2e8f9f7 129
<> 144:ef7eb2e8f9f7 130 /** The system revision. */
<> 144:ef7eb2e8f9f7 131 extern const mib_systemRevision_t systemRevision;
<> 144:ef7eb2e8f9f7 132
<> 144:ef7eb2e8f9f7 133
<> 144:ef7eb2e8f9f7 134 #endif /* MIB_H_ */