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