0.01.00
icmp6.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, The OpenThread Authors.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. Neither the name of the copyright holder nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
35 #ifndef OPENTHREAD_ICMP6_H_
36 #define OPENTHREAD_ICMP6_H_
37 
38 #include <openthread/message.h>
39 #include <openthread/types.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
59 typedef enum otIcmp6Type
60 {
64 } otIcmp6Type;
65 
70 typedef enum otIcmp6Code
71 {
73 } otIcmp6Code;
74 
75 #define OT_ICMP6_HEADER_DATA_SIZE 4
76 
77 
85 {
86  uint8_t mType;
87  uint8_t mCode;
88  uint16_t mChecksum;
90  {
91  uint8_t m8[OT_ICMP6_HEADER_DATA_SIZE / sizeof(uint8_t)];
92  uint16_t m16[OT_ICMP6_HEADER_DATA_SIZE / sizeof(uint16_t)];
93  uint32_t m32[OT_ICMP6_HEADER_DATA_SIZE / sizeof(uint32_t)];
94  } mData;
96 
102 
112 typedef void (*otIcmp6ReceiveCallback)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo,
113  const otIcmp6Header *aIcmpHeader);
114 
119 typedef struct otIcmp6Handler
120 {
122  void *mContext;
125 
135 bool otIcmp6IsEchoEnabled(otInstance *aInstance);
136 
144 void otIcmp6SetEchoEnabled(otInstance *aInstance, bool aEnabled);
145 
158 
169 otError otIcmp6SendEchoRequest(otInstance *aInstance, otMessage *aMessage,
170  const otMessageInfo *aMessageInfo, uint16_t aIdentifier);
171 
177 #ifdef __cplusplus
178 } // extern "C"
179 #endif
180 
181 #endif // OPENTHREAD_ICMP6_H_
Echo Request.
Definition: icmp6.h:62
This type represents all the static / global variables used by OpenThread allocated in one place...
Definition: openthread-instance.h:59
This file defines the types and structures used in the OpenThread library API.
otIcmp6ReceiveCallback mReceiveCallback
The ICMPv6 received callback.
Definition: icmp6.h:121
#define OT_ICMP6_HEADER_DATA_SIZE
Size of an message specific data of ICMPv6 Header.
Definition: icmp6.h:75
This file defines the top-level OpenThread APIs related to message buffer and queues.
This type points to an OpenThread message buffer.
Definition: types.h:479
#define OT_TOOL_PACKED_BEGIN
Compiler-specific indication that a class or struct must be byte packed.
Definition: toolchain.h:170
uint8_t mType
Type.
Definition: icmp6.h:86
otIcmp6Code
ICMPv6 Message Codes.
Definition: icmp6.h:70
otError otIcmp6RegisterHandler(otInstance *aInstance, otIcmp6Handler *aHandler)
This function registers a handler to provide received ICMPv6 messages.
Definition: icmp6_api.cpp:52
struct otIcmp6Handler otIcmp6Handler
This structure implements ICMPv6 message handler.
struct otIcmp6Handler * mNext
A pointer to the next handler in the list.
Definition: icmp6.h:123
otIcmp6Type
ICMPv6 Message Types.
Definition: icmp6.h:59
uint16_t mChecksum
Checksum.
Definition: icmp6.h:88
This structure implements ICMPv6 message handler.
Definition: icmp6.h:119
uint8_t mCode
Code.
Definition: icmp6.h:87
bool otIcmp6IsEchoEnabled(otInstance *aInstance)
This function indicates whether or not ICMPv6 Echo processing is enabled.
Definition: icmp6_api.cpp:42
#define OT_TOOL_PACKED_END
Compiler-specific indication at the end of a byte packed class or struct.
Definition: toolchain.h:172
Destination Unreachable No Route.
Definition: icmp6.h:72
This structure represents an ICMPv6 header.
Definition: icmp6.h:84
This structure represents the local and peer IPv6 socket addresses.
Definition: types.h:436
otError otIcmp6SendEchoRequest(otInstance *aInstance, otMessage *aMessage, const otMessageInfo *aMessageInfo, uint16_t aIdentifier)
This function sends an ICMPv6 Echo Request via the Thread interface.
Definition: icmp6_api.cpp:57
Destination Unreachable.
Definition: icmp6.h:61
Echo Reply.
Definition: icmp6.h:63
union otIcmp6Header::OT_TOOL_PACKED_FIELD mData
Message-specific data.
void * mContext
A pointer to arbitrary context information.
Definition: icmp6.h:122
otError
This enumeration represents error codes used throughout OpenThread.
Definition: types.h:107
void otIcmp6SetEchoEnabled(otInstance *aInstance, bool aEnabled)
This function sets whether or not ICMPv6 Echo processing is enabled.
Definition: icmp6_api.cpp:47
void(* otIcmp6ReceiveCallback)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo, const otIcmp6Header *aIcmpHeader)
This callback allows OpenThread to inform the application of a received ICMPv6 message.
Definition: icmp6.h:112