Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
icmpv6.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 #ifndef _ICMPV6_H 00018 #define _ICMPV6_H 00019 #include "Common_Protocols/icmpv6_prefix.h" 00020 00021 #define ICMPV6_TYPE_ERROR_DESTINATION_UNREACH 1 00022 #define ICMPV6_TYPE_ERROR_PACKET_TOO_BIG 2 00023 #define ICMPV6_TYPE_ERROR_TIME_EXCEEDED 3 00024 #define ICMPV6_TYPE_ERROR_PARAMETER_PROBLEM 4 00025 00026 #define ICMPV6_TYPE_INFO_ECHO_REQUEST 128 00027 #define ICMPV6_TYPE_INFO_ECHO_REPLY 129 00028 #define ICMPV6_TYPE_INFO_MCAST_LIST_QUERY 130 00029 #define ICMPV6_TYPE_INFO_MCAST_LIST_REPORT 131 00030 #define ICMPV6_TYPE_INFO_MCAST_LIST_DONE 132 00031 #define ICMPV6_TYPE_INFO_RS 133 00032 #define ICMPV6_TYPE_INFO_RA 134 00033 #define ICMPV6_TYPE_INFO_NS 135 00034 #define ICMPV6_TYPE_INFO_NA 136 00035 #define ICMPV6_TYPE_INFO_REDIRECT 137 00036 #define ICMPV6_TYPE_INFO_MCAST_LIST_REPORT_V2 143 00037 #define ICMPV6_TYPE_INFO_RPL_CONTROL 155 00038 #define ICMPV6_TYPE_INFO_DAR 157 00039 #define ICMPV6_TYPE_INFO_DAC 158 00040 #define ICMPV6_TYPE_INFO_MPL_CONTROL 159 00041 00042 #define ICMPV6_CODE_DST_UNREACH_NO_ROUTE 0 00043 #define ICMPV6_CODE_DST_UNREACH_ADM_PROHIB 1 00044 #define ICMPV6_CODE_DST_UNREACH_BEYOND_SCOPE 2 00045 #define ICMPV6_CODE_DST_UNREACH_ADDR_UNREACH 3 00046 #define ICMPV6_CODE_DST_UNREACH_PORT_UNREACH 4 00047 #define ICMPV6_CODE_DST_UNREACH_SRC_FAILED_POLICY 5 00048 #define ICMPV6_CODE_DST_UNREACH_ROUTE_REJECTED 6 00049 #define ICMPV6_CODE_DST_UNREACH_SRC_RTE_HDR_ERR 7 00050 00051 #define ICMPV6_CODE_TME_EXCD_HOP_LIM_EXCD 0 00052 #define ICMPV6_CODE_TME_EXCD_FRG_REASS_TME_EXCD 1 00053 00054 #define ICMPV6_CODE_PARAM_PRB_HDR_ERR 0 00055 #define ICMPV6_CODE_PARAM_PRB_UNREC_NEXT_HDR 1 00056 #define ICMPV6_CODE_PARAM_PRB_UNREC_IPV6_OPT 2 00057 #define ICMPV6_CODE_PARAM_PRB_FIRST_FRAG_IPV6_HDR 3 00058 00059 #define ICMPV6_CODE_RPL_DIS 0x00 00060 #define ICMPV6_CODE_RPL_DIO 0x01 00061 #define ICMPV6_CODE_RPL_DAO 0x02 00062 #define ICMPV6_CODE_RPL_DAO_ACK 0x03 00063 #define ICMPV6_CODE_RPL_P2P_DRO 0x04 00064 #define ICMPV6_CODE_RPL_P2P_DRO_ACK 0x05 00065 #define ICMPV6_CODE_RPL_SECURE_DIS 0x80 00066 #define ICMPV6_CODE_RPL_SECURE_DIO 0x81 00067 #define ICMPV6_CODE_RPL_SECURE_DAO 0x82 00068 #define ICMPV6_CODE_RPL_SECURE_DAO_ACK 0x83 00069 #define ICMPV6_CODE_RPL_SECURE_P2P_DRO 0x84 00070 #define ICMPV6_CODE_RPL_SECURE_P2P_DRO_ACK 0x85 00071 #define ICMPV6_CODE_RPL_CC 0x8A 00072 00073 /* Options in ICMPv6 Neighbor Discovery Protocol (RPL has totally different options...) */ 00074 #define ICMPV6_OPT_SRC_LL_ADDR 1 00075 #define ICMPV6_OPT_TGT_LL_ADDR 2 00076 #define ICMPV6_OPT_PREFIX_INFO 3 00077 #define ICMPV6_OPT_REDIRECTED_HDR 4 00078 #define ICMPV6_OPT_MTU 5 00079 #define ICMPV6_OPT_ROUTE_INFO 24 00080 #define ICMPV6_OPT_ADDR_REGISTRATION 33 00081 #define ICMPV6_OPT_6LOWPAN_CONTEXT 34 00082 #define ICMPV6_OPT_AUTHORITATIVE_BORDER_RTR 35 00083 00084 /* Neighbour Advertisement flags */ 00085 #define NA_R 0x80 00086 #define NA_S 0x40 00087 #define NA_O 0x20 00088 00089 /* Router Advertisement flags */ 00090 #define RA_M 0x80 // Managed 00091 #define RA_O 0x40 // Other Configuration 00092 #define RA_H 0x20 // Home Agent (RFC 6275) 00093 #define RA_PRF_MASK 0x18 // Router Preference (RFC 4191) 00094 #define RA_PRF_LOW 0x18 // (RA_PRF_xxx also occurs in Route Info Options) 00095 #define RA_PRF_MEDIUM 0x00 00096 #define RA_PRF_HIGH 0x08 00097 #define RA_PRF_INVALID 0x10 00098 00099 struct buffer; 00100 struct protocol_interface_info_entry; 00101 00102 typedef struct aro { 00103 uint16_t lifetime; 00104 uint8_t status; 00105 uint8_t eui64[8]; 00106 bool present; 00107 } aro_t; 00108 00109 typedef enum slaac_src { 00110 SLAAC_IID_DEFAULT, // OPAQUE if key available and enabled on interface, else FIXED 00111 SLAAC_IID_EUI64, // use fixed IID based on EUI-64/MAC-64 (iid_eui64) 00112 SLAAC_IID_FIXED, // use fixed IID (iid_slaac) 00113 SLAAC_IID_OPAQUE, // RFC 7217 opaque 00114 SLAAC_IID_6LOWPAN_SHORT // use IID based on 6LoWPAN short address 00115 } slaac_src_e; 00116 00117 #define ARO_SUCCESS 0 00118 #define ARO_DUPLICATE 1 00119 #define ARO_FULL 2 00120 00121 extern void icmpv6_init(void); 00122 extern struct buffer *icmpv6_down(struct buffer *buf ); 00123 extern struct buffer *icmpv6_up(struct buffer *buf ); 00124 extern struct buffer *icmpv6_error(struct buffer *buf , struct protocol_interface_info_entry *cur, uint8_t type, uint8_t code, uint32_t aux); 00125 00126 extern bool icmpv6_options_well_formed(const uint8_t *dptr, uint_fast16_t dlen); 00127 extern bool icmpv6_options_well_formed_in_buffer(const struct buffer *buf , uint16_t offset ); 00128 extern const uint8_t *icmpv6_find_option(const uint8_t *dptr, uint_fast16_t dlen, uint8_t option, uint8_t optlen); 00129 extern const uint8_t *icmpv6_find_option_in_buffer(const struct buffer *buf , uint_fast16_t offset , uint8_t option, uint8_t optlen); 00130 00131 struct protocol_interface_info_entry; 00132 00133 extern struct buffer *icmpv6_build_rs(struct protocol_interface_info_entry *cur, const uint8_t *dest_addr); 00134 extern struct buffer *icmpv6_build_ns(struct protocol_interface_info_entry *cur, const uint8_t target_addr[static 16], const uint8_t *prompting_src_addr, bool unicast, bool unspecified_source, const struct aro *aro); 00135 extern struct buffer *icmpv6_build_na(struct protocol_interface_info_entry *cur, bool solicited, bool override, bool tllao_required, const uint8_t target[static 16], const aro_t *aro, const uint8_t src_addr[static 16]); 00136 extern struct buffer *icmpv6_build_dad(struct protocol_interface_info_entry *cur, struct buffer *buf , uint8_t type, const uint8_t dest_addr[16], const uint8_t eui64[8], const uint8_t reg_addr[16], uint8_t status, uint16_t lifetime); 00137 extern void icmpv6_build_echo_req(struct protocol_interface_info_entry *cur, const uint8_t target_addr[16]); 00138 00139 extern void icmpv6_recv_ra_routes(struct protocol_interface_info_entry *cur, bool enable); 00140 extern void icmpv6_recv_ra_prefixes(struct protocol_interface_info_entry *cur, bool enable); 00141 00142 extern void icmpv6_slaac_prefix_register_trig(struct protocol_interface_info_entry *cur, uint8_t *prefix_ptr, uint8_t prefix_len); 00143 extern int icmpv6_slaac_prefix_update(struct protocol_interface_info_entry *cur, uint8_t *prefix_ptr, uint8_t prefix_len, uint32_t valid_lifetime, uint32_t preferred_lifetime); 00144 extern struct if_address_entry *icmpv6_slaac_address_add(struct protocol_interface_info_entry *cur, uint8_t *prefix_ptr, uint8_t prefix_len, uint32_t valid_lifetime, uint32_t preferred_lifetime, bool skip_dad, slaac_src_e slaac_src); 00145 00146 00147 /* 00148 * Write either an ICMPv6 Prefix Information Option for a Router Advertisement 00149 * (RFC4861+6275), or an RPL Prefix Information Option (RFC6550). 00150 * Same payload, different type/len. 00151 */ 00152 uint8_t *icmpv6_write_prefix_option(const prefix_list_t *prefixes, uint8_t *dptr, uint8_t rpl_prefix, struct protocol_interface_info_entry *cur); 00153 uint8_t *icmpv6_write_mtu_option(uint32_t mtu, uint8_t *dptr); 00154 uint8_t *icmpv6_write_icmp_lla(struct protocol_interface_info_entry *cur, uint8_t *dptr, uint8_t icmp_opt, bool must, const uint8_t *ip_addr); 00155 00156 #endif /* _ICMPV6_H */
Generated on Tue Jul 12 2022 14:23:50 by
