0.01.00
udp.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_UDP_H_
36 #define OPENTHREAD_UDP_H_
37 
38 #include <openthread/message.h>
39 #include <openthread/types.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
59 typedef void (*otUdpReceive)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo);
60 
65 typedef struct otUdpSocket
66 {
70  void *mContext;
71  void *mTransport;
72  struct otUdpSocket *mNext;
73 } otUdpSocket;
74 
86 otMessage *otUdpNewMessage(otInstance *aInstance, bool aLinkSecurityEnabled);
87 
106 otError otUdpOpen(otInstance *aInstance, otUdpSocket *aSocket, otUdpReceive aCallback, void *aContext);
107 
122 otError otUdpClose(otUdpSocket *aSocket);
123 
139 otError otUdpBind(otUdpSocket *aSocket, otSockAddr *aSockName);
140 
156 otError otUdpConnect(otUdpSocket *aSocket, otSockAddr *aSockName);
157 
173 otError otUdpSend(otUdpSocket *aSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo);
174 
180 #ifdef __cplusplus
181 } // extern "C"
182 #endif
183 
184 #endif // OPENTHREAD_UDP_H_
This type represents all the static / global variables used by OpenThread allocated in one place...
Definition: openthread-instance.h:59
struct otUdpSocket * mNext
A pointer to the next UDP socket (internal use only).
Definition: udp.h:72
This file defines the types and structures used in the OpenThread library API.
otError otUdpOpen(otInstance *aInstance, otUdpSocket *aSocket, otUdpReceive aCallback, void *aContext)
Open a UDP/IPv6 socket.
Definition: udp_api.cpp:54
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
This structure represents an IPv6 socket address.
Definition: types.h:1140
otSockAddr mSockName
The local IPv6 socket address.
Definition: udp.h:67
otError otUdpSend(otUdpSocket *aSocket, otMessage *aMessage, const otMessageInfo *aMessageInfo)
Send a UDP/IPv6 message.
Definition: udp_api.cpp:98
struct otUdpSocket otUdpSocket
This structure represents a UDP socket.
otUdpReceive mHandler
A function pointer to the application callback.
Definition: udp.h:69
otMessage * otUdpNewMessage(otInstance *aInstance, bool aLinkSecurityEnabled)
Allocate a new message buffer for sending a UDP message.
Definition: udp_api.cpp:42
void(* otUdpReceive)(void *aContext, otMessage *aMessage, const otMessageInfo *aMessageInfo)
This callback allows OpenThread to inform the application of a received UDP message.
Definition: udp.h:59
otError otUdpBind(otUdpSocket *aSocket, otSockAddr *aSockName)
Bind a UDP/IPv6 socket.
Definition: udp_api.cpp:86
This structure represents the local and peer IPv6 socket addresses.
Definition: types.h:436
otError otUdpConnect(otUdpSocket *aSocket, otSockAddr *aSockName)
Connect a UDP/IPv6 socket.
Definition: udp_api.cpp:92
otSockAddr mPeerName
The peer IPv6 socket address.
Definition: udp.h:68
This structure represents a UDP socket.
Definition: udp.h:65
otError otUdpClose(otUdpSocket *aSocket)
Close a UDP/IPv6 socket.
Definition: udp_api.cpp:68
void * mContext
A pointer to application-specific context.
Definition: udp.h:70
otError
This enumeration represents error codes used throughout OpenThread.
Definition: types.h:107
void * mTransport
A pointer to the transport object (internal use only).
Definition: udp.h:71