mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-06 13:10:33 +02:00
syscalls: Add bindings for SIOCGIFNETMASK and SIOCSIFNETMASK.
* guix/build/syscalls.scm (SIOCGIFNETMASK, SIOCSIFNETMASK): New
variables.
(set-network-interface-netmask, network-interface-netmask): New
procedures.
* tests/syscalls.scm ("network-interface-netmask lo")
("set-network-interface-netmask"): New tests.
This commit is contained in:
@@ -326,6 +326,27 @@
|
||||
;; We get EPERM with Linux 3.18ish and EACCES with 2.6.32.
|
||||
(memv (system-error-errno args) (list EPERM EACCES))))))
|
||||
|
||||
(test-equal "network-interface-netmask lo"
|
||||
(make-socket-address AF_INET (inet-pton AF_INET "255.0.0.0") 0)
|
||||
(let* ((sock (socket AF_INET SOCK_STREAM 0))
|
||||
(addr (network-interface-netmask sock "lo")))
|
||||
(close-port sock)
|
||||
addr))
|
||||
|
||||
(test-skip (if (zero? (getuid)) 1 0))
|
||||
(test-assert "set-network-interface-netmask"
|
||||
(let ((sock (socket AF_INET SOCK_STREAM 0)))
|
||||
(catch 'system-error
|
||||
(lambda ()
|
||||
(set-network-interface-netmask sock "nonexistent"
|
||||
(make-socket-address
|
||||
AF_INET
|
||||
(inet-pton AF_INET "255.0.0.0")
|
||||
0)))
|
||||
(lambda args
|
||||
(close-port sock)
|
||||
(memv (system-error-errno args) (list EPERM EACCES))))))
|
||||
|
||||
(test-equal "network-interfaces returns one or more interfaces"
|
||||
'(#t #t #t)
|
||||
(match (network-interfaces)
|
||||
|
||||
Reference in New Issue
Block a user