[gssdp] Enable global scope v6 addresses



commit d667244f1d7bdbd6165601da4b73d8115337581a
Author: Jens Georg <mail jensge org>
Date:   Fri Jul 15 00:59:48 2022 +0200

    Enable global scope v6 addresses

 libgssdp/gssdp-client.c    | 15 ++++++++++++---
 libgssdp/gssdp-net-posix.c | 22 ++--------------------
 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"
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]