mbed-os

Fork of mbed-os by erkin yucel

Committer:
xuaner
Date:
Thu Jul 20 14:26:57 2017 +0000
Revision:
1:3deb71413561
Parent:
0:f269e3021894
mbed_os

Who changed what in which revision?

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