Subject: bug#38218: network-interface-list only returns IPv4 addresses

From: Robert Pluim <[email-masked]>
Date: Tue, 26 Nov 2019 19:10:04 +0100

>>>>> On Tue, 26 Nov 2019 19:17:49 +0200, Eli Zaretskii <[email-masked]> said:

    Eli> It needed a bit of tweaking for mingw.org's MinGW, so that it would
    Eli> work on XP.  However, after making the changes, one test from
    Eli> nsm-tests.el fails here:

Thanks for that

    Eli>   127.1/0 No such host is known.
    Eli>   127.1/0 No such host is known.
    Eli>   Test nsm-check-local-subnet-ipv4 backtrace:
    Eli>     signal(ert-test-failed (((should (eq nil (nsm-should-check "127.1")
    Eli>     ert-fail(((should (eq nil (nsm-should-check "127.1"))) :form (eq ni
    Eli>     (if (unwind-protect (setq value-44 (apply fn-42 args-43)) (setq for
    Eli>     (let (form-description-46) (if (unwind-protect (setq value-44 (appl
    Eli>     (let ((value-44 'ert-form-evaluation-aborted-45)) (let (form-descri
    Eli>     (let* ((fn-42 #'eq) (args-43 (condition-case err (let ((signal-hook
    Eli>     (let ((nsm-trust-local-network t)) (let* ((fn-37 #'eq) (args-38 (co
    Eli>     (let ((local-ip '[172 26 128 160 0]) (mask '[255 255 255 0 0]) (wro
    Eli>     (closure (t) nil (let ((local-ip '[172 26 128 160 0]) (mask '[255 2
    Eli>     ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-tes
    Eli>     ert-run-test(#s(ert-test :name nsm-check-local-subnet-ipv4 :documen
    Eli>     ert-run-or-rerun-test(#s(ert--stats :selector (not (tag :unstable))
    Eli>     ert-run-tests((not (tag :unstable)) #f(compiled-function (event-typ
    Eli>     ert-run-tests-batch((not (tag :unstable)))
    Eli>     ert-run-tests-batch-and-exit((not (tag :unstable)))
    Eli>     eval((ert-run-tests-batch-and-exit '(not (tag :unstable))) t)
    Eli>     command-line-1((#("-L" 0 2 (charset cp862)) #(";." 0 2 (charset cp8
    Eli>     command-line()
    Eli>     normal-top-level()
    Eli>   Test nsm-check-local-subnet-ipv4 condition:
    Eli>       (ert-test-failed
    Eli>        ((should
    Eli> 	 (eq nil
    Eli> 	     (nsm-should-check "127.1")))
    Eli> 	:form
    Eli> 	(eq nil t)
    Eli> 	:value nil))
    Eli>      FAILED  1/2  nsm-check-local-subnet-ipv4 (4.656250 sec)

Eek. mingw (or winsock) doesnʼt support getaddrinfo("127.1",...),
although getaddrinfo("127.0.0.1",...) seems to work. This fixes it for me:

>From e441c874ac7e7a0c7724af85ebf2d1678aea3a88 Mon Sep 17 00:00:00 2001
From: Robert Pluim <[email-masked]>
Date: Tue, 26 Nov 2019 19:07:42 +0100
Subject: [PATCH] Use 127.0.0.1 in nsm-tests
To: [email-masked]

Winsock doesn't like "127.1"

* test/lisp/net/nsm-tests.el (nsm-check-local-subnet-ipv4): Spell
numeric localhost as "127.0.0.1" instead of "127.1".
---
 test/lisp/net/nsm-tests.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/lisp/net/nsm-tests.el b/test/lisp/net/nsm-tests.el
index 8e52568d71..97edcca80d 100644
--- a/test/lisp/net/nsm-tests.el
+++ b/test/lisp/net/nsm-tests.el
@@ -42,11 +42,11 @@ nsm-check-local-subnet-ipv4
     (should-error (nsm-network-same-subnet local-ip wrong-length-mask remote-ip-yes))
     (should (eq nil (nsm-network-same-subnet local-ip wrong-mask remote-ip-yes)))
     (should (eq t (nsm-should-check "google.com")))
-    (should (eq t (nsm-should-check "127.1")))
+    (should (eq t (nsm-should-check "127.0.0.1")))
     (should (eq t (nsm-should-check "localhost")))
     (let ((nsm-trust-local-network t))
       (should (eq t (nsm-should-check "google.com")))
-      (should (eq nil (nsm-should-check "127.1")))
+      (should (eq nil (nsm-should-check "127.0.0.1")))
       (should (eq nil (nsm-should-check "localhost"))))))
 
 (defun nsm-ipv6-is-available ()
-- 
2.24.0.155.gd9f6f3b619