Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of OmniWheels by
thread_tmfcop_lib.h
00001 /* 00002 * Copyright (c) 2015-2017, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: BSD-3-Clause 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 3. Neither the name of the copyright holder nor the 00014 * names of its contributors may be used to endorse or promote products 00015 * derived from this software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00030 /** 00031 * Thread internal API to handles the Thread management framework message parsing and building for address resolution. 00032 * This library is needed only for thread internal operations. 00033 * This library is stand alone and only supports TMFCOP message parsing and finding functions. 00034 */ 00035 #ifndef THREAD_TMFCOP_LIB_H_ 00036 #define THREAD_TMFCOP_LIB_H_ 00037 00038 #include "ns_types.h" 00039 #include "thread_meshcop_lib.h" // this uses the same parser functions than meshcop but different message types 00040 00041 /** 00042 * CoAP address registration TLV definitions 00043 * Note that these TLV types overlap with meshcop 00044 * and must not be used in same messages. 00045 */ 00046 #define TMFCOP_TLV_TARGET_EID 0 00047 #define TMFCOP_TLV_MAC_ADDRESS 1 00048 #define TMFCOP_TLV_RLOC16 2 00049 #define TMFCOP_TLV_ML_EID 3 00050 #define TMFCOP_TLV_STATUS 4 00051 #define TMFCOP_TLV_ATTACHED_TIME 5 00052 #define TMFCOP_TLV_LAST_TRANSACTION_TIME 6 00053 #define TMFCOP_TLV_ROUTER_MASK 7 00054 #define TMFCOP_TLV_ND_OPTION 8 00055 #define TMFCOP_TLV_ND_DATA 9 00056 #define TMFCOP_TLV_NETWORK_DATA 10 00057 00058 00059 /** 00060 * Write array TLV. 00061 * 00062 * \param ptr pointer for array where to write the TLV. 00063 * \param type Type of TLV. 00064 * \param length length of the data that is written in TLV. 00065 * \param data array for TLV value. 00066 * \return pointer value for writing the next TLV. 00067 */ 00068 #define thread_tmfcop_tlv_data_write(ptr,type,length,data) thread_meshcop_tlv_data_write(ptr,type,length,data) 00069 00070 /** 00071 * Write header. 00072 * 00073 * \param ptr pointer for array where to write the TLV. 00074 * \param type Type of TLV. 00075 * \param length length of the data that is written in TLV. 00076 * 00077 * \return pointer value for writing the remaining bytes of network data. 00078 */ 00079 #define thread_tmfcop_tlv_data_write_header(ptr,type,length) thread_meshcop_tlv_data_write_header(ptr,type,length) 00080 00081 /** 00082 * Write 1 byte length TLV. 00083 * 00084 * \param ptr pointer for array where to write the TLV. 00085 * \param type Type of TLV. 00086 * \param data value. 00087 * \return pointer value for writing the next TLV. 00088 */ 00089 #define thread_tmfcop_tlv_data_write_uint8(ptr,type,data) thread_meshcop_tlv_data_write_uint8(ptr,type,data) 00090 00091 /** 00092 * Write 2 byte length TLV. 00093 * 00094 * \param ptr pointer for array where to write the TLV. 00095 * \param type Type of TLV. 00096 * \param data value. 00097 * \return pointer value for writing the next TLV. 00098 */ 00099 #define thread_tmfcop_tlv_data_write_uint16(ptr,type,data) thread_meshcop_tlv_data_write_uint16(ptr,type,data) 00100 00101 /** 00102 * Write 4 byte length TLV. 00103 * 00104 * \param ptr pointer for array where to write the TLV. 00105 * \param type Type of TLV. 00106 * \param data value. 00107 * \return pointer value for writing the next TLV. 00108 */ 00109 #define thread_tmfcop_tlv_data_write_uint32(ptr,type,data) thread_meshcop_tlv_data_write_uint32(ptr,type,data) 00110 00111 /** 00112 * Write 8 byte length TLV. 00113 * 00114 * \param ptr pointer for array where to write the TLV. 00115 * \param type Type of TLV. 00116 * \param data value. 00117 * \return pointer value for writing the next TLV. 00118 */ 00119 #define thread_tmfcop_tlv_data_write_uint64(ptr,type,data) thread_meshcop_tlv_data_write_uint64(ptr,type,data) 00120 00121 /** 00122 * Check if TLV exists in the message. 00123 * 00124 * \param ptr Message buffer. 00125 * \param length Length of the message buffer to validate message. 00126 * \param type Type of TLV searched. 00127 * 00128 * \return true if TLV is found. 00129 * \return false if TLV does not exist. 00130 */ 00131 #define thread_tmfcop_tlv_exist(ptr, length, type) thread_meshcop_tlv_exist(ptr, length, type) 00132 00133 /** 00134 * Find TLV from message. 00135 * 00136 * \param ptr Message buffer. 00137 * \param length Length of the message buffer to validate message. 00138 * \param type Type of TLV searched. 00139 * \param result_ptr Pointer value is given as result if length is positive. Can be NULL which only searches for the length. 00140 * \return The length of the TLV data found 00141 * \return 0 if TLV is empty or no TLV found. 00142 * \return negative value indicates corrupted message. 00143 */ 00144 #define thread_tmfcop_tlv_find(ptr,length,type,result) thread_meshcop_tlv_find(ptr,length,type,result) 00145 00146 /** 00147 * Read 1 byte length TLV. 00148 * 00149 * \param ptr pointer TLV message array. 00150 * \param length length of TLV message array. 00151 * \param type Type of TLV. 00152 * \param data_ptr pointer to variable where the value is read. 00153 * \return pointer length of TLV 1 if success. 0 means TLV not found or does not have any data. 00154 * Any other value indicates that TLV is not as expected. 00155 */ 00156 #define thread_tmfcop_tlv_data_get_uint8(ptr,length,type,data) thread_meshcop_tlv_data_get_uint8(ptr,length,type,data) 00157 00158 /** 00159 * Read 2 byte length TLV. 00160 * 00161 * \param ptr pointer TLV message array. 00162 * \param length length of TLV message array. 00163 * \param type Type of TLV. 00164 * \param data_ptr pointer to variable where the value is read. 00165 * \return pointer length of TLV 2 if success. 0 means TLV not found or does not have any data. 00166 * Any other value indicates that TLV is not as expected. 00167 */ 00168 #define thread_tmfcop_tlv_data_get_uint16(ptr,length,type,data) thread_meshcop_tlv_data_get_uint16(ptr,length,type,data) 00169 00170 /** 00171 * Read 4 byte length TLV. 00172 * 00173 * \param ptr pointer TLV message array. 00174 * \param length length of TLV message array. 00175 * \param type Type of TLV. 00176 * \param data_ptr pointer to variable where the value is read. 00177 * \return pointer length of TLV 4 if success. 0 means TLV not found or does not have any data. 00178 * Any other value indicates that TLV is not as expected. 00179 */ 00180 #define thread_tmfcop_tlv_data_get_uint32(ptr,length,type,data) thread_meshcop_tlv_data_get_uint32(ptr,length,type,data) 00181 00182 /** 00183 * Read 8 byte length TLV. 00184 * 00185 * \param ptr pointer TLV message array. 00186 * \param length length of TLV message array. 00187 * \param type Type of TLV. 00188 * \param data_ptr pointer to variable where the value is read. 00189 * \return pointer length of TLV 4 if success. 0 means TLV not found or does not have any data. 00190 * Any other value indicates that TLV is not as expected. 00191 */ 00192 #define thread_tmfcop_tlv_data_get_uint64(ptr,length,type,data) thread_meshcop_tlv_data_get_uint64(ptr,length,type,data) 00193 00194 #endif /* THREAD_TMFCOP_LIB_H_ */
Generated on Fri Jul 22 2022 04:54:03 by
1.7.2
