aboutsummaryrefslogtreecommitdiff
path: root/guix/build/syscalls.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-05-17 23:20:59 +0200
committerLudovic Courtès <ludo@gnu.org>2015-05-17 23:20:59 +0200
commit6944fdbdbd2339ee66f30e416806da9c7e8b6e01 (patch)
tree6c00b9bc67dc39d06c3e546be4f0eab2d3e37b82 /guix/build/syscalls.scm
parent152dd61ca4fcbd268a43ebe202917937ea1647a2 (diff)
downloadgnu-guix-6944fdbdbd2339ee66f30e416806da9c7e8b6e01.tar
gnu-guix-6944fdbdbd2339ee66f30e416806da9c7e8b6e01.tar.gz
syscalls: Add 'set-network-interface-up'.
* guix/build/syscalls.scm (set-network-interface-up): New procedure.
Diffstat (limited to 'guix/build/syscalls.scm')
-rw-r--r--guix/build/syscalls.scm16
1 files changed, 15 insertions, 1 deletions
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index b62a8cce64..5bc4595d08 100644
--- a/guix/build/syscalls.scm
+++ b/guix/build/syscalls.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -46,6 +46,7 @@
network-interface-address
set-network-interface-flags
set-network-interface-address
+ set-network-interface-up
configure-network-interface))
;;; Commentary:
@@ -552,4 +553,17 @@ the same type as that returned by 'make-socket-address'."
(lambda ()
(close-port sock)))))
+(define* (set-network-interface-up name
+ #:key (family AF_INET))
+ "Turn up the interface NAME."
+ (let ((sock (socket family SOCK_STREAM 0)))
+ (dynamic-wind
+ (const #t)
+ (lambda ()
+ (let ((flags (network-interface-flags sock name)))
+ (set-network-interface-flags sock name
+ (logior flags IFF_UP))))
+ (lambda ()
+ (close-port sock)))))
+
;;; syscalls.scm ends here