diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2018-08-01 23:12:41 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2018-08-01 23:12:41 +0200 |
commit | a239f9feadd015fa91d391df01365dcade8ce503 (patch) | |
tree | 979554817c2069a525e94e2ad5f6346b53e19eb5 /icmpd.h | |
parent | 9f2fccfdc2eae83efbde1e3ae94a2cc220537983 (diff) |
Threaded communication (icmpd)
Diffstat (limited to 'icmpd.h')
-rw-r--r-- | icmpd.h | 31 |
1 files changed, 31 insertions, 0 deletions
@@ -0,0 +1,31 @@ +#pragma once + +#include <stdbool.h> +#include <stdint.h> +#include "mt.h" + + +struct icmpd_received { + uint8_t *data; // points to malloc'd buffer; should be freed by recipient + size_t length; // length of 'data' + + uint32_t source_addr; + int id, seqnum; +}; + + +struct icmpd; + +// Pass 0 as client_addr to listen for messages from any IP (this channel will then only receive unassigned messages) +// Pass -1 as id to listen for messages with any id +struct icmpd* icmpd_create_server(int id, uint32_t client_addr); + +struct icmpd* icmpd_create_client(uint32_t server_addr); + +void icmpd_server_set_outstanding(struct icmpd *d, int seqnum); + +bool icmpd_peek(struct icmpd *d); +struct icmpd_received icmpd_recv(struct icmpd *d); +void icmpd_send(struct icmpd *d, const void *data, size_t length); + +void icmpd_destroy(struct icmpd *d); |