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.
Fork of OmniWheels by
net_6lowpan_parameter_api.c
00001 /* 00002 * Copyright (c) 2014-2017, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #include "nsconfig.h" 00019 #include "ns_types.h" 00020 #include "string.h" 00021 #include "NWK_INTERFACE/Include/protocol.h" 00022 #include "net_6lowpan_parameter_api.h" 00023 #include "6LoWPAN/ND/nd_router_object.h" 00024 00025 /** 00026 * \brief API to change 6LoWPAN ND bootstrap parameters. 00027 * 00028 * Note: This function should be called after net_init_core() and definitely 00029 * before creating any 6LoWPAN interface. 00030 * 00031 * For future compatibility, to avoid problems with extensions to the 00032 * structure, read the parameters using 00033 * net_6lowpan_timer_parameter_read(), modify known fields, then set. 00034 * 00035 * \param parameter_ptr Pointer for ND parameters 00036 * 00037 * \return 0, Change OK 00038 * \return -1, Invalid values 00039 * \return -2, 6LoWPAN interface already active 00040 * 00041 */ 00042 int8_t net_6lowpan_nd_parameter_set(const nd_parameters_s *p) 00043 { 00044 #ifdef HAVE_6LOWPAN_ND 00045 if (protocol_stack_interface_info_get(IF_6LoWPAN)) { 00046 return -2; 00047 } 00048 00049 if (p->rs_retry_interval_min == 0 || p->ns_retry_interval_min == 0) { 00050 return -1; 00051 } 00052 00053 if ((uint32_t) p->rs_retry_interval_min + p->timer_random_max > 0xFFFF || 00054 (uint32_t) p->ns_retry_interval_min + p->timer_random_max + 00055 ((uint32_t) p->ns_retry_max - 1) * p->ns_retry_linear_backoff > 0xFFFF) { 00056 return -1; 00057 } 00058 00059 /* Random range must be power of two minus 1, so we can just mask */ 00060 if ((p->timer_random_max + 1) & p->timer_random_max) { 00061 return -1; 00062 } 00063 00064 nd_params = *p; 00065 00066 return 0; 00067 #else 00068 return -2; 00069 #endif 00070 } 00071 00072 /** 00073 * \brief API for change 6LoWPAN bootstrap base tick 100ms multiplier. 00074 * 00075 * Note: This function MUST be called after net_init_core(). Do not change this 00076 * unless you really want 6LoWPAN bootstrap working slower than normally. 00077 * \param base_tick_x_100ms Tick resolution in 100ms units. 00078 * Max value 10 --> 10 times slower functionality 00079 * 00080 * \return 0, Change OK 00081 * \return -1, Invalid value (<1 or >10) 00082 * 00083 */ 00084 int8_t net_6lowpan_nd_timer_base_tick_set(uint8_t base_tick_x_100ms) 00085 { 00086 #ifdef HAVE_6LOWPAN_ND 00087 if (base_tick_x_100ms < 1 || base_tick_x_100ms > 10) { 00088 return -1; 00089 } 00090 00091 nd_base_tick = base_tick_x_100ms; 00092 #endif 00093 return 0; 00094 } 00095 00096 /** 00097 * \brief API to read 6LoWPAN ND bootstrap parameters. 00098 * 00099 * \param parameter_ptr Output pointer for ND parameters 00100 * 00101 */ 00102 void net_6lowpan_nd_parameter_read(nd_parameters_s *p) 00103 { 00104 #ifdef HAVE_6LOWPAN_ND 00105 *p = nd_params; 00106 #endif 00107 }
Generated on Fri Jul 22 2022 04:53:57 by
 1.7.2
 1.7.2 
    