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.
net_thread_test.h
00001 /* 00002 * Copyright (c) 2014-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 #ifndef NET_THREAD_TEST_H_ 00031 #define NET_THREAD_TEST_H_ 00032 00033 /* Prevent this file being inserted in public Doxygen generated file 00034 * this is not part of our external API. */ 00035 #ifndef DOXYGEN 00036 00037 /** 00038 * \file net_thread_test.h 00039 * \brief Thread Library Test API. 00040 * 00041 * \warning NOTICE! This is test API must not be used externally. 00042 * 00043 * \warning This file is not part of the version number control and can change any time. 00044 * 00045 */ 00046 00047 00048 #ifdef __cplusplus 00049 extern "C" { 00050 #endif 00051 00052 #include "ns_types.h" 00053 00054 #define thread_test_router_upgrade(iface) thread_test_router_id_request_send(iface, 2) // THREAD_COAP_STATUS_TLV_TOO_FEW_ROUTERS 00055 /** 00056 * \brief Add a static neighbour 00057 * 00058 * Test API: Add a neighbour. Adds, or updates, a non-expiring neighbour to the 00059 * Thread Link Set, and updates the Route Set accordingly. Basically equivalent 00060 * to receiving an MLE advertisement with a Route TLV, except it doesn't expire. 00061 * 00062 * See draft-kelsey-thread-routing-00 for more info on data format. 00063 * 00064 * \param interface_id Interface to modify 00065 * \param neighbour_addr Neighbour short address (must be a router address) 00066 * \param link_margin_db Notional link margin for reception from this neighbour. 00067 * \param id_sequence Sequence number for id_mask 00068 * \param id_mask Bit mask of router IDs 00069 * \param route_data One octet per set bit in id_mask 00070 * 00071 * \return 0 Success 00072 * \return <0 Failure 00073 */ 00074 int_fast8_t arm_nwk_6lowpan_thread_test_add_neighbour( 00075 int8_t interface_id, 00076 uint16_t neighbour_short_addr, 00077 uint_fast8_t link_margin_db, 00078 uint8_t id_sequence, 00079 const uint8_t *id_mask, 00080 const uint8_t *route_data); 00081 00082 /** 00083 * \brief API to set reed advertisement interval 00084 * \param interface_id Interface to modify 00085 * \param advertisement_interval Interval between advertisements to be set 00086 * \param jitter_interval Maximum value of random jitter interval to be added to advertisement_interval 00087 * \return 0 Success 00088 * \return < 0 Other errors 00089 */ 00090 int8_t thread_reed_set_advertisement_interval(int8_t interface_id, uint16_t advertisement_interval, uint16_t jitter_interval); 00091 00092 /** 00093 * \brief Remove a static neighbour 00094 * 00095 * Test API: Remove a neighbour. Remove a neighbour from the Thread Link Set 00096 * (whether added through arm_nwk_6lowpan_thread_test_add_neighbour, or 00097 * automatically through MLE). 00098 * 00099 * \param interface_id Interface to modify 00100 * \param neighbour_addr Neighbour short address (must be a router address) 00101 * 00102 * \return 0 Success 00103 * \return -1 Not an existing neighbour 00104 * \return <-1 Other errors 00105 */ 00106 int_fast8_t arm_nwk_6lowpan_thread_test_remove_neighbour( 00107 int8_t interface_id, 00108 uint16_t neighbour_short_addr); 00109 00110 /** 00111 * \brief Print routing database 00112 * 00113 * Test API: Dump the routing data base (Router ID Set, Link Set and Route 00114 * Set) to the debug channel. 00115 * 00116 * \param interface_id Interface to interrogate 00117 */ 00118 void arm_nwk_6lowpan_thread_test_print_routing_database(int8_t interface_id); 00119 00120 00121 /** 00122 * \brief Thread Leader max router ID limit set 00123 * 00124 * This function should use just for test purpose Thread define this by default to 32 00125 * 00126 * \param interface_id Network Interface 00127 * \param maxRouterLimit Min Accepted value is 1 and max 32 00128 * 00129 * return 0, Set OK 00130 * return <0 Set Fail 00131 */ 00132 int thread_test_max_accepted_router_id_limit_set( 00133 int8_t interface_id, 00134 uint8_t maxRouterLimit); 00135 00136 /** 00137 * \brief Set Thread network ID timeout 00138 * 00139 * \param interface_id Interface to modify 00140 * \param network_id_timeout network timeout as seconds 00141 * 00142 * \return 0 Success 00143 * \return -1 Invalid interface id 00144 * \return -2 Thread not active 00145 * \return -3 invalid timeout value 00146 */ 00147 int8_t thread_routing_set_network_id_timeout(int8_t interface_id, uint16_t network_id_timeout); 00148 00149 /** 00150 * \brief Get Thread network ID timeout 00151 * 00152 * \param interface_id Interface to modify 00153 * \param network_id_timeout pointer, where current network id timeout will be saved as seconds 00154 * 00155 * \return 0 Success 00156 * \return -1 Invalid interface id 00157 * \return -2 Thread not active 00158 * \return -3 invalid pointer 00159 */ 00160 int8_t thread_routing_get_network_id_timeout(int8_t interface_id, uint16_t *network_id_timeout); 00161 00162 /** 00163 * \brief Print Thread network data 00164 * 00165 * \param interface_id Network Interface 00166 * 00167 * \return 0, OK 00168 * \return <0 Not OK 00169 */ 00170 00171 int thread_test_print_network_data(int8_t interface_id); 00172 00173 /** 00174 * \brief Thread Leader Context ID reuse timeout set 00175 * 00176 * This function should be used to change default 48 hours to shorter one 00177 * 00178 * \param interface_id Network Interface 00179 * \param timeout Min Accepted value is 60 seconds and max 48 hours (48*3600) 00180 * 00181 * \return 0, Set OK 00182 * \return <0 Set Fail 00183 */ 00184 int thread_test_set_context_id_reuse_timeout( 00185 int8_t interface_id, 00186 uint32_t timeout); 00187 00188 /** 00189 * \brief Leader of Thread network can kick Router out from Network. 00190 * 00191 * \param interface_id Network Interface 00192 * \param routerId Routter id of router that is kicked 00193 * 00194 * \return 0, Remove OK 00195 * \return <0 Remove fail 00196 */ 00197 int thread_test_remove_router_by_id(int8_t interface_id, uint8_t routerId); 00198 00199 /** 00200 * \brief Start router downgrade process. 00201 * 00202 * \param interface_id Network Interface 00203 * 00204 * \return 0, downgrade started 00205 * \return <0 fail 00206 */ 00207 int thread_test_router_downgrade(int8_t interface_id); 00208 00209 /** 00210 * \brief Set Thread Security Material. Terms are defined in Thread security specification 00211 * 00212 * \param interface_id Network Interface 00213 * \param enableSecurity Boolean for enable security or disable 00214 * \param thrMasterKey Master Key material which will be used for generating new key 00215 * \param thrKeySequenceCounter Periodic counter used to generate new MAC and MLE keys 00216 * \param thrKeyRotation Update period (in seconds) for thrKeySequenceCounter 00217 * 00218 * \return 0, ADD OK 00219 * \return <0 Add Not OK 00220 */ 00221 int thread_test_security_material_set(int8_t interface_id, bool enableSecurity, uint8_t *thrMasterKey, uint32_t thrKeySequenceCounter, uint32_t thrKeyRotation); 00222 00223 /** 00224 * \brief Set Thread version number. 00225 * 00226 * \param interface_id Network Interface 00227 * \param version "1 == Thread version 1.0" or "2 == Thread version 1.1" 00228 * 00229 * \return 0, OK 00230 * \return <0 Error 00231 */ 00232 int thread_test_version_set(int8_t interface_id, uint8_t version); 00233 /** 00234 * \brief Set Thread router selection jitter. 00235 * 00236 * \param interface_id Network Interface 00237 * \param value must be over 1 default is 120 00238 * 00239 * \return 0, OK 00240 * \return <0 Error 00241 */ 00242 int thread_test_router_selection_jitter_set(int8_t interface_id, uint32_t jitter); 00243 00244 /** 00245 * \brief Sets the thread MIN_DELAY_TIMER default value. 00246 * 00247 * \param interface_id Network Interface 00248 * \param delay_timer_value delay timer value in seconds used in leader 00249 * 00250 * \return 0, OK 00251 * \return <0 Error 00252 */ 00253 int thread_test_min_delay_timer_set(int8_t interface_id, uint32_t delay_timer_value); 00254 /** 00255 * \brief Increment Thread key sequence counter 00256 * 00257 * \param interface_id Network Interface 00258 * 00259 * \return 0, OK 00260 * \return <0 Error 00261 */ 00262 int thread_test_increment_key_sequence_counter(int8_t interface_id); 00263 00264 /** 00265 * \brief Set new Thread key sequence counter 00266 * 00267 * Call define new key and next key same time 00268 * 00269 * \param interface_id Network Interface 00270 * \param thrKeySequenceCounter this need to be bigger than current sequence 00271 * 00272 * \return 0, OK 00273 * \return <0 Error 00274 */ 00275 int thread_test_key_sequence_counter_update(int8_t interface_id, uint32_t thrKeySequenceCounter); 00276 00277 /** 00278 * \brief Set new Thread key rotation value 00279 * 00280 * \param interface_id Network interface ID 00281 * \param thrKeyRotation Key rotation value in seconds 00282 * 00283 * \return 0, OK 00284 * \return <0 Error 00285 */ 00286 int thread_test_key_rotation_update(int8_t interface_id, uint32_t thrKeyRotation); 00287 00288 /** 00289 * \brief Thread router select threshold values set 00290 * 00291 * \param interface_id Network Interface 00292 * \param upgradeThreshold Set REED up grade to router threshold 00293 * \param downgradeThreshold Set Router down grade to REED threshold 00294 * 00295 * \return 0, Set OK 00296 * \return <0 Set Fail 00297 */ 00298 int thread_test_router_select_threshold_values_set( 00299 int8_t interface_id, 00300 uint8_t upgradeThreshold, 00301 uint8_t downgradeThreshold); 00302 00303 /** 00304 * \brief Send PAN ID query message to destination 00305 * 00306 * \param interface_id Network Interface 00307 * 00308 * \return 0, Set OK 00309 * \return <0 Set Fail 00310 */ 00311 int thread_test_panid_query_send(int8_t interface_id, uint8_t *address_ptr, uint16_t session_id, uint16_t panid, uint8_t channel_page, uint8_t *mask_ptr); 00312 00313 /** 00314 * \brief Send energy scan message to destination 00315 * 00316 * \param interface_id Network Interface 00317 * 00318 * \return 0, Set OK 00319 * \return <0 Set Fail 00320 */ 00321 int thread_test_energy_scan_send(int8_t interface_id, uint8_t *address_ptr, uint16_t session_id, uint8_t channel_page, uint8_t *mask_ptr, uint16_t period, uint8_t count, uint16_t duration); 00322 00323 /** 00324 * \brief Send announcement message 00325 * 00326 * \param interface_id Network Interface 00327 * \param channel high uint16 is the channel page, lower part is the channel number on that page 00328 * 00329 * \return 0, Set OK 00330 * \return <0 Set Fail 00331 */ 00332 int thread_test_announce_ntf_send(int8_t interface_id, uint8_t *address_ptr, uint32_t channel, uint16_t panid, uint64_t timestamp); 00333 00334 /** 00335 * \brief Send energy scan message to destination 00336 * 00337 * \param interface_id Network Interface 00338 * 00339 * \return 0, Set OK 00340 * \return <0 Set Fail 00341 */ 00342 int thread_test_announce_begin_send(int8_t interface_id, uint8_t *address_ptr, uint16_t session_id, uint8_t channel_page, uint8_t *mask_ptr, uint16_t period, uint8_t count); 00343 00344 /** 00345 * \brief Get partition info 00346 * 00347 * \param interface_id Network Interface 00348 * \param partition_id Current partition id can be NULL if not needed. 00349 * \param weighting Current weighting can be NULL if not needed. 00350 * \param data_version Current data version can be NULL if not needed. 00351 * \param stable_data_version Current stable data version can be NULL if not needed. 00352 * \param leader_id Current leader id can be NULL if not needed. 00353 * 00354 * \return 0, Set OK 00355 * \return <0 Set Fail 00356 */ 00357 int thread_test_partition_info_get(int8_t interface_id, uint32_t *partition_id, uint8_t *weighting, uint8_t *data_version, uint8_t *stable_data_version, uint8_t *leader_id); 00358 00359 /** 00360 * \brief Set next partition ID when we next time partition. This is used to control specific behaviour in tests. 00361 * 00362 * \param interface_id Network Interface 00363 * 00364 * \return 0, Set OK 00365 * \return <0 Set Fail 00366 */ 00367 int thread_test_partition_info_set(int8_t interface_id, uint32_t partition_id); 00368 00369 /** 00370 * \brief Get thread information. 00371 * 00372 * \param interface_id Network Interface 00373 * \param short_addr own short address 00374 * \param router_count amount of active routers in network 00375 * \param network_stable stable network achieved no upgrade or downgrade pending 00376 * 00377 * \return 0, Set OK 00378 * \return <0 Set Fail 00379 */ 00380 int8_t thread_test_thread_information_get(int8_t interface_id, uint16_t *short_addr, uint8_t *router_count, bool *network_stable); 00381 00382 /** 00383 * \brief Get child count 00384 * 00385 * \param interface_id Network Interface 00386 * 00387 * \return 0, Set OK 00388 * \return <0 Set Fail 00389 */ 00390 int8_t thread_test_child_count_get(int8_t interface_id); 00391 00392 /** 00393 * \brief Get child information 00394 * 00395 * get information for index child. if found returns 0 with correct information. 00396 * 00397 * \param interface_id Network Interface 00398 * 00399 * \return 0, OK 00400 * \return <0 Fail no child with this index found 00401 */ 00402 int8_t thread_test_child_info_get(int8_t interface_id, uint8_t index, uint16_t *short_addr, bool *sleepy, uint8_t *mac64, uint8_t *margin); 00403 00404 /** 00405 * \brief Get neighbour information 00406 * 00407 * \param interface_id Network Interface 00408 * 00409 * \return 0, Set OK 00410 * \return <0 Set Fail 00411 */ 00412 int8_t thread_test_neighbour_info_get(int8_t interface_id, uint8_t index, uint16_t *short_addr, uint8_t *mac64, uint8_t *margin); 00413 00414 typedef int (response_cb)(int8_t interface_id, uint8_t *response_ptr, uint16_t response_len); 00415 00416 /** 00417 * \brief Send diagnostic command DEPRECATED 00418 * 00419 * \param interface_id Network Interface 00420 * \param address_ptr Address to which the command is sent 00421 * \param uri_ptr Uri for the command 00422 * \param request_length The length of the request 00423 * \param request_ptr Pointer to the beginning of the request contents 00424 * \param resp_cb Pointer to callback function that is called after the reply for the command is obtained 00425 * \return 0, Command send OK 00426 * \return <0 Command send Fail 00427 */ 00428 int thread_test_diagnostic_command_send(int8_t interface_id, uint8_t *address_ptr,const char *uri_ptr, uint8_t request_length, uint8_t *request_ptr, response_cb *resp_cb); 00429 00430 typedef int (coap_response_cb)(int8_t interface_id, uint8_t message_code, uint8_t message_type, uint8_t *response_ptr, uint16_t response_len); 00431 00432 /** 00433 * \brief Send diagnostic request 00434 * 00435 * \param interface_id Network Interface 00436 * \param address_ptr Address to which the command is sent 00437 * \param msg_type Uri for the command 00438 * \param msg_code Uri for the command 00439 * \param uri_ptr Uri for the command 00440 * \param request_length The length of the request 00441 * \param request_ptr Pointer to the beginning of the request contents 00442 * \param resp_cb Pointer to callback function that is called after the reply for the command is obtained 00443 * 00444 * \return 0, Command send OK 00445 * \return <0 Command send Fail 00446 */ 00447 int thread_test_coap_request_send(int8_t interface_id, uint8_t *address_ptr, uint16_t port, uint8_t msg_type, uint8_t msg_code, uint16_t content_format, const char *uri_ptr, uint8_t *request_ptr, uint8_t request_length, coap_response_cb *resp_cb); 00448 00449 /** 00450 * \brief Set initial SLAAC iid. 00451 * 00452 * \param interface_id Network Interface 00453 * \param iid Interface identifier pointer must be 8 bytes long buffer. can be NULL to disable. 00454 * \return 0, Command OK 00455 * \return <0 Command Fail 00456 */ 00457 int8_t thread_test_initial_slaac_iid_set(int8_t interface_id, uint8_t *iid); 00458 00459 /** 00460 * \brief Send router ID request. 00461 * 00462 * \param interface_id Network Interface 00463 * \param status Value of router ID request status TLV 00464 * \return 0, Command OK 00465 * \return <0 Command Fail 00466 */ 00467 int8_t thread_test_router_id_request_send(int8_t interface_id, uint8_t status); 00468 00469 /** 00470 * \brief Set joiner port to joiner router device. 00471 * If port == 0, then default port is used. 00472 * 00473 * \param iid Joiner port. 00474 * \return 0, Command OK 00475 * \return <0 Command Fail 00476 */ 00477 int8_t thread_test_joiner_router_joiner_port_set(uint16_t port); 00478 00479 /** 00480 *\brief set a router address to be requested. For a router, this address is sent 00481 *\in address solicit request to leader and for leader this is the router address 00482 * 00483 * \param interface_id Network Interface 00484 * \param router_addr Address requested 00485 * \return 0, Command OK 00486 * \return <0 Command Fail 00487 */ 00488 int8_t thread_test_router_address_set(int8_t interface_id, uint16_t router_addr); 00489 00490 /** 00491 *\brief sends any MLE message to any destination. 00492 * 00493 * \param interface_id Network Interface 00494 * \param dst_address destination address 00495 * \param msg_id MLE message id 00496 * \param write_src_addr write short address of the device 00497 * \param write_leader_data write leader data 00498 * \param write_network_data write network data 00499 * \param write_timestamp write current timestamps* 00500 * \param write_operational_set write current operational datasets * 00501 * \param write_challenge add challenge to the message 00502 * \param msg_ptr additional buffer addded to message 00503 * \param msg_len length of the additional message 00504 * \return 0, Command OK 00505 * \return <0 Command Fail 00506 */ 00507 int thread_test_mle_message_send(int8_t interface_id, uint8_t *dst_address, uint8_t msg_id, bool write_src_addr, bool write_leader_data, bool write_network_data, bool write_timestamp, bool write_operational_set, bool write_challenge, uint8_t *msg_ptr, uint8_t msg_len); 00508 00509 00510 /** 00511 * \brief Set extension name. 00512 * 00513 * \param interface_id Network Interface 00514 * \param extension_name Extension name string 00515 * 00516 * \return 0 OK 00517 * \return <0 Failure 00518 */ 00519 int thread_test_extension_name_set(int8_t interface_id, char extension_name[16]); 00520 #ifdef __cplusplus 00521 } 00522 #endif 00523 00524 #endif /* DOXYGEN */ 00525 #endif /* NET_THREAD_TEST_H_ */
Generated on Tue Jul 12 2022 14:24:29 by
