Nanostack Border Router is a generic mbed border router implementation that provides the 6LoWPAN ND or Thread border router initialization logic.

Committer:
mbed_official
Date:
Wed Nov 27 10:02:22 2019 +0000
Revision:
108:0c14bd1d3334
Parent:
82:3d9e3b7b3dcf
Fix conflicting declarations of main() (#197)

Update the main() to be compatible with the declaration from
platform/mbed_toolchain.h that adds the MBED_USED attribute.
Without the attribute the main() symbol is not emitted with the
GCC toolchain using "-Wl,--wrap,main" and "-flto" flags.
.
Commit copied from https://github.com/ARMmbed/nanostack-border-router

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:85f4174a8e29 1 /*
mbed_official 0:85f4174a8e29 2 * Copyright (c) 2016 ARM Limited. All rights reserved.
mbed_official 0:85f4174a8e29 3 */
mbed_official 0:85f4174a8e29 4
mbed_official 0:85f4174a8e29 5 #include <string.h>
mbed_official 0:85f4174a8e29 6 #include <stdlib.h>
mbed_official 0:85f4174a8e29 7 #include <stdio.h>
mbed_official 0:85f4174a8e29 8 #include <ctype.h>
mbed_official 0:85f4174a8e29 9 #include "ip6string.h"
mbed_official 0:85f4174a8e29 10 #include "ns_types.h"
mbed_official 0:85f4174a8e29 11 #include "common_functions.h"
mbed_official 0:85f4174a8e29 12 #include "ns_trace.h"
mbed_official 13:993808eb2e9c 13 #include "nsdynmemLIB.h"
mbed_official 0:85f4174a8e29 14 #define TRACE_GROUP "app"
mbed_official 0:85f4174a8e29 15
mbed_official 0:85f4174a8e29 16 static char tmp_print_buffer[128] = {0};
mbed_official 0:85f4174a8e29 17
mbed_official 0:85f4174a8e29 18 char *print_ipv6(const void *addr_ptr)
mbed_official 0:85f4174a8e29 19 {
mbed_official 0:85f4174a8e29 20 ip6tos(addr_ptr, tmp_print_buffer);
mbed_official 0:85f4174a8e29 21 return tmp_print_buffer;
mbed_official 0:85f4174a8e29 22 }
mbed_official 0:85f4174a8e29 23
mbed_official 0:85f4174a8e29 24 char *print_ipv6_prefix(const uint8_t *prefix, uint8_t prefix_len)
mbed_official 0:85f4174a8e29 25 {
mbed_official 0:85f4174a8e29 26 char *str = tmp_print_buffer;
mbed_official 0:85f4174a8e29 27 int retval;
mbed_official 0:85f4174a8e29 28 char tmp[40];
mbed_official 0:85f4174a8e29 29 uint8_t addr[16] = {0};
mbed_official 0:85f4174a8e29 30
mbed_official 0:85f4174a8e29 31 if (prefix_len != 0) {
mbed_official 0:85f4174a8e29 32 if (prefix == NULL || prefix_len > 128) {
mbed_official 0:85f4174a8e29 33 return "<err>";
mbed_official 0:85f4174a8e29 34 }
mbed_official 0:85f4174a8e29 35 bitcopy(addr, prefix, prefix_len);
mbed_official 0:85f4174a8e29 36 }
mbed_official 0:85f4174a8e29 37
mbed_official 0:85f4174a8e29 38 ip6tos(addr, tmp);
mbed_official 0:85f4174a8e29 39 retval = snprintf(str, 128, "%s/%u", tmp, prefix_len);
mbed_official 0:85f4174a8e29 40 if (retval <= 0) {
mbed_official 0:85f4174a8e29 41 return "";
mbed_official 0:85f4174a8e29 42 }
mbed_official 0:85f4174a8e29 43 return str;
mbed_official 0:85f4174a8e29 44 }
mbed_official 0:85f4174a8e29 45
mbed_official 13:993808eb2e9c 46 void print_memory_stats(void)
mbed_official 13:993808eb2e9c 47 {
mbed_official 13:993808eb2e9c 48 const mem_stat_t *heap_info = ns_dyn_mem_get_mem_stat();
mbed_official 13:993808eb2e9c 49 if (heap_info) {
mbed_official 13:993808eb2e9c 50 tr_info(
mbed_official 69:a8a0ac9f3f8a 51 "Heap size: %lu, Reserved: %lu, Reserved max: %lu, Alloc fail: %lu"
mbed_official 82:3d9e3b7b3dcf 52 , (unsigned long)heap_info->heap_sector_size
mbed_official 82:3d9e3b7b3dcf 53 , (unsigned long)heap_info->heap_sector_allocated_bytes
mbed_official 82:3d9e3b7b3dcf 54 , (unsigned long)heap_info->heap_sector_allocated_bytes_max
mbed_official 82:3d9e3b7b3dcf 55 , (unsigned long)heap_info->heap_alloc_fail_cnt);
mbed_official 13:993808eb2e9c 56 }
mbed_official 13:993808eb2e9c 57 }
mbed_official 13:993808eb2e9c 58