update liblokinet udp header

pull/1748/head
Jeff Becker 3 years ago committed by Jeff
parent 50001da9a1
commit db7050cd2d

@ -14,12 +14,8 @@ extern "C"
int socket_id;
/// remote endpoint's .loki or .snode address
char remote_addr[256];
/// local endpoint's ip address
char local_addr[64];
/// remote endpont's port
int remote_port;
/// local endpoint's port
int local_port;
};
/// a result from a lokinet_udp_bind call
@ -30,23 +26,37 @@ extern "C"
};
/// flow acceptor hook, return 0 success, return nonzero with errno on failure
typedef int (*lokinet_udp_flow_filter)(void*, const struct lokinet_udp_flowinfo*, void**, int*);
typedef int (*lokinet_udp_flow_filter)(
void* /*user*/,
const struct lokinet_udp_flowinfo* /* remote address */,
void** /* flow-userdata */,
int* /* timeout */);
/// hook function for handling packets
typedef void (*lokinet_udp_flow_recv_func)(
const struct lokinet_udp_flowinfo*, char*, size_t, void*);
const struct lokinet_udp_flowinfo* /* remote address */,
char* /* data pointer */,
size_t /* data length */,
void* /* flow-userdata */);
/// hook function for flow timeout
typedef void (*lokinet_udp_flow_timeout_func)(const lokinet_udp_flowinfo*, void*);
typedef void (*lokinet_udp_flow_timeout_func)(
const lokinet_udp_flowinfo* /* remote address */, void* /* flow-userdata */);
/// inbound listen udp socket
/// expose udp port exposePort to the void
/// filter MUST be non null, pointing to a flow filter for accepting new udp flows, called with
/// user data recv MUST be non null, pointing to a packet handler function for each flow, called
/// with per flow user data provided by filter function if accepted timeout MUST be non null,
////
/// @param filter MUST be non null, pointing to a flow filter for accepting new udp flows, called
/// with user data
///
/// @param recv MUST be non null, pointing to a packet handler function for each flow, called
/// with per flow user data provided by filter function if accepted
///
/// @param timeout MUST be non null,
/// pointing to a cleanup function to clean up a stale flow, staleness determined by the value
/// given by the filter function returns 0 on success returns nonzero on error in which it is an
/// errno value
/// given by the filter function returns 0 on success
///
/// @returns nonzero on error in which it is an errno value
int EXPORT
lokinet_udp_bind(
int exposedPort,
@ -57,6 +67,34 @@ extern "C"
struct lokinet_udp_listen_result* result,
struct lokinet_context* ctx);
/// @brief establish a udp flow to remote endpoint
///
/// @param remote the remote address to establish to
///
/// @param ctx the lokinet context to use
///
/// @return 0 on success, non zero errno on fail
int EXPORT
lokinet_udp_establish(const struct lokinet_udp_flowinfo* remote, struct lokinet_context* ctx);
/// @brief send on an established flow to remote endpoint
///
/// @param flowinfo populated after call on success
///
/// @param ptr pointer to data to send
///
/// @param len the length of the data
///
/// @param ctx the lokinet context to use
///
/// @returns 0 on success and non zero errno on fail
int EXPORT
lokinet_udp_flow_send(
const struct lokinet_udp_flowinfo* remote,
const void* ptr,
size_t len,
struct lokinet_ctx* ctx);
#ifdef __cplusplus
}
#endif

Loading…
Cancel
Save