From: ludo@gnu.org (Ludovic Courtès)
To: Danny Milosavljevic <dannym@scratchpost.org>
Cc: 27570@debbugs.gnu.org
Subject: [bug#27570] [PATCH v3] syscalls: Add network-interface-running?
Date: Mon, 10 Jul 2017 12:18:05 +0200 [thread overview]
Message-ID: <874luk7fz6.fsf@gnu.org> (raw)
In-Reply-To: <20170704005602.14932-1-dannym@scratchpost.org> (Danny Milosavljevic's message of "Tue, 4 Jul 2017 02:56:02 +0200")
Danny Milosavljevic <dannym@scratchpost.org> 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 @@
>
> 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 valid.
> (define-as-needed IFF_LOOPBACK #x8) ;Is a loopback net.
> +(define-as-needed IFF_RUNNING #x40) ;interface RFC2863 OPER_UP
>
> (define IF_NAMESIZE 16) ;maximum interface name size
>
> @@ -1282,6 +1284,13 @@ interface NAME."
> (close-port sock)
> (not (zero? (logand flags IFF_LOOPBACK)))))
>
> +(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
‘loopback-network-interface?’ test that’s there? (I think the test can
assume that “lo” is running.)
OK with this change.
(And you can disregard the reply I sent just before.)
Thanks!
Ludo’.
next prev parent reply other threads:[~2017-07-10 10:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-04 0:39 [bug#27570] [PATCH] syscalls: Add IFF_UP, IFF_BROADCAST, IFF_LOOPBACK, IFF_RUNNING Danny Milosavljevic
2017-07-04 0:46 ` [bug#27570] [PATCH] syscalls: Export " Danny Milosavljevic
2017-07-04 0:56 ` [bug#27570] [PATCH v3] syscalls: Add network-interface-running? Danny Milosavljevic
2017-07-10 10:18 ` Ludovic Courtès [this message]
2017-07-10 14:30 ` Danny Milosavljevic
2017-07-10 10:15 ` [bug#27570] [PATCH] syscalls: Add IFF_UP, IFF_BROADCAST, IFF_LOOPBACK, IFF_RUNNING Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874luk7fz6.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=27570@debbugs.gnu.org \
--cc=dannym@scratchpost.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).