Windows API DLL (#882)

* VS Solution files and minor fixes.

* Move Tasklet into platform include file

* Refactor data path APIs into openthread-ip6.h
This commit is contained in:
Nick Banks
2016-11-04 09:28:17 -07:00
committed by Jonathan Hui
parent 0509a139e2
commit 74a95f042d
28 changed files with 5127 additions and 650 deletions
+7 -3
View File
@@ -60,10 +60,14 @@ PRETTY_SUBDIRS = \
include_HEADERS = \
openthread.h \
openthread-diag.h \
openthread-crypto.h \
openthread-types.h \
openthread-coap.h \
openthread-crypto.h \
openthread-diag.h \
openthread-ip6.h \
openthread-message.h \
openthread-tasklet.h \
openthread-types.h \
openthread-udp.h \
$(NULL)
install-headers: install-includeHEADERS
+23 -19
View File
@@ -35,6 +35,8 @@
#ifndef OPENTHREAD_COMMISSIONER_H_
#define OPENTHREAD_COMMISSIONER_H_
#include <platform/toolchain.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -54,7 +56,7 @@ extern "C" {
* @retval kThreadError_None Successfully started the Commissioner role.
*
*/
ThreadError otCommissionerStart(otInstance *aInstance);
OTAPI ThreadError OTCALL otCommissionerStart(otInstance *aInstance);
/**
* This function disables the Thread Commissioner role.
@@ -64,7 +66,7 @@ ThreadError otCommissionerStart(otInstance *aInstance);
* @retval kThreadError_None Successfully started the Commissioner role.
*
*/
ThreadError otCommissionerStop(otInstance *aInstance);
OTAPI ThreadError OTCALL otCommissionerStop(otInstance *aInstance);
/**
* This function adds a Joiner entry.
@@ -78,7 +80,8 @@ ThreadError otCommissionerStop(otInstance *aInstance);
* @retval kThreadError_InvalidArgs @p aExtAddress or @p aPSKd is invalid.
*
*/
ThreadError otCommissionerAddJoiner(otInstance *aInstance, const otExtAddress *aExtAddress, const char *aPSKd);
OTAPI ThreadError OTCALL otCommissionerAddJoiner(otInstance *aInstance, const otExtAddress *aExtAddress,
const char *aPSKd);
/**
* This function removes a Joiner entry.
@@ -91,7 +94,7 @@ ThreadError otCommissionerAddJoiner(otInstance *aInstance, const otExtAddress *a
* @retval kThreadError_InvalidArgs @p aExtAddress is invalid.
*
*/
ThreadError otCommissionerRemoveJoiner(otInstance *aIntsance, const otExtAddress *aExtAddress);
OTAPI ThreadError OTCALL otCommissionerRemoveJoiner(otInstance *aIntsance, const otExtAddress *aExtAddress);
/**
* This function sets the Provisioning URL.
@@ -102,7 +105,7 @@ ThreadError otCommissionerRemoveJoiner(otInstance *aIntsance, const otExtAddress
* @retval kThreadError_InvalidArgs @p aProvisioningUrl is invalid.
*
*/
ThreadError otCommissionerSetProvisioningUrl(otInstance *aInstance, const char *aProvisioningUrl);
OTAPI ThreadError OTCALL otCommissionerSetProvisioningUrl(otInstance *aInstance, const char *aProvisioningUrl);
/**
* This function sends an Announce Begin message.
@@ -117,8 +120,9 @@ ThreadError otCommissionerSetProvisioningUrl(otInstance *aInstance, const char *
* @retval kThreadError_NoBufs Insufficient buffers to generate an Announce Begin message.
*
*/
ThreadError otCommissionerAnnounceBegin(otInstance *aInstance, uint32_t aChannelMask, uint8_t aCount, uint16_t aPeriod,
const otIp6Address *aAddress);
OTAPI ThreadError OTCALL otCommissionerAnnounceBegin(otInstance *aInstance, uint32_t aChannelMask, uint8_t aCount,
uint16_t aPeriod,
const otIp6Address *aAddress);
/**
* This function pointer is called when the Commissioner receives an Energy Report.
@@ -129,8 +133,8 @@ ThreadError otCommissionerAnnounceBegin(otInstance *aInstance, uint32_t aChannel
* @param[in] aContext A pointer to application-specific context.
*
*/
typedef void (*otCommissionerEnergyReportCallback)(uint32_t aChannelMask, const uint8_t *aEnergyList,
uint8_t aEnergyListLength, void *aContext);
typedef void (OTCALL *otCommissionerEnergyReportCallback)(uint32_t aChannelMask, const uint8_t *aEnergyList,
uint8_t aEnergyListLength, void *aContext);
/**
* This function sends an Energy Scan Query message.
@@ -148,9 +152,9 @@ typedef void (*otCommissionerEnergyReportCallback)(uint32_t aChannelMask, const
* @retval kThreadError_NoBufs Insufficient buffers to generate an Energy Scan Query message.
*
*/
ThreadError otCommissionerEnergyScan(otInstance *aInstance, uint32_t aChannelMask, uint8_t aCount, uint16_t aPeriod,
uint16_t aScanDuration, const otIp6Address *aAddress,
otCommissionerEnergyReportCallback aCallback, void *aContext);
OTAPI ThreadError OTCALL otCommissionerEnergyScan(otInstance *aInstance, uint32_t aChannelMask, uint8_t aCount,
uint16_t aPeriod, uint16_t aScanDuration, const otIp6Address *aAddress,
otCommissionerEnergyReportCallback aCallback, void *aContext);
/**
* This function pointer is called when the Commissioner receives a PAN ID Conflict message.
@@ -160,7 +164,7 @@ ThreadError otCommissionerEnergyScan(otInstance *aInstance, uint32_t aChannelMas
* @param[in] aContext A pointer to application-specific context.
*
*/
typedef void (*otCommissionerPanIdConflictCallback)(uint16_t aPanId, uint32_t aChannelMask, void *aContext);
typedef void (OTCALL *otCommissionerPanIdConflictCallback)(uint16_t aPanId, uint32_t aChannelMask, void *aContext);
/**
* This function sends a PAN ID Query message.
@@ -176,9 +180,9 @@ typedef void (*otCommissionerPanIdConflictCallback)(uint16_t aPanId, uint32_t aC
* @retval kThreadError_NoBufs Insufficient buffers to generate a PAN ID Query message.
*
*/
ThreadError otCommissionerPanIdQuery(otInstance *aInstance, uint16_t aPanId, uint32_t aChannelMask,
const otIp6Address *aAddress,
otCommissionerPanIdConflictCallback aCallback, void *aContext);
OTAPI ThreadError OTCALL otCommissionerPanIdQuery(otInstance *aInstance, uint16_t aPanId, uint32_t aChannelMask,
const otIp6Address *aAddress,
otCommissionerPanIdConflictCallback aCallback, void *aContext);
/**
* This function sends MGMT_COMMISSIONER_GET.
@@ -191,7 +195,7 @@ ThreadError otCommissionerPanIdQuery(otInstance *aInstance, uint16_t aPanId, uin
* @retval kThreadError_NoBufs Insufficient buffer space to send.
*
*/
ThreadError otSendMgmtCommissionerGet(otInstance *, const uint8_t *aTlvs, uint8_t aLength);
OTAPI ThreadError OTCALL otSendMgmtCommissionerGet(otInstance *, const uint8_t *aTlvs, uint8_t aLength);
/**
* This function sends MGMT_COMMISSIONER_SET.
@@ -205,8 +209,8 @@ ThreadError otSendMgmtCommissionerGet(otInstance *, const uint8_t *aTlvs, uint8_
* @retval kThreadError_NoBufs Insufficient buffer space to send.
*
*/
ThreadError otSendMgmtCommissionerSet(otInstance *, const otCommissioningDataset *aDataset,
const uint8_t *aTlvs, uint8_t aLength);
OTAPI ThreadError OTCALL otSendMgmtCommissionerSet(otInstance *, const otCommissioningDataset *aDataset,
const uint8_t *aTlvs, uint8_t aLength);
/**
* @}
+4 -2
View File
@@ -35,6 +35,8 @@
#ifndef OPENTHREAD_JOINER_H_
#define OPENTHREAD_JOINER_H_
#include <platform/toolchain.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -57,7 +59,7 @@ extern "C" {
* @retval kThreadError_InvalidArgs @p aPSKd or @p aProvisioningUrl is invalid.
*
*/
ThreadError otJoinerStart(otInstance *aInstance, const char *aPSKd, const char *aProvisioningUrl);
OTAPI ThreadError OTCALL otJoinerStart(otInstance *aInstance, const char *aPSKd, const char *aProvisioningUrl);
/**
* This function disables the Thread Joiner role.
@@ -65,7 +67,7 @@ ThreadError otJoinerStart(otInstance *aInstance, const char *aPSKd, const char *
* @param[in] aInstance A pointer to an OpenThread instance.
*
*/
ThreadError otJoinerStop(otInstance *aInstance);
OTAPI ThreadError OTCALL otJoinerStop(otInstance *aInstance);
/**
* @}
+245
View File
@@ -0,0 +1,245 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* @brief
* This file defines the top-level ip6 functions for the OpenThread library.
*/
#ifndef OPENTHREAD_IP6_H_
#define OPENTHREAD_IP6_H_
#include <openthread-message.h>
#include <platform/radio.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup api API
* @brief
* This module includes the application programming interface to the OpenThread stack.
*
* @{
*
* @defgroup execution Execution
* @defgroup commands Commands
* @defgroup config Configuration
* @defgroup diags Diagnostics
* @defgroup messages Message Buffers
* @defgroup ip6 IPv6
* @defgroup udp UDP
* @defgroup coap CoAP
*
* @}
*
*/
/**
* @addtogroup diags Diagnostics
*
* @brief
* This module includes functions that expose internal state.
*
* @{
*
*/
/**
* This function pointer is called when an IEEE 802.15.4 frame is received.
*
* @note This callback is called after FCS processing and @p aFrame may not contain the actual FCS that was received.
*
* @note This callback is called before IEEE 802.15.4 security processing and mSecurityValid in @p aFrame will
* always be false.
*
* @param[in] aFrame A pointer to the received IEEE 802.15.4 frame.
* @param[in] aContext A pointer to application-specific context.
*
*/
typedef void (*otLinkPcapCallback)(const RadioPacket *aFrame, void *aContext);
/**
* This function registers a callback to provide received raw IEEE 802.15.4 frames.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPcapCallback A pointer to a function that is called when receiving an IEEE 802.15.4 link frame or
* NULL to disable the callback.
* @param[in] aCallbackContext A pointer to application-specific context.
*
*/
void otSetLinkPcapCallback(otInstance *aInstance, otLinkPcapCallback aPcapCallback, void *aCallbackContext);
/**
* This function indicates whether or not promiscuous mode is enabled at the link layer.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @retval true Promiscuous mode is enabled.
* @retval false Promiscuous mode is not enabled.
*
*/
bool otIsLinkPromiscuous(otInstance *aInstance);
/**
* This function enables or disables the link layer promiscuous mode.
*
* @note Promiscuous mode may only be enabled when the Thread interface is disabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aPromiscuous true to enable promiscuous mode, or false otherwise.
*
* @retval kThreadError_None Successfully enabled promiscuous mode.
* @retval kThreadError_InvalidState Could not enable promiscuous mode because
* the Thread interface is enabled.
*
*/
ThreadError otSetLinkPromiscuous(otInstance *aInstance, bool aPromiscuous);
/**
* @}
*
*/
/**
* @addtogroup ip6 IPv6
*
* @brief
* This module includes functions that control IPv6 communication.
*
* @{
*
*/
/**
* Allocate a new message buffer for sending an IPv6 message.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aLinkSecurityEnabled TRUE if the message should be secured at Layer 2
*
* @returns A pointer to the message buffer or NULL if no message buffers are available.
*
* @sa otFreeMessage
*/
otMessage otNewIp6Message(otInstance *aInstance, bool aLinkSecurityEnabled);
/**
* This function pointer is called when an IPv6 datagram is received.
*
* @param[in] aMessage A pointer to the message buffer containing the received IPv6 datagram.
* @param[in] aContext A pointer to application-specific context.
*
*/
typedef void (*otReceiveIp6DatagramCallback)(otMessage aMessage, void *aContext);
/**
* This function registers a callback to provide received IPv6 datagrams.
*
* By default, this callback does not pass Thread control traffic. See otSetReceiveIp6DatagramFilterEnabled() to
* change the Thread control traffic filter setting.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aCallback A pointer to a function that is called when an IPv6 datagram is received or
* NULL to disable the callback.
* @param[in] aCallbackContext A pointer to application-specific context.
*
* @sa otIsReceiveIp6DatagramFilterEnabled
* @sa otSetReceiveIp6DatagramFilterEnabled
*
*/
void otSetReceiveIp6DatagramCallback(otInstance *aInstance, otReceiveIp6DatagramCallback aCallback,
void *aCallbackContext);
/**
* This function indicates whether or not Thread control traffic is filtered out when delivering IPv6 datagrams
* via the callback specified in otSetReceiveIp6DatagramCallback().
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns TRUE if Thread control traffic is filtered out, FALSE otherwise.
*
* @sa otSetReceiveIp6DatagramCallback
* @sa otSetReceiveIp6DatagramFilterEnabled
*
*/
bool otIsReceiveIp6DatagramFilterEnabled(otInstance *aInstance);
/**
* This function sets whether or not Thread control traffic is filtered out when delivering IPv6 datagrams
* via the callback specified in otSetReceiveIp6DatagramCallback().
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aEnabled TRUE if Thread control traffic is filtered out, FALSE otherwise.
*
* @sa otSetReceiveIp6DatagramCallback
* @sa otIsReceiveIp6DatagramFilterEnabled
*
*/
void otSetReceiveIp6DatagramFilterEnabled(otInstance *aInstance, bool aEnabled);
/**
* This function sends an IPv6 datagram via the Thread interface.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aMessage A pointer to the message buffer containing the IPv6 datagram.
*
*/
ThreadError otSendIp6Datagram(otInstance *aInstance, otMessage aMessage);
/**
* This function indicates whether or not ICMPv6 Echo processing is enabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @retval TRUE ICMPv6 Echo processing is enabled.
* @retval FALSE ICMPv6 Echo processing is disabled.
*
*/
bool otIsIcmpEchoEnabled(otInstance *aInstance);
/**
* This function sets whether or not ICMPv6 Echo processing is enabled.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aEnabled TRUE to enable ICMPv6 Echo processing, FALSE otherwise.
*
*/
void otSetIcmpEchoEnabled(otInstance *aInstance, bool aEnabled);
/**
* @}
*
*/
#ifdef __cplusplus
} // extern "C"
#endif
#endif // OPENTHREAD_IP6_H_
+241
View File
@@ -0,0 +1,241 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* @brief
* This file defines the top-level ip6 functions for the OpenThread library.
*/
#ifndef OPENTHREAD_MESSAGE_H_
#define OPENTHREAD_MESSAGE_H_
#include <openthread-types.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup api API
* @brief
* This module includes the application programming interface to the OpenThread stack.
*
* @{
*
* @defgroup execution Execution
* @defgroup commands Commands
* @defgroup config Configuration
* @defgroup diags Diagnostics
* @defgroup messages Message Buffers
* @defgroup ip6 IPv6
* @defgroup udp UDP
* @defgroup coap CoAP
*
* @}
*
*/
/**
* @addtogroup messages Message Buffers
*
* @brief
* This module includes functions that manipulate OpenThread message buffers
*
* @{
*
*/
/**
* Free an allocated message buffer.
*
* @param[in] aMessage A pointer to a message buffer.
*
* @retval kThreadErrorNone Successfully freed the message buffer.
*
* @sa otNewUdpMessage
* @sa otAppendMessage
* @sa otGetMessageLength
* @sa otSetMessageLength
* @sa otGetMessageOffset
* @sa otSetMessageOffset
* @sa otReadMessage
* @sa otWriteMessage
*/
ThreadError otFreeMessage(otMessage aMessage);
/**
* Get the message length in bytes.
*
* @param[in] aMessage A pointer to a message buffer.
*
* @returns The message length in bytes.
*
* @sa otNewUdpMessage
* @sa otFreeMessage
* @sa otAppendMessage
* @sa otSetMessageLength
* @sa otGetMessageOffset
* @sa otSetMessageOffset
* @sa otReadMessage
* @sa otWriteMessage
* @sa otSetMessageLength
*/
uint16_t otGetMessageLength(otMessage aMessage);
/**
* Set the message length in bytes.
*
* @param[in] aMessage A pointer to a message buffer.
* @param[in] aLength A length in bytes.
*
* @retval kThreadErrorNone Successfully set the message length.
* @retval kThreadErrorNoBufs No available buffers to grow the message.
*
* @sa otNewUdpMessage
* @sa otFreeMessage
* @sa otAppendMessage
* @sa otGetMessageLength
* @sa otGetMessageOffset
* @sa otSetMessageOffset
* @sa otReadMessage
* @sa otWriteMessage
*/
ThreadError otSetMessageLength(otMessage aMessage, uint16_t aLength);
/**
* Get the message offset in bytes.
*
* @param[in] aMessage A pointer to a message buffer.
*
* @returns The message offset value.
*
* @sa otNewUdpMessage
* @sa otFreeMessage
* @sa otAppendMessage
* @sa otGetMessageLength
* @sa otSetMessageLength
* @sa otSetMessageOffset
* @sa otReadMessage
* @sa otWriteMessage
*/
uint16_t otGetMessageOffset(otMessage aMessage);
/**
* Set the message offset in bytes.
*
* @param[in] aMessage A pointer to a message buffer.
* @param[in] aOffset An offset in bytes.
*
* @retval kThreadErrorNone Successfully set the message offset.
* @retval kThreadErrorInvalidArg The offset is beyond the message length.
*
* @sa otNewUdpMessage
* @sa otFreeMessage
* @sa otAppendMessage
* @sa otGetMessageLength
* @sa otSetMessageLength
* @sa otGetMessageOffset
* @sa otReadMessage
* @sa otWriteMessage
*/
ThreadError otSetMessageOffset(otMessage aMessage, uint16_t aOffset);
/**
* Append bytes to a message.
*
* @param[in] aMessage A pointer to a message buffer.
* @param[in] aBuf A pointer to the data to append.
* @param[in] aLength Number of bytes to append.
*
* @retval kThreadErrorNone Successfully appended to the message
* @retval kThreadErrorNoBufs No available buffers to grow the message.
*
* @sa otNewUdpMessage
* @sa otFreeMessage
* @sa otGetMessageLength
* @sa otSetMessageLength
* @sa otGetMessageOffset
* @sa otSetMessageOffset
* @sa otReadMessage
* @sa otWriteMessage
*/
ThreadError otAppendMessage(otMessage aMessage, const void *aBuf, uint16_t aLength);
/**
* Read bytes from a message.
*
* @param[in] aMessage A pointer to a message buffer.
* @param[in] aOffset An offset in bytes.
* @param[in] aBuf A pointer to a buffer that message bytes are read to.
* @param[in] aLength Number of bytes to read.
*
* @returns The number of bytes read.
*
* @sa otNewUdpMessage
* @sa otFreeMessage
* @sa otAppendMessage
* @sa otGetMessageLength
* @sa otSetMessageLength
* @sa otGetMessageOffset
* @sa otSetMessageOffset
* @sa otWriteMessage
*/
int otReadMessage(otMessage aMessage, uint16_t aOffset, void *aBuf, uint16_t aLength);
/**
* Write bytes to a message.
*
* @param[in] aMessage A pointer to a message buffer.
* @param[in] aOffset An offset in bytes.
* @param[in] aBuf A pointer to a buffer that message bytes are written from.
* @param[in] aLength Number of bytes to write.
*
* @returns The number of bytes written.
*
* @sa otNewUdpMessage
* @sa otFreeMessage
* @sa otAppendMessage
* @sa otGetMessageLength
* @sa otSetMessageLength
* @sa otGetMessageOffset
* @sa otSetMessageOffset
* @sa otReadMessage
*/
int otWriteMessage(otMessage aMessage, uint16_t aOffset, const void *aBuf, uint16_t aLength);
/**
* @}
*
*/
#ifdef __cplusplus
} // extern "C"
#endif
#endif // OPENTHREAD_MESSAGE_H_
+88
View File
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* @brief
* This file includes the platform abstraction for the tasklet service.
*/
#ifndef OPENTHREAD_TASKLET_H_
#define OPENTHREAD_TASKLET_H_
#include <openthread-types.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @addtogroup execution Execution
*
* @brief
* This module includes functions that control the Thread stack's execution.
*
* @{
*
*/
/**
* Run all queued OpenThread tasklets at the time this is called.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*/
void otProcessQueuedTasklets(otInstance *aInstance);
/**
* Indicates whether or not OpenThread has tasklets pending.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @retval TRUE If there are tasklets pending.
* @retval FALSE If there are no tasklets pending.
*/
bool otAreTaskletsPending(otInstance *aInstance);
/**
* OpenThread calls this function when the tasklet queue transitions from empty to non-empty.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
*/
extern void otSignalTaskletPending(otInstance *aInstance);
/**
* @}
*
*/
#ifdef __cplusplus
} // extern "C"
#endif
#endif // OPENTHREAD_TASKLET_H_
+26 -2
View File
@@ -37,6 +37,9 @@
#include <stdint.h>
#include <stdbool.h>
#ifdef OTDLL
#include <guiddef.h>
#endif
#include <platform/toolchain.h>
@@ -61,14 +64,32 @@ extern "C" {
#define myoffsetof(s,m) (((size_t)&(((s*)BASE)->m))-BASE)
#define CONTAINING_RECORD(address, type, field) \
((type *)((uint8_t*)(address) - myoffsetof(type, field)))
#endif
#endif
#endif /* CONTAINING_RECORD */
#endif /* _WIN32 */
/**
* This type represents the OpenThread instance structure.
*/
typedef struct otInstance otInstance;
#ifdef OTDLL
/**
* This type represents the handle to the OpenThread API.
*/
typedef struct otApiInstance otApiInstance;
/**
* This type represents a list of device GUIDs.
*/
typedef struct otDeviceList
{
uint16_t aDevicesLength;
GUID aDevices[1];
} otDeviceList;
#endif
/**
* This enumeration represents error codes used throughout OpenThread.
*/
@@ -489,6 +510,7 @@ typedef enum otMeshcopTlvType
/**
* This structure represents an MLE Link Mode configuration.
*/
OT_TOOL_ALIGN(4)
typedef struct otLinkModeConfig
{
/**
@@ -709,6 +731,7 @@ typedef struct otMacBlacklistEntry
*/
typedef enum
{
kDeviceRoleOffline, ///< The Thread device is offline and unavailable.
kDeviceRoleDisabled, ///< The Thread stack is disabled.
kDeviceRoleDetached, ///< Not currently participating in a Thread network/partition.
kDeviceRoleChild, ///< The Thread Child role.
@@ -764,6 +787,7 @@ typedef struct
* This structure holds diagnostic information for a Thread Router
*
*/
OT_TOOL_ALIGN(4)
typedef struct
{
otExtAddress mExtAddress; ///< IEEE 802.15.4 Extended Address
+157
View File
@@ -0,0 +1,157 @@
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file
* @brief
* This file defines the top-level ip6 functions for the OpenThread library.
*/
#ifndef OPENTHREAD_UDP_H_
#define OPENTHREAD_UDP_H_
#include <openthread-message.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup api API
* @brief
* This module includes the application programming interface to the OpenThread stack.
*
* @{
*
* @defgroup execution Execution
* @defgroup commands Commands
* @defgroup config Configuration
* @defgroup diags Diagnostics
* @defgroup messages Message Buffers
* @defgroup ip6 IPv6
* @defgroup udp UDP
* @defgroup coap CoAP
*
* @}
*
*/
/**
* @addtogroup udp UDP
*
* @brief
* This module includes functions that control UDP communication.
*
* @{
*
*/
/**
* Allocate a new message buffer for sending a UDP message.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aLinkSecurityEnabled TRUE if the message should be secured at Layer 2.
*
* @returns A pointer to the message buffer or NULL if no message buffers are available.
*
* @sa otFreeMessage
*/
otMessage otNewUdpMessage(otInstance *aInstance, bool aLinkSecurityEnabled);
/**
* Open a UDP/IPv6 socket.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aSocket A pointer to a UDP socket structure.
* @param[in] aCallback A pointer to the application callback function.
* @param[in] aContext A pointer to application-specific context.
*
* @retval kThreadErrorNone Successfully opened the socket.
* @retval kThreadErrorInvalidArgs Given socket structure was already opened.
*
* @sa otNewUdpMessage
* @sa otCloseUdpSocket
* @sa otBindUdpSocket
* @sa otSendUdp
*/
ThreadError otOpenUdpSocket(otInstance *aInstance, otUdpSocket *aSocket, otUdpReceive aCallback, void *aContext);
/**
* Close a UDP/IPv6 socket.
*
* @param[in] aSocket A pointer to a UDP socket structure.
*
* @retval kThreadErrorNone Successfully closed the socket.
*
* @sa otNewUdpMessage
* @sa otOpenUdpSocket
* @sa otBindUdpSocket
* @sa otSendUdp
*/
ThreadError otCloseUdpSocket(otUdpSocket *aSocket);
/**
* Bind a UDP/IPv6 socket.
*
* @param[in] aSocket A pointer to a UDP socket structure.
* @param[in] aSockName A pointer to an IPv6 socket address structure.
*
* @retval kThreadErrorNone Bind operation was successful.
*
* @sa otNewUdpMessage
* @sa otOpenUdpSocket
* @sa otCloseUdpSocket
* @sa otSendUdp
*/
ThreadError otBindUdpSocket(otUdpSocket *aSocket, otSockAddr *aSockName);
/**
* Send a UDP/IPv6 message.
*
* @param[in] aSocket A pointer to a UDP socket structure.
* @param[in] aMessage A pointer to a message buffer.
* @param[in] aMessageInfo A pointer to a message info structure.
*
* @sa otNewUdpMessage
* @sa otOpenUdpSocket
* @sa otCloseUdpSocket
* @sa otBindUdpSocket
* @sa otSendUdp
*/
ThreadError otSendUdp(otUdpSocket *aSocket, otMessage aMessage, const otMessageInfo *aMessageInfo);
/**
* @}
*
*/
#ifdef __cplusplus
} // extern "C"
#endif
#endif // OPENTHREAD_UDP_H_
+268 -618
View File
File diff suppressed because it is too large Load Diff
+20 -2
View File
@@ -96,6 +96,8 @@ extern "C" {
#define OT_TOOL_PACKED_FIELD __attribute__((packed))
#define OT_TOOL_PACKED_END __attribute__((packed))
#define OT_TOOL_ALIGN(X)
#elif defined(__ICCARM__) || defined(__ICC8051__)
// http://supp.iar.com/FilesPublic/UPDINFO/004916/arm/doc/EWARM_DevelopmentGuide.ENU.pdf
@@ -106,12 +108,16 @@ extern "C" {
#define OT_TOOL_PACKED_FIELD
#define OT_TOOL_PACKED_END
#define OT_TOOL_ALIGN(X)
#elif defined(_MSC_VER)
#define OT_TOOL_PACKED_BEGIN __pragma(pack(push,1))
#define OT_TOOL_PACKED_FIELD
#define OT_TOOL_PACKED_END __pragma(pack(pop))
#define OT_TOOL_ALIGN(X) __declspec(align(4))
#elif defined(__SDCC)
// Structures are packed by default in sdcc, as it primarily targets 8-bit MCUs.
@@ -120,6 +126,8 @@ extern "C" {
#define OT_TOOL_PACKED_FIELD
#define OT_TOOL_PACKED_END
#define OT_TOOL_ALIGN(X)
#else
#error "Error: No valid Toolchain specified"
@@ -130,6 +138,8 @@ extern "C" {
#define OT_TOOL_PACKED_FIELD
#define OT_TOOL_PACKED_END
#define OT_TOOL_ALIGN(X)
#endif
// =========== TOOLCHAIN SELECTION : END ===========
@@ -137,10 +147,8 @@ extern "C" {
#ifdef _MSC_VER
#ifdef _WIN64
#define OT_CALL
#define OT_CDECL
#else
#define OT_CALL __stdcall
#define OT_CDECL __cdecl
#endif
@@ -151,6 +159,16 @@ extern "C" {
#endif
#ifdef OTDLL
#ifndef OTAPI
#define OTAPI __declspec(dllimport)
#endif
#define OTCALL WINAPI
#else
#define OTAPI
#define OTCALL
#endif
/**
* @}
*