Distributed Publish & Subscribe for IoT
dps.h File Reference

Public APIs. More...

Go to the source code of this file.

Data Structures

struct  _DPS_Buffer
 A buffer. More...
 
struct  _DPS_Key
 Union of supported key types. More...
 
struct  _DPS_KeyCert
 Certificate key data. More...
 
struct  _DPS_KeyEC
 Elliptic curve key data. More...
 
struct  _DPS_KeyId
 An identifier of a key in a key store. More...
 
struct  _DPS_KeySymmetric
 Symmetric key data. More...
 

Macros

#define DPS_FALSE   0
 FALSE boolean value.
 
#define DPS_LINK_LOSS_TIMEOUT   30000
 This establishes the base rate at which keep-alive subscription messages are sent to remote nodes. More...
 
#define DPS_MCAST_PUB_DISABLED   0
 Disable multicast send and receive on the node. More...
 
#define DPS_MCAST_PUB_ENABLE_RECV   2
 Enable multicast receive on the node. More...
 
#define DPS_MCAST_PUB_ENABLE_SEND   1
 Enable multicast send on the node. More...
 
#define DPS_SUBSCRIPTION_UPDATE_RATE   2000
 The default maximum rate (in msecs) to compute and send out subscription updates. More...
 
#define DPS_TRUE   1
 TRUE boolean value.
 

Typedefs

typedef void(* DPS_AcknowledgementHandler) (DPS_Publication *pub, uint8_t *payload, size_t len)
 Function prototype for a publication acknowledgement handler called when an acknowledgement for a publication is received from a remote subscriber. More...
 
typedef void(* DPS_AckPublicationBufsComplete) (DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, DPS_Status status, void *data)
 Called when DPS_AckPublicationBufs() completes. More...
 
typedef struct _DPS_Buffer DPS_Buffer
 A buffer.
 
typedef struct _DPS_Node DPS_Node
 Opaque type for a node.
 
typedef struct _DPS_NodeAddress DPS_NodeAddress
 Opaque type for a remote node address.
 
typedef void(* DPS_OnLinkComplete) (DPS_Node *node, const DPS_NodeAddress *addr, DPS_Status status, void *data)
 Function prototype for function called when a DPS_Link() completes. More...
 
typedef void(* DPS_OnLinkLoss) (DPS_Node *node, const DPS_NodeAddress *addr, void *data)
 Function prototype for function called when a link is lossed. More...
 
typedef void(* DPS_OnNodeDestroyed) (DPS_Node *node, void *data)
 Function prototype for callback function called when a node is destroyed. More...
 
typedef void(* DPS_OnNodeShutdown) (DPS_Node *node, void *data)
 Function prototype for callback function called when a node is shutdown. More...
 
typedef void(* DPS_OnPublicationDestroyed) (DPS_Publication *pub)
 Function prototype for callback function called when a publication is destroyed. More...
 
typedef void(* DPS_OnResolveAddressComplete) (DPS_Node *node, const DPS_NodeAddress *addr, void *data)
 Function prototype for function called when a DPS_ResolveAddress() completes. More...
 
typedef void(* DPS_OnSubscriptionDestroyed) (DPS_Subscription *sub)
 Function prototype for callback function called when a subscription is destroyed. More...
 
typedef void(* DPS_OnUnlinkComplete) (DPS_Node *node, const DPS_NodeAddress *addr, void *data)
 Function prototype for function called when a DPS_Unlink() completes. More...
 
typedef struct _DPS_Publication DPS_Publication
 Opaque type for a publication.
 
typedef void(* DPS_PublicationHandler) (DPS_Subscription *sub, const DPS_Publication *pub, uint8_t *payload, size_t len)
 Function prototype for a publication handler called when a publication is received that matches a subscription. More...
 
typedef void(* DPS_PublishBufsComplete) (DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, DPS_Status status, void *data)
 Called when DPS_PublishBufs() completes. More...
 
typedef struct _DPS_Subscription DPS_Subscription
 Opaque type for a subscription.
 

Functions

const DPS_KeyIdDPS_AckGetSenderKeyId (const DPS_Publication *pub)
 Get the key identifier of an acknowledgement, only valid with the body of the DPS_AcknowledgementHandler function. More...
 
uint32_t DPS_AckGetSequenceNum (const DPS_Publication *pub)
 Get the sequence number being acknowledged, only valid with the body of the DPS_AcknowledgementHandler function. More...
 
DPS_Status DPS_AckPublication (const DPS_Publication *pub, const uint8_t *ackPayload, size_t len)
 Acknowledge a publication. More...
 
DPS_Status DPS_AckPublicationBufs (const DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, DPS_AckPublicationBufsComplete cb, void *data)
 Acknowledge a publication. More...
 
void DPS_CopyAddress (DPS_NodeAddress *dest, const DPS_NodeAddress *src)
 Copy a node address. More...
 
DPS_PublicationDPS_CopyPublication (const DPS_Publication *pub)
 Creates a partial copy of a publication that can be used to acknowledge the publication. More...
 
DPS_NodeAddressDPS_CreateAddress (void)
 Creates a node address. More...
 
DPS_NodeDPS_CreateNode (const char *separators, DPS_KeyStore *keyStore, const DPS_KeyId *keyId)
 Allocates space for a local DPS node. More...
 
DPS_PublicationDPS_CreatePublication (DPS_Node *node)
 Allocates storage for a publication. More...
 
DPS_SubscriptionDPS_CreateSubscription (DPS_Node *node, const char **topics, size_t numTopics)
 Allocate memory for a subscription and initialize topics. More...
 
void DPS_DestroyAddress (DPS_NodeAddress *addr)
 Frees resources associated with an address. More...
 
DPS_Status DPS_DestroyNode (DPS_Node *node, DPS_OnNodeDestroyed cb, void *data)
 Destroys a node and free any resources. More...
 
DPS_Status DPS_DestroyPublication (DPS_Publication *pub, DPS_OnPublicationDestroyed cb)
 Delete a publication and frees any resources allocated. More...
 
DPS_Status DPS_DestroySubscription (DPS_Subscription *sub, DPS_OnSubscriptionDestroyed cb)
 Stop subscribing to the subscription topic and free resources allocated for the subscription. More...
 
const DPS_NodeAddressDPS_GetListenAddress (DPS_Node *node)
 Get the address this node is listening for connections on. More...
 
const char * DPS_GetListenAddressString (DPS_Node *node)
 Get text representation of the address this node is listening for connections on. More...
 
void * DPS_GetNodeData (const DPS_Node *node)
 Get application data pointer previously set by DPS_SetNodeData() More...
 
void * DPS_GetPublicationData (const DPS_Publication *pub)
 Get application data pointer previously set by DPS_SetPublicationData() More...
 
void * DPS_GetSubscriptionData (DPS_Subscription *sub)
 Get application data pointer previously set by DPS_SetSubscriptionData() More...
 
DPS_Status DPS_InitPublication (DPS_Publication *pub, const char **topics, size_t numTopics, int noWildCard, const DPS_KeyId *keyId, DPS_AcknowledgementHandler handler)
 Initializes a newly created publication with a set of topics. More...
 
DPS_Status DPS_Link (DPS_Node *node, const char *addrText, DPS_OnLinkComplete cb, void *data)
 Link the local node to a remote node. More...
 
const char * DPS_NodeAddrToString (const DPS_NodeAddress *addr)
 Get text representation of an address. More...
 
DPS_Status DPS_PublicationAddSubId (DPS_Publication *pub, const DPS_KeyId *keyId)
 Adds a key identifier to use for encrypted publications. More...
 
DPS_NodeDPS_PublicationGetNode (const DPS_Publication *pub)
 Get the local node associated with a publication. More...
 
size_t DPS_PublicationGetNumTopics (const DPS_Publication *pub)
 Get the number of topics in a publication. More...
 
const DPS_KeyIdDPS_PublicationGetSenderKeyId (const DPS_Publication *pub)
 Get the key identifier of a publication. More...
 
uint32_t DPS_PublicationGetSequenceNum (const DPS_Publication *pub)
 Get the sequence number for a publication. More...
 
const char * DPS_PublicationGetTopic (const DPS_Publication *pub, size_t index)
 Get a topic for a publication. More...
 
int16_t DPS_PublicationGetTTL (const DPS_Publication *pub)
 Get the TTL for a publication. More...
 
const DPS_UUIDDPS_PublicationGetUUID (const DPS_Publication *pub)
 Get the UUID for a publication. More...
 
int DPS_PublicationIsAckRequested (const DPS_Publication *pub)
 Check if an acknowledgement was requested for a publication. More...
 
void DPS_PublicationRemoveSubId (DPS_Publication *pub, const DPS_KeyId *keyId)
 Removes a key identifier to use for encrypted publications. More...
 
DPS_Status DPS_Publish (DPS_Publication *pub, const uint8_t *pubPayload, size_t len, int16_t ttl)
 Publish a set of topics along with an optional payload. More...
 
DPS_Status DPS_PublishBufs (DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, int16_t ttl, DPS_PublishBufsComplete cb, void *data)
 Publish a set of topics along with an optional payload. More...
 
DPS_Status DPS_ResolveAddress (DPS_Node *node, const char *host, const char *service, DPS_OnResolveAddressComplete cb, void *data)
 Resolve a host name or IP address and service name or port number. More...
 
DPS_NodeAddressDPS_SetAddress (DPS_NodeAddress *addr, const char *addrText)
 Set a node address. More...
 
DPS_Status DPS_SetLinkLossCallback (DPS_Node *node, DPS_OnLinkLoss cb, void *data)
 Set a callback function to called when a link explicily established by this node was lost. More...
 
DPS_Status DPS_SetNodeData (DPS_Node *node, void *data)
 Store a pointer to application data in a node. More...
 
void DPS_SetNodeLinkLossTimeout (DPS_Node *node, uint32_t linkLossMsecs)
 Override the default link-loss detection timeout (in msecs) More...
 
void DPS_SetNodeSubscriptionUpdateDelay (DPS_Node *node, uint32_t subsRateMsecs)
 Override the default time delay (in msecs) between subscription updates. More...
 
DPS_Status DPS_SetPublicationData (DPS_Publication *pub, void *data)
 Store a pointer to application data in a publication. More...
 
DPS_Status DPS_SetSubscriptionData (DPS_Subscription *sub, void *data)
 Store a pointer to application data in a subscription. More...
 
DPS_Status DPS_ShutdownNode (DPS_Node *node, DPS_OnNodeShutdown cb, void *data)
 Shutdowns a node. More...
 
DPS_Status DPS_StartNode (DPS_Node *node, int mcastPub, DPS_NodeAddress *listenAddr)
 Initialized and starts running a local node. More...
 
DPS_Status DPS_Subscribe (DPS_Subscription *sub, DPS_PublicationHandler handler)
 Start subscribing to a set of topics. More...
 
DPS_Status DPS_SubscribeExpired (DPS_Subscription *sub, int enable)
 Call the publication handler when a matching retained publication expires. More...
 
DPS_NodeDPS_SubscriptionGetNode (const DPS_Subscription *sub)
 Get the local node associated with a subscription. More...
 
size_t DPS_SubscriptionGetNumTopics (const DPS_Subscription *sub)
 Get the number of topics registered with an active subscription. More...
 
const char * DPS_SubscriptionGetTopic (const DPS_Subscription *sub, size_t index)
 Get a topic for an active subscription. More...
 
DPS_Status DPS_Unlink (DPS_Node *node, const DPS_NodeAddress *addr, DPS_OnUnlinkComplete cb, void *data)
 Unlink a local node from a remote node. More...
 

KeyStore

Hooks for implementing an application-defined key store.

#define DPS_AES_256_KEY_LEN   32
 AES 256 key length, in bytes.
 
enum  DPS_KeyType { DPS_KEY_SYMMETRIC, DPS_KEY_EC, DPS_KEY_EC_CERT }
 A DPS key type. More...
 
enum  DPS_ECCurve { DPS_EC_CURVE_RESERVED = 0, DPS_EC_CURVE_P384 = 2, DPS_EC_CURVE_P521 = 3 }
 Allowed elliptic curves. More...
 
typedef struct _DPS_KeySymmetric DPS_KeySymmetric
 Symmetric key data. More...
 
typedef struct _DPS_KeyEC DPS_KeyEC
 Elliptic curve key data. More...
 
typedef struct _DPS_KeyCert DPS_KeyCert
 Certificate key data. More...
 
typedef struct _DPS_Key DPS_Key
 Union of supported key types.
 
typedef struct _DPS_KeyId DPS_KeyId
 An identifier of a key in a key store.
 
typedef struct _DPS_KeyStore DPS_KeyStore
 Opaque type for a key store.
 
typedef struct _DPS_KeyStoreRequest DPS_KeyStoreRequest
 Opaque type for a key store request.
 
typedef DPS_Status(* DPS_KeyAndIdHandler) (DPS_KeyStoreRequest *request)
 Function prototype for a key store handler called when a key and key identifier is requested. More...
 
typedef DPS_Status(* DPS_KeyHandler) (DPS_KeyStoreRequest *request, const DPS_KeyId *keyId)
 Function prototype for a key store handler called when a key with the provided key identifier is requested. More...
 
typedef DPS_Status(* DPS_EphemeralKeyHandler) (DPS_KeyStoreRequest *request, const DPS_Key *key)
 Function prototype for a key store handler called when an ephemeral key with the provided type is requested. More...
 
typedef DPS_Status(* DPS_CAHandler) (DPS_KeyStoreRequest *request)
 Function prototype for a key store handler called when the trusted CA chain is requested. More...
 
DPS_Status DPS_SetKeyAndId (DPS_KeyStoreRequest *request, const DPS_Key *key, const DPS_KeyId *keyId)
 Provide a key and key identifier to a key store request. More...
 
DPS_Status DPS_SetKey (DPS_KeyStoreRequest *request, const DPS_Key *key)
 Provide a key to a key store request. More...
 
DPS_Status DPS_SetCA (DPS_KeyStoreRequest *request, const char *ca)
 Provide a trusted CA chain to a key store request. More...
 
DPS_KeyStoreDPS_KeyStoreHandle (DPS_KeyStoreRequest *request)
 Returns the DPS_KeyStore* of a key store request. More...
 
DPS_KeyStoreDPS_CreateKeyStore (DPS_KeyAndIdHandler keyAndIdHandler, DPS_KeyHandler keyHandler, DPS_EphemeralKeyHandler ephemeralKeyHandler, DPS_CAHandler caHandler)
 Creates a key store. More...
 
void DPS_DestroyKeyStore (DPS_KeyStore *keyStore)
 Destroys a previously created key store. More...
 
DPS_Status DPS_SetKeyStoreData (DPS_KeyStore *keyStore, void *data)
 Store a pointer to application data in a key store. More...
 
void * DPS_GetKeyStoreData (const DPS_KeyStore *keyStore)
 Get application data pointer previously set by DPS_SetKeyStoreData(). More...
 

In-memory Key Store

The implementation of an in-memory key store.

typedef struct _DPS_MemoryKeyStore DPS_MemoryKeyStore
 Opaque type for an in-memory key store.
 
DPS_MemoryKeyStoreDPS_CreateMemoryKeyStore (void)
 Creates an in-memory key store. More...
 
void DPS_DestroyMemoryKeyStore (DPS_MemoryKeyStore *keyStore)
 Destroys a previously created in-memory key store. More...
 
DPS_Status DPS_SetContentKey (DPS_MemoryKeyStore *keyStore, const DPS_KeyId *keyId, const DPS_Key *key)
 Create or replace a key with the specified key identifier in the key store. More...
 
DPS_Status DPS_SetNetworkKey (DPS_MemoryKeyStore *keyStore, const DPS_KeyId *keyId, const DPS_Key *key)
 Create or replace the network key in the key store. More...
 
DPS_Status DPS_SetTrustedCA (DPS_MemoryKeyStore *mks, const char *ca)
 Create or replace the trusted CA(s) in the key store. More...
 
DPS_Status DPS_SetCertificate (DPS_MemoryKeyStore *mks, const char *cert, const char *key, const char *password)
 Create or replace a certificate in the key store. More...
 
DPS_KeyStoreDPS_MemoryKeyStoreHandle (DPS_MemoryKeyStore *keyStore)
 Returns the DPS_KeyStore* of an in-memory key store. More...
 

Detailed Description

Public APIs.