Skip to content

Commit 038bc2e

Browse files
author
Arto Kinnunen
committed
Copy ingress rate limiting API to ns_conf
Copy ns_sw_mac_packet_ingress_rate_limit_by_mem function to ns_conf.h as it logically belongs to configuration.
1 parent 940b516 commit 038bc2e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

nanostack/ns_conf.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ extern "C" {
4646
*/
4747
int ns_conf_gc_threshold_set(uint8_t percentage_high, uint8_t percentage_critical);
4848

49+
/**
50+
* \brief Limit amount of incoming packets if system does not have enough free memory.
51+
* Memory statistics must been initialized in nsdynmemLIB to get this feature working.
52+
*
53+
* \param free_heap_percentage Percentage of free heap that must be available when packet arrives to MAC layer.
54+
* \return 0 in case of success, <0 otherwise.
55+
*/
56+
int ns_conf_packet_ingress_rate_limit_by_mem(uint8_t free_heap_percentage);
4957

5058
#ifdef __cplusplus
5159
}

source/Service_Libs/utils/ns_conf.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@
1515
* limitations under the License.
1616
*/
1717

18+
#include "nsconfig.h"
1819
#include "ns_types.h"
1920

2021
#include "Core/include/ns_monitor.h"
22+
#include "mac_api.h" // for mcps_packet_ingress_rate_limit_by_memory
23+
#include "MAC/IEEE802_15_4/mac_mcps_sap.h" // for mcps_packet_ingress_rate_limit_by_memory
2124

2225
int ns_conf_gc_threshold_set(uint8_t percentage_high, uint8_t percentage_critical)
2326
{
2427
return ns_monitor_heap_gc_threshold_set(percentage_high, percentage_critical);
2528
}
29+
30+
int ns_conf_packet_ingress_rate_limit_by_mem(uint8_t free_heap_percentage)
31+
{
32+
return mcps_packet_ingress_rate_limit_by_memory(free_heap_percentage);
33+
}

0 commit comments

Comments
 (0)