From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUVma-0004hA-So for guix-patches@gnu.org; Mon, 10 Jul 2017 06:19:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUVmV-0002Rw-VA for guix-patches@gnu.org; Mon, 10 Jul 2017 06:19:12 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:56915) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUVmV-0002Ro-RT for guix-patches@gnu.org; Mon, 10 Jul 2017 06:19:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dUVmQ-0001X6-HK for guix-patches@gnu.org; Mon, 10 Jul 2017 06:19:02 -0400 Subject: [bug#27570] [PATCH v3] syscalls: Add network-interface-running? Resent-Message-ID: From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20170704003948.13966-1-dannym@scratchpost.org> <20170704005602.14932-1-dannym@scratchpost.org> Date: Mon, 10 Jul 2017 12:18:05 +0200 In-Reply-To: <20170704005602.14932-1-dannym@scratchpost.org> (Danny Milosavljevic's message of "Tue, 4 Jul 2017 02:56:02 +0200") Message-ID: <874luk7fz6.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Danny Milosavljevic Cc: 27570@debbugs.gnu.org Danny Milosavljevic skribis: > * guix/build/syscalls.scm (network-interface-running?): New variable. > Export it. > --- > guix/build/syscalls.scm | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm > index 9c082b435..5a6662afe 100644 > --- a/guix/build/syscalls.scm > +++ b/guix/build/syscalls.scm > @@ -88,6 +88,7 @@ >=20=20 > PF_PACKET > AF_PACKET > + network-interface-running? > all-network-interface-names > network-interface-names > network-interface-netmask > @@ -1108,6 +1109,7 @@ bytes." > (define-as-needed IFF_UP #x1) ;Interface is up > (define-as-needed IFF_BROADCAST #x2) ;Broadcast address val= id. > (define-as-needed IFF_LOOPBACK #x8) ;Is a loopback net. > +(define-as-needed IFF_RUNNING #x40) ;interface RFC2863 OPE= R_UP >=20=20 > (define IF_NAMESIZE 16) ;maximum interface nam= e size >=20=20 > @@ -1282,6 +1284,13 @@ interface NAME." > (close-port sock) > (not (zero? (logand flags IFF_LOOPBACK))))) >=20=20 > +(define (network-interface-running? name) > + "Return true if NAME designates a running network interface." > + (let* ((sock (socket SOCK_STREAM AF_INET 0)) > + (flags (network-interface-flags sock name))) > + (close-port sock) > + (not (zero? (logand flags IFF_RUNNING))))) Could you also add a test in tests/syscalls.scm along the lines of the =E2=80=98loopback-network-interface?=E2=80=99 test that=E2=80=99s there? (= I think the test can assume that =E2=80=9Clo=E2=80=9D is running.) OK with this change. (And you can disregard the reply I sent just before.) Thanks! Ludo=E2=80=99.