BA / Mbed OS BaBoRo1
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mle_service_interface.h Source File

mle_service_interface.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_interface.h
00020  * \brief Add short description about this file!!!
00021  *
00022  */
00023 
00024 #ifndef MLE_SERVICE_INTERFACE_H_
00025 #define MLE_SERVICE_INTERFACE_H_
00026 #include <ns_types.h>
00027 #include "ns_list.h"
00028 
00029 #include "Service_Libs/mle_service/mle_service_api.h"
00030 
00031 typedef struct {
00032     mle_service_receive_cb *recv_cb; /*!< Interface message handler */
00033     mle_service_receive_security_bypass_cb *recv_security_bypass_cb; /*!< Interface message security bypass handler */
00034     uint8_t mac64[8]; /*!< Interface MAC 64 used for Security nonce and LL64 address define */
00035     int8_t interface_id; /*!< Interface Id */
00036     uint8_t challenge_length; /*!< Define MLE challenge length */
00037     uint16_t URT; /*!< Unicast Retransmission timeout */
00038     uint16_t MRT; /*!< Multicast Retransmission timeout */
00039     uint8_t MRC; /*!< Maximum retransmission count */
00040     int16_t token_bucket; /*!< Token bucket */
00041     uint16_t token_bucket_ticks; /*!< Token bucket ticks */
00042     uint8_t token_bucket_size; /*!< MLE token bucket size */
00043     uint8_t token_bucket_rate; /*!< Rate in which tokens are added to bucket (0.1 seconds * rate) */
00044     uint8_t token_bucket_count; /*!< Count of tokens added to bucket at a time */
00045     ns_list_link_t link;
00046 } service_instance_t;
00047 
00048 typedef NS_LIST_HEAD (service_instance_t, link) service_instance_list_t;
00049 
00050 /**
00051  * Find registered service client class
00052  *
00053  * \param interface_id interface id
00054  *
00055  * \return >0 Pointer to interface structure
00056  * \return < 0 Unknown interface id
00057  */
00058 service_instance_t *mle_service_interface_find(int8_t interface_id);
00059 
00060 /**
00061  * Allocate or return current registered service client class
00062  *
00063  * \param interface_id interface id
00064  *
00065  * \return >0 Pointer to interface structure
00066  * \return < 0 Allocate fail
00067  */
00068 service_instance_t *mle_service_interface_get(int8_t interface_id);
00069 
00070 /**
00071  * Delete and free service
00072  */
00073 int mle_service_interface_delete(int8_t interface_id);
00074 /**
00075  * Check is all interfaced freed
00076  */
00077 bool mle_service_interface_list_empty(void);
00078 
00079 /**
00080  *  MLE service interface timer call back
00081  *
00082  *  This function will be called when timer is updated
00083  *
00084  * \param ticks
00085  *
00086  * \return true Keep timer active
00087  * \return false Stop timer
00088  *
00089  */
00090 typedef bool (mle_service_interface_timer_cb)(uint16_t ticks, service_instance_t *cur_ptr);
00091 
00092 /**
00093  * MLE service interface timeout handling
00094  *
00095  * \param ticks timer ticks
00096  * \param timeout_cb callback called ticks are updated
00097  *
00098  * \return true Keep timer active
00099  * \return false Stop timer
00100  */
00101 bool mle_service_interface_timer_tick(uint16_t ticks, mle_service_interface_timer_cb *timeout_cb);
00102 
00103 #endif /* MLE_SERVICE_INTERFACE_H_ */