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_defines.h Source File

nd_defines.h

00001 /*
00002  * Copyright (c) 2014-2017, 2019, 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 
00018 #ifndef ND_DEFINES_H_
00019 #define ND_DEFINES_H_
00020 
00021 #include "Core/include/ns_address_internal.h"
00022 #include "ns_list.h"
00023 #include "6LoWPAN/IPHC_Decode/lowpan_context.h"
00024 #include "Common_Protocols/icmpv6_prefix.h"
00025 
00026 typedef enum {
00027     ND_READY = 0,
00028     ND_BR_READY = 1,
00029     ND_RS_UNCAST = 2,
00030     ND_RS_MULTICAST = 3,
00031 } nd_obj_state;
00032 
00033 #define nd_is_ready_state(state) ((state) == ND_READY || (state) == ND_BR_READY)
00034 #define nd_is_bootstrap_state(state) (!nd_is_ready_state(state))
00035 
00036 typedef enum {
00037     ND_ADDRESS_PRIMARY = 0,
00038     ND_ADDRESS_SECONDARY = 1,
00039 } nd_multi_address_type;
00040 
00041 typedef struct nd_router_next_hop {
00042     addrtype_t addrtype;
00043     uint8_t address[8];
00044     uint8_t LQI;
00045 } nd_router_next_hop;
00046 
00047 // This structure conflates a few things, confusingly. It's basically
00048 // a "per-border-router"/"per-ABRO" (RFC 6775) structure.
00049 // This is sensible for a 6LR, which has to store prefixes and contexts
00050 // per-ABRO for relaying, and needs to time them out, but it's not the same
00051 // structure needed as a host (or for the host part of the router). For a host,
00052 // contexts and prefixes and addresses are needed per-interface, and they
00053 // shouldn't time out just because an ABRO timed out.
00054 // Also, because of this structure, we always end up requiring ABROs as a host,
00055 // which isn't really necessary.
00056 // This also isn't the RFC 4861 "Default Router List", alas.
00057 // Note also that this is used both to describe a remote border router, and
00058 // ourselves as a border router, with some confusing effects on lifetimes
00059 // (we're in danger of timing ourselves out as a border router)
00060 typedef struct nd_router {
00061     nwk_interface_id nwk_id;
00062     uint8_t border_router[16];
00063     uint8_t flags;
00064     uint16_t life_time;
00065     uint16_t nd_re_validate;
00066     nd_obj_state nd_state;
00067     uint16_t ns_forward_timer;
00068     uint16_t nd_timer;
00069     uint16_t mle_advert_timer;
00070     uint8_t mle_purge_timer;
00071     uint8_t nd_bootstrap_tick;
00072     uint8_t ns_retry;
00073     uint32_t abro_version_num;
00074     bool trig_address_reg;
00075     ipv6_ra_timing_t ra_timing;
00076     prefix_list_t prefix_list;
00077     lowpan_context_list_t context_list;
00078     nd_router_next_hop default_hop;
00079     nd_router_next_hop *secondaty_hop;
00080 
00081     ns_list_link_t link;
00082 
00083 } nd_router_t;
00084 
00085 /* XXX why isn't this a substructure of nd_router_t? or share one */
00086 typedef struct nd_router_setup {
00087     uint16_t life_time;
00088     uint32_t abro_version_num;
00089     prefix_list_t prefix_list;
00090     lowpan_context_list_t context_list;
00091 } nd_router_setup_t;
00092 
00093 
00094 #endif /* ND_DEFINES_H_ */