Nanostack Border Router is a generic mbed border router implementation that provides the 6LoWPAN ND or Thread border router initialization logic.
source/thread_br_conn_handler.c@55:01540dd2f111, 2018-03-28 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Mar 28 12:15:20 2018 +0100
- Revision:
- 55:01540dd2f111
- Parent:
- 22:8740285d8f09
- Child:
- 82:3d9e3b7b3dcf
Merge pull request #97 from ARMmbed/mbed-os-5.8
Merge mbed-os-5.8.0-oob
.
Commit copied from https://github.com/ARMmbed/nanostack-border-router
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:85f4174a8e29 | 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 | 55:01540dd2f111 | 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 | 55:01540dd2f111 | 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 | 55:01540dd2f111 | 57 | if (thread_br_handler.thread_interface_id > -1 && |
mbed_official | 55:01540dd2f111 | 58 | thread_br_handler.eth_interface_id > -1) { |
mbed_official | 55:01540dd2f111 | 59 | thread_bbr_start(thread_br_handler.thread_interface_id, thread_br_handler.eth_interface_id); |
mbed_official | 55:01540dd2f111 | 60 | } |
mbed_official | 0:85f4174a8e29 | 61 | } |
mbed_official | 0:85f4174a8e29 | 62 | |
mbed_official | 0:85f4174a8e29 | 63 | int8_t thread_br_conn_handler_thread_interface_id_get(void) |
mbed_official | 0:85f4174a8e29 | 64 | { |
mbed_official | 0:85f4174a8e29 | 65 | return thread_br_handler.thread_interface_id; |
mbed_official | 0:85f4174a8e29 | 66 | } |
mbed_official | 0:85f4174a8e29 | 67 | |
mbed_official | 0:85f4174a8e29 | 68 | bool thread_br_conn_handler_eth_connection_status_get(void) |
mbed_official | 0:85f4174a8e29 | 69 | { |
mbed_official | 0:85f4174a8e29 | 70 | return thread_br_handler.eth_connection_ready; |
mbed_official | 0:85f4174a8e29 | 71 | } |
mbed_official | 0:85f4174a8e29 | 72 | |
mbed_official | 0:85f4174a8e29 | 73 | bool thread_br_conn_handler_thread_connection_status_get(void) |
mbed_official | 0:85f4174a8e29 | 74 | { |
mbed_official | 0:85f4174a8e29 | 75 | return thread_br_handler.thread_connection_ready; |
mbed_official | 0:85f4174a8e29 | 76 | } |
mbed_official | 0:85f4174a8e29 | 77 | |
mbed_official | 0:85f4174a8e29 | 78 | void thread_br_conn_handler_eth_interface_id_set(int8_t interfaceId) |
mbed_official | 0:85f4174a8e29 | 79 | { |
mbed_official | 0:85f4174a8e29 | 80 | thread_br_handler.eth_interface_id = interfaceId; |
mbed_official | 0:85f4174a8e29 | 81 | thread_bbr_extension_bb_interface_updated_ntf(thread_br_handler.eth_interface_id); |
mbed_official | 55:01540dd2f111 | 82 | if (thread_br_handler.thread_interface_id > -1 && |
mbed_official | 55:01540dd2f111 | 83 | thread_br_handler.eth_interface_id > -1) { |
mbed_official | 55:01540dd2f111 | 84 | thread_bbr_start(thread_br_handler.thread_interface_id, thread_br_handler.eth_interface_id); |
mbed_official | 55:01540dd2f111 | 85 | } |
mbed_official | 0:85f4174a8e29 | 86 | } |
mbed_official | 0:85f4174a8e29 | 87 | |
mbed_official | 0:85f4174a8e29 | 88 | int8_t thread_br_conn_handler_eth_interface_id_get(void) |
mbed_official | 0:85f4174a8e29 | 89 | { |
mbed_official | 0:85f4174a8e29 | 90 | return thread_br_handler.eth_interface_id; |
mbed_official | 0:85f4174a8e29 | 91 | } |