[gssdp/gssdp_1.0] client. Always set network mask
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gssdp/gssdp_1.0] client. Always set network mask
- Date: Thu, 2 Jul 2020 19:47:43 +0000 (UTC)
commit bc0785aa234cea019effc1824561d0cd16866543
Author: Jens Georg <mail jensge org>
Date: Thu Jul 2 21:47:08 2020 +0200
client. Always set network mask
Fixes #7
libgssdp/gssdp-client.c | 26 +-------------------------
tests/test-regression.c | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+), 25 deletions(-)
---
diff --git a/libgssdp/gssdp-client.c b/libgssdp/gssdp-client.c
index e6ec737..f06f62d 100644
--- a/libgssdp/gssdp-client.c
+++ b/libgssdp/gssdp-client.c
@@ -2034,31 +2034,7 @@ init_network_info (GSSDPClient *client, GError **error)
{
gboolean ret = TRUE;
- /* Either interface name or host_ip wasn't given during construction.
- * If one is given, try to find the other, otherwise just pick an
- * interface.
- */
- if (client->priv->device.iface_name == NULL ||
- client->priv->device.host_ip == NULL)
- get_host_ip (&(client->priv->device));
- else {
- /* Ugly. Ideally, get_host_ip needs to be run everytime, but
- * it is currently to stupid so just query index here if we
- * have a name and an interface already.
- *
- * query_ifindex will return -1 on platforms that don't
- * support this.
- */
- client->priv->device.index =
- query_ifindex (client->priv->device.iface_name);
- }
-
- if (client->priv->device.host_addr == NULL &&
- client->priv->device.host_ip != NULL) {
- client->priv->device.host_addr =
- g_inet_address_new_from_string
- (client->priv->device.host_ip);
- }
+ get_host_ip (&(client->priv->device));
if (client->priv->device.iface_name == NULL) {
g_set_error_literal (error,
diff --git a/tests/test-regression.c b/tests/test-regression.c
index 045ce11..bfb692d 100644
--- a/tests/test-regression.c
+++ b/tests/test-regression.c
@@ -411,6 +411,30 @@ static void test_ggo_1(void)
* ============================================================================
*/
+/* BEGIN Regression test
+ * https://gitlab.gnome.org/GNOME/gssdp/issues/7
+ * ============================================================================
+ * - Check that creating a GSSDPClient with interface and ip will have a set
+ * network mask
+ */
+void test_ggo_7 () {
+ GError *error = NULL;
+
+ GSSDPClient *client = g_initable_new (GSSDP_TYPE_CLIENT,
+ NULL,
+ &error,
+ "host-ip", "127.0.0.1",
+ "interface", "lo",
+ NULL);
+ g_assert_no_error (error);
+ g_assert_nonnull (gssdp_client_get_address_mask (client));
+}
+
+/* END Regression test
+ * https://gitlab.gnome.org/GNOME/gssdp/issues/7
+ * ============================================================================
+ */
+
int main (int argc, char *argv[])
{
@@ -425,6 +449,7 @@ int main (int argc, char *argv[])
g_test_add_func ("/bugs/gnome/724030", test_bgo724030);
g_test_add_func ("/bugs/ggo/1", test_ggo_1);
}
+ g_test_add_func ("/bugs/ggo/7", test_ggo_7);
g_test_run ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]