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.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
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 /* Thread 1.2 defines*/ 00059 #define TMFCOP_TLV_TIMEOUT 11 00060 #define TMFCOP_TLV_NETWORK_NAME 12 00061 #define TMFCOP_TLV_SEQUENCE_NUMBER 13 00062 #define TMFCOP_TLV_IPV6_ADDRESS 14 00063 #define TMFCOP_TLV_COMMISSIONER_SESSION_ID 15 00064 00065 00066 00067 /** 00068 * Write array TLV. 00069 * 00070 * \param ptr pointer for array where to write the TLV. 00071 * \param type Type of TLV. 00072 * \param length length of the data that is written in TLV. 00073 * \param data array for TLV value. 00074 * \return pointer value for writing the next TLV. 00075 */ 00076 #define thread_tmfcop_tlv_data_write(ptr,type,length,data) thread_meshcop_tlv_data_write(ptr,type,length,data) 00077 00078 /** 00079 * Write header. 00080 * 00081 * \param ptr pointer for array where to write the TLV. 00082 * \param type Type of TLV. 00083 * \param length length of the data that is written in TLV. 00084 * 00085 * \return pointer value for writing the remaining bytes of network data. 00086 */ 00087 #define thread_tmfcop_tlv_data_write_header(ptr,type,length) thread_meshcop_tlv_data_write_header(ptr,type,length) 00088 00089 /** 00090 * Write 1 byte length TLV. 00091 * 00092 * \param ptr pointer for array where to write the TLV. 00093 * \param type Type of TLV. 00094 * \param data value. 00095 * \return pointer value for writing the next TLV. 00096 */ 00097 #define thread_tmfcop_tlv_data_write_uint8(ptr,type,data) thread_meshcop_tlv_data_write_uint8(ptr,type,data) 00098 00099 /** 00100 * Write 2 byte length TLV. 00101 * 00102 * \param ptr pointer for array where to write the TLV. 00103 * \param type Type of TLV. 00104 * \param data value. 00105 * \return pointer value for writing the next TLV. 00106 */ 00107 #define thread_tmfcop_tlv_data_write_uint16(ptr,type,data) thread_meshcop_tlv_data_write_uint16(ptr,type,data) 00108 00109 /** 00110 * Write 4 byte length TLV. 00111 * 00112 * \param ptr pointer for array where to write the TLV. 00113 * \param type Type of TLV. 00114 * \param data value. 00115 * \return pointer value for writing the next TLV. 00116 */ 00117 #define thread_tmfcop_tlv_data_write_uint32(ptr,type,data) thread_meshcop_tlv_data_write_uint32(ptr,type,data) 00118 00119 /** 00120 * Write 8 byte length TLV. 00121 * 00122 * \param ptr pointer for array where to write the TLV. 00123 * \param type Type of TLV. 00124 * \param data value. 00125 * \return pointer value for writing the next TLV. 00126 */ 00127 #define thread_tmfcop_tlv_data_write_uint64(ptr,type,data) thread_meshcop_tlv_data_write_uint64(ptr,type,data) 00128 00129 /** 00130 * Check if TLV exists in the message. 00131 * 00132 * \param ptr Message buffer. 00133 * \param length Length of the message buffer to validate message. 00134 * \param type Type of TLV searched. 00135 * 00136 * \return true if TLV is found. 00137 * \return false if TLV does not exist. 00138 */ 00139 #define thread_tmfcop_tlv_exist(ptr, length, type) thread_meshcop_tlv_exist(ptr, length, type) 00140 00141 /** 00142 * Find TLV from message. 00143 * 00144 * \param ptr Message buffer. 00145 * \param length Length of the message buffer to validate message. 00146 * \param type Type of TLV searched. 00147 * \param result_ptr Pointer value is given as result if length is positive. Can be NULL which only searches for the length. 00148 * \return The length of the TLV data found 00149 * \return 0 if TLV is empty or no TLV found. 00150 * \return negative value indicates corrupted message. 00151 */ 00152 #define thread_tmfcop_tlv_find(ptr,length,type,result) thread_meshcop_tlv_find(ptr,length,type,result) 00153 00154 /** 00155 * Read 1 byte length TLV. 00156 * 00157 * \param ptr pointer TLV message array. 00158 * \param length length of TLV message array. 00159 * \param type Type of TLV. 00160 * \param data_ptr pointer to variable where the value is read. 00161 * \return pointer length of TLV 1 if success. 0 means TLV not found or does not have any data. 00162 * Any other value indicates that TLV is not as expected. 00163 */ 00164 #define thread_tmfcop_tlv_data_get_uint8(ptr,length,type,data) thread_meshcop_tlv_data_get_uint8(ptr,length,type,data) 00165 00166 /** 00167 * Read 2 byte length TLV. 00168 * 00169 * \param ptr pointer TLV message array. 00170 * \param length length of TLV message array. 00171 * \param type Type of TLV. 00172 * \param data_ptr pointer to variable where the value is read. 00173 * \return pointer length of TLV 2 if success. 0 means TLV not found or does not have any data. 00174 * Any other value indicates that TLV is not as expected. 00175 */ 00176 #define thread_tmfcop_tlv_data_get_uint16(ptr,length,type,data) thread_meshcop_tlv_data_get_uint16(ptr,length,type,data) 00177 00178 /** 00179 * Read 4 byte length TLV. 00180 * 00181 * \param ptr pointer TLV message array. 00182 * \param length length of TLV message array. 00183 * \param type Type of TLV. 00184 * \param data_ptr pointer to variable where the value is read. 00185 * \return pointer length of TLV 4 if success. 0 means TLV not found or does not have any data. 00186 * Any other value indicates that TLV is not as expected. 00187 */ 00188 #define thread_tmfcop_tlv_data_get_uint32(ptr,length,type,data) thread_meshcop_tlv_data_get_uint32(ptr,length,type,data) 00189 00190 /** 00191 * Read 8 byte length TLV. 00192 * 00193 * \param ptr pointer TLV message array. 00194 * \param length length of TLV message array. 00195 * \param type Type of TLV. 00196 * \param data_ptr pointer to variable where the value is read. 00197 * \return pointer length of TLV 4 if success. 0 means TLV not found or does not have any data. 00198 * Any other value indicates that TLV is not as expected. 00199 */ 00200 #define thread_tmfcop_tlv_data_get_uint64(ptr,length,type,data) thread_meshcop_tlv_data_get_uint64(ptr,length,type,data) 00201 00202 #endif /* THREAD_TMFCOP_LIB_H_ */
Generated on Tue Jul 12 2022 13:55:00 by
