From b950efd6b10f06dd3ecb5b692e5d415f48474647 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Mon, 2 Jan 2023 17:42:27 +0100 Subject: [PATCH] Remove WIN32_EXPORT, only support static compilation --- src/libusockets.h | 160 +++++++++++++++++++++++----------------------- src/udp.c | 22 +++---- 2 files changed, 90 insertions(+), 92 deletions(-) diff --git a/src/libusockets.h b/src/libusockets.h index 4e1e6c5e..f5a6c121 100644 --- a/src/libusockets.h +++ b/src/libusockets.h @@ -34,10 +34,8 @@ #endif #include #define LIBUS_SOCKET_DESCRIPTOR SOCKET -#define WIN32_EXPORT __declspec(dllexport) #else #define LIBUS_SOCKET_DESCRIPTOR int -#define WIN32_EXPORT #endif #ifdef __cplusplus @@ -63,63 +61,63 @@ struct us_udp_packet_buffer_t; /* Public interface for UDP sockets */ /* Peeks data and length of UDP payload */ -WIN32_EXPORT char *us_udp_packet_buffer_payload(struct us_udp_packet_buffer_t *buf, int index); -WIN32_EXPORT int us_udp_packet_buffer_payload_length(struct us_udp_packet_buffer_t *buf, int index); +char *us_udp_packet_buffer_payload(struct us_udp_packet_buffer_t *buf, int index); +int us_udp_packet_buffer_payload_length(struct us_udp_packet_buffer_t *buf, int index); /* Copies out local (received destination) ip (4 or 16 bytes) of received packet */ -WIN32_EXPORT int us_udp_packet_buffer_local_ip(struct us_udp_packet_buffer_t *buf, int index, char *ip); +int us_udp_packet_buffer_local_ip(struct us_udp_packet_buffer_t *buf, int index, char *ip); /* Get the bound port in host byte order */ -WIN32_EXPORT int us_udp_socket_bound_port(struct us_udp_socket_t *s); +int us_udp_socket_bound_port(struct us_udp_socket_t *s); /* Peeks peer addr (sockaddr) of received packet */ -WIN32_EXPORT char *us_udp_packet_buffer_peer(struct us_udp_packet_buffer_t *buf, int index); +char *us_udp_packet_buffer_peer(struct us_udp_packet_buffer_t *buf, int index); /* Peeks ECN of received packet */ -WIN32_EXPORT int us_udp_packet_buffer_ecn(struct us_udp_packet_buffer_t *buf, int index); +int us_udp_packet_buffer_ecn(struct us_udp_packet_buffer_t *buf, int index); /* Receives a set of packets into specified packet buffer */ -WIN32_EXPORT int us_udp_socket_receive(struct us_udp_socket_t *s, struct us_udp_packet_buffer_t *buf); +int us_udp_socket_receive(struct us_udp_socket_t *s, struct us_udp_packet_buffer_t *buf); -WIN32_EXPORT void us_udp_buffer_set_packet_payload(struct us_udp_packet_buffer_t *send_buf, int index, int offset, void *payload, int length, void *peer_addr); +void us_udp_buffer_set_packet_payload(struct us_udp_packet_buffer_t *send_buf, int index, int offset, void *payload, int length, void *peer_addr); -WIN32_EXPORT int us_udp_socket_send(struct us_udp_socket_t *s, struct us_udp_packet_buffer_t *buf, int num); +int us_udp_socket_send(struct us_udp_socket_t *s, struct us_udp_packet_buffer_t *buf, int num); /* Allocates a packet buffer that is reuable per thread. Mutated by us_udp_socket_receive. */ -WIN32_EXPORT struct us_udp_packet_buffer_t *us_create_udp_packet_buffer(); +struct us_udp_packet_buffer_t *us_create_udp_packet_buffer(); /* Creates a (heavy-weight) UDP socket with a user space ring buffer. Again, this one is heavy weight and * shoud be reused. One entire QUIC server can be implemented using only one single UDP socket so weight * is not a concern as is the case for TCP sockets which are 1-to-1 with TCP connections. */ -//WIN32_EXPORT struct us_udp_socket_t *us_create_udp_socket(struct us_loop_t *loop, void (*read_cb)(struct us_udp_socket_t *), unsigned short port); +//struct us_udp_socket_t *us_create_udp_socket(struct us_loop_t *loop, void (*read_cb)(struct us_udp_socket_t *), unsigned short port); -//WIN32_EXPORT struct us_udp_socket_t *us_create_udp_socket(struct us_loop_t *loop, void (*data_cb)(struct us_udp_socket_t *, struct us_udp_packet_buffer_t *, int), void (*drain_cb)(struct us_udp_socket_t *), char *host, unsigned short port); +//struct us_udp_socket_t *us_create_udp_socket(struct us_loop_t *loop, void (*data_cb)(struct us_udp_socket_t *, struct us_udp_packet_buffer_t *, int), void (*drain_cb)(struct us_udp_socket_t *), char *host, unsigned short port); -WIN32_EXPORT struct us_udp_socket_t *us_create_udp_socket(struct us_loop_t *loop, struct us_udp_packet_buffer_t *buf, void (*data_cb)(struct us_udp_socket_t *, struct us_udp_packet_buffer_t *, int), void (*drain_cb)(struct us_udp_socket_t *), const char *host, unsigned short port, void *user); +struct us_udp_socket_t *us_create_udp_socket(struct us_loop_t *loop, struct us_udp_packet_buffer_t *buf, void (*data_cb)(struct us_udp_socket_t *, struct us_udp_packet_buffer_t *, int), void (*drain_cb)(struct us_udp_socket_t *), const char *host, unsigned short port, void *user); /* This one is ugly, should be ext! not user */ void *us_udp_socket_user(struct us_udp_socket_t *s); /* Binds the UDP socket to an interface and port */ -WIN32_EXPORT int us_udp_socket_bind(struct us_udp_socket_t *s, const char *hostname, unsigned int port); +int us_udp_socket_bind(struct us_udp_socket_t *s, const char *hostname, unsigned int port); /* Public interfaces for timers */ /* Create a new high precision, low performance timer. May fail and return null */ -WIN32_EXPORT struct us_timer_t *us_create_timer(struct us_loop_t *loop, int fallthrough, unsigned int ext_size); +struct us_timer_t *us_create_timer(struct us_loop_t *loop, int fallthrough, unsigned int ext_size); /* Returns user data extension for this timer */ -WIN32_EXPORT void *us_timer_ext(struct us_timer_t *timer); +void *us_timer_ext(struct us_timer_t *timer); /* */ -WIN32_EXPORT void us_timer_close(struct us_timer_t *timer); +void us_timer_close(struct us_timer_t *timer); /* Arm a timer with a delay from now and eventually a repeat delay. * Specify 0 as repeat delay to disable repeating. Specify both 0 to disarm. */ -WIN32_EXPORT void us_timer_set(struct us_timer_t *timer, void (*cb)(struct us_timer_t *t), int ms, int repeat_ms); +void us_timer_set(struct us_timer_t *timer, void (*cb)(struct us_timer_t *t), int ms, int repeat_ms); /* Returns the loop for this timer */ -WIN32_EXPORT struct us_loop_t *us_timer_loop(struct us_timer_t *t); +struct us_loop_t *us_timer_loop(struct us_timer_t *t); /* Public interfaces for contexts */ @@ -134,190 +132,190 @@ struct us_socket_context_options_t { }; /* Return 15-bit timestamp for this context */ -WIN32_EXPORT unsigned short us_socket_context_timestamp(int ssl, struct us_socket_context_t *context); +unsigned short us_socket_context_timestamp(int ssl, struct us_socket_context_t *context); /* Adds SNI domain and cert in asn1 format */ -WIN32_EXPORT void us_socket_context_add_server_name(int ssl, struct us_socket_context_t *context, const char *hostname_pattern, struct us_socket_context_options_t options, void *user); -WIN32_EXPORT void us_socket_context_remove_server_name(int ssl, struct us_socket_context_t *context, const char *hostname_pattern); -WIN32_EXPORT void us_socket_context_on_server_name(int ssl, struct us_socket_context_t *context, void (*cb)(struct us_socket_context_t *, const char *hostname)); -WIN32_EXPORT void *us_socket_server_name_userdata(int ssl, struct us_socket_t *s); -WIN32_EXPORT void *us_socket_context_find_server_name_userdata(int ssl, struct us_socket_context_t *context, const char *hostname_pattern); +void us_socket_context_add_server_name(int ssl, struct us_socket_context_t *context, const char *hostname_pattern, struct us_socket_context_options_t options, void *user); +void us_socket_context_remove_server_name(int ssl, struct us_socket_context_t *context, const char *hostname_pattern); +void us_socket_context_on_server_name(int ssl, struct us_socket_context_t *context, void (*cb)(struct us_socket_context_t *, const char *hostname)); +void *us_socket_server_name_userdata(int ssl, struct us_socket_t *s); +void *us_socket_context_find_server_name_userdata(int ssl, struct us_socket_context_t *context, const char *hostname_pattern); /* Returns the underlying SSL native handle, such as SSL_CTX or nullptr */ -WIN32_EXPORT void *us_socket_context_get_native_handle(int ssl, struct us_socket_context_t *context); +void *us_socket_context_get_native_handle(int ssl, struct us_socket_context_t *context); /* A socket context holds shared callbacks and user data extension for associated sockets */ -WIN32_EXPORT struct us_socket_context_t *us_create_socket_context(int ssl, struct us_loop_t *loop, +struct us_socket_context_t *us_create_socket_context(int ssl, struct us_loop_t *loop, int ext_size, struct us_socket_context_options_t options); /* Delete resources allocated at creation time. */ -WIN32_EXPORT void us_socket_context_free(int ssl, struct us_socket_context_t *context); +void us_socket_context_free(int ssl, struct us_socket_context_t *context); /* Setters of various async callbacks */ -WIN32_EXPORT void us_socket_context_on_open(int ssl, struct us_socket_context_t *context, +void us_socket_context_on_open(int ssl, struct us_socket_context_t *context, struct us_socket_t *(*on_open)(struct us_socket_t *s, int is_client, char *ip, int ip_length)); -WIN32_EXPORT void us_socket_context_on_close(int ssl, struct us_socket_context_t *context, +void us_socket_context_on_close(int ssl, struct us_socket_context_t *context, struct us_socket_t *(*on_close)(struct us_socket_t *s, int code, void *reason)); -WIN32_EXPORT void us_socket_context_on_data(int ssl, struct us_socket_context_t *context, +void us_socket_context_on_data(int ssl, struct us_socket_context_t *context, struct us_socket_t *(*on_data)(struct us_socket_t *s, char *data, int length)); -WIN32_EXPORT void us_socket_context_on_writable(int ssl, struct us_socket_context_t *context, +void us_socket_context_on_writable(int ssl, struct us_socket_context_t *context, struct us_socket_t *(*on_writable)(struct us_socket_t *s)); -WIN32_EXPORT void us_socket_context_on_timeout(int ssl, struct us_socket_context_t *context, +void us_socket_context_on_timeout(int ssl, struct us_socket_context_t *context, struct us_socket_t *(*on_timeout)(struct us_socket_t *s)); -WIN32_EXPORT void us_socket_context_on_long_timeout(int ssl, struct us_socket_context_t *context, +void us_socket_context_on_long_timeout(int ssl, struct us_socket_context_t *context, struct us_socket_t *(*on_timeout)(struct us_socket_t *s)); /* This one is only used for when a connecting socket fails in a late stage. */ -WIN32_EXPORT void us_socket_context_on_connect_error(int ssl, struct us_socket_context_t *context, +void us_socket_context_on_connect_error(int ssl, struct us_socket_context_t *context, struct us_socket_t *(*on_connect_error)(struct us_socket_t *s, int code)); /* Emitted when a socket has been half-closed */ -WIN32_EXPORT void us_socket_context_on_end(int ssl, struct us_socket_context_t *context, struct us_socket_t *(*on_end)(struct us_socket_t *s)); +void us_socket_context_on_end(int ssl, struct us_socket_context_t *context, struct us_socket_t *(*on_end)(struct us_socket_t *s)); /* Returns user data extension for this socket context */ -WIN32_EXPORT void *us_socket_context_ext(int ssl, struct us_socket_context_t *context); +void *us_socket_context_ext(int ssl, struct us_socket_context_t *context); /* Closes all open sockets, including listen sockets. Does not invalidate the socket context. */ -WIN32_EXPORT void us_socket_context_close(int ssl, struct us_socket_context_t *context); +void us_socket_context_close(int ssl, struct us_socket_context_t *context); /* Listen for connections. Acts as the main driving cog in a server. Will call set async callbacks. */ -WIN32_EXPORT struct us_listen_socket_t *us_socket_context_listen(int ssl, struct us_socket_context_t *context, +struct us_listen_socket_t *us_socket_context_listen(int ssl, struct us_socket_context_t *context, const char *host, int port, int options, int socket_ext_size); -WIN32_EXPORT struct us_listen_socket_t *us_socket_context_listen_unix(int ssl, struct us_socket_context_t *context, +struct us_listen_socket_t *us_socket_context_listen_unix(int ssl, struct us_socket_context_t *context, const char *path, int options, int socket_ext_size); /* listen_socket.c/.h */ -WIN32_EXPORT void us_listen_socket_close(int ssl, struct us_listen_socket_t *ls); +void us_listen_socket_close(int ssl, struct us_listen_socket_t *ls); /* Land in on_open or on_connection_error or return null or return socket */ -WIN32_EXPORT struct us_socket_t *us_socket_context_connect(int ssl, struct us_socket_context_t *context, +struct us_socket_t *us_socket_context_connect(int ssl, struct us_socket_context_t *context, const char *host, int port, const char *source_host, int options, int socket_ext_size); -WIN32_EXPORT struct us_socket_t *us_socket_context_connect_unix(int ssl, struct us_socket_context_t *context, +struct us_socket_t *us_socket_context_connect_unix(int ssl, struct us_socket_context_t *context, const char *server_path, int options, int socket_ext_size); /* Is this socket established? Can be used to check if a connecting socket has fired the on_open event yet. * Can also be used to determine if a socket is a listen_socket or not, but you probably know that already. */ -WIN32_EXPORT int us_socket_is_established(int ssl, struct us_socket_t *s); +int us_socket_is_established(int ssl, struct us_socket_t *s); /* Cancel a connecting socket. Can be used together with us_socket_timeout to limit connection times. * Entirely destroys the socket - this function works like us_socket_close but does not trigger on_close event since * you never got the on_open event first. */ -WIN32_EXPORT struct us_socket_t *us_socket_close_connecting(int ssl, struct us_socket_t *s); +struct us_socket_t *us_socket_close_connecting(int ssl, struct us_socket_t *s); /* Returns the loop for this socket context. */ -WIN32_EXPORT struct us_loop_t *us_socket_context_loop(int ssl, struct us_socket_context_t *context); +struct us_loop_t *us_socket_context_loop(int ssl, struct us_socket_context_t *context); /* Invalidates passed socket, returning a new resized socket which belongs to a different socket context. * Used mainly for "socket upgrades" such as when transitioning from HTTP to WebSocket. */ -WIN32_EXPORT struct us_socket_t *us_socket_context_adopt_socket(int ssl, struct us_socket_context_t *context, struct us_socket_t *s, int ext_size); +struct us_socket_t *us_socket_context_adopt_socket(int ssl, struct us_socket_context_t *context, struct us_socket_t *s, int ext_size); /* Create a child socket context which acts much like its own socket context with its own callbacks yet still relies on the * parent socket context for some shared resources. Child socket contexts should be used together with socket adoptions and nothing else. */ -WIN32_EXPORT struct us_socket_context_t *us_create_child_socket_context(int ssl, struct us_socket_context_t *context, int context_ext_size); +struct us_socket_context_t *us_create_child_socket_context(int ssl, struct us_socket_context_t *context, int context_ext_size); /* Public interfaces for loops */ /* Returns a new event loop with user data extension */ -WIN32_EXPORT struct us_loop_t *us_create_loop(void *hint, void (*wakeup_cb)(struct us_loop_t *loop), +struct us_loop_t *us_create_loop(void *hint, void (*wakeup_cb)(struct us_loop_t *loop), void (*pre_cb)(struct us_loop_t *loop), void (*post_cb)(struct us_loop_t *loop), unsigned int ext_size); /* Frees the loop immediately */ -WIN32_EXPORT void us_loop_free(struct us_loop_t *loop); +void us_loop_free(struct us_loop_t *loop); /* Returns the loop user data extension */ -WIN32_EXPORT void *us_loop_ext(struct us_loop_t *loop); +void *us_loop_ext(struct us_loop_t *loop); /* Blocks the calling thread and drives the event loop until no more non-fallthrough polls are scheduled */ -WIN32_EXPORT void us_loop_run(struct us_loop_t *loop); +void us_loop_run(struct us_loop_t *loop); /* Signals the loop from any thread to wake up and execute its wakeup handler from the loop's own running thread. * This is the only fully thread-safe function and serves as the basis for thread safety */ -WIN32_EXPORT void us_wakeup_loop(struct us_loop_t *loop); +void us_wakeup_loop(struct us_loop_t *loop); /* Hook up timers in existing loop */ -WIN32_EXPORT void us_loop_integrate(struct us_loop_t *loop); +void us_loop_integrate(struct us_loop_t *loop); /* Returns the loop iteration number */ -WIN32_EXPORT long long us_loop_iteration_number(struct us_loop_t *loop); +long long us_loop_iteration_number(struct us_loop_t *loop); /* Public interfaces for polls */ /* A fallthrough poll does not keep the loop running, it falls through */ -WIN32_EXPORT struct us_poll_t *us_create_poll(struct us_loop_t *loop, int fallthrough, unsigned int ext_size); +struct us_poll_t *us_create_poll(struct us_loop_t *loop, int fallthrough, unsigned int ext_size); /* After stopping a poll you must manually free the memory */ -WIN32_EXPORT void us_poll_free(struct us_poll_t *p, struct us_loop_t *loop); +void us_poll_free(struct us_poll_t *p, struct us_loop_t *loop); /* Associate this poll with a socket descriptor and poll type */ -WIN32_EXPORT void us_poll_init(struct us_poll_t *p, LIBUS_SOCKET_DESCRIPTOR fd, int poll_type); +void us_poll_init(struct us_poll_t *p, LIBUS_SOCKET_DESCRIPTOR fd, int poll_type); /* Start, change and stop polling for events */ -WIN32_EXPORT void us_poll_start(struct us_poll_t *p, struct us_loop_t *loop, int events); -WIN32_EXPORT void us_poll_change(struct us_poll_t *p, struct us_loop_t *loop, int events); -WIN32_EXPORT void us_poll_stop(struct us_poll_t *p, struct us_loop_t *loop); +void us_poll_start(struct us_poll_t *p, struct us_loop_t *loop, int events); +void us_poll_change(struct us_poll_t *p, struct us_loop_t *loop, int events); +void us_poll_stop(struct us_poll_t *p, struct us_loop_t *loop); /* Return what events we are polling for */ -WIN32_EXPORT int us_poll_events(struct us_poll_t *p); +int us_poll_events(struct us_poll_t *p); /* Returns the user data extension of this poll */ -WIN32_EXPORT void *us_poll_ext(struct us_poll_t *p); +void *us_poll_ext(struct us_poll_t *p); /* Get associated socket descriptor from a poll */ -WIN32_EXPORT LIBUS_SOCKET_DESCRIPTOR us_poll_fd(struct us_poll_t *p); +LIBUS_SOCKET_DESCRIPTOR us_poll_fd(struct us_poll_t *p); /* Resize an active poll */ -WIN32_EXPORT struct us_poll_t *us_poll_resize(struct us_poll_t *p, struct us_loop_t *loop, unsigned int ext_size); +struct us_poll_t *us_poll_resize(struct us_poll_t *p, struct us_loop_t *loop, unsigned int ext_size); /* Public interfaces for sockets */ /* Returns the underlying native handle for a socket, such as SSL or file descriptor. * In the case of file descriptor, the value of pointer is fd. */ -WIN32_EXPORT void *us_socket_get_native_handle(int ssl, struct us_socket_t *s); +void *us_socket_get_native_handle(int ssl, struct us_socket_t *s); /* Write up to length bytes of data. Returns actual bytes written. * Will call the on_writable callback of active socket context on failure to write everything off in one go. * Set hint msg_more if you have more immediate data to write. */ -WIN32_EXPORT int us_socket_write(int ssl, struct us_socket_t *s, const char *data, int length, int msg_more); +int us_socket_write(int ssl, struct us_socket_t *s, const char *data, int length, int msg_more); /* Set a low precision, high performance timer on a socket. A socket can only have one single active timer * at any given point in time. Will remove any such pre set timer */ -WIN32_EXPORT void us_socket_timeout(int ssl, struct us_socket_t *s, unsigned int seconds); +void us_socket_timeout(int ssl, struct us_socket_t *s, unsigned int seconds); /* Set a low precision, high performance timer on a socket. Suitable for per-minute precision. */ -WIN32_EXPORT void us_socket_long_timeout(int ssl, struct us_socket_t *s, unsigned int minutes); +void us_socket_long_timeout(int ssl, struct us_socket_t *s, unsigned int minutes); /* Return the user data extension of this socket */ -WIN32_EXPORT void *us_socket_ext(int ssl, struct us_socket_t *s); +void *us_socket_ext(int ssl, struct us_socket_t *s); /* Return the socket context of this socket */ -WIN32_EXPORT struct us_socket_context_t *us_socket_context(int ssl, struct us_socket_t *s); +struct us_socket_context_t *us_socket_context(int ssl, struct us_socket_t *s); /* Withdraw any msg_more status and flush any pending data */ -WIN32_EXPORT void us_socket_flush(int ssl, struct us_socket_t *s); +void us_socket_flush(int ssl, struct us_socket_t *s); /* Shuts down the connection by sending FIN and/or close_notify */ -WIN32_EXPORT void us_socket_shutdown(int ssl, struct us_socket_t *s); +void us_socket_shutdown(int ssl, struct us_socket_t *s); /* Shuts down the connection in terms of read, meaning next event loop * iteration will catch the socket being closed. Can be used to defer closing * to next event loop iteration. */ -WIN32_EXPORT void us_socket_shutdown_read(int ssl, struct us_socket_t *s); +void us_socket_shutdown_read(int ssl, struct us_socket_t *s); /* Returns whether the socket has been shut down or not */ -WIN32_EXPORT int us_socket_is_shut_down(int ssl, struct us_socket_t *s); +int us_socket_is_shut_down(int ssl, struct us_socket_t *s); /* Returns whether this socket has been closed. Only valid if memory has not yet been released. */ -WIN32_EXPORT int us_socket_is_closed(int ssl, struct us_socket_t *s); +int us_socket_is_closed(int ssl, struct us_socket_t *s); /* Immediately closes the socket */ -WIN32_EXPORT struct us_socket_t *us_socket_close(int ssl, struct us_socket_t *s, int code, void *reason); +struct us_socket_t *us_socket_close(int ssl, struct us_socket_t *s, int code, void *reason); /* Returns local port or -1 on failure. */ -WIN32_EXPORT int us_socket_local_port(int ssl, struct us_socket_t *s); +int us_socket_local_port(int ssl, struct us_socket_t *s); /* Copy remote (IP) address of socket, or fail with zero length. */ -WIN32_EXPORT void us_socket_remote_address(int ssl, struct us_socket_t *s, char *buf, int *length); +void us_socket_remote_address(int ssl, struct us_socket_t *s, char *buf, int *length); #ifdef __cplusplus } diff --git a/src/udp.c b/src/udp.c index ed3cd815..70a7d3a0 100644 --- a/src/udp.c +++ b/src/udp.c @@ -22,28 +22,28 @@ #include #include -WIN32_EXPORT int us_udp_packet_buffer_ecn(struct us_udp_packet_buffer_t *buf, int index) { +int us_udp_packet_buffer_ecn(struct us_udp_packet_buffer_t *buf, int index) { return bsd_udp_packet_buffer_ecn(buf, index); } -WIN32_EXPORT int us_udp_packet_buffer_local_ip(struct us_udp_packet_buffer_t *buf, int index, char *ip) { +int us_udp_packet_buffer_local_ip(struct us_udp_packet_buffer_t *buf, int index, char *ip) { return bsd_udp_packet_buffer_local_ip(buf, index, ip); } -WIN32_EXPORT char *us_udp_packet_buffer_peer(struct us_udp_packet_buffer_t *buf, int index) { +char *us_udp_packet_buffer_peer(struct us_udp_packet_buffer_t *buf, int index) { return bsd_udp_packet_buffer_peer(buf, index); } -WIN32_EXPORT char *us_udp_packet_buffer_payload(struct us_udp_packet_buffer_t *buf, int index) { +char *us_udp_packet_buffer_payload(struct us_udp_packet_buffer_t *buf, int index) { return bsd_udp_packet_buffer_payload(buf, index); } -WIN32_EXPORT int us_udp_packet_buffer_payload_length(struct us_udp_packet_buffer_t *buf, int index) { +int us_udp_packet_buffer_payload_length(struct us_udp_packet_buffer_t *buf, int index) { return bsd_udp_packet_buffer_payload_length(buf, index); } // what should we return? number of sent datagrams? -WIN32_EXPORT int us_udp_socket_send(struct us_udp_socket_t *s, struct us_udp_packet_buffer_t *buf, int num) { +int us_udp_socket_send(struct us_udp_socket_t *s, struct us_udp_packet_buffer_t *buf, int num) { int fd = us_poll_fd((struct us_poll_t *) s); // we need to poll out if we failed @@ -51,16 +51,16 @@ WIN32_EXPORT int us_udp_socket_send(struct us_udp_socket_t *s, struct us_udp_pac return bsd_sendmmsg(fd, buf, num, 0); } -WIN32_EXPORT int us_udp_socket_receive(struct us_udp_socket_t *s, struct us_udp_packet_buffer_t *buf) { +int us_udp_socket_receive(struct us_udp_socket_t *s, struct us_udp_packet_buffer_t *buf) { int fd = us_poll_fd((struct us_poll_t *) s); return bsd_recvmmsg(fd, buf, LIBUS_UDP_MAX_NUM, 0, 0); } -WIN32_EXPORT void us_udp_buffer_set_packet_payload(struct us_udp_packet_buffer_t *send_buf, int index, int offset, void *payload, int length, void *peer_addr) { +void us_udp_buffer_set_packet_payload(struct us_udp_packet_buffer_t *send_buf, int index, int offset, void *payload, int length, void *peer_addr) { bsd_udp_buffer_set_packet_payload(send_buf, index, offset, payload, length, peer_addr); } -WIN32_EXPORT struct us_udp_packet_buffer_t *us_create_udp_packet_buffer() { +struct us_udp_packet_buffer_t *us_create_udp_packet_buffer() { return (struct us_udp_packet_buffer_t *) bsd_create_udp_packet_buffer(); } @@ -76,7 +76,7 @@ struct us_internal_udp_t { int port; }; -WIN32_EXPORT int us_udp_socket_bound_port(struct us_udp_socket_t *s) { +int us_udp_socket_bound_port(struct us_udp_socket_t *s) { return ((struct us_internal_udp_t *) s)->port; } @@ -101,7 +101,7 @@ void *us_udp_socket_user(struct us_udp_socket_t *s) { return udp->user; } -WIN32_EXPORT struct us_udp_socket_t *us_create_udp_socket(struct us_loop_t *loop, struct us_udp_packet_buffer_t *buf, void (*data_cb)(struct us_udp_socket_t *, struct us_udp_packet_buffer_t *, int), void (*drain_cb)(struct us_udp_socket_t *), const char *host, unsigned short port, void *user) { +struct us_udp_socket_t *us_create_udp_socket(struct us_loop_t *loop, struct us_udp_packet_buffer_t *buf, void (*data_cb)(struct us_udp_socket_t *, struct us_udp_packet_buffer_t *, int), void (*drain_cb)(struct us_udp_socket_t *), const char *host, unsigned short port, void *user) { LIBUS_SOCKET_DESCRIPTOR fd = bsd_create_udp_socket(host, port); if (fd == LIBUS_SOCKET_ERROR) {