Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mle_service_api.h Source File

mle_service_api.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2015-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 #ifndef MLE_SERVICE_API_H_
00019 #define MLE_SERVICE_API_H_
00020 
00021 #include <ns_types.h>
00022 #include "ns_list.h"
00023 #include "ccmLIB.h"
00024 
00025 #define MLE_STANDARD_RESPONSE_DELAY 10
00026 #define MLE_HALF_SECOND_MAX_DELAY 5
00027 #define MLE_NO_DELAY 0
00028 #define MLE_TOKEN_DELAY 10
00029 #define MLE_TOKEN_BUFFER_MAX_NBR 10
00030 #define MLE_TOKEN_BUFFER_MIN_NBR -10
00031 
00032 /**
00033  * \file mle_service_api.h
00034  * \brief Mle service API for multiple MLE protocol user.
00035  *
00036  * MLE service interface configuration API
00037  *
00038  * - mle_service_interface_register(), Register interface for first user service will open socket
00039  * - mle_service_interface_unregister(), Unregister service after last user call socket will be closed
00040  * - mle_service_interface_registeration_validate(), Validate has interface registered service already
00041  * - mle_service_interface_receiver_handler_update(), Update registered message handler to new one
00042  * - mle_service_interface_tx_queue_clean(), Free interface active queued messages
00043  * - mle_service_interface_token_bucket_settings_set(), Sets token bucket settings
00044  *
00045  * MLE Security configuration API
00046  *
00047  * - mle_service_security_init(), allocate security class for interface
00048  * - mle_service_security_set_security_key(), Set security key to security class
00049  * - mle_service_security_set_frame_counter(), Update security class frame counter
00050  * - mle_service_security_key_trig() Indicate mle security class to switch default key
00051  *
00052  * MLE Security class get API
00053  *
00054  * - mle_service_security_default_key_get(). Get default key pointer
00055  * - mle_service_security_default_key_id_get(), Get default key id
00056  * - mle_service_security_next_key_get(), Get secondary or pending key pointer
00057  * - mle_service_security_next_key_id_get(), Get secondary or pending key id
00058  * - mle_service_security_level_get(), Get configured security level
00059  *
00060  * MLE message Data flow API
00061  *
00062  * - mle_service_msg_allocate(), Allocate message buffer and set default security params based on configuration
00063  * - mle_service_msg_free(), Release allocated buffer
00064  * - mle_service_message_tail_get(), Get more space for message end
00065  * - mle_service_get_data_pointer(), Get messages data pointer DO NOT USE FOR WRITE
00066  * - mle_service_get_payload_length(), Get messages payload length
00067  * - mle_service_get_payload_start_point(), Get pointer to message payload start
00068  * - mle_service_update_length(), Update messages data length by given number of added bytes
00069  * - mle_service_update_length_by_ptr(), Update messages data length by updated data pointer
00070  * - mle_service_msg_update_security_params(), Change messages default setup
00071  * - mle_service_set_msg_response_true(), Mark message response status when you know that
00072  * - mle_service_check_msg_response(), Verify messages response status (typically called at timeout call back)
00073  * - mle_service_trasnaction_buffer_get_for_response(), Validate received response for interface request
00074  * - mle_service_check_msg_sent(), Check if message has been sent to socket
00075  *
00076  * Messages TX API
00077  * - mle_service_set_packet_callback(), Set messages timeout call back
00078  * - mle_service_get_msg_destination_address_pointer(), Get messages destination address pointer for verify or write
00079  * - mle_service_set_msg_destination_address(), Set messages IPv6 destination address
00080  * - mle_service_set_msg_timeout_parameters(), Update messages timeout and delay parameters
00081  * - mle_service_send_message(), Send builded message with given timeout parameters
00082  * - mle_service_reject_message_build(), Build and send MLE link reject message to given destination address
00083  * - mle_service_set_msg_token_bucket_priority(), Sets message a priority over token bucket restrictions
00084  *
00085  * Service Messages timeout API
00086  * - mle_service_timer_tick(), This need to be call periodically and give time in 100ms ticks
00087  *
00088  */
00089 
00090 typedef struct mle_security_header {
00091     unsigned securityLevel: 3;
00092     unsigned KeyIdMode: 2;
00093     uint32_t frameCounter;
00094     uint8_t Keysource[8];
00095     uint8_t KeyIndex;
00096     bool invalid_frame_counter;
00097 } mle_security_header_t;
00098 
00099 
00100 typedef enum mle_security_event  {
00101     MLE_SEC_MAX_FRAME_COUNTER_REACHED  = 0, /*!< MLE security counter reach max 0xffffffff value when device can't use same key anymore */
00102     MLE_SEC_KEY_UPDATE_NOTIFY , /*!< MLE security have trigger new default key */
00103     MLE_SEC_UNKNOWN_KEY  /*!< MLE security have detect unknown key id*/
00104 } mle_security_event_t;
00105 
00106 #define MLE_ALLOCATED_PORT 19788    /* Mesh Link Establishment - draft */
00107 
00108 /*
00109  * When MLE service receives MLE message it will parse Generic MLE header
00110  *
00111  */
00112 typedef struct {
00113     uint8_t message_type; /*!< MLE message type */
00114     uint8_t *packet_src_address; /*!< Packet Source address */
00115     uint8_t *packet_dst_address; /*!< Packet Destination address */
00116     uint8_t *data_ptr; /*!< Data pointer */
00117     void    *interface_ptr;
00118     uint16_t data_length; /*!< Data Length */
00119     uint16_t src_pan_id;  /*!< Link source Pan-id */
00120     uint16_t dst_pan_id; /*!< Link destination Pan-id */
00121     uint8_t lqi; /*!< Received Link quality*/
00122     int8_t dbm; /*!< Received RSSI */
00123 } mle_message_t;
00124 
00125 /*
00126  * MLE message timeout and re transmission parameters
00127  *
00128  */
00129 typedef struct {
00130     uint16_t timeout_init; /*!< Define start timeout */
00131     uint16_t timeout_max; /*!< Define max timeout time */
00132     uint8_t retrans_max; /*!< Define max packet TX count */
00133     uint8_t delay; /*!< 100ms Ticks for random delay */
00134 } mle_message_timeout_params_t;
00135 
00136 
00137 /**
00138  *  MLE service message receiver handler call back function pointer
00139  *
00140  *  All service user need to register this function pointer.
00141  *
00142  *  \param interface_id define interface id for receiver
00143  *  \param mle_msg mle message structure
00144  *  \param security_headers indicate messages security parameters
00145  */
00146 typedef void (mle_service_receive_cb)(int8_t interface_id, mle_message_t *mle_msg, mle_security_header_t *security_headers);
00147 
00148 /**
00149  *  MLE service security bypass message receiver handler call back function pointer
00150  *
00151  *  All service user need to register this function pointer.
00152  *
00153  *  \param interface_id define interface id for receiver
00154  *  \param mle_msg mle message structure
00155  */
00156 typedef void (mle_service_receive_security_bypass_cb)(int8_t interface_id, mle_message_t *mle_msg);
00157 
00158 /**
00159  *  MLE service security key request by 32-bit key source
00160  *
00161  *  All service user need to register this function pointer if they support 32-bit key source.
00162  *
00163  *  \param interface_id define interface id for receiver
00164  *  \param keyId key identifier
00165  *  \param keySequnce 32-bit key source
00166  */
00167 typedef uint8_t *(mle_service_key_request_by_counter_cb)(int8_t interface_id, uint8_t keyId, uint32_t keySequnce);
00168 
00169 /**
00170  *  MLE service security event notify
00171  *
00172  *  \param interface_id define interface id for receiver
00173  *  \param event
00174  *  \param keyId key identifier
00175  *
00176  */
00177 typedef uint8_t *(mle_service_security_notify_cb)(int8_t interface_id, mle_security_event_t event, uint8_t keyId);
00178 
00179 /**
00180  *  MLE service message timeout call back
00181  *
00182  *  This function will be called when msg timeout happen
00183  *
00184  *  \param interface_id define interface id for receiver
00185  *  \param msgId key identifier
00186  *  \param usedAllRetries false when
00187  *
00188  *  \return true Continue packet retry
00189  *  \return false Stop TX process and
00190  *
00191  */
00192 typedef bool (mle_service_message_timeout_cb)(int8_t interface_id, uint16_t msgId, bool usedAllRetries);
00193 
00194 /**
00195  *  A callback for receive MLE message filtering
00196  *
00197  *  This function will be called when MLE message is received. Only for testing purposes.
00198  *
00199  *  \param interface_id define interface id for receiver
00200  *  \param mle_msg received MLE message
00201  *  \param security_headers messages security parameters
00202  *
00203  *  \return true continue MLE packet processing
00204  *  \return false drop MLE packet
00205  *
00206  */
00207 typedef bool (mle_service_filter_cb)(int8_t interface_id, mle_message_t *mle_msg, mle_security_header_t *security_headers);
00208 
00209 /*
00210  * Initialise server instance.
00211  * Creates and shares socket for other mle services.
00212  *
00213  * \param interface_id Registered services interface Id.
00214  * \param interface_ptr Pointer tointerface
00215  * \param receive_cb Message RX handler.
00216  * \param mac64 Interface 64-bit MAC.
00217  * \param challengeLength challenge length
00218  * Return values
00219  * 0, Register OK.
00220  */
00221 int mle_service_interface_register(int8_t interface_id, void *interface_ptr, mle_service_receive_cb *receive_cb, uint8_t *mac64, uint8_t challengeLength);
00222 
00223 /*
00224 * Deletes server instance.
00225 * Removes all data related to this instance
00226 *
00227 * \param interface_id interface Id.
00228 *
00229 */
00230 void mle_service_interface_unregister(int8_t interface_id);
00231 
00232 /*
00233 * Validate is this interface register service already.
00234 *
00235 * \param interface_id interface Id.
00236 *
00237 * \return true when register ready
00238 * \return false when register not ready
00239 *
00240 */
00241 bool mle_service_interface_registeration_validate(int8_t interface_id);
00242 
00243 /*
00244 * Update Interface packet handler.
00245 *
00246 * Usefully function to switch message handler based on state machine
00247 *
00248 * \param interface_id interface Id.
00249 * \param receive_cb new message handler function pointer
00250 *
00251 * \return 0 register OK
00252 * \return < 0 Register fail
00253 *
00254 */
00255 int mle_service_interface_receiver_handler_update(int8_t interface_id, mle_service_receive_cb *receive_cb);
00256 
00257 /*
00258 * Update Interface security by pass handler.
00259 *
00260 * Usefully function to switch message handler based on state machine
00261 *
00262 * \param interface_id interface Id.
00263 * \param receive_cb new message handler function pointer
00264 *
00265 * \return 0 register OK
00266 * \return < 0 Register fail
00267 *
00268 */
00269 int mle_service_interface_receiver_bypass_handler_update(int8_t interface_id, mle_service_receive_security_bypass_cb *receive_cb);
00270 
00271 /**
00272 * Delete and free all activated Transaction.
00273 *
00274 * \param interface_id interface Id.
00275 *
00276 */
00277 void mle_service_interface_tx_queue_clean(int8_t interface_id);
00278 
00279 /**
00280 * count all activated Transactions.
00281 *
00282 * \param interface_id interface Id.
00283 *
00284 * \return count of active buffers
00285 *
00286 */
00287 
00288 int mle_service_reset_frame_counters(int8_t interfaceId);
00289 
00290 uint16_t mle_service_interface_tx_queue_size(int8_t interface_id);
00291 
00292 /**
00293 * Sets MLE token bucket settings
00294 *
00295 * Using of message tokens is optional.
00296 *
00297 * \param size Bucket size, 0 to 255, 0 means not in use
00298 * \param rate Token rate, 0 to 255, 0 means not in use
00299 * \param count, 0 to 255, 0 means not in use
00300 *
00301 * \return 0 Set is OK
00302 * \return -1 Unknown interface id
00303 * \return -2 Other error
00304 */
00305 int mle_service_interface_token_bucket_settings_set(int8_t interface_id, uint8_t size, uint8_t rate, uint8_t count);
00306 
00307 /*
00308  * MLE service interface security init.
00309  *
00310  * \param interface_id Id of registered server.
00311  * \param security_level valid values below:
00312  *  - AES_NO_SECURITY
00313  *  - AES_SECURITY_LEVEL_MIC32
00314  *  - AES_SECURITY_LEVEL_MIC64
00315  *  - AES_SECURITY_LEVEL_MIC128
00316  *  - AES_SECURITY_LEVEL_ENC
00317  *  - AES_SECURITY_LEVEL_ENC_MIC32
00318  *  - AES_SECURITY_LEVEL_ENC_MIC64
00319  *  - AES_SECURITY_LEVEL_ENC_MIC128
00320  *  \param security_frame_counter MLE security frame counter init value
00321  *  \param key_counter_req function pointer for request key by when key source is 32-bit
00322  *  \param notify function pointer for service notify security events
00323  *
00324  *  \return 0 Init OK
00325  *  \return -1 Unknown interface id
00326  *  \return -2 Un supported security level
00327  *
00328  */
00329 int mle_service_security_init(int8_t interfaceId, uint8_t security_level, uint32_t security_frame_counter, mle_service_key_request_by_counter_cb *key_counter_req, mle_service_security_notify_cb *notify);
00330 
00331 /*
00332  * SET MLE service interfac primary or pending primary security key.
00333  *
00334  * \param interface_id Id of registered server.
00335  * \param security_key pointer to 128-bit key
00336  * \param keyId key id.
00337  * \param primary true when set new primary and
00338  *
00339  */
00340 
00341 bool mle_service_security_set_security_key(int8_t interfaceId, const uint8_t *security_key, uint8_t keyId, bool primary);
00342 
00343 /*
00344  * SET MLE security frame counter
00345  *
00346  * \param interface_id Id of registered server.
00347  * \param frame_counter new frame counter
00348  *
00349  */
00350 bool mle_service_security_set_frame_counter(int8_t interfaceId, uint32_t frame_counter);
00351 /*
00352  * GET MLE security frame counter
00353  *
00354  * \param interface_id Id of registered server.
00355  *
00356  * \return Current frame counter
00357  *
00358  */
00359 uint32_t mle_service_security_get_frame_counter(int8_t interfaceId);
00360 
00361 
00362 /*
00363  * Notify MLE service interface for switch default security key.
00364  *
00365  * \param interface_id Id of registered server.
00366  * \param keyId Trigged key id.
00367  *
00368  */
00369 bool mle_service_security_key_trig(int8_t interfaceId, uint8_t keyId);
00370 
00371 /*
00372  * GET MLE security default key
00373  *
00374  * \param interface_id Id of registered server.
00375  *
00376  * \return > 0 Key pointer
00377  * \return NULL No key available
00378  */
00379 uint8_t *mle_service_security_default_key_get(int8_t interfaceId);
00380 
00381 /*
00382  * GET MLE security default key id
00383  *
00384  * \param interface_id Id of registered server.
00385  *
00386  * \return > 0 Key id
00387  * \return 0 not key id available or interface is not regostred
00388  */
00389 uint8_t  mle_service_security_default_key_id_get(int8_t interfaceId);
00390 
00391 /*
00392  * GET MLE security coming key pointer
00393  *
00394  * \param interface_id Id of registered server.
00395  *
00396  * \return > 0 Key id
00397  * \return 0 no available
00398  */
00399 uint8_t *mle_service_security_next_key_get(int8_t interfaceId);
00400 
00401 /**
00402  * GET MLE security coming key id
00403  *
00404  * \param interface_id Id of registered server.
00405  *
00406  * \return > 0 Pointer to key
00407  * \return NULL no available
00408  */
00409 uint8_t  mle_service_security_next_key_id_get(int8_t interfaceId);
00410 
00411 /*
00412  * GET MLE security security level
00413  *
00414  * \param interface_id Id of registered server.
00415  *
00416  * \return Security level
00417  */
00418 uint8_t  mle_service_security_level_get(int8_t interfaceId);
00419 
00420 /**
00421 * Allocate MLE transaction buffer and set default security parameters to buffer.
00422 *
00423 * Configured security params from interface
00424 *  * security level
00425 *  * key id mode MAC_KEY_ID_MODE_IDX
00426 * Service will automatically set next params
00427 *  * Key id
00428 *  * security frame counter
00429 *
00430 * \param interface_id interface Id.
00431 * \param data_length Payload max length
00432 * \param challengeAllocate True allocate challenge and write that to message automatically
00433 * \param type message type
00434 *
00435 * \return > 0 Message id
00436 * \return 0 Allocate fail
00437 *
00438 */
00439 uint16_t mle_service_msg_allocate(int8_t interface_id, uint16_t data_length, bool challengeAllocate, uint8_t type);
00440 
00441 /**
00442 * Free message.
00443 *
00444 * \param msgId buffer Id.
00445 *
00446 * \return  0 Free Valid
00447 * \return -1 Unknown Id
00448 *
00449 */
00450 int mle_service_msg_free(uint16_t msgId);
00451 
00452 /**
00453 * Set new security level and Key id mode.
00454 *
00455 *
00456 * \param msgId message id for update.
00457 * \param security_level valid values below:
00458 *  - AES_NO_SECURITY
00459 *  - AES_SECURITY_LEVEL_MIC32
00460 *  - AES_SECURITY_LEVEL_MIC64
00461 *  - AES_SECURITY_LEVEL_MIC128
00462 *  - AES_SECURITY_LEVEL_ENC
00463 *  - AES_SECURITY_LEVEL_ENC_MIC32
00464 *  - AES_SECURITY_LEVEL_ENC_MIC64
00465 *  - AES_SECURITY_LEVEL_ENC_MIC128
00466 *
00467 * \param key_id_mode valid values below:
00468 * - MAC_KEY_ID_MODE_IDX
00469 * - MAC_KEY_ID_MODE_SRC4_IDX
00470 *
00471 * \return 0 Set OK
00472 * \return -1 Unknown message id
00473 * \return -2 Not supported parameters
00474 *
00475 */
00476 int mle_service_msg_update_security_params(uint16_t msgId, uint8_t security_level, uint8_t key_id_mode, uint32_t keysequence);
00477 
00478 /**
00479 * MLE message tail get for new payload.
00480 *
00481 * \param msgId message id.
00482 * \param tail_length define messages new need tail length
00483 *
00484 * \return 0 tail allocated  OK
00485 * \return -1 tail allocate fail
00486 * \return -2 unknown message id
00487 *
00488 */
00489 int mle_service_message_tail_get(uint16_t msgId, uint16_t tail_length);
00490 
00491 /**
00492 * Get MLE message data pointer for write.
00493 *
00494 * \param msgId message id.
00495 *
00496 * \return >0 Valid pointer for write
00497 * \return NULL Not valid message id
00498 *
00499 */
00500 uint8_t *mle_service_get_data_pointer(uint16_t msgId);
00501 
00502 /**
00503 * Get MLE message pointer to message start
00504 *
00505 * \param msgId message id.
00506 *
00507 * \return >0 Valid pointer for read or verify
00508 * \return NULL Not valid message id
00509 *
00510 */
00511 uint8_t *mle_service_get_payload_start_point(uint16_t msgId);
00512 
00513 /**
00514 * Get MLE message payload length
00515 *
00516 * \param msgId message id.
00517 *
00518 * \return length of payload
00519 *
00520 */
00521 uint16_t  mle_service_get_payload_length(uint16_t msgId);
00522 
00523 /**
00524 * Set MLE message end point by new tail.
00525 *
00526 * \param msgId message id.
00527 * \param tail_length how many new byte added to message end
00528 *
00529 * \return 0 Length Update OK
00530 * \return -1 Unknown message id
00531 * \return -2 buffer overflow
00532 *
00533 */
00534 int mle_service_update_length(uint16_t msgId, uint16_t tail_length);
00535 
00536 /**
00537 * Set MLE message end point by new data end pointer.
00538 *
00539 * \param msgId message id.
00540 * \param data_end_ptr new message end pointer
00541 *
00542 * \return 0 Length Update OK
00543 * \return -1 Unknown message id
00544 * \return -2 buffer overflow
00545 *
00546 */
00547 int mle_service_update_length_by_ptr(uint16_t msgId, uint8_t *data_end_ptr);
00548 
00549 /**
00550 * Get MLE message destination address pointer for write purpose.
00551 *
00552 * \param msgId message id.
00553 *
00554 * \return >0 Pointer get OK
00555 * \return NULL message id not valid
00556 *
00557 */
00558 uint8_t *mle_service_get_msg_destination_address_pointer(uint16_t msgId);
00559 
00560 
00561 /**
00562 * Set MLE message destination address
00563 *
00564 * \param msgId message id.
00565 * \param dstAddress message destination address
00566 *
00567 * \return 0 Set OK
00568 * \return -1 message id not valid
00569 * \return -2 address pointer is NULL
00570 *
00571 */
00572 int mle_service_set_msg_destination_address(uint16_t msgId, const uint8_t *dstAddress);
00573 
00574 /**
00575 * Set Messages link PAN
00576 *
00577 * \param msgId message id.
00578 * \param panid Link pan-id for this packet
00579 *
00580 * \return 0 Set OK
00581 * \return -1 message id not valid
00582 *
00583 */
00584 int mle_service_set_msg_panid(uint16_t msgId, uint16_t panid);
00585 
00586 /**
00587 * Set messages timeout parameters.
00588 *
00589 * Struct timeout_params defines messages retransmission times in seconds, retransmission count and sending delay.
00590 * Delayed message will affect random time between 100-900ms
00591 *
00592 * \param msgId Message Id.
00593 * \param timeout_params messages transmission parameters
00594 */
00595 int mle_service_set_msg_timeout_parameters(uint16_t msgId, mle_message_timeout_params_t *timeout_params);
00596 
00597 /**
00598 * Set messages timeout parameters.
00599 *
00600 * Struct timeout_params defines messages retransmission times in 100ms, retransmission count and sending delay.
00601 * Delayed message will affect random time between 100-900ms
00602 *
00603 * \param msgId Message Id.
00604 * \param timeout_params messages transmission parameters
00605 */
00606 int mle_service_set_msg_timeout_parameters_fast(uint16_t msgId, mle_message_timeout_params_t *timeout_params);
00607 
00608 int mle_service_set_msg_rf_channel(uint16_t msgId, uint8_t channel);
00609 
00610 int mle_service_set_msg_link_layer_security_mode(uint16_t msgId, bool use_key_id_mode_2);
00611 
00612 
00613 /**
00614 * Set MLE message response received state
00615 *
00616 * \param msgId message id.
00617 *
00618 * \return 0 Set OK
00619 * \return -1 Unknown Id
00620 *
00621 */
00622 int mle_service_set_msg_response_true(uint16_t msgId);
00623 
00624 /**
00625 * Check MLE message response received state
00626 *
00627 * Usefully function at message timeout call back to check response status
00628 *
00629 * \param msgId message id.
00630 *
00631 * \return true message has received response
00632 * \return false no response or unknow message id
00633 *
00634 */
00635 bool mle_service_check_msg_response(uint16_t msgId);
00636 
00637 /*
00638 * MLE active  transaction buffer id get by challenge data.
00639 *
00640 * \param responseData
00641 * \param responseData True allocate challenge and write that to message automatically
00642 * \param msgId pointer where message id can be saved
00643 *
00644 * \return true Response is valid and tied to this msgId
00645 * \return false No active Tx buffer available for this response
00646 *
00647 */
00648 bool mle_service_transaction_buffer_get_for_response(uint8_t *responseData, uint16_t length, uint16_t *msgId);
00649 
00650 /**
00651 * Check if message has been sent to socket.
00652 *
00653 * Function can be used whether message has been sent to socket or
00654 * has been rejected by token bucket.
00655 *
00656 * \param msgId message id.
00657 *
00658 * \return true message has been sent
00659 * \return false message has not been sent
00660 *
00661 */
00662 bool mle_service_check_msg_sent(uint16_t msgId);
00663 
00664 /**
00665 * MLE message timeout handler set.
00666 *
00667 * \param msgId message id.
00668 * \param cb message timeout call back
00669 *
00670 * \return 0 Callback set OK
00671 * \return < 0 unknown message id
00672 *
00673 */
00674 int mle_service_set_packet_callback(uint16_t msgId, mle_service_message_timeout_cb *cb);
00675 
00676 
00677 /**
00678 * Sends MLE message.
00679 *
00680 * \param msgId Message Id.
00681 */
00682 int mle_service_send_message(uint16_t msgId);
00683 
00684 /**
00685  * Timer tick function.
00686  *
00687  * should be called in 100ms intervals if more time passes before call amount in 100ms units.
00688  *
00689  */
00690 bool mle_service_timer_tick(uint16_t ticks);
00691 
00692 /**
00693 * Build and send standard link reject message.
00694 *
00695 * \param msgId Message Id.
00696 * \param dstIpv6 rejected link
00697 * \param force_unsecure true force force disbale security
00698 */
00699 int mle_service_reject_message_build(int8_t interfaceId, uint8_t *dstIpv6, bool force_unsecure);
00700 
00701 /**
00702 * Sets message a priority over token bucket restrictions.
00703 *
00704 * \param msgId Message Id.
00705 *
00706 * \return 0 priority set OK
00707 * \return < 0 unknown message id
00708 */
00709 int mle_service_set_msg_token_bucket_priority(uint16_t msgId);
00710 
00711 /**
00712 * Activates MLE Frame counter checking for the interface.
00713 *
00714 * \param value set true for check activation.
00715 *
00716 */
00717 void mle_service_set_frame_counter_check(bool value);
00718 
00719 /**
00720 * Set 802.15.4 security option for fragmented MLE messages
00721 *
00722 * \param value set true to force security for fragmented packets.
00723 * \param value set false to use default security for fragmented packets.
00724 *
00725 */
00726 void mle_service_set_fragmented_msg_ll_security(bool value);
00727 
00728 /**
00729 * Commands MLE service to accept message with invalid MLE frame counter.
00730 *
00731 * \param value set true to accept invalid frame counters
00732 *
00733 */
00734 void mle_service_set_accept_invalid_frame_counter(bool value);
00735 
00736 
00737 /**
00738 * Commands MLE service to allocate mle frame counter table for giving neighbor count.
00739 *
00740 * \param interface_id Interface ID
00741 * \param table_size Table size
00742 *
00743 * \return 0 Allocate OK
00744 * \return -1 Allocate Fail
00745 *
00746 */
00747 int mle_service_frame_counter_table_allocate(int8_t interface_id, uint8_t table_size);
00748 
00749 /**
00750 * Commands MLE service to free mle frame counter table
00751 *
00752 * \param interface_id Interface ID
00753 *
00754 * \return 0 Free OK
00755 * \return -1 Free Fail
00756 *
00757 */
00758 int mle_service_frame_counter_table_free(int8_t interface_id);
00759 
00760 /**
00761 * Commands MLE service to add / Update frame counter to neighbor
00762 *
00763 * \param interface_id Interface ID
00764 * \param attribute_index Attribute index for neighbor
00765 * \param frame_counter MLE frame counter
00766 *
00767 */
00768 void mle_service_frame_counter_entry_add(int8_t interface_id, uint8_t attribute_index, uint32_t frame_counter);
00769 
00770 /**
00771 * Commands MLE service get mle frame counter for neighbor
00772 *
00773 * \param interface_id Interface ID
00774 * \param attribute_index Attribute index for neighbor
00775 *
00776 * \return Stored Frame Counter, may return 0 if unknow attribute
00777 *
00778 */
00779 uint32_t mle_service_neighbor_frame_counter_get(int8_t interface_id, uint8_t attribute_index);
00780 
00781 /**
00782 * Commands MLE service frame counter new key pending state activate
00783 *
00784 * \param interface_id Interface ID
00785 * \param attribute_index Attribute index for neighbor
00786 *
00787 */
00788 void mle_service_frame_counter_entry_new_key_pending_set(int8_t interface_id, uint8_t attribute_index);
00789 
00790 /**
00791 * Commands MLE service frame counter info delete
00792 *
00793 * \param interface_id Interface ID
00794 * \param attribute_index Attribute index for neighbor
00795 *
00796 */
00797 void mle_service_frame_counter_entry_delete(int8_t interface_id, uint8_t attribute_index);
00798 
00799 #ifdef MLE_TEST
00800 /**
00801  * Set callback for MLE receiving packet filtering.
00802  *
00803  * If this is set, all received MLE messages will be passed to given callback.
00804  */
00805 void mle_service_receive_filter_cb_set(mle_service_filter_cb *filter_cb);
00806 #else
00807 #define mle_service_receive_filter_cb_set(filter_cb) ((void) filter_cb)
00808 #endif /* MLE_TEST */
00809 #endif /* MLE_SERVICE_API_H_ */