Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelP committed Mar 27, 2023
1 parent 9756369 commit 590b686
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/arvgvinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,17 @@ arv_gv_discover_socket_list_new (void)
ArvGvDiscoverSocket *discover_socket = g_new0 (ArvGvDiscoverSocket, 1);
GSocketAddress *socket_address;
GSocketAddress *socket_broadcast;
GSocketAddress *any_socket_address;
GInetAddress *any_address;
GInetAddress *inet_address;
GInetAddress *inet_broadcast;
char *inet_address_string;
char *inet_broadcast_string;
GError *error = NULL;
gint buffer_size = ARV_GV_INTERFACE_DISCOVERY_SOCKET_BUFFER_SIZE;
int socket_fd;
const char *interface_name;

socket_address = g_socket_address_new_from_native (arv_network_interface_get_addr(iface_iter->data),
sizeof (struct sockaddr));
socket_broadcast = g_socket_address_new_from_native (arv_network_interface_get_broadaddr(iface_iter->data),
Expand All @@ -112,7 +117,16 @@ arv_gv_discover_socket_list_new (void)
G_SOCKET_TYPE_DATAGRAM,
G_SOCKET_PROTOCOL_UDP, NULL);
arv_socket_set_recv_buffer_size (g_socket_get_fd (discover_socket->socket), buffer_size);
g_socket_bind (discover_socket->socket, discover_socket->interface_address, FALSE, &error);

any_address = g_inet_address_new_any (G_SOCKET_FAMILY_IPV4);
any_socket_address = g_inet_socket_address_new (any_address, 0);
g_socket_bind (discover_socket->socket, any_socket_address, FALSE, &error);
g_object_unref (any_socket_address);
g_object_unref (any_address);

interface_name = arv_network_interface_get_name (iface_iter->data);
socket_fd = g_socket_get_fd(discover_socket->socket);
setsockopt (socket_fd, SOL_SOCKET, SO_BINDTODEVICE, interface_name, strlen (interface_name));

socket_list->sockets = g_slist_prepend (socket_list->sockets, discover_socket);
socket_list->n_sockets++;
Expand Down

0 comments on commit 590b686

Please sign in to comment.