Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers nd_router_object.h Source File

nd_router_object.h

00001 /*
00002  * Copyright (c) 2013-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 #include "6LoWPAN/ND/nd_defines.h"
00018 #include "net_6lowpan_parameter_api.h"
00019 
00020 #ifndef ND_ROUTER_OBJECT_H_
00021 #define ND_ROUTER_OBJECT_H_
00022 
00023 
00024 #define ND_OBJECT_MAX 1
00025 
00026 #define ND_MAX_PROXY_CONTEXT_COUNT 5
00027 #define ND_MAX_PROXY_PREFIX_COUNT 5
00028 
00029 /* RFC4861 AdvCurHopLimit: value placed in Router Advertisement Cur Hop Limit */
00030 #ifndef ADV_CUR_HOP_LIMIT
00031 #define ADV_CUR_HOP_LIMIT 64
00032 #endif
00033 #ifdef HAVE_6LOWPAN_ND
00034 extern uint8_t nd_base_tick;
00035 extern nd_parameters_s nd_params;
00036 struct aro;
00037 
00038 #ifdef HAVE_6LOWPAN_BORDER_ROUTER
00039 int8_t icmp_nd_router_prefix_proxy_update(uint8_t *dptr, nd_router_setup_t *nd_router_object);
00040 int8_t nd_set_br(nd_router_t *br);
00041 #else
00042 #define icmp_nd_router_prefix_proxy_update(dptr, nd_router_object) -1
00043 #define nd_set_br(br) -1
00044 #endif
00045 extern void icmp_nd_prefixs_parse(buffer_t *buf, nd_router_t *nd_router_object, protocol_interface_info_entry_t *cur_interface);
00046 extern int8_t icmp_nd_router_prefix_update(uint8_t *dptr, nd_router_t *nd_router_object, protocol_interface_info_entry_t *cur_interface);
00047 extern void gp_address_add_to_end(gp_ipv6_address_list_t *list, const uint8_t address[static 16]);
00048 extern void gp_address_list_free(gp_ipv6_address_list_t *list);
00049 extern uint8_t nd_set_adr_by_dest_prefix(uint8_t *ptr, uint8_t *prefix);
00050 extern bool nd_object_active(void);
00051 extern void icmp_nd_set_nd_def_router_address(uint8_t *ptr, nd_router_t *cur);
00052 extern nd_router_t *icmp_nd_router_object_get(const uint8_t *border_router, nwk_interface_id nwk_id);
00053 extern void icmp_nd_set_next_hop(nd_router_next_hop *hop, sockaddr_t *adr);
00054 
00055 
00056 
00057 /** 6LoWPAN spesific ICMP message Handler */
00058 extern buffer_t *nd_dar_parse(buffer_t *buf, protocol_interface_info_entry_t *cur_interface);
00059 extern buffer_t *nd_dac_handler(buffer_t *buf, protocol_interface_info_entry_t *cur);
00060 extern void nd_ns_build(nd_router_t *cur, protocol_interface_info_entry_t *cur_interface, uint8_t *address_ptr);
00061 extern int8_t nd_parent_loose_indcate(uint8_t *neighbor_address, protocol_interface_info_entry_t *cur_interface);
00062 
00063 void nd_router_base_init(nd_router_t *new_entry);
00064 
00065 
00066 void icmp_nd_routers_init(void);
00067 
00068 #ifdef HAVE_RPL
00069 ipv6_ra_timing_t *nd_ra_timing(const uint8_t abro[16]);
00070 void nd_ra_build_by_abro(const uint8_t *abro, const uint8_t *dest, protocol_interface_info_entry_t *cur_interface);
00071 void nd_trigger_ras_from_rs(const uint8_t *unicast_adr, protocol_interface_info_entry_t *cur_interface);
00072 /** 6LoWPAN spesific ICMP message Handler */
00073 bool nd_ns_aro_handler(protocol_interface_info_entry_t *cur_interface, const uint8_t *aro_opt, const uint8_t *slaa_opt, const uint8_t *target, struct aro *aro_out);
00074 void nd_remove_registration(protocol_interface_info_entry_t *cur_interface, addrtype_t ll_type, const uint8_t *ll_address);
00075 #else
00076 #define nd_ra_timing(abro) NULL
00077 #define nd_ra_build_by_abro(abro, dest, cur_interface) ((void)0)
00078 #define nd_trigger_ras_from_rs(unicast_adr, cur_interface) ((void)0)
00079 #define nd_ns_aro_handler(cur_interface, aro_opt, slaa_opt, target, aro_out) false
00080 #define nd_remove_registration(cur_interface, l_type, ll_address) ((void)0)
00081 #endif
00082 
00083 nd_router_t *nd_get_pana_address(void);
00084 /* This processes the 6CO for the interface itself - separate from the ABRO
00085  * multihop relay storage.
00086  *
00087  *  0                   1                   2                   3
00088  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
00089  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
00090  * |     Type      |     Length    |Context Length | Res |C|  CID  |
00091  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
00092  * |            Reserved           |         Valid Lifetime        |
00093  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
00094  * .                                                               .
00095  * .                       Context Prefix                          .
00096  * .                                                               .
00097  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
00098  *
00099  */
00100 void nd_ra_process_lowpan_context_option(struct protocol_interface_info_entry *cur, const uint8_t *opt);
00101 
00102 /** ND Routing Part */
00103 uint8_t nd_prefix_dst_check(uint8_t *ptr);
00104 nd_router_t *nd_get_object_by_nwk_id(nwk_interface_id nwk_id);
00105 /* Original ABRO-based all-in-one parser. This needs some rework to separate ABRO-related and unrelated bits */
00106 /* Returns "false" if ABRO suggested it was a stale message, so not worth handling in the normal code */
00107 extern bool nd_ra_process_abro(struct protocol_interface_info_entry *cur, buffer_t *buf, const uint8_t *dptr, uint8_t ra_flags, uint16_t router_lifetime);
00108 extern void nd_object_timer(struct protocol_interface_info_entry *cur_interface, uint16_t ticks_update);
00109 extern uint32_t nd_object_time_to_next_nd_reg(void);
00110 
00111 extern void icmp_nd_router_object_reset(nd_router_t *router_object);
00112 extern void icmp_nd_border_router_release(nd_router_t *router_object);
00113 void nd_6lowpan_set_radv_params(protocol_interface_info_entry_t *cur_interface);
00114 #else
00115 #define icmp_nd_routers_init() ((void)0)
00116 #define nd_ns_aro_handler(cur_interface, aro_opt, slaa_opt, target, aro_out) false
00117 #define nd_ra_build_by_abro(abro, dest, cur_interface) ((void)0)
00118 #define nd_trigger_ras_from_rs(unicast_adr, cur_interface) ((void)0)
00119 #define nd_ra_timing(abro) NULL
00120 #define nd_prefix_dst_check(x) 0
00121 #define nd_get_object_by_nwk_id(x) NULL
00122 #define nd_ra_process_abro(x,y,z,a,b) false
00123 #define nd_ra_process_lowpan_context_option(x,y) ((void)0)
00124 #define nd_get_pana_address() NULL
00125 #define nd_object_timer(x, ticks_update) ((void)0)
00126 #define nd_object_time_to_next_nd_reg() 0
00127 #define nd_object_active() false
00128 #define gp_address_list_free(list) ((void)0)
00129 #define gp_address_add_to_end(list, address) ((void)0)
00130 #define nd_6lowpan_set_radv_params(cur) ((void)0)
00131 #define nd_remove_registration(cur_interface, l_type, ll_address) ((void)0)
00132 #endif
00133 #endif /* ND_ROUTER_OBJECT_H_ */