Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jthomas43 committed Dec 6, 2024
1 parent 4818326 commit dece88f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
17 changes: 17 additions & 0 deletions include/udx.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ typedef enum {
UDX_LOOKUP_FAMILY_IPV6 = 2,
} udx_lookup_flags;

typedef enum {
UDX_JOIN_GROUP,
UDX_LEAVE_GROUP
} udx_multicast_membership;

typedef struct udx_lookup_s udx_lookup_t;

typedef struct udx_interface_event_s udx_interface_event_t;
Expand Down Expand Up @@ -418,6 +423,18 @@ udx_socket_set_ttl (udx_socket_t *socket, int ttl);
int
udx_socket_bind (udx_socket_t *socket, const struct sockaddr *addr, unsigned int flags);

int
udx_socket_set_membership (udx_socket_t *socket, const char *multicast_addr, const char *interface_addr, udx_multicast_membership membership);

int
udx_socket_set_source_membership (udx_socket_t *socket, const char *multicast_addr, const char *interface_addr, const char *source_addr, udx_multicast_membership membership);

int
udx_socket_set_multicast_loop (udx_socket_t *socket, int on);

int
udx_socket_set_multicast_interface (udx_socket_t *socket, const char *addr);

int
udx_socket_getsockname (udx_socket_t *socket, struct sockaddr *name, int *name_len);

Expand Down
22 changes: 22 additions & 0 deletions src/udx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2111,6 +2111,28 @@ udx_socket_getsockname (udx_socket_t *socket, struct sockaddr *name, int *name_l
return uv_udp_getsockname(&(socket->handle), name, name_len);
}

int
udx_socket_set_membership (udx_socket_t *socket, const char *multicast_addr, const char *interface_addr, udx_multicast_membership membership) {
uv_membership m = membership == UDX_JOIN_GROUP ? UV_JOIN_GROUP : UV_LEAVE_GROUP;
return uv_udp_set_membership(&socket->handle, multicast_addr, interface_addr, m);
}

int
udx_socket_set_source_membership (udx_socket_t *socket, const char *multicast_addr, const char *interface_addr, const char *source_addr, udx_multicast_membership membership) {
uv_membership m = membership == UDX_JOIN_GROUP ? UV_JOIN_GROUP : UV_LEAVE_GROUP;
return uv_udp_set_source_membership(&socket->handle, multicast_addr, interface_addr, source_addr, m);
}

int
udx_socket_set_multicast_loop (udx_socket_t *socket, int on) {
return uv_udp_set_multicast_loop(&socket->handle, on);
}

int
udx_socket_set_multicast_interface (udx_socket_t *socket, const char *addr) {
return uv_udp_set_multicast_interface(&socket->handle, addr);
}

int
udx_socket_send (udx_socket_send_t *req, udx_socket_t *socket, const uv_buf_t bufs[], unsigned int bufs_len, const struct sockaddr *dest, udx_socket_send_cb cb) {
return udx_socket_send_ttl(req, socket, bufs, bufs_len, dest, 0, cb);
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ list(APPEND tests
lookup-invalid
lookup-ipv6
socket-send-recv
socket-send-recv-multicast
socket-send-recv-dualstack
socket-send-recv-ipv6
stream-destroy
Expand Down

0 comments on commit dece88f

Please sign in to comment.