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: blinky_max32630fthr
thread_meshcop_lib.h
00001 /* 00002 * Copyright (c) 2015 ARM Limited. All rights reserved. 00003 * 00004 * SPDX-License-Identifier: LicenseRef-PBL 00005 * 00006 * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * https://www.mbed.com/licenses/PBL-1.0 00010 * 00011 * See the License for the specific language governing permissions and limitations under the License. 00012 * 00013 */ 00014 00015 /** 00016 * \file thread_meshcop_lib.h 00017 * \brief Public API to handle the Thread management framework message parsing and building. 00018 * 00019 */ 00020 00021 #ifndef THREAD_MESHCOP_LIB_H_ 00022 #define THREAD_MESHCOP_LIB_H_ 00023 00024 #include "ns_types.h" 00025 00026 /** 00027 * TLV Types used in thread network 00028 */ 00029 /** 00030 * Network configuration TLV 00031 */ 00032 #define MESHCOP_TLV_CHANNEL 0 00033 #define MESHCOP_TLV_PANID 1 00034 #define MESHCOP_TLV_XPANID 2 00035 #define MESHCOP_TLV_NETWORK_NAME 3 00036 #define MESHCOP_TLV_PSKC 4 00037 #define MESHCOP_TLV_NETWORK_MASTER_KEY 5 00038 #define MESHCOP_TLV_NETWORK_KEY_SEQUENCE 6 00039 #define MESHCOP_TLV_NETWORK_MESH_LOCAL_ULA 7 00040 00041 /** 00042 * Network management TLV 00043 */ 00044 #define MESHCOP_TLV_STEERING_DATA 8 00045 #define MESHCOP_TLV_BORDER_ROUTER_LOCATOR 9 00046 #define MESHCOP_TLV_COMMISSIONER_ID 10 00047 #define MESHCOP_TLV_COMMISSIONER_SESSION_ID 11 00048 #define MESHCOP_TLV_SECURITY_POLICY 12 00049 #define MESHCOP_TLV_GET 13 00050 #define MESHCOP_TLV_ACTIVE_TIME_STAMP 14 00051 #define MESHCOP_TLV_COMMISSIONER_UDP_PORT 15 00052 #define MESHCOP_TLV_STATE 16 00053 #define MESHCOP_TLV_JOINER_UDP_PORT 18 00054 00055 /** 00056 * Network management TLV specific bit defines 00057 */ 00058 #define MESHCOP_TLV_ACTIVE_TIME_STAMP_U_BIT 0x01 00059 00060 /** 00061 * Relay message TLV 00062 */ 00063 #define MESHCOP_TLV_JOINER_ENCAPSULATION 17 00064 #define MESHCOP_TLV_JOINER_UDP_PORT 18 00065 #define MESHCOP_TLV_JOINER_IID 19 00066 #define MESHCOP_TLV_JOINER_ROUTER_LOCATOR 20 00067 #define MESHCOP_TLV_JOINER_ROUTER_KEK 21 00068 00069 /** 00070 * Application provisioning TLV? 00071 */ 00072 #define MESHCOP_TLV_PROVISIONING_URL 32 00073 #define MESHCOP_TLV_VENDOR_NAME 33 00074 #define MESHCOP_TLV_VENDOR_MODEL 34 00075 #define MESHCOP_TLV_VENDOR_SW_VERSION 35 00076 #define MESHCOP_TLV_VENDOR_DATA 36 00077 #define MESHCOP_TLV_VENDOR_STACK_VERSION 37 00078 00079 /** 00080 * Tunneling 00081 */ 00082 #define MESHCOP_TLV_UDP_ENCAPSULATION 48 00083 #define MESHCOP_TLV_IPV6_ADDRESS 49 00084 #define MESHCOP_TLV_TMF_FORWARDING_PORT 50 00085 00086 /** 00087 * 1.1 new feature TLV 00088 */ 00089 #define MESHCOP_TLV_PENDING_TIMESTAMP 51 00090 #define MESHCOP_TLV_DELAY_TIMER 52 00091 #define MESHCOP_TLV_CHANNEL_MASK 53 00092 #define MESHCOP_TLV_COUNT 54 00093 #define MESHCOP_TLV_PERIOD 55 00094 #define MESHCOP_TLV_DURATION 56 00095 #define MESHCOP_TLV_ENERGY_LIST 57 00096 #define MESHCOP_TLV_DISCOVERY_REQUEST 128 00097 #define MESHCOP_TLV_DISCOVERY_RESPONSE 129 00098 00099 /** 00100 * Write array TLV. 00101 * 00102 * \param ptr pointer for array where to write the TLV. 00103 * \param type Type of TLV. 00104 * \param length length of the data that is written in TLV. 00105 * \param data array for TLV value. 00106 * 00107 * \return pointer value for writing the next TLV. 00108 */ 00109 uint8_t *thread_meshcop_tlv_data_write(uint8_t *ptr, const uint8_t type, const uint16_t length, const uint8_t *data); 00110 00111 /** 00112 * Write header. 00113 * 00114 * \param ptr pointer for array where to write the TLV. 00115 * \param type Type of TLV. 00116 * \param length length of the data that is written in TLV. 00117 * 00118 * \return pointer value for writing the remaining bytes of network data. 00119 */ 00120 uint8_t *thread_meshcop_tlv_data_write_header(uint8_t *ptr, uint8_t type, uint16_t length); 00121 00122 /** 00123 * Write 1 byte length TLV. 00124 * 00125 * \param ptr pointer for array where to write the TLV. 00126 * \param type Type of TLV. 00127 * \param data value. 00128 * 00129 * \return pointer value for writing the next TLV. 00130 */ 00131 uint8_t *thread_meshcop_tlv_data_write_uint8(uint8_t *ptr, const uint8_t type, const uint8_t data); 00132 00133 /** 00134 * Write 2 byte length TLV. 00135 * 00136 * \param ptr pointer for array where to write the TLV. 00137 * \param type Type of TLV. 00138 * \param data value. 00139 * 00140 * \return pointer value for writing the next TLV. 00141 */ 00142 uint8_t *thread_meshcop_tlv_data_write_uint16(uint8_t *ptr, const uint8_t type, const uint16_t data); 00143 00144 /** 00145 * Write 4 byte length TLV. 00146 * 00147 * \param ptr pointer for array where to write the TLV. 00148 * \param type Type of TLV. 00149 * \param data value. 00150 * 00151 * \return pointer value for writing the next TLV. 00152 */ 00153 uint8_t *thread_meshcop_tlv_data_write_uint32(uint8_t *ptr, const uint8_t type, const uint32_t data); 00154 00155 /** 00156 * Write 8 byte length TLV. 00157 * 00158 * \param ptr pointer for array where to write the TLV. 00159 * \param type Type of TLV. 00160 * \param data value. 00161 * 00162 * \return pointer value for writing the next TLV. 00163 */ 00164 uint8_t *thread_meshcop_tlv_data_write_uint64(uint8_t *ptr, const uint8_t type, const uint64_t data); 00165 00166 /** 00167 * Check if TLV exists in the message. 00168 * 00169 * \param ptr Message buffer. 00170 * \param length Length of the message buffer to validate message. 00171 * \param type Type of TLV searched. 00172 * 00173 * \return true if TLV is found. 00174 * \return false if TLV does not exist. 00175 */ 00176 bool thread_meshcop_tlv_exist(const uint8_t *ptr, const uint16_t length, const uint8_t type); 00177 00178 /** 00179 * Find TLV from message. 00180 * 00181 * \param ptr Message buffer. 00182 * \param length Length of the message buffer to validate message. 00183 * \param type Type of TLV searched. 00184 * \param result_ptr Pointer value is given as result if length is positive. Can be NULL which only searches for the length. 00185 * 00186 * \return The length of the TLV data found 00187 * \return 0 if TLV is empty or no TLV found. 00188 * \return negative value indicates corrupted message. 00189 */ 00190 uint16_t thread_meshcop_tlv_find(const uint8_t *ptr, const uint16_t length, const uint8_t type, uint8_t **result_ptr); 00191 00192 /** 00193 * Read 1 byte length TLV. 00194 * 00195 * \param ptr pointer TLV message array. 00196 * \param length length of TLV message array. 00197 * \param type Type of TLV. 00198 * \param data_ptr pointer to variable where the value is read. 00199 * 00200 * \return pointer length of TLV 1 if success. 0 means TLV not found or does not have any data. 00201 * \return Any other value indicates that TLV is not as expected. 00202 */ 00203 uint8_t thread_meshcop_tlv_data_get_uint8(const uint8_t *ptr, const uint16_t length, const uint8_t type, uint8_t *data_ptr); 00204 00205 /** 00206 * Read 2 byte length TLV. 00207 * 00208 * \param ptr pointer TLV message array. 00209 * \param length length of TLV message array. 00210 * \param type Type of TLV. 00211 * \param data_ptr pointer to variable where the value is read. 00212 * 00213 * \return pointer length of TLV 2 if success. 0 means TLV not found or does not have any data. 00214 * \return Any other value indicates that TLV is not as expected. 00215 */ 00216 uint8_t thread_meshcop_tlv_data_get_uint16(const uint8_t *ptr, const uint16_t length, const uint8_t type, uint16_t *data_ptr); 00217 00218 /** 00219 * Read 4 byte length TLV. 00220 * 00221 * \param ptr pointer TLV message array. 00222 * \param length length of TLV message array. 00223 * \param type Type of TLV. 00224 * \param data_ptr pointer to variable where the value is read. 00225 * 00226 * \return pointer length of TLV 4 if success. 0 means TLV not found or does not have any data. 00227 * \return Any other value indicates that TLV is not as expected. 00228 */ 00229 uint8_t thread_meshcop_tlv_data_get_uint32(const uint8_t *ptr, const uint16_t length, const uint8_t type, uint32_t *data_ptr); 00230 00231 /** 00232 * Read 8 byte length TLV. 00233 * 00234 * \param ptr pointer TLV message array. 00235 * \param length length of TLV message array. 00236 * \param type Type of TLV. 00237 * \param data_ptr pointer to variable where the value is read. 00238 * 00239 * \return pointer length of TLV 4 if success. 0 means TLV not found or does not have any data. 00240 * \return Any other value indicates that TLV is not as expected. 00241 */ 00242 uint8_t thread_meshcop_tlv_data_get_uint64(const uint8_t *ptr, const uint16_t length, const uint8_t type, uint64_t *data_ptr); 00243 00244 #endif /* THREAD_MESHCOP_LIB_H_ */
Generated on Tue Jul 12 2022 14:21:23 by
1.7.2
