Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers mle.h Source File

mle.h

00001 /*
00002  * Copyright (c) 2013-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 MLE_H_
00019 #define MLE_H_
00020 
00021 #include "nsconfig.h"
00022 #include "Core/include/ns_address_internal.h"
00023 #include "ns_list.h"
00024 
00025 struct buffer;
00026 struct mac_neighbor_table_entry;
00027 
00028 #define MLE_MAX_ROUTERS 64
00029 /* Route option layout: 1 Sequence byte, ID mask (bit per router), Data (byte per valid ID) */
00030 #define MLE_ROUTE_ID_MASK_SIZE   ((MLE_MAX_ROUTERS+7)/8)
00031 #define MLE_ROUTE_MAX_DATA_SIZE  MLE_MAX_ROUTERS
00032 #define MLE_ROUTE_MIN_OPTION_LEN (1 + MLE_ROUTE_ID_MASK_SIZE)
00033 
00034 /* MLE messge types */
00035 #define MLE_COMMAND_REQUEST                 0
00036 #define MLE_COMMAND_ACCEPT                  1
00037 #define MLE_COMMAND_ACCEPT_AND_REQUEST      2
00038 #define MLE_COMMAND_REJECT                  3
00039 #define MLE_COMMAND_ADVERTISEMENT           4
00040 #define MLE_COMMAND_UPDATE                  5
00041 #define MLE_COMMAND_UPDATE_REQUEST          6
00042 /* New messages for Thread */
00043 #define MLE_COMMAND_DATA_REQUEST            7
00044 #define MLE_COMMAND_DATA_RESPONSE           8
00045 #define MLE_COMMAND_PARENT_REQUEST          9  //Old MLE attache message number 1
00046 #define MLE_COMMAND_PARENT_RESPONSE        10  //Old MLE attache message number 2
00047 #define MLE_COMMAND_CHILD_ID_REQUEST       11  //Old MLE attache message number 3
00048 #define MLE_COMMAND_CHILD_ID_RESPONSE      12  //Old MLE attache message number 4
00049 #define MLE_COMMAND_CHILD_UPDATE_REQUEST   13
00050 #define MLE_COMMAND_CHILD_UPDATE_RESPONSE  14
00051 #define MLE_COMMAND_DATASET_ANNOUNCE       15
00052 #define MLE_COMMAND_DISCOVERY_REQUEST      16
00053 #define MLE_COMMAND_DISCOVERY_RESPONSE     17
00054 #define MLE_COMMAND_METRIC_MANAGEMENT_REQUEST            18 // Experimental for BH
00055 #define MLE_COMMAND_METRIC_MANAGEMENT_RESPONSE           19 // Experimental for BH
00056 #define MLE_COMMAND_PROBE                                20 // Experimental for BH
00057 
00058 #define MLE_UPDATE_CHANNEL          0
00059 #define MLE_UPDATE_PAN_ID             1
00060 #define MLE_UPDATE_PERMIT_MSG         2
00061 #define MLE_UPDATE_BEACON_PAYLOAD   3
00062 
00063 #define MLE_UPDATE_CHANNEL_FLAG          (1 << 0)
00064 #define MLE_UPDATE_PAN_ID_FLAG           (1 << 1)
00065 #define MLE_UPDATE_PERMIT_MSG_FLAG       (1 << 2)
00066 #define MLE_UPDATE_BEACON_PAYLOAD_FLAG (1 << 3)
00067 
00068 #define MLE_UPDATE_PROCESS_TRIG         0x80
00069 
00070 #define MLE_ERROR_NO_ERROR            0
00071 #define MLE_ERROR_BUFFER_ERROR        1
00072 #define MLE_ERROR_ADDRESS_ERROR       2
00073 #define MLE_ERROR_WRONG_TYPE          3
00074 #define MLE_ERROR_ALLOCATION_ERROR    4
00075 #define MLE_ERROR_DATA_TOO_LONG       5
00076 #define MLE_ERROR_UNSUPPORTED_TYPE    6
00077 #define MLE_ERROR_RESPONSE_NOT_WAITED 7
00078 
00079 #define MLE_CHALLENGE_SIZE 4
00080 #define MLE_RESPONSE_SIZE  32
00081 #define MLE_MAX_SIZE       116
00082 
00083 /* MLE TLV types */
00084 typedef enum mle_tlv_type_t_ {
00085     /* draft-kelsey-intarea-mesh-link-establishment-06 */
00086     MLE_TYPE_SRC_ADDRESS = 0,
00087     MLE_TYPE_MODE = 1,
00088     MLE_TYPE_TIMEOUT = 2,
00089     MLE_TYPE_CHALLENGE = 3,
00090     MLE_TYPE_RESPONSE = 4,
00091     MLE_TYPE_LL_FRAME_COUNTER = 5,
00092     MLE_TYPE_LINK_QUALITY = 6,
00093     MLE_TYPE_NWK_PARAM = 7,
00094     MLE_TYPE_MLE_FRAME_COUNTER = 8,
00095     /* Thread MLE Extensions (draft-kelsey-thread-mle-01) */
00096     MLE_TYPE_ROUTE = 9,
00097     MLE_TYPE_ADDRESS16 = 10,
00098     MLE_TYPE_LEADER_DATA = 11,
00099     MLE_TYPE_NETWORK_DATA = 12,
00100     MLE_TYPE_TLV_REQUEST = 13,
00101     MLE_TYPE_SCAN_MASK = 14,
00102     MLE_TYPE_CONNECTIVITY = 15,
00103     MLE_TYPE_RSSI = 16,
00104     MLE_TYPE_STATUS = 17,
00105     MLE_TYPE_VERSION = 18,
00106     MLE_TYPE_ADDRESS_REGISTRATION = 19,
00107     MLE_TYPE_CHANNEL = 20,
00108     MLE_TYPE_PANID = 21,
00109     MLE_TYPE_ACTIVE_TIMESTAMP = 22,
00110     MLE_TYPE_PENDING_TIMESTAMP = 23,
00111     MLE_TYPE_OPERATIONAL_DATASET = 24,
00112     MLE_TYPE_PENDING_OPERATIONAL_DATASET = 25,
00113     MLE_TYPE_DISCOVERY = 26,
00114     /* Thread low power TLVs*/
00115     MLE_TYPE_LINK_METRICS_QUERY = 87,
00116     MLE_TYPE_LINK_METRICS_MANAGEMENT = 88,
00117     MLE_TYPE_LINK_METRICS_REPORT = 89,
00118     MLE_TYPE_UNASSIGNED = 0xFF
00119 } mle_tlv_type_t;
00120 
00121 #define MLE_STATUS_ERROR 1
00122 /* MLE Mode = IEEE 802.15.4 Capability Information */
00123 #define MLE_DEV_MASK 2
00124 #define MLE_FFD_DEV 2
00125 #define MLE_RFD_DEV 0
00126 #define MLE_RX_ON_IDLE 8
00127 
00128 #define MLE_TABLE_CHALLENGE_TIMER       12
00129 
00130 #define MLE_NEIGHBOR_PRIORITY_LINK (1 << 5)
00131 #define MLE_NEIGHBOR_OUTGOING_LINK (1 << 6)
00132 #define MLE_NEIGHBOR_INCOMING_LINK (1 << 7)
00133 
00134 
00135 int8_t mle_class_set_new_key_pending(struct protocol_interface_info_entry *cur);
00136 int16_t mle_class_free_entry_count_get(struct protocol_interface_info_entry *cur);
00137 int16_t mle_class_sleepy_entry_count_get(struct protocol_interface_info_entry *cur);
00138 int16_t mle_class_rfd_entry_count_get(struct protocol_interface_info_entry *cur);
00139 uint16_t mle_class_active_neigh_counter(struct protocol_interface_info_entry *cur);
00140 bool mle_neigh_entry_frame_counter_update(struct mac_neighbor_table_entry *entry_temp, uint8_t *tlv_ptr, uint16_t tlv_length, struct protocol_interface_info_entry *cur, uint8_t key_id);
00141 uint8_t *mle_general_write_source_address(uint8_t *ptr, struct protocol_interface_info_entry *cur);
00142 
00143 uint8_t *mle_general_write_link_layer_framecounter(uint8_t *ptr, struct protocol_interface_info_entry *cur);
00144 
00145 void mle_mode_parse_to_mac_entry(struct mac_neighbor_table_entry *mac_entry, uint8_t mode);
00146 uint8_t  mle_mode_write_from_mac_entry(struct mac_neighbor_table_entry *mac_entry);
00147 
00148 #endif /* MLE_H_ */