diff options
author | Jens Georg <mail@jensge.org> | 2022-07-15 00:59:48 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2022-07-15 00:59:48 +0200 |
commit | d667244f1d7bdbd6165601da4b73d8115337581a (patch) | |
tree | ab2159e8bfb7c8436332eb9d3b5df3d7b9982212 | |
parent | 28d8f9d2fb5387d8df1f8da21815d6fe27eb4877 (diff) | |
download | gssdp-d667244f1d7bdbd6165601da4b73d8115337581a.tar.gz |
Enable global scope v6 addresses
-rw-r--r-- | libgssdp/gssdp-client.c | 15 | ||||
-rw-r--r-- | libgssdp/gssdp-net-posix.c | 22 | ||||
-rw-r--r-- | libgssdp/gssdp-protocol.h | 2 |
3 files changed, 16 insertions, 23 deletions
diff --git a/libgssdp/gssdp-client.c b/libgssdp/gssdp-client.c index 716084f..ebf1bb6 100644 --- a/libgssdp/gssdp-client.c +++ b/libgssdp/gssdp-client.c @@ -55,6 +55,7 @@ static GInetAddress *SSDP_V6_LL_ADDR = NULL; static GInetAddress *SSDP_V6_SL_ADDR = NULL; +static GInetAddress *SSDP_V6_GL_ADDR = NULL; static GInetAddress *SSDP_V4_ADDR = NULL; static void @@ -1421,8 +1422,11 @@ _gssdp_client_get_mcast_group (GSSDPClient *client) * address to use the proper multicast group */ if (g_inet_address_get_is_link_local (priv->device.host_addr)) { return SSDP_V6_LL; + } else if (g_inet_address_get_is_site_local ( + priv->device.host_addr)) { + return SSDP_V6_SL; } else { - return SSDP_V6_SL; + return SSDP_V6_GL; } } } @@ -1457,10 +1461,15 @@ _gssdp_client_get_mcast_group_addr (GSSDPClient *client) ENSURE_V6_GROUP(LL); return SSDP_V6_LL_ADDR; + } else if (g_inet_address_get_is_site_local ( + priv->device.host_addr)) { + ENSURE_V6_GROUP (SL); + + return SSDP_V6_SL_ADDR; } else { - ENSURE_V6_GROUP(SL); + ENSURE_V6_GROUP (GL); - return SSDP_V6_SL_ADDR; + return SSDP_V6_GL_ADDR; } } } diff --git a/libgssdp/gssdp-net-posix.c b/libgssdp/gssdp-net-posix.c index 2525c67..b3266a9 100644 --- a/libgssdp/gssdp-net-posix.c +++ b/libgssdp/gssdp-net-posix.c @@ -461,17 +461,6 @@ gssdp_net_get_host_ip (GSSDPNetworkDevice *device) */ if (device->host_addr) { family = g_inet_address_get_family (device->host_addr); - if (family == G_SOCKET_FAMILY_IPV6 && - !g_inet_address_get_is_link_local (device->host_addr) && - !g_inet_address_get_is_site_local (device->host_addr) && - !g_inet_address_get_is_loopback (device->host_addr)) { - char *addr = g_inet_address_to_string (device->host_addr); - /* FIXME: Discard the address, but use the interface */ - g_warning("Invalid IP address given: %s, discarding", - addr); - g_free (addr); - g_clear_object (&device->host_addr); - } } for (ifaceptr = up_ifaces; @@ -500,15 +489,8 @@ gssdp_net_get_host_ip (GSSDPNetworkDevice *device) device->host_addr = g_object_ref (device_addr); break; case AF_INET6: - /* IP: Bit more complicated. We have to select a link-local or - * ULA address */ - if (!g_inet_address_get_is_link_local (device_addr) && - !g_inet_address_get_is_site_local (device_addr)) { - g_clear_object (&device_addr); - - continue; - } - + /* IP: Bit more complicated. We have to select a + * link-local or ULA address */ device->host_addr = g_object_ref (device_addr); break; default: diff --git a/libgssdp/gssdp-protocol.h b/libgssdp/gssdp-protocol.h index 413f024..e4e4233 100644 --- a/libgssdp/gssdp-protocol.h +++ b/libgssdp/gssdp-protocol.h @@ -15,6 +15,8 @@ G_BEGIN_DECLS #define SSDP_ADDR "239.255.255.250" #define SSDP_V6_LL "FF02::C" #define SSDP_V6_SL "FF05::C" +#define SSDP_V6_GL "FF0E::C" + #define SSDP_PORT 1900 #define SSDP_PORT_STR "1900" |