Contiki 2.6
|
00001 /** 00002 * \addtogroup uip6 00003 * @{ 00004 */ 00005 00006 /** 00007 * \file 00008 * ICMPv6 echo request and error messages (RFC 4443) 00009 * \author Julien Abeille <jabeille@cisco.com> 00010 * \author Mathilde Durvy <mdurvy@cisco.com> 00011 */ 00012 00013 /* 00014 * Copyright (c) 2006, Swedish Institute of Computer Science. 00015 * All rights reserved. 00016 * 00017 * Redistribution and use in source and binary forms, with or without 00018 * modification, are permitted provided that the following conditions 00019 * are met: 00020 * 1. Redistributions of source code must retain the above copyright 00021 * notice, this list of conditions and the following disclaimer. 00022 * 2. Redistributions in binary form must reproduce the above copyright 00023 * notice, this list of conditions and the following disclaimer in the 00024 * documentation and/or other materials provided with the distribution. 00025 * 3. Neither the name of the Institute nor the names of its contributors 00026 * may be used to endorse or promote products derived from this software 00027 * without specific prior written permission. 00028 * 00029 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 00030 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00031 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00032 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 00033 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00034 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00035 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00036 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00037 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00038 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00039 * SUCH DAMAGE. 00040 * 00041 * This file is part of the Contiki operating system. 00042 * 00043 */ 00044 00045 00046 #ifndef __ICMP6_H__ 00047 #define __ICMP6_H__ 00048 00049 #include "net/uip.h" 00050 00051 00052 /** \name ICMPv6 message types */ 00053 /** @{ */ 00054 #define ICMP6_DST_UNREACH 1 /**< dest unreachable */ 00055 #define ICMP6_PACKET_TOO_BIG 2 /**< packet too big */ 00056 #define ICMP6_TIME_EXCEEDED 3 /**< time exceeded */ 00057 #define ICMP6_PARAM_PROB 4 /**< ip6 header bad */ 00058 #define ICMP6_ECHO_REQUEST 128 /**< Echo request */ 00059 #define ICMP6_ECHO_REPLY 129 /**< Echo reply */ 00060 00061 #define ICMP6_RS 133 /**< Router Solicitation */ 00062 #define ICMP6_RA 134 /**< Router Advertisement */ 00063 #define ICMP6_NS 135 /**< Neighbor Solicitation */ 00064 #define ICMP6_NA 136 /**< Neighbor advertisement */ 00065 #define ICMP6_REDIRECT 137 /**< Redirect */ 00066 00067 #define ICMP6_RPL 155 /**< RPL */ 00068 /** @} */ 00069 00070 00071 /** \name ICMPv6 Destination Unreachable message codes*/ 00072 /** @{ */ 00073 #define ICMP6_DST_UNREACH_NOROUTE 0 /**< no route to destination */ 00074 #define ICMP6_DST_UNREACH_ADMIN 1 /**< administratively prohibited */ 00075 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /**< not a neighbor(obsolete) */ 00076 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /**< beyond scope of source address */ 00077 #define ICMP6_DST_UNREACH_ADDR 3 /**< address unreachable */ 00078 #define ICMP6_DST_UNREACH_NOPORT 4 /**< port unreachable */ 00079 /** @} */ 00080 00081 /** \name ICMPv6 Time Exceeded message codes*/ 00082 /** @{ */ 00083 #define ICMP6_TIME_EXCEED_TRANSIT 0 /**< ttl==0 in transit */ 00084 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /**< ttl==0 in reass */ 00085 /** @} */ 00086 00087 /** \name ICMPv6 Parameter Problem message codes*/ 00088 /** @{ */ 00089 #define ICMP6_PARAMPROB_HEADER 0 /**< erroneous header field */ 00090 #define ICMP6_PARAMPROB_NEXTHEADER 1 /**< unrecognized next header */ 00091 #define ICMP6_PARAMPROB_OPTION 2 /**< unrecognized option */ 00092 /** @} */ 00093 00094 /** \brief Echo Request constant part length */ 00095 #define UIP_ICMP6_ECHO_REQUEST_LEN 4 00096 00097 /** \brief ICMPv6 Error message constant part length */ 00098 #define UIP_ICMP6_ERROR_LEN 4 00099 00100 /** \brief ICMPv6 Error message constant part */ 00101 typedef struct uip_icmp6_error{ 00102 uint32_t param; 00103 } uip_icmp6_error; 00104 00105 /** \name ICMPv6 RFC4443 Message processing and sending */ 00106 /** @{ */ 00107 /** \ 00108 * brief Process an echo request 00109 * 00110 * Perform a few checks, then send an Echo reply. The reply is 00111 * built here. 00112 */ 00113 void 00114 uip_icmp6_echo_request_input(void); 00115 00116 /** 00117 * \brief Send an icmpv6 error message 00118 * \param type type of the error message 00119 * \param code of the error message 00120 * \param type 32 bit parameter of the error message, semantic depends on error 00121 */ 00122 void 00123 uip_icmp6_error_output(uint8_t type, uint8_t code, uint32_t param); 00124 00125 /** 00126 * \brief Send an icmpv6 message 00127 * \param dest destination address of the message 00128 * \param type type of the message 00129 * \param code of the message 00130 * \param payload_len length of the payload 00131 */ 00132 void 00133 uip_icmp6_send(uip_ipaddr_t *dest, int type, int code, int payload_len); 00134 00135 00136 /** @} */ 00137 00138 #endif /*__ICMP6_H__*/ 00139 /** @} */ 00140