guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/04: syscalls: Add 'set-network-interface-up'.


From: Ludovic Courtès
Subject: 03/04: syscalls: Add 'set-network-interface-up'.
Date: Sun, 17 May 2015 21:25:30 +0000

civodul pushed a commit to branch master
in repository guix.

commit 6944fdbdbd2339ee66f30e416806da9c7e8b6e01
Author: Ludovic Courtès <address@hidden>
Date:   Sun May 17 23:20:59 2015 +0200

    syscalls: Add 'set-network-interface-up'.
    
    * guix/build/syscalls.scm (set-network-interface-up): New procedure.
---
 guix/build/syscalls.scm |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm
index b62a8cc..5bc4595 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 <address@hidden>
+;;; Copyright © 2014, 2015 Ludovic Courtès <address@hidden>
 ;;;
 ;;; 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]