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.
This commit is contained in:
parent
4a30e84e61
commit
3ca337699a
|
@ -57,6 +57,8 @@
|
||||||
clone
|
clone
|
||||||
setns
|
setns
|
||||||
|
|
||||||
|
PF_PACKET
|
||||||
|
AF_PACKET
|
||||||
IFF_UP
|
IFF_UP
|
||||||
IFF_BROADCAST
|
IFF_BROADCAST
|
||||||
IFF_LOOPBACK
|
IFF_LOOPBACK
|
||||||
|
@ -506,7 +508,10 @@ bytevector BV at INDEX."
|
||||||
(else
|
(else
|
||||||
(error "unsupported socket address" sockaddr)))))
|
(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."
|
"Read a socket address from bytevector BV at INDEX."
|
||||||
(let ((family (bytevector-u16-native-ref bv index)))
|
(let ((family (bytevector-u16-native-ref bv index)))
|
||||||
(cond ((= family AF_INET)
|
(cond ((= family AF_INET)
|
||||||
|
@ -514,7 +519,9 @@ bytevector BV at INDEX."
|
||||||
((= family AF_INET6)
|
((= family AF_INET6)
|
||||||
(read-sockaddr-in6 bv index))
|
(read-sockaddr-in6 bv index))
|
||||||
(else
|
(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
|
(define %ioctl
|
||||||
;; The most terrible interface, live from Scheme.
|
;; The most terrible interface, live from Scheme.
|
||||||
|
|
Loading…
Reference in New Issue