diff options
author | Ludovic Courtès <ludo@gnu.org> | 2015-07-25 12:22:30 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2015-07-25 14:43:44 +0200 |
commit | 3ca337699a2feb2a42f3661b7321a5e7d5fec594 (patch) | |
tree | 03131fc0f44ebaced68a97995046b0535ca17915 | |
parent | 4a30e84e6182686fde93504e07616fe8e70d94d5 (diff) | |
download | guix-3ca337699a2feb2a42f3661b7321a5e7d5fec594.tar guix-3ca337699a2feb2a42f3661b7321a5e7d5fec594.tar.gz |
syscalls: 'read-socket-address' gracefully handles unsupported families.
* guix/build/syscalls.scm (PF_PACKET, AF_PACKET): New variables.
(read-socket-address): Make 'index' optional. Return (vector FAMILY) when
FAMILY is neither AF_INET nor AF_INET6.
-rw-r--r-- | guix/build/syscalls.scm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 73c54372e1..69abea1ef6 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -57,6 +57,8 @@ clone setns + PF_PACKET + AF_PACKET IFF_UP IFF_BROADCAST IFF_LOOPBACK @@ -506,7 +508,10 @@ bytevector BV at INDEX." (else (error "unsupported socket address" sockaddr))))) -(define (read-socket-address bv index) +(define PF_PACKET 17) ;<bits/socket.h> +(define AF_PACKET PF_PACKET) + +(define* (read-socket-address bv #:optional (index 0)) "Read a socket address from bytevector BV at INDEX." (let ((family (bytevector-u16-native-ref bv index))) (cond ((= family AF_INET) @@ -514,7 +519,9 @@ bytevector BV at INDEX." ((= family AF_INET6) (read-sockaddr-in6 bv index)) (else - "unsupported socket address family" family)))) + ;; XXX: Unsupported address family, such as AF_PACKET. Return a + ;; vector such that the vector can at least call 'sockaddr:fam'. + (vector family))))) (define %ioctl ;; The most terrible interface, live from Scheme. |