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.
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
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 * Relay message TLV 00057 */ 00058 #define MESHCOP_TLV_JOINER_ENCAPSULATION 17 00059 #define MESHCOP_TLV_JOINER_UDP_PORT 18 00060 #define MESHCOP_TLV_JOINER_IID 19 00061 #define MESHCOP_TLV_JOINER_ROUTER_LOCATOR 20 00062 #define MESHCOP_TLV_JOINER_ROUTER_KEK 21 00063 00064 /** 00065 * Application provisioning TLV? 00066 */ 00067 #define MESHCOP_TLV_PROVISIONING_URL 32 00068 #define MESHCOP_TLV_VENDOR_NAME 33 00069 #define MESHCOP_TLV_VENDOR_MODEL 34 00070 #define MESHCOP_TLV_VENDOR_SW_VERSION 35 00071 #define MESHCOP_TLV_VENDOR_DATA 36 00072 #define MESHCOP_TLV_VENDOR_STACK_VERSION 37 00073 00074 /** 00075 * Tunneling 00076 */ 00077 #define MESHCOP_TLV_UDP_ENCAPSULATION 48 00078 #define MESHCOP_TLV_IPV6_ADDRESS 49 00079 #define MESHCOP_TLV_TMF_FORWARDING_PORT 50 00080 00081 /** 00082 * 1.1 new feature TLV 00083 */ 00084 #define MESHCOP_TLV_PENDING_TIMESTAMP 51 00085 #define MESHCOP_TLV_DELAY_TIMER 52 00086 #define MESHCOP_TLV_CHANNEL_MASK 53 00087 #define MESHCOP_TLV_COUNT 54 00088 #define MESHCOP_TLV_PERIOD 55 00089 #define MESHCOP_TLV_DURATION 56 00090 #define MESHCOP_TLV_ENERGY_LIST 57 00091 #define MESHCOP_TLV_DISCOVERY_REQUEST 128 00092 #define MESHCOP_TLV_DISCOVERY_RESPONSE 129 00093 00094 /** 00095 * Write array TLV. 00096 * 00097 * \param ptr pointer for array where to write the TLV. 00098 * \param type Type of TLV. 00099 * \param length length of the data that is written in TLV. 00100 * \param data array for TLV value. 00101 * 00102 * \return pointer value for writing the next TLV. 00103 */ 00104 uint8_t *thread_meshcop_tlv_data_write(uint8_t *ptr, const uint8_t type, const uint16_t length, const uint8_t *data); 00105 00106 /** 00107 * Write header. 00108 * 00109 * \param ptr pointer for array where to write the TLV. 00110 * \param type Type of TLV. 00111 * \param length length of the data that is written in TLV. 00112 * 00113 * \return pointer value for writing the remaining bytes of network data. 00114 */ 00115 uint8_t *thread_meshcop_tlv_data_write_header(uint8_t *ptr, uint8_t type, uint16_t length); 00116 00117 /** 00118 * Write 1 byte length TLV. 00119 * 00120 * \param ptr pointer for array where to write the TLV. 00121 * \param type Type of TLV. 00122 * \param data value. 00123 * 00124 * \return pointer value for writing the next TLV. 00125 */ 00126 uint8_t *thread_meshcop_tlv_data_write_uint8(uint8_t *ptr, const uint8_t type, const uint8_t data); 00127 00128 /** 00129 * Write 2 byte length TLV. 00130 * 00131 * \param ptr pointer for array where to write the TLV. 00132 * \param type Type of TLV. 00133 * \param data value. 00134 * 00135 * \return pointer value for writing the next TLV. 00136 */ 00137 uint8_t *thread_meshcop_tlv_data_write_uint16(uint8_t *ptr, const uint8_t type, const uint16_t data); 00138 00139 /** 00140 * Write 4 byte length TLV. 00141 * 00142 * \param ptr pointer for array where to write the TLV. 00143 * \param type Type of TLV. 00144 * \param data value. 00145 * 00146 * \return pointer value for writing the next TLV. 00147 */ 00148 uint8_t *thread_meshcop_tlv_data_write_uint32(uint8_t *ptr, const uint8_t type, const uint32_t data); 00149 00150 /** 00151 * Write 8 byte length TLV. 00152 * 00153 * \param ptr pointer for array where to write the TLV. 00154 * \param type Type of TLV. 00155 * \param data value. 00156 * 00157 * \return pointer value for writing the next TLV. 00158 */ 00159 uint8_t *thread_meshcop_tlv_data_write_uint64(uint8_t *ptr, const uint8_t type, const uint64_t data); 00160 00161 /** 00162 * Find TLV from message. 00163 * 00164 * \param ptr Message buffer. 00165 * \param length Length of the message buffer to validate message. 00166 * \param type Type of TLV searched. 00167 * \param result_ptr Pointer value is given as result if length is positive. Can be NULL which only searches for the length. 00168 * 00169 * \return The length of the TLV data found 00170 * \return 0 if TLV is empty or no TLV found. 00171 * \return negative value indicates corrupted message. 00172 */ 00173 uint16_t thread_meshcop_tlv_find(const uint8_t *ptr, const uint16_t length, const uint8_t type, uint8_t **result_ptr); 00174 00175 /** 00176 * Read 1 byte length TLV. 00177 * 00178 * \param ptr pointer TLV message array. 00179 * \param length length of TLV message array. 00180 * \param type Type of TLV. 00181 * \param data_ptr pointer to variable where the value is read. 00182 * 00183 * \return pointer length of TLV 1 if success. 0 means TLV not found or does not have any data. 00184 * \return Any other value indicates that TLV is not as expected. 00185 */ 00186 uint8_t thread_meshcop_tlv_data_get_uint8(const uint8_t *ptr, const uint16_t length, const uint8_t type, uint8_t *data_ptr); 00187 00188 /** 00189 * Read 2 byte length TLV. 00190 * 00191 * \param ptr pointer TLV message array. 00192 * \param length length of TLV message array. 00193 * \param type Type of TLV. 00194 * \param data_ptr pointer to variable where the value is read. 00195 * 00196 * \return pointer length of TLV 2 if success. 0 means TLV not found or does not have any data. 00197 * \return Any other value indicates that TLV is not as expected. 00198 */ 00199 uint8_t thread_meshcop_tlv_data_get_uint16(const uint8_t *ptr, const uint16_t length, const uint8_t type, uint16_t *data_ptr); 00200 00201 /** 00202 * Read 4 byte length TLV. 00203 * 00204 * \param ptr pointer TLV message array. 00205 * \param length length of TLV message array. 00206 * \param type Type of TLV. 00207 * \param data_ptr pointer to variable where the value is read. 00208 * 00209 * \return pointer length of TLV 4 if success. 0 means TLV not found or does not have any data. 00210 * \return Any other value indicates that TLV is not as expected. 00211 */ 00212 uint8_t thread_meshcop_tlv_data_get_uint32(const uint8_t *ptr, const uint16_t length, const uint8_t type, uint32_t *data_ptr); 00213 00214 /** 00215 * Read 8 byte length TLV. 00216 * 00217 * \param ptr pointer TLV message array. 00218 * \param length length of TLV message array. 00219 * \param type Type of TLV. 00220 * \param data_ptr pointer to variable where the value is read. 00221 * 00222 * \return pointer length of TLV 4 if success. 0 means TLV not found or does not have any data. 00223 * \return Any other value indicates that TLV is not as expected. 00224 */ 00225 uint8_t thread_meshcop_tlv_data_get_uint64(const uint8_t *ptr, const uint16_t length, const uint8_t type, uint64_t *data_ptr); 00226 00227 #endif /* THREAD_MESHCOP_LIB_H_ */
Generated on Tue Jul 12 2022 12:28:56 by
1.7.2
