BA
/
BaBoRo1
Embed:
(wiki syntax)
Show/hide line numbers
fnet_icmp6.h
00001 /************************************************************************** 00002 * 00003 * Copyright 2011-2016 by Andrey Butok. FNET Community. 00004 * Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, Inc. 00005 * 00006 *************************************************************************** 00007 * 00008 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00009 * not use this file except in compliance with the License. 00010 * You may obtain a copy of the License at 00011 * 00012 * http://www.apache.org/licenses/LICENSE-2.0 00013 * 00014 * Unless required by applicable law or agreed to in writing, software 00015 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00016 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00017 * See the License for the specific language governing permissions and 00018 * limitations under the License. 00019 * 00020 **********************************************************************/ 00021 /*! 00022 * @brief Private. ICMP protocol function definitions, data structures, etc. 00023 * 00024 ***************************************************************************/ 00025 #ifndef _FNET_ICMP6_H_ 00026 #define _FNET_ICMP6_H_ 00027 00028 #include "fnet.h" 00029 #include "fnet_netbuf.h" 00030 00031 /************************************************************************ 00032 * Definition of type and code field values. 00033 *************************************************************************/ 00034 00035 /****************************************************************** 00036 * ICMPv6 message types (RFC 4443) 00037 ******************************************************************/ 00038 00039 /* ICMPv6 error messages:*/ 00040 #define FNET_ICMP6_TYPE_DEST_UNREACH (1u) /* Destination Unreachable. */ 00041 #define FNET_ICMP6_TYPE_PACKET_TOOBIG (2u) /* Packet Too Big. */ 00042 #define FNET_ICMP6_TYPE_TIME_EXCEED (3u) /* Time Exceeded. */ 00043 #define FNET_ICMP6_TYPE_PARAM_PROB (4u) /* Parameter Problem. */ 00044 00045 /* ICMPv6 informational messages:*/ 00046 #define FNET_ICMP6_TYPE_ECHO_REQ (128u) /* Echo Request. */ 00047 #define FNET_ICMP6_TYPE_ECHO_REPLY (129u) /* Echo Reply. */ 00048 00049 /* MLD messages (RFC2710):*/ 00050 #define FNET_ICMP6_TYPE_MULTICAST_LISTENER_QUERY (130u) /* Multicast Listener Query */ 00051 #define FNET_ICMP6_TYPE_MULTICAST_LISTENER_REPORT (131u) /* Multicast Listener Report */ 00052 #define FNET_ICMP6_TYPE_MULTICAST_LISTENER_DONE (132u) /* Multicast Listener Done */ 00053 00054 /* Neighbor Discovery defines five different ICMP packet types (RFC4861):*/ 00055 #define FNET_ICMP6_TYPE_ROUTER_SOLICITATION (133u) /* Router Solicitation. */ 00056 #define FNET_ICMP6_TYPE_ROUTER_ADVERTISEMENT (134u) /* Router Advertisement. */ 00057 #define FNET_ICMP6_TYPE_NEIGHBOR_SOLICITATION (135u) /* Neighbor Solicitation. */ 00058 #define FNET_ICMP6_TYPE_NEIGHBOR_ADVERTISEMENT (136u) /* Neighbor Advertisement. */ 00059 #define FNET_ICMP6_TYPE_REDIRECT (137u) /* Redirect.*/ 00060 00061 /* Destination Unreachable codes */ 00062 #define FNET_ICMP6_CODE_DU_NO_ROUTE (0u) /* No route to destination. */ 00063 #define FNET_ICMP6_CODE_DU_ADMIN_PROHIBITED (1u) /* Communication with destination administratively prohibited. */ 00064 #define FNET_ICMP6_CODE_DU_BEYOND_SCOPE (2u) /* Beyond scope of source address.*/ 00065 #define FNET_ICMP6_CODE_DU_ADDR_UNREACH (3u) /* Address unreachable.*/ 00066 #define FNET_ICMP6_CODE_DU_PORT_UNREACH (4u) /* Port unreachable.*/ 00067 #define FNET_ICMP6_CODE_DU_ADDR_FAILED (5u) /* Source address failed ingress/egress policy.*/ 00068 #define FNET_ICMP6_CODE_DU_REJECT_ROUTE (6u) /* Reject route to destination.*/ 00069 00070 /* Packet Too Big codes */ 00071 #define FNET_ICMP6_CODE_PTB (0u) 00072 00073 /* Time Exceeded codes */ 00074 #define FNET_ICMP6_CODE_TE_HOP_LIMIT (0u) /* Hop limit exceeded in transit.*/ 00075 #define FNET_ICMP6_CODE_TE_FRG_REASSEMBLY (1u) /* Fragment reassembly time exceeded.*/ 00076 00077 /* Parameter Problem codes */ 00078 #define FNET_ICMP6_CODE_PP_HEADER (0u) /* Erroneous header field encountered.*/ 00079 #define FNET_ICMP6_CODE_PP_NEXT_HEADER (1u) /* Unrecognized Next Header type encountered.*/ 00080 #define FNET_ICMP6_CODE_PP_OPTION (2u) /* Unrecognized IPv6 option encountered.*/ 00081 00082 /* The Hop Limit of ICMPv6 messages.*/ 00083 #define FNET_ICMP6_HOP_LIMIT (FNET_IP6_HOP_LIMIT_DEFAULT) 00084 00085 /* 00086 * Error messages are identified as such by a 00087 * zero in the high-order bit of their message Type field values. Thus, 00088 * error messages have message types from 0 to 127; informational 00089 * messages have message types from 128 to 255. 00090 */ 00091 #define FNET_ICMP6_TYPE_IS_ERROR(t) (((t) & 0x80u) == 0x00u) 00092 00093 /*********************************************************************** 00094 * Generic ICMP packet header 00095 *********************************************************************** 00096 * 00097 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 00098 * | Type | Code | Checksum | 00099 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 00100 * | | 00101 * + Message Body + 00102 * | | 00103 * 00104 ***********************************************************************/ 00105 FNET_COMP_PACKED_BEGIN 00106 typedef struct 00107 { 00108 fnet_uint8_t type FNET_COMP_PACKED; /* The type of the message.*/ 00109 fnet_uint8_t code FNET_COMP_PACKED; /* The code of the message.*/ 00110 fnet_uint16_t checksum FNET_COMP_PACKED; /* The checksum of the message.*/ 00111 } fnet_icmp6_header_t; 00112 FNET_COMP_PACKED_END 00113 00114 /*********************************************************************** 00115 * ICMPv6 Echo packet 00116 *********************************************************************** 00117 * RFC4443 4: 00118 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 00119 * | Type | Code | Checksum | 00120 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 00121 * | Identifier | Sequence Number | 00122 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 00123 * | Data ... 00124 * +-+-+-+-+- 00125 ***********************************************************************/ 00126 FNET_COMP_PACKED_BEGIN 00127 typedef struct fnet_icmp6_echo_header 00128 { 00129 fnet_icmp6_header_t icmp6_header FNET_COMP_PACKED; 00130 fnet_uint16_t id FNET_COMP_PACKED; 00131 fnet_uint16_t seq_number FNET_COMP_PACKED; 00132 } fnet_icmp6_echo_header_t; 00133 FNET_COMP_PACKED_END 00134 00135 /*********************************************************************** 00136 * ICMPv6 Error packet 00137 ***********************************************************************/ 00138 typedef struct fnet_icmp6_err_header 00139 { 00140 fnet_icmp6_header_t icmp6_header FNET_COMP_PACKED; 00141 fnet_uint32_t data FNET_COMP_PACKED; 00142 } fnet_icmp6_err_header_t; 00143 00144 extern struct fnet_prot_if fnet_icmp6_prot_if; 00145 00146 /************************************************************************ 00147 * Function Prototypes 00148 *************************************************************************/ 00149 #if defined(__cplusplus) 00150 extern "C" { 00151 #endif 00152 struct fnet_netif; /* Forward declaration.*/ 00153 void fnet_icmp6_error(struct fnet_netif *netif, fnet_uint8_t type, fnet_uint8_t code, fnet_uint32_t param, fnet_netbuf_t *origin_nb); 00154 void fnet_icmp6_output(struct fnet_netif *netif, const fnet_ip6_addr_t *src_ip, const fnet_ip6_addr_t *dest_ip, fnet_uint8_t hop_limit, fnet_netbuf_t *nb ); 00155 #if defined(__cplusplus) 00156 } 00157 #endif 00158 00159 #endif
Generated on Tue Jul 12 2022 12:21:52 by
