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