summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2022-08-04 19:47:49 +0200
committerJens Georg <mail@jensge.org>2022-08-07 19:15:50 +0200
commit083e9f17d28df9591437bd8de8f35d47f07a8f80 (patch)
treeba66a4ff3c3eeb906bba79521a4b9c89d49e24db
parentf8bbc98979131d94edd4f1a0643645cecbf59d5f (diff)
downloadgupnp-083e9f17d28df9591437bd8de8f35d47f07a8f80.tar.gz
Connman: Entertain both address families
-rw-r--r--libgupnp/gupnp-connman-manager.c72
1 files changed, 54 insertions, 18 deletions
diff --git a/libgupnp/gupnp-connman-manager.c b/libgupnp/gupnp-connman-manager.c
index 5e20bfe..de6d903 100644
--- a/libgupnp/gupnp-connman-manager.c
+++ b/libgupnp/gupnp-connman-manager.c
@@ -93,28 +93,64 @@ loopback_context_create (gpointer data)
g_object_get (manager, "port", &port, NULL);
- context = g_initable_new (GUPNP_TYPE_CONTEXT,
- NULL,
- &error,
- "interface",
- LOOPBACK_IFACE,
- "port",
- port,
- "address-family",
- gupnp_context_manager_get_socket_family (
- GUPNP_CONTEXT_MANAGER (manager)),
- NULL);
+ GSocketFamily family = gupnp_context_manager_get_socket_family (
+ GUPNP_CONTEXT_MANAGER (manager));
+
+ if (family == G_SOCKET_FAMILY_INVALID ||
+ family == G_SOCKET_FAMILY_IPV4) {
+ GInetAddress *addr =
+ g_inet_address_new_loopback (G_SOCKET_FAMILY_IPV4);
+
+ context = g_initable_new (GUPNP_TYPE_CONTEXT,
+ NULL,
+ &error,
+ "address",
+ addr,
+ "port",
+ port,
+ NULL);
+ if (error) {
+ g_warning ("Error creating GUPnP context: %s\n",
+ error->message);
+
+ g_clear_error (&error);
+ } else {
+ g_signal_emit_by_name (manager,
+ "context-available",
+ context);
+ }
- if (error != NULL) {
- g_warning ("Error creating GUPnP context: %s", error->message);
- g_error_free (error);
+ g_object_unref (context);
+ g_object_unref (addr);
+ }
+
+ if (family == G_SOCKET_FAMILY_INVALID ||
+ family == G_SOCKET_FAMILY_IPV6) {
+ GInetAddress *addr =
+ g_inet_address_new_loopback (G_SOCKET_FAMILY_IPV6);
+ context = g_initable_new (GUPNP_TYPE_CONTEXT,
+ NULL,
+ &error,
+ "address",
+ addr,
+ "port",
+ port,
+ NULL);
+ if (error) {
+ g_warning ("Error creating GUPnP context: %s\n",
+ error->message);
+
+ g_clear_error (&error);
+ } else {
+ g_signal_emit_by_name (manager,
+ "context-available",
+ context);
+ }
- return FALSE;
+ g_object_unref (context);
+ g_object_unref (addr);
}
- g_signal_emit_by_name (manager, "context-available", context);
- g_object_unref (context);
-
return FALSE;
}