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 "net_interface.h"
mbed_official 0:85f4174a8e29 7 #include "mbed-trace/mbed_trace.h"
mbed_official 55:01540dd2f111 8 #include "thread_bbr_api.h"
mbed_official 0:85f4174a8e29 9 #include "thread_border_router_api.h"
mbed_official 0:85f4174a8e29 10 #include "thread_br_conn_handler.h"
mbed_official 0:85f4174a8e29 11 #include "thread_dhcpv6_server.h"
mbed_official 0:85f4174a8e29 12 #include "borderrouter_helpers.h"
mbed_official 0:85f4174a8e29 13 #include "common_functions.h"
mbed_official 0:85f4174a8e29 14 #include "eventOS_event_timer.h"
mbed_official 0:85f4174a8e29 15 #include "thread_bbr_ext.h"
mbed_official 22:8740285d8f09 16 #include "multicast_api.h"
mbed_official 0:85f4174a8e29 17
mbed_official 0:85f4174a8e29 18 #define TRACE_GROUP "TBRH"
mbed_official 22:8740285d8f09 19
mbed_official 0:85f4174a8e29 20 typedef struct {
mbed_official 82:3d9e3b7b3dcf 21
mbed_official 0:85f4174a8e29 22 int8_t thread_interface_id;
mbed_official 0:85f4174a8e29 23 int8_t eth_interface_id;
mbed_official 0:85f4174a8e29 24 bool eth_connection_ready;
mbed_official 0:85f4174a8e29 25 bool thread_connection_ready;
mbed_official 0:85f4174a8e29 26 } thread_br_handler_t;
mbed_official 0:85f4174a8e29 27
mbed_official 0:85f4174a8e29 28 static thread_br_handler_t thread_br_handler;
mbed_official 0:85f4174a8e29 29
mbed_official 0:85f4174a8e29 30 void thread_br_conn_handler_init(void)
mbed_official 0:85f4174a8e29 31 {
mbed_official 82:3d9e3b7b3dcf 32 thread_br_handler.thread_interface_id = -1;
mbed_official 55:01540dd2f111 33 thread_br_handler.thread_connection_ready = 0;
mbed_official 0:85f4174a8e29 34
mbed_official 82:3d9e3b7b3dcf 35 thread_br_handler.eth_interface_id = -1;
mbed_official 55:01540dd2f111 36 thread_br_handler.eth_connection_ready = 0;
mbed_official 0:85f4174a8e29 37 }
mbed_official 0:85f4174a8e29 38
mbed_official 0:85f4174a8e29 39 void thread_br_conn_handler_thread_connection_update(bool status)
mbed_official 0:85f4174a8e29 40 {
mbed_official 0:85f4174a8e29 41 thread_br_handler.thread_connection_ready = status;
mbed_official 4:0a9d1eeaa905 42 tr_debug("mesh0 connection status: %d", status);
mbed_official 4:0a9d1eeaa905 43
mbed_official 0:85f4174a8e29 44 }
mbed_official 0:85f4174a8e29 45
mbed_official 0:85f4174a8e29 46 void thread_br_conn_handler_ethernet_connection_update(bool status)
mbed_official 0:85f4174a8e29 47 {
mbed_official 0:85f4174a8e29 48 thread_br_handler.eth_connection_ready = status;
mbed_official 4:0a9d1eeaa905 49 tr_debug("Eth0 connection status: %d", status);
mbed_official 4:0a9d1eeaa905 50
mbed_official 0:85f4174a8e29 51 }
mbed_official 0:85f4174a8e29 52
mbed_official 0:85f4174a8e29 53 void thread_br_conn_handler_thread_interface_id_set(int8_t interfaceId)
mbed_official 0:85f4174a8e29 54 {
mbed_official 0:85f4174a8e29 55 thread_br_handler.thread_interface_id = interfaceId;
mbed_official 0:85f4174a8e29 56 thread_bbr_extension_mesh_interface_updated_ntf(thread_br_handler.thread_interface_id);
mbed_official 82:3d9e3b7b3dcf 57 if (thread_br_handler.thread_interface_id > -1 && thread_br_handler.eth_interface_id > -1) {
mbed_official 82:3d9e3b7b3dcf 58 thread_bbr_start(thread_br_handler.thread_interface_id, thread_br_handler.eth_interface_id);
mbed_official 55:01540dd2f111 59 }
mbed_official 0:85f4174a8e29 60 }
mbed_official 0:85f4174a8e29 61
mbed_official 0:85f4174a8e29 62 int8_t thread_br_conn_handler_thread_interface_id_get(void)
mbed_official 0:85f4174a8e29 63 {
mbed_official 0:85f4174a8e29 64 return thread_br_handler.thread_interface_id;
mbed_official 0:85f4174a8e29 65 }
mbed_official 0:85f4174a8e29 66
mbed_official 0:85f4174a8e29 67 bool thread_br_conn_handler_eth_connection_status_get(void)
mbed_official 0:85f4174a8e29 68 {
mbed_official 0:85f4174a8e29 69 return thread_br_handler.eth_connection_ready;
mbed_official 0:85f4174a8e29 70 }
mbed_official 0:85f4174a8e29 71
mbed_official 0:85f4174a8e29 72 bool thread_br_conn_handler_thread_connection_status_get(void)
mbed_official 0:85f4174a8e29 73 {
mbed_official 0:85f4174a8e29 74 return thread_br_handler.thread_connection_ready;
mbed_official 0:85f4174a8e29 75 }
mbed_official 0:85f4174a8e29 76
mbed_official 0:85f4174a8e29 77 void thread_br_conn_handler_eth_interface_id_set(int8_t interfaceId)
mbed_official 0:85f4174a8e29 78 {
mbed_official 0:85f4174a8e29 79 thread_br_handler.eth_interface_id = interfaceId;
mbed_official 0:85f4174a8e29 80 thread_bbr_extension_bb_interface_updated_ntf(thread_br_handler.eth_interface_id);
mbed_official 82:3d9e3b7b3dcf 81 if (thread_br_handler.thread_interface_id > -1 && thread_br_handler.eth_interface_id > -1) {
mbed_official 82:3d9e3b7b3dcf 82 thread_bbr_start(thread_br_handler.thread_interface_id, thread_br_handler.eth_interface_id);
mbed_official 55:01540dd2f111 83 }
mbed_official 0:85f4174a8e29 84 }
mbed_official 0:85f4174a8e29 85
mbed_official 0:85f4174a8e29 86 int8_t thread_br_conn_handler_eth_interface_id_get(void)
mbed_official 0:85f4174a8e29 87 {
mbed_official 0:85f4174a8e29 88 return thread_br_handler.eth_interface_id;
mbed_official 0:85f4174a8e29 89 }