Contiki 2.5
uip-icmp6.h
Go to the documentation of this file.
1 /**
2  * \addtogroup uip6
3  * @{
4  */
5 
6 /**
7  * \file
8  * ICMPv6 echo request and error messages (RFC 4443)
9  * \author Julien Abeille <jabeille@cisco.com>
10  * \author Mathilde Durvy <mdurvy@cisco.com>
11  */
12 
13 /*
14  * Copyright (c) 2006, Swedish Institute of Computer Science.
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  * 1. Redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer.
22  * 2. Redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution.
25  * 3. Neither the name of the Institute nor the names of its contributors
26  * may be used to endorse or promote products derived from this software
27  * without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
30  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
33  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39  * SUCH DAMAGE.
40  *
41  * This file is part of the Contiki operating system.
42  *
43  */
44 
45 
46 #ifndef __ICMP6_H__
47 #define __ICMP6_H__
48 
49 #include "net/uip.h"
50 
51 
52 /** \name ICMPv6 message types */
53 /** @{ */
54 #define ICMP6_DST_UNREACH 1 /**< dest unreachable */
55 #define ICMP6_PACKET_TOO_BIG 2 /**< packet too big */
56 #define ICMP6_TIME_EXCEEDED 3 /**< time exceeded */
57 #define ICMP6_PARAM_PROB 4 /**< ip6 header bad */
58 #define ICMP6_ECHO_REQUEST 128 /**< Echo request */
59 #define ICMP6_ECHO_REPLY 129 /**< Echo reply */
60 
61 #define ICMP6_RS 133 /**< Router Solicitation */
62 #define ICMP6_RA 134 /**< Router Advertisement */
63 #define ICMP6_NS 135 /**< Neighbor Solicitation */
64 #define ICMP6_NA 136 /**< Neighbor advertisement */
65 #define ICMP6_REDIRECT 137 /**< Redirect */
66 
67 #define ICMP6_RPL 155 /**< RPL */
68 /** @} */
69 
70 
71 /** \name ICMPv6 Destination Unreachable message codes*/
72 /** @{ */
73 #define ICMP6_DST_UNREACH_NOROUTE 0 /**< no route to destination */
74 #define ICMP6_DST_UNREACH_ADMIN 1 /**< administratively prohibited */
75 #define ICMP6_DST_UNREACH_NOTNEIGHBOR 2 /**< not a neighbor(obsolete) */
76 #define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /**< beyond scope of source address */
77 #define ICMP6_DST_UNREACH_ADDR 3 /**< address unreachable */
78 #define ICMP6_DST_UNREACH_NOPORT 4 /**< port unreachable */
79 /** @} */
80 
81 /** \name ICMPv6 Time Exceeded message codes*/
82 /** @{ */
83 #define ICMP6_TIME_EXCEED_TRANSIT 0 /**< ttl==0 in transit */
84 #define ICMP6_TIME_EXCEED_REASSEMBLY 1 /**< ttl==0 in reass */
85 /** @} */
86 
87 /** \name ICMPv6 Parameter Problem message codes*/
88 /** @{ */
89 #define ICMP6_PARAMPROB_HEADER 0 /**< erroneous header field */
90 #define ICMP6_PARAMPROB_NEXTHEADER 1 /**< unrecognized next header */
91 #define ICMP6_PARAMPROB_OPTION 2 /**< unrecognized option */
92 /** @} */
93 
94 /** \brief Echo Request constant part length */
95 #define UIP_ICMP6_ECHO_REQUEST_LEN 4
96 
97 /** \brief ICMPv6 Error message constant part length */
98 #define UIP_ICMP6_ERROR_LEN 4
99 
100 /** \brief ICMPv6 Error message constant part */
101 typedef struct uip_icmp6_error{
102  u32_t param;
104 
105 /** \name ICMPv6 RFC4443 Message processing and sending */
106 /** @{ */
107 /** \
108  * brief Process an echo request
109  *
110  * Perform a few checks, then send an Echo reply. The reply is
111  * built here.
112  */
113 void
115 
116 /**
117  * \brief Send an icmpv6 error message
118  * \param type type of the error message
119  * \param code of the error message
120  * \param type 32 bit parameter of the error message, semantic depends on error
121  */
122 void
123 uip_icmp6_error_output(u8_t type, u8_t code, u32_t param);
124 
125 /**
126  * \brief Send an icmpv6 message
127  * \param dest destination address of the message
128  * \param type type of the message
129  * \param code of the message
130  * \param payload_len length of the payload
131  */
132 void
133 uip_icmp6_send(uip_ipaddr_t *dest, int type, int code, int payload_len);
134 
135 
136 /** @} */
137 
138 #endif /*__ICMP6_H__*/
139 /** @} */
140