Nicolas Borla / Mbed OS BBR_1Ebene
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers thread_diagcop_lib.h Source File

thread_diagcop_lib.h

Go to the documentation of this file.
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 #ifndef NANOSTACK_SOURCE_6LOWPAN_THREAD_THREAD_DIAGCOP_LIB_H_
00032 #define NANOSTACK_SOURCE_6LOWPAN_THREAD_THREAD_DIAGCOP_LIB_H_
00033 
00034 #include "ns_types.h"
00035 #include "thread_meshcop_lib.h" // this uses the same parser functions than meshcop but different message types
00036 
00037 /**
00038  * \file thread_diagcop_lib.h
00039  * \brief CoAP diagnostic TLV.
00040  * Note that these TLV types overlap with meshcop
00041  * and must not be used in same messages.
00042  */
00043 
00044 #define DIAGCOP_TLV_EXTENDED_MAC_ADDRESS                     0  /**< Can not reset*/
00045 #define DIAGCOP_TLV_ADDRESS16                                1  /**< Can not reset*/
00046 #define DIAGCOP_TLV_MODE                                     2  /**< Can not reset*/
00047 #define DIAGCOP_TLV_TIMEOUT                                  3  /**< Can not reset*/
00048 #define DIAGCOP_TLV_CONNECTIVITY                             4  /**< Can not reset*/
00049 #define DIAGCOP_TLV_ROUTE64                                  5  /**< Can not reset*/
00050 #define DIAGCOP_TLV_LEADER_DATA                              6  /**< Can not reset*/
00051 #define DIAGCOP_TLV_NETWORK_DATA                             7  /**< Can not reset*/
00052 #define DIAGCOP_TLV_IPV6_ADDRESS_LIST                        8  /**< Can not reset*/
00053 #define DIAGCOP_TLV_MAC_COUNTERS                             9  /**< Can reset*/
00054 #define DIAGCOP_TLV_BATTERY_LEVEL                           14  /**< Can reset*/
00055 #define DIAGCOP_TLV_SUPPLY_VOLTAGE                          15  /**< Can not reset*/
00056 #define DIAGCOP_TLV_CHILD_TABLE                             16  /**< Can not reset*/
00057 #define DIAGCOP_TLV_CHANNEL_PAGES                           17  /**< Can not reset*/
00058 #define DIAGCOP_TLV_TYPE_LIST                               18  /**< List type*/
00059 
00060 /**
00061  * \brief Write array TLV.
00062  *
00063  * \param ptr A pointer to array in which to write the TLV.
00064  * \param type The type of TLV.
00065  * \param length The length of the data that is written in TLV.
00066  * \param data The array for TLV value.
00067  * \return pointer The value for writing the next TLV.
00068  */
00069 #define thread_diagcop_tlv_data_write(ptr,type,length,data) thread_meshcop_tlv_data_write(ptr,type,length,data)
00070 
00071 /**
00072  * \brief Write 1 byte length TLV.
00073  *
00074  * \param ptr A pointer to array in which to write the TLV.
00075  * \param type The type of TLV.
00076  * \param data value.
00077  * \return pointer value for writing the next TLV.
00078  */
00079 #define thread_diagcop_tlv_data_write_uint8(ptr,type,data) thread_meshcop_tlv_data_write_uint8(ptr,type,data)
00080 
00081 /**
00082  * \brief Write 2 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_diagcop_tlv_data_write_uint16(ptr,type,data) thread_meshcop_tlv_data_write_uint16(ptr,type,data)
00090 
00091 /**
00092  * \brief Write 4 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_diagcop_tlv_data_write_uint32(ptr,type,data) thread_meshcop_tlv_data_write_uint32(ptr,type,data)
00100 
00101 /**
00102  * \brief Write 8 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_diagcop_tlv_data_write_uint64(ptr,type,data) thread_meshcop_tlv_data_write_uint64(ptr,type,data)
00110 
00111 /**
00112  * \brief Find TLV from message.
00113  *
00114  * \param ptr Message buffer.
00115  * \param length Length of the message buffer to validate message.
00116  * \param type Type of TLV searched.
00117  * \param result Pointer value is given as result if length is positive. Can be NULL which only searches for the length.
00118  * \return The length of the TLV data found
00119  * \return 0 if TLV is empty or no TLV found.
00120  * \return negative value indicates corrupted message.
00121  */
00122 #define thread_diagcop_tlv_find(ptr,length,type,result) thread_meshcop_tlv_find(ptr,length,type,result)
00123 
00124 /**
00125  * \brief Read 1 byte length TLV.
00126  *
00127  * \param ptr pointer TLV message array.
00128  * \param length length of TLV message array.
00129  * \param type Type of TLV.
00130  * \param data pointer to variable where the value is read.
00131  * \return pointer length of TLV 1 if success. 0 means TLV not found or does not have any data.
00132  * Any other value indicates that TLV is not as expected.
00133  */
00134 #define thread_diagcop_tlv_data_get_uint8(ptr,length,type,data) thread_meshcop_tlv_data_get_uint8(ptr,length,type,data)
00135 
00136 /**
00137  * \brief Read 2 byte length TLV.
00138  *
00139  * \param ptr pointer TLV message array.
00140  * \param length length of TLV message array.
00141  * \param type Type of TLV.
00142  * \param data pointer to variable where the value is read.
00143  * \return pointer length of TLV 2 if success. 0 means TLV not found or does not have any data.
00144  * Any other value indicates that TLV is not as expected.
00145  */
00146 #define thread_diagcop_tlv_data_get_uint16(ptr,length,type,data) thread_meshcop_tlv_data_get_uint16(ptr,length,type,data)
00147 
00148 /**
00149  * \brief Read 4 byte length TLV.
00150  *
00151  * \param ptr pointer TLV message array.
00152  * \param length length of TLV message array.
00153  * \param type Type of TLV.
00154  * \param data pointer to variable where the value is read.
00155  * \return pointer length of TLV 4 if success. 0 means TLV not found or does not have any data.
00156  * Any other value indicates that TLV is not as expected.
00157  */
00158 #define thread_diagcop_tlv_data_get_uint32(ptr,length,type,data) thread_meshcop_tlv_data_get_uint32(ptr,length,type,data)
00159 
00160 /**
00161  * \brief Read 8 byte length TLV.
00162  *
00163  * \param ptr pointer TLV message array.
00164  * \param length length of TLV message array.
00165  * \param type Type of TLV.
00166  * \param data pointer to variable where the value is read.
00167  * \return pointer length of TLV 4 if success. 0 means TLV not found or does not have any data.
00168  * Any other value indicates that TLV is not as expected.
00169  */
00170 #define thread_diagcop_tlv_data_get_uint64(ptr,length,type,data) thread_meshcop_tlv_data_get_uint64(ptr,length,type,data)
00171 
00172 
00173 #endif /* NANOSTACK_SOURCE_6LOWPAN_THREAD_THREAD_DIAGCOP_LIB_H_ */