Commit 146eaa1e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Fix warnings and set sockaddr.sa_len

parent 0a867131
......@@ -54,8 +54,12 @@ Broadcast::Broadcast(int i_ttl, const char *psz_iface) : fd4 (-1), fd6 (-1),
int dummy = 1;
setsockopt (fd6, SOL_SOCKET, SO_REUSEADDR, &dummy, sizeof (dummy));
struct sockaddr_in6 addr = { };
struct sockaddr_in6 addr;
memset (&addr, 0, sizeof (addr));
addr.sin6_family = AF_INET6;
#ifdef HAVE_SA_LEN
addr.sin6_len = sizeof (addr);
#endif
if (psz_iface != NULL)
{
......@@ -99,8 +103,12 @@ Broadcast::Broadcast(int i_ttl, const char *psz_iface) : fd4 (-1), fd6 (-1),
int dummy = 1;
setsockopt (fd4, SOL_SOCKET, SO_REUSEADDR, &dummy, sizeof (dummy));
struct sockaddr_in addr = { };
struct sockaddr_in addr;
memset (&addr, 0, sizeof (addr));
addr.sin_family = AF_INET;
#ifdef HAVE_SA_LEN
addr.sin_len = sizeof (addr);
#endif
if (psz_iface != NULL)
{
......@@ -239,6 +247,9 @@ int Broadcast::GuessDestination (const char *str,
struct sockaddr_in *a4 = (struct sockaddr_in *)addr;
memset (a4, 0, sizeof (*a4));
a4->sin_family = AF_INET;
#ifdef HAVE_SA_LEN
a4->sin_len = sizeof (*a4);
#endif
a4->sin_port = htons (HELLO_PORT);
memcpy (&a4->sin_addr.s_addr, &ip, sizeof (ip));
*addrlen = sizeof (*a4);
......@@ -266,6 +277,9 @@ int Broadcast::GuessDestination (const char *str,
struct sockaddr_in6 *a6 = (struct sockaddr_in6 *)addr;
memset (a6, 0, sizeof (*a6));
a6->sin6_family = AF_INET6;
#ifdef HAVE_SA_LEN
a6->sin_len = sizeof (*a6);
#endif
a6->sin6_scope_id = scope_id;
a6->sin6_port = htons (HELLO_PORT);
memcpy (&a6->sin6_addr, &n.in6, sizeof (n.in6));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment