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
mle_service_buffer.h
00001 /* 00002 * Copyright (c) 2015-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 /* 00019 * \file mle_service_buffer.h 00020 * \brief Add short description about this file!!! 00021 * 00022 */ 00023 00024 #ifndef MLE_SERVICE_BUFFER_H_ 00025 #define MLE_SERVICE_BUFFER_H_ 00026 00027 #include <ns_types.h> 00028 #include "ns_list.h" 00029 #include "Service_Libs/mle_service/mle_service_api.h" 00030 00031 struct mle_security_header; 00032 00033 typedef struct mle_service_msg_buf { 00034 00035 uint16_t msg_id; /*!< Buffer Id what could be used for update or free message */ 00036 int8_t interfaceId; /*!< Which interface buffer is tiegted */ 00037 mle_service_message_timeout_cb *timeout_cb; /*!< This will be called every time when timeout happen */ 00038 uint8_t * buf; /*!< Payload buffer pointer */ 00039 uint16_t size; /*!< Buffer total allocated size */ 00040 uint16_t buf_end; /*!< End pointer in the buffer */ 00041 uint8_t dst_address[16]; /*!< Messages IPv6 destination address */ 00042 struct mle_security_header security_header; /*!< Messages security parameters */ 00043 uint8_t *challengePtr; /*!< Messages challenge data */ 00044 uint8_t challengeLen; /*!< Messages challenge data length */ 00045 uint8_t delayed_response; /*!< Define delayed response message */ 00046 uint16_t timeout; /*!< Messages active timeout */ 00047 uint16_t timeout_init; /*!< Init timeout period length */ 00048 uint16_t timeout_max; /*!< Define Max retransmission timeout */ 00049 uint8_t retrans_max; /*!< Define max re transmission count */ 00050 uint8_t retrans; /*!< Current retrans count */ 00051 uint8_t selected_rf_channel; /*!< Packet selected channel (only valid when selected_channel is true*/ 00052 uint16_t packet_panid; /*!< Packet selected Pan-id (only valid when selected_pan_id is true*/ 00053 unsigned response_status:1; 00054 unsigned tokens_delay:1; /*!< Delay message because of tokens */ 00055 unsigned tokens_priority:1; /*!< Message has priority over token bucket */ 00056 unsigned message_sent:1; /* Message has been sent */ 00057 unsigned selected_channel:1; 00058 unsigned selected_pan_id:1; 00059 unsigned enable_link_layer_security; 00060 unsigned psk_key_id_mode_2; 00061 ns_list_link_t link; 00062 } mle_service_msg_buf_t; 00063 00064 /** 00065 * MLE service buffer timeout callback 00066 * 00067 * \param mle_msg mle buffer pointer 00068 */ 00069 typedef void (mle_service_buffer_timeout_cb)(mle_service_msg_buf_t *mle_msg); 00070 00071 /** get pointer to data end*/ 00072 #define mle_msg_data_pointer(x) (&(x)->buf[(x)->buf_end]) 00073 00074 /** set data length Set*/ 00075 #define mle_msg_length_set(x,z) ((x)->buf_end = (x)->buf_end + (z)) 00076 00077 /** set data length by updated data pointer*/ 00078 #define mle_msg_length_set_by_pointer(x,z) ((x)->buf_end = (z) - (x)->buf) 00079 00080 /** get data length*/ 00081 #define mle_msg_data_length(x) (uint16_t)(x->buf_end) 00082 00083 /** 00084 * MLE service buffers free by interface id 00085 * 00086 * Call this when unregister MLe service 00087 * 00088 * \param interface_id interface id of mle service user 00089 * 00090 */ 00091 void mle_service_buffer_clean_buffers_by_interface_id(int8_t interface_id); 00092 00093 /** 00094 * MLE service buffers count by interface id 00095 * 00096 * get amount of active buffer count 00097 * 00098 * \param interface_id interface id of mle service user 00099 * 00100 * \return count of active buffers. 00101 */ 00102 uint16_t mle_service_buffer_count_by_interface_id(int8_t interface_id); 00103 00104 /** 00105 * MLE service buffers allocate 00106 * 00107 * 00108 * \param data_length mle message init length 00109 * 00110 * \return a Pointer to mle message or 00111 * \return NULL if allocate failed. 00112 * 00113 */ 00114 mle_service_msg_buf_t * mle_service_buffer_get(uint16_t data_length); 00115 00116 /** 00117 * MLE service buffer pointer free. 00118 * 00119 * This function frees elements received from mle_service_buffer_get(). 00120 * You should not feed in any other elements. 00121 * 00122 * \param buf buffer pointer 00123 * 00124 * \return 0 Free OK 00125 * \return -1 Free error 00126 */ 00127 int mle_service_buffer_free(mle_service_msg_buf_t *buf); 00128 00129 /** 00130 * MLE service buffers discover by buffer id 00131 * 00132 * 00133 * \param id mle message id 00134 * 00135 * \return > 0 Pointer to mle message 00136 * \return NULL unknown id 00137 * 00138 */ 00139 mle_service_msg_buf_t *mle_service_buffer_find(uint16_t id); 00140 00141 /** 00142 * MLE service buffers discover by resonse data 00143 * 00144 * This function should call when mle service user need to verify response data to own challenge 00145 * 00146 * \param responseData pointer to response data 00147 * \param length length of response 00148 * 00149 * \return > 0 Pointer to mle message 00150 * \return NULL unknown response data 00151 * 00152 */ 00153 mle_service_msg_buf_t * mle_service_buffer_find_for_response(uint8_t *responseData, uint16_t length); 00154 00155 /** 00156 * MLE service buffers data pointer get 00157 * 00158 * 00159 * \param msgId mle message id 00160 * 00161 * \return > 0 Pointer next data write 00162 * \return NULL unknown message id 00163 * 00164 */ 00165 uint8_t * mle_service_buffer_get_data_pointer(uint16_t msgId); 00166 00167 /** 00168 * MLE service buffers data length updated given length 00169 * 00170 * 00171 * \param msgId mle message id 00172 * \param tail_length how much length pointer will be moved ahead 00173 * 00174 * \return 0 dat length update OK 00175 * \return < 0 Unknown id or length update detect possible overwrite operation 00176 * 00177 */ 00178 int mle_service_buffer_update_length(uint16_t msgId, uint16_t tail_length); 00179 00180 /** 00181 * MLE service buffers data length updated given updated data pointer 00182 * 00183 * 00184 * \param msgId mle message id 00185 * \param data_end_ptr new data end pointer 00186 * 00187 * \return 0 dat length update OK 00188 * \return < 0 Unknown id or length update detect possible overwrite operation 00189 * 00190 */ 00191 int mle_service_buffer_update_length_by_ptr(uint16_t msgId, uint8_t *data_end_ptr); 00192 00193 /** 00194 * MLE service allocate more tail to current mle payload 00195 * 00196 * 00197 * \param msgId mle message id 00198 * \param tail_length new need data count 00199 * 00200 * \return 0 dat length allocate ok OK 00201 * \return < 0 Unknown id or allocate fail 00202 * 00203 */ 00204 int mle_service_buffer_tail_get(uint16_t msgId, uint16_t tail_length); 00205 00206 /** 00207 * MLE service buffer timeout call back set 00208 * 00209 * \param msgId mle message id 00210 * \param cb new messgaes timeout call back function pointer 00211 * 00212 * \return 0 set OK 00213 * \return < 0 set fail 00214 * 00215 */ 00216 int mle_service_buffer_set_timeout_cb(uint16_t msgId, mle_service_message_timeout_cb *cb); 00217 00218 /** 00219 * MLE service buffer response RX state set 00220 * 00221 * \param msgId mle message id 00222 * 00223 * \return 0 set OK 00224 * \return < 0 set fail 00225 * 00226 */ 00227 int mle_service_buffer_set_response(uint16_t msgId); 00228 00229 /** 00230 * MLE service mle message type write 00231 * 00232 * 00233 * \param msgId mle message id 00234 * \param message_type mle message type 00235 * 00236 * \return 0 dat length allocate ok OK 00237 * \return < 0 Unknown id 00238 * 00239 */ 00240 int mle_service_buffer_set_msg_type(uint16_t msgId, uint8_t message_type); 00241 00242 /** 00243 * MLE service mle message address pointer get 00244 * 00245 * 00246 * \param msgId mle message id 00247 * 00248 * \return >0 Pointer to message destination address 00249 * \return < 0 Unknown message id 00250 * 00251 */ 00252 uint8_t * mle_service_buffer_get_msg_destination_address_pointer(uint16_t msgId); 00253 00254 /** 00255 * MLE service mle message address set 00256 * 00257 * 00258 * \param msgId mle message id 00259 * \param address_ptr destination address 00260 * 00261 * \return 0 Write OK 00262 * \return < 0 Unknown message id 00263 * 00264 */ 00265 int mle_service_buffer_set_msg_destination_address(uint16_t msgId, uint8_t *address_ptr); 00266 00267 /** 00268 * MLE service transaction timeout and retry handling 00269 */ 00270 bool mle_service_buffer_timer_tick(uint16_t ticks, mle_service_buffer_timeout_cb *timeout_cb); 00271 00272 /** 00273 * Counts MLE service message buffers that tokens has delayed. 00274 * 00275 * \return Buffer count 00276 * 00277 */ 00278 uint16_t mle_service_buffer_tokens_delay_count(void); 00279 00280 /** 00281 * MLE service mle message rf channel set for this packet 00282 * 00283 * 00284 * \param msgId mle message id 00285 * \param channel selected rf channel 00286 * 00287 * \return 0 Set OK 00288 * \return < 0 Unknown message id 00289 * 00290 */ 00291 int mle_service_buffer_set_msg_rf_channel(uint16_t msgId, uint8_t channel); 00292 00293 /** 00294 * MLE service mle message link layer security enable and set key id mode set for this packet 00295 * 00296 * 00297 * \param msgId mle message id 00298 * \param key_id_mode_2 true select psk key id mode 2 false slect mac default mode 00299 * 00300 * \return 0 Set OK 00301 * \return < 0 Unknown message id 00302 * 00303 */ 00304 int mle_service_buffer_set_msg_security_mode(uint16_t msgId, bool key_id_mode_2); 00305 00306 #endif /* MLE_SERVICE_BUFFER_H_ */
Generated on Fri Jul 22 2022 04:53:57 by
 1.7.2
 1.7.2 
    