syscalls: Add 'arp-network-interface?'.

* guix/build/syscalls.scm (IFF_NOARP): New variable.
(arp-network-interface?): New public procedure.
This commit is contained in:
Marius Bakke 2019-05-09 17:03:03 +02:00
parent a0dc97a517
commit 5f5499d684
No known key found for this signature in database
GPG key ID: A2A06DF2A33A54FA

View file

@ -104,6 +104,7 @@ (define-module (guix build syscalls)
network-interface-netmask network-interface-netmask
network-interface-running? network-interface-running?
loopback-network-interface? loopback-network-interface?
arp-network-interface?
network-interface-address network-interface-address
set-network-interface-netmask set-network-interface-netmask
set-network-interface-up set-network-interface-up
@ -1160,6 +1161,7 @@ (define-as-needed IFF_UP #x1) ;Interface is up
(define-as-needed IFF_BROADCAST #x2) ;Broadcast address valid. (define-as-needed IFF_BROADCAST #x2) ;Broadcast address valid.
(define-as-needed IFF_LOOPBACK #x8) ;Is a loopback net. (define-as-needed IFF_LOOPBACK #x8) ;Is a loopback net.
(define-as-needed IFF_RUNNING #x40) ;interface RFC2863 OPER_UP (define-as-needed IFF_RUNNING #x40) ;interface RFC2863 OPER_UP
(define-as-needed IFF_NOARP #x80) ;ARP disabled or unsupported
(define IF_NAMESIZE 16) ;maximum interface name size (define IF_NAMESIZE 16) ;maximum interface name size
@ -1341,6 +1343,13 @@ (define (network-interface-running? name)
(close-port sock) (close-port sock)
(not (zero? (logand flags IFF_RUNNING))))) (not (zero? (logand flags IFF_RUNNING)))))
(define (arp-network-interface? name)
"Return true if NAME supports the Address Resolution Protocol."
(let* ((sock (socket SOCK_STREAM AF_INET 0))
(flags (network-interface-flags sock name)))
(close-port sock)
(zero? (logand flags IFF_NOARP))))
(define-as-needed (set-network-interface-flags socket name flags) (define-as-needed (set-network-interface-flags socket name flags)
"Set the flag of network interface NAME to FLAGS." "Set the flag of network interface NAME to FLAGS."
(let ((req (make-bytevector ifreq-struct-size))) (let ((req (make-bytevector ifreq-struct-size)))