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: TYBLE16_simple_data_logger TYBLE16_MP3_Air
net_mle.c
00001 /* 00002 * Copyright (c) 2016-2017, 2019, 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 /* 00019 * \file net_mle.c 00020 * \brief 6LoWPAN MLE options control API 00021 * 00022 */ 00023 #include "nsconfig.h" 00024 #include "ns_types.h" 00025 #include "string.h" 00026 #include "ns_trace.h" 00027 #include "net_mle_api.h" 00028 #include "Core/include/ns_address_internal.h" 00029 #include "net_interface.h" 00030 #include "MLE/mle.h" 00031 #include "NWK_INTERFACE/Include/protocol.h" 00032 #include "Service_Libs/mle_service/mle_service_api.h" 00033 #include "6LoWPAN/Bootstraps/protocol_6lowpan_bootstrap.h" 00034 00035 /** Set parameter. 00036 00037 * \return zero on success, negative on failure. 00038 00039 */ 00040 00041 int8_t arm_nwk_6lowpan_mle_router_lifetime_set(int8_t interface_id, uint16_t lifetime) 00042 { 00043 protocol_interface_info_entry_t *cur; 00044 mle_6lowpan_data_t *mle_6lowpan_data; 00045 00046 cur = protocol_stack_interface_info_get_by_id(interface_id); 00047 00048 if (!cur || cur->nwk_id != IF_6LoWPAN) { 00049 return -1; 00050 } 00051 00052 mle_6lowpan_data = protocol_6lowpan_mle_data_get(); 00053 00054 if (!mle_6lowpan_data) { 00055 return -1; 00056 } 00057 00058 if (lifetime < 64 || lifetime > 2560) { 00059 return -1; 00060 } 00061 00062 mle_6lowpan_data->router_lifetime = lifetime; 00063 00064 return 0; 00065 } 00066 00067 int8_t arm_nwk_6lowpan_mle_host_lifetime_set(int8_t interface_id, uint16_t lifetime) 00068 { 00069 protocol_interface_info_entry_t *cur; 00070 mle_6lowpan_data_t *mle_6lowpan_data; 00071 00072 cur = protocol_stack_interface_info_get_by_id(interface_id); 00073 00074 if (!cur || cur->nwk_id != IF_6LoWPAN) { 00075 return -1; 00076 } 00077 00078 mle_6lowpan_data = protocol_6lowpan_mle_data_get(); 00079 00080 if (!mle_6lowpan_data) { 00081 return -1; 00082 } 00083 00084 if (lifetime < 64 || lifetime > 2560) { 00085 return -1; 00086 } 00087 00088 mle_6lowpan_data->host_lifetime = lifetime; 00089 00090 return 0; 00091 } 00092 00093 int8_t arm_nwk_6lowpan_mle_neighbor_limits_set(int8_t interface_id, uint16_t lower_threshold, uint16_t upper_threshold, uint16_t max) 00094 { 00095 protocol_interface_info_entry_t *cur; 00096 mle_6lowpan_data_t *mle_6lowpan_data; 00097 00098 cur = protocol_stack_interface_info_get_by_id(interface_id); 00099 00100 if (!cur || cur->nwk_id != IF_6LoWPAN) { 00101 return -1; 00102 } 00103 00104 if (lower_threshold == 0 || upper_threshold == 0 || max == 0) { 00105 if (lower_threshold != 0) { 00106 return -1; 00107 } 00108 if (upper_threshold != 0) { 00109 return -1; 00110 } 00111 if (max != 0) { 00112 return -1; 00113 } 00114 } 00115 00116 if ((lower_threshold < 5 && lower_threshold != 0) || lower_threshold > 499) { 00117 return -1; 00118 } 00119 if ((upper_threshold < 5 && upper_threshold != 0) || upper_threshold > 500) { 00120 return -1; 00121 } 00122 if ((max < 5 && max != 0) || max > 500) { 00123 return -1; 00124 } 00125 if (lower_threshold >= upper_threshold) { 00126 return -1; 00127 } 00128 if (lower_threshold >= max) { 00129 return -1; 00130 } 00131 if (upper_threshold > max) { 00132 return -1; 00133 } 00134 00135 mle_6lowpan_data = protocol_6lowpan_mle_data_get(); 00136 00137 if (!mle_6lowpan_data) { 00138 return -1; 00139 } 00140 00141 mle_6lowpan_data->nbr_of_neigh_lower_threshold = lower_threshold; 00142 mle_6lowpan_data->nbr_of_neigh_upper_threshold = upper_threshold; 00143 mle_6lowpan_data->nbr_of_neigh_max = max; 00144 00145 return 0; 00146 } 00147 00148 int8_t arm_nwk_6lowpan_mle_token_bucket_settings_set(int8_t interface_id, uint8_t size, uint8_t rate, uint8_t count) 00149 { 00150 protocol_interface_info_entry_t *cur; 00151 mle_6lowpan_data_t *mle_6lowpan_data; 00152 00153 cur = protocol_stack_interface_info_get_by_id(interface_id); 00154 00155 if (!cur || cur->nwk_id != IF_6LoWPAN) { 00156 return -1; 00157 } 00158 00159 if (size == 0 || rate == 0 || count == 0) { 00160 if (size != 0) { 00161 return -1; 00162 } 00163 if (rate != 0) { 00164 return -1; 00165 } 00166 if (count != 0) { 00167 return -1; 00168 } 00169 } 00170 00171 mle_6lowpan_data = protocol_6lowpan_mle_data_get(); 00172 00173 if (!mle_6lowpan_data) { 00174 return -1; 00175 } 00176 00177 mle_6lowpan_data->token_bucket_size = size; 00178 mle_6lowpan_data->token_bucket_rate = rate; 00179 mle_6lowpan_data->token_bucket_count = count; 00180 00181 return mle_service_interface_token_bucket_settings_set(interface_id, size, rate, count); 00182 } 00183
Generated on Tue Jul 12 2022 13:54:37 by
