36 #include <sys/socket.h> 57 typedef struct _DPS_NodeAddress DPS_NodeAddress; 136 #define DPS_AES_256_KEY_LEN 32 142 DPS_EC_CURVE_RESERVED = 0,
426 const char* password);
485 #define DPS_MCAST_PUB_DISABLED 0 490 #define DPS_MCAST_PUB_ENABLE_SEND 1 495 #define DPS_MCAST_PUB_ENABLE_RECV 2 567 #define DPS_SUBSCRIPTION_UPDATE_RATE 2000 575 #define DPS_LINK_LOSS_TIMEOUT 30000 DPS_Subscription * DPS_CreateSubscription(DPS_Node *node, const char **topics, size_t numTopics)
Allocate memory for a subscription and initialize topics.
DPS_KeyStore * DPS_MemoryKeyStoreHandle(DPS_MemoryKeyStore *keyStore)
Returns the DPS_KeyStore* of an in-memory key store.
void DPS_CopyAddress(DPS_NodeAddress *dest, const DPS_NodeAddress *src)
Copy a node address.
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.
DPS_KeySymmetric.
Definition: dps.h:121
DPS_Status DPS_SetSubscriptionData(DPS_Subscription *sub, void *data)
Store a pointer to application data in a subscription.
Type definition for a UUID.
Definition: uuid.h:47
struct _DPS_Key DPS_Key
Union of supported key types.
DPS_Status DPS_DestroySubscription(DPS_Subscription *sub, DPS_OnSubscriptionDestroyed cb)
Stop subscribing to the subscription topic and free resources allocated for the subscription.
void DPS_SetNodeLinkLossTimeout(DPS_Node *node, uint32_t linkLossMsecs)
Override the default link-loss detection timeout (in msecs)
void DPS_SetNodeSubscriptionUpdateDelay(DPS_Node *node, uint32_t subsRateMsecs)
Override the default time delay (in msecs) between subscription updates.
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.
DPS_KeyEC.
Definition: dps.h:122
struct _DPS_KeyId DPS_KeyId
An identifier of a key in a key store.
struct _DPS_MemoryKeyStore DPS_MemoryKeyStore
Opaque type for an in-memory key store.
Definition: dps.h:364
void(* DPS_OnNodeDestroyed)(DPS_Node *node, void *data)
Function prototype for callback function called when a node is destroyed.
Definition: dps.h:543
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.
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...
DPS_MemoryKeyStore * DPS_CreateMemoryKeyStore(void)
Creates an in-memory key store.
void DPS_DestroyKeyStore(DPS_KeyStore *keyStore)
Destroys a previously created key store.
struct _DPS_KeyStore DPS_KeyStore
Opaque type for a key store.
Definition: dps.h:197
struct _DPS_KeySymmetric DPS_KeySymmetric
Symmetric key data.
uint8_t * base
Pointer to the base of the buffer.
Definition: dps.h:905
DPS_KeyType
A DPS key type.
Definition: dps.h:120
NIST P-521 also known as secp521r1.
Definition: dps.h:144
Create and compare UUIDs.
size_t len
Length of the buffer.
Definition: dps.h:906
DPS_Status DPS_SubscribeExpired(DPS_Subscription *sub, int enable)
Call the publication handler when a matching retained publication expires.
DPS_KeyEC ec
DPS_KEY_EC.
Definition: dps.h:181
const char * DPS_GetListenAddressString(DPS_Node *node)
Get text representation of the address this node is listening for connections on. ...
const char * DPS_NodeAddrToString(const DPS_NodeAddress *addr)
Get text representation of an address.
DPS_Node * DPS_SubscriptionGetNode(const DPS_Subscription *sub)
Get the local node associated with a subscription.
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.
Definition: dps.h:622
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 req...
Definition: dps.h:254
struct _DPS_NodeAddress DPS_NodeAddress
Opaque type for a remote node address.
Definition: dps.h:57
struct _DPS_Buffer DPS_Buffer
A buffer.
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.
struct _DPS_Subscription DPS_Subscription
Opaque type for a subscription.
Definition: dps.h:1044
const char * password
The optional password protecting the key.
Definition: dps.h:170
struct _DPS_KeyCert DPS_KeyCert
Certificate key data.
Union of supported key types.
Definition: dps.h:176
struct _DPS_Publication DPS_Publication
Opaque type for a publication.
Definition: dps.h:712
void(* DPS_OnPublicationDestroyed)(DPS_Publication *pub)
Function prototype for callback function called when a publication is destroyed.
Definition: dps.h:953
DPS_Status DPS_AckPublicationBufs(const DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, DPS_AckPublicationBufsComplete cb, void *data)
Acknowledge a publication.
DPS_KeyType type
Type of key.
Definition: dps.h:177
DPS_Status DPS_StartNode(DPS_Node *node, int mcastPub, DPS_NodeAddress *listenAddr)
Initialized and starts running a local node.
DPS_Status DPS_SetKey(DPS_KeyStoreRequest *request, const DPS_Key *key)
Provide a key to a key store request.
void * DPS_GetNodeData(const DPS_Node *node)
Get application data pointer previously set by DPS_SetNodeData()
DPS_Status DPS_SetPublicationData(DPS_Publication *pub, void *data)
Store a pointer to application data in a publication.
DPS_KeyCert.
Definition: dps.h:123
Elliptic curve key data.
Definition: dps.h:155
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.
DPS_Status DPS_Subscribe(DPS_Subscription *sub, DPS_PublicationHandler handler)
Start subscribing to a set of topics.
const uint8_t * x
X coordinate.
Definition: dps.h:157
int DPS_Status
The status code type.
Definition: err.h:41
const char * cert
The certificate in PEM format.
Definition: dps.h:168
DPS_Status DPS_ShutdownNode(DPS_Node *node, DPS_OnNodeShutdown cb, void *data)
Shutdowns a node.
A buffer.
Definition: dps.h:904
void DPS_DestroyAddress(DPS_NodeAddress *addr)
Frees resources associated with an address.
DPS_Status DPS_SetCA(DPS_KeyStoreRequest *request, const char *ca)
Provide a trusted CA chain to a key store request.
DPS_Publication * DPS_CreatePublication(DPS_Node *node)
Allocates storage for a publication.
DPS_KeyStore * DPS_CreateKeyStore(DPS_KeyAndIdHandler keyAndIdHandler, DPS_KeyHandler keyHandler, DPS_EphemeralKeyHandler ephemeralKeyHandler, DPS_CAHandler caHandler)
Creates a key store.
DPS_Status DPS_SetTrustedCA(DPS_MemoryKeyStore *mks, const char *ca)
Create or replace the trusted CA(s) in the key store.
DPS_Status DPS_SetNodeData(DPS_Node *node, void *data)
Store a pointer to application data in a node.
Certificate key data.
Definition: dps.h:167
NIST P-384 also known as secp384r1.
Definition: dps.h:143
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 sub...
Definition: dps.h:1137
DPS_Status DPS_DestroyPublication(DPS_Publication *pub, DPS_OnPublicationDestroyed cb)
Delete a publication and frees any resources allocated.
DPS_NodeAddress * DPS_CreateAddress(void)
Creates a node address.
DPS_KeySymmetric symmetric
DPS_KEY_SYMMETRIC.
Definition: dps.h:180
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 requ...
Definition: dps.h:236
uint32_t DPS_AckGetSequenceNum(const DPS_Publication *pub)
Get the sequence number being acknowledged, only valid with the body of the DPS_AcknowledgementHandle...
size_t DPS_PublicationGetNumTopics(const DPS_Publication *pub)
Get the number of topics in a publication.
const char * DPS_SubscriptionGetTopic(const DPS_Subscription *sub, size_t index)
Get a topic for an active subscription.
DPS_ECCurve curve
The named curve.
Definition: dps.h:156
void(* DPS_OnSubscriptionDestroyed)(DPS_Subscription *sub)
Function prototype for callback function called when a subscription is destroyed. ...
Definition: dps.h:1155
void DPS_PublicationRemoveSubId(DPS_Publication *pub, const DPS_KeyId *keyId)
Removes a key identifier to use for encrypted publications.
const uint8_t * id
the identifier of the key
Definition: dps.h:190
DPS_Status DPS_DestroyNode(DPS_Node *node, DPS_OnNodeDestroyed cb, void *data)
Destroys a node and free any resources.
const DPS_UUID * DPS_PublicationGetUUID(const DPS_Publication *pub)
Get the UUID for a publication.
void(* DPS_OnUnlinkComplete)(DPS_Node *node, const DPS_NodeAddress *addr, void *data)
Function prototype for function called when a DPS_Unlink() completes.
Definition: dps.h:643
DPS_KeyCert cert
DPS_KEY_EC_CERT.
Definition: dps.h:182
const uint8_t * key
Key data.
Definition: dps.h:132
void * DPS_GetKeyStoreData(const DPS_KeyStore *keyStore)
Get application data pointer previously set by DPS_SetKeyStoreData().
const char * DPS_PublicationGetTopic(const DPS_Publication *pub, size_t index)
Get a topic for a publication.
DPS_Node * DPS_PublicationGetNode(const DPS_Publication *pub)
Get the local node associated with a publication.
uint32_t DPS_PublicationGetSequenceNum(const DPS_Publication *pub)
Get the sequence number for a publication.
struct _DPS_KeyEC DPS_KeyEC
Elliptic curve key data.
const DPS_NodeAddress * DPS_GetListenAddress(DPS_Node *node)
Get the address this node is listening for connections on.
DPS_Status DPS_Link(DPS_Node *node, const char *addrText, DPS_OnLinkComplete cb, void *data)
Link the local node to a remote node.
DPS_Status DPS_AckPublication(const DPS_Publication *pub, const uint8_t *ackPayload, size_t len)
Acknowledge a publication.
DPS_Status(* DPS_KeyAndIdHandler)(DPS_KeyStoreRequest *request)
Function prototype for a key store handler called when a key and key identifier is requested...
Definition: dps.h:219
void * DPS_GetSubscriptionData(DPS_Subscription *sub)
Get application data pointer previously set by DPS_SetSubscriptionData()
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.
size_t len
Size of key data.
Definition: dps.h:133
size_t len
the length of the identifier, in bytes
Definition: dps.h:191
void(* DPS_OnLinkLoss)(DPS_Node *node, const DPS_NodeAddress *addr, void *data)
Function prototype for function called when a link is lossed.
Definition: dps.h:664
void(* DPS_OnNodeShutdown)(DPS_Node *node, void *data)
Function prototype for callback function called when a node is shutdown.
Definition: dps.h:519
int DPS_PublicationIsAckRequested(const DPS_Publication *pub)
Check if an acknowledgement was requested for a publication.
void * DPS_GetPublicationData(const DPS_Publication *pub)
Get application data pointer previously set by DPS_SetPublicationData()
const char * privateKey
The optional private key in PEM format.
Definition: dps.h:169
DPS_Status DPS_PublicationAddSubId(DPS_Publication *pub, const DPS_KeyId *keyId)
Adds a key identifier to use for encrypted publications.
const DPS_KeyId * DPS_PublicationGetSenderKeyId(const DPS_Publication *pub)
Get the key identifier of a publication.
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.
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.
DPS_Node * DPS_CreateNode(const char *separators, DPS_KeyStore *keyStore, const DPS_KeyId *keyId)
Allocates space for a local DPS node.
const DPS_KeyId * DPS_AckGetSenderKeyId(const DPS_Publication *pub)
Get the key identifier of an acknowledgement, only valid with the body of the DPS_AcknowledgementHand...
void DPS_DestroyMemoryKeyStore(DPS_MemoryKeyStore *keyStore)
Destroys a previously created in-memory key store.
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 pub...
Definition: dps.h:838
DPS_Status(* DPS_CAHandler)(DPS_KeyStoreRequest *request)
Function prototype for a key store handler called when the trusted CA chain is requested.
Definition: dps.h:270
size_t DPS_SubscriptionGetNumTopics(const DPS_Subscription *sub)
Get the number of topics registered with an active subscription.
Symmetric key data.
Definition: dps.h:131
int16_t DPS_PublicationGetTTL(const DPS_Publication *pub)
Get the TTL for a publication.
DPS_Status DPS_SetKeyStoreData(DPS_KeyStore *keyStore, void *data)
Store a pointer to application data in a key store.
An identifier of a key in a key store.
Definition: dps.h:189
DPS_NodeAddress * DPS_SetAddress(DPS_NodeAddress *addr, const char *addrText)
Set a node address.
DPS_Status DPS_Unlink(DPS_Node *node, const DPS_NodeAddress *addr, DPS_OnUnlinkComplete cb, void *data)
Unlink a local node from a remote node.
void(* DPS_AckPublicationBufsComplete)(DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, DPS_Status status, void *data)
Called when DPS_AckPublicationBufs() completes.
Definition: dps.h:992
DPS_Publication * DPS_CopyPublication(const DPS_Publication *pub)
Creates a partial copy of a publication that can be used to acknowledge the publication.
DPS_ECCurve
Allowed elliptic curves.
Definition: dps.h:141
struct _DPS_KeyStoreRequest DPS_KeyStoreRequest
Opaque type for a key store request.
Definition: dps.h:202
void(* DPS_OnResolveAddressComplete)(DPS_Node *node, const DPS_NodeAddress *addr, void *data)
Function prototype for function called when a DPS_ResolveAddress() completes.
Definition: dps.h:686
DPS_KeyStore * DPS_KeyStoreHandle(DPS_KeyStoreRequest *request)
Returns the DPS_KeyStore* of a key store request.
struct _DPS_Node DPS_Node
Opaque type for a node.
Definition: dps.h:450
const uint8_t * d
D coordinate.
Definition: dps.h:159
const uint8_t * y
Y coordinate.
Definition: dps.h:158
void(* DPS_PublishBufsComplete)(DPS_Publication *pub, const DPS_Buffer *bufs, size_t numBufs, DPS_Status status, void *data)
Called when DPS_PublishBufs() completes.
Definition: dps.h:918