From: Saverio Proto Date: Sat, 28 Jun 2014 10:04:44 +0000 (+0200) Subject: Skeleton design for opening a reliable channel X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=13f7499864f93157a96c0946d09047704f11e074;p=meshlink Skeleton design for opening a reliable channel --- diff --git a/src/meshlink.c b/src/meshlink.c index e5982721..7d717e5a 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -1370,6 +1370,16 @@ void meshlink_blacklist(meshlink_handle_t *mesh, meshlink_node_t *node) { } +meshlink_connection_t* meshlink_open_rchannel(meshlink_handle_t *mesh, meshlink_node_t *destination, uint16_t dport) { + +//TODO: check in mesh->socketsbitmap for a free descriptor and allocate a source port for this connection + +//TODO: register a callback for the data that will be received from this connection + +//TODO: return a description value that the user will use to write on this channel + +} + static void __attribute__((constructor)) meshlink_init(void) { crypto_init(); } diff --git a/src/meshlink.h b/src/meshlink.h index 036637b0..96dcdf24 100644 --- a/src/meshlink.h +++ b/src/meshlink.h @@ -33,6 +33,8 @@ typedef struct meshlink_handle meshlink_handle_t; /// A handle for a MeshLink node. typedef struct meshlink_node meshlink_node_t; +typedef struct meshlink_connection meshlink_connection_t; + /// Code of most recent error encountered. typedef enum { MESHLINK_OK, ///< Everything is fine @@ -52,6 +54,10 @@ struct meshlink_node { void *priv; ///< Private pointer which the application can set at will. }; +struct meshlink_connection { + uint16_t sd; +}; + #endif // MESHLINK_INTERNAL_H /// Get the text for the given MeshLink error code. @@ -308,6 +314,9 @@ extern bool meshlink_import(meshlink_handle_t *mesh, const char *data); */ extern void meshlink_blacklist(meshlink_handle_t *mesh, meshlink_node_t *node); +/// Open a channel to destination node for reliable data delivery +extern meshlink_connection_t* meshlink_open_rchannel(meshlink_handle_t *mesh, meshlink_node_t *destination, uint16_t dport); + #ifdef __cplusplus } #endif diff --git a/src/meshlink_internal.h b/src/meshlink_internal.h index 8700b94e..f625857d 100644 --- a/src/meshlink_internal.h +++ b/src/meshlink_internal.h @@ -55,6 +55,11 @@ typedef struct outpacketqueue { unsigned int len; } outpacketqueue_t; +struct meshlink_connection { + uint16_t sd; + outpacketqueue_t packetwindow; +}; + /// A handle for an instance of MeshLink. struct meshlink_handle { char *confbase; @@ -85,6 +90,8 @@ struct meshlink_handle { struct list_t *outpacketqueue; + uint16_t socketsbitmap; //bitmap of 16 bits + int contradicting_add_edge; int contradicting_del_edge; int sleeptime;