From 3ca337699a2feb2a42f3661b7321a5e7d5fec594 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 25 Jul 2015 12:22:30 +0200 Subject: 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. --- guix/build/syscalls.scm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'guix') 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) ; +(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. -- cgit v1.2.3