diff options
author | Jens Georg <mail@jensge.org> | 2022-08-04 19:47:49 +0200 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2022-08-04 19:47:49 +0200 |
commit | 8471bb3dc50162a10a801c37b66b332f0d4e8ad5 (patch) | |
tree | 37944fca0422e63aff01f2ea2bb0f253c0a019a6 | |
parent | 25f54b704bd367341ae7065d2269dabb78d4dbbe (diff) | |
download | gupnp-wip/ipv6-behavior-alignment.tar.gz |
Connman: Entertain both address familieswip/ipv6-behavior-alignment
-rw-r--r-- | libgupnp/gupnp-connman-manager.c | 72 |
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; } |