[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#27570] [PATCH v3] syscalls: Add network-interface-running?
From: |
Danny Milosavljevic |
Subject: |
[bug#27570] [PATCH v3] syscalls: Add network-interface-running? |
Date: |
Tue, 4 Jul 2017 02:56:02 +0200 |
* 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)))))
+
(define-as-needed (set-network-interface-flags socket name flags)
"Set the flag of network interface NAME to FLAGS."
(let ((req (make-bytevector ifreq-struct-size)))
- [bug#27570] [PATCH] syscalls: Add IFF_UP, IFF_BROADCAST, IFF_LOOPBACK, IFF_RUNNING., Danny Milosavljevic, 2017/07/03
- [bug#27570] [PATCH] syscalls: Export IFF_UP, IFF_BROADCAST, IFF_LOOPBACK, IFF_RUNNING., Danny Milosavljevic, 2017/07/03
- [bug#27570] [PATCH v3] syscalls: Add network-interface-running?,
Danny Milosavljevic <=
- [bug#27570] [PATCH] syscalls: Add IFF_UP, IFF_BROADCAST, IFF_LOOPBACK, IFF_RUNNING., Ludovic Courtès, 2017/07/10