mirror of
https://github.com/golang/go
synced 2024-11-22 03:34:40 -07:00
net, syscall: return source address in Recvmsg
R=rsc CC=golang-dev https://golang.org/cl/3766042
This commit is contained in:
parent
655da99627
commit
3a97119517
@ -417,7 +417,7 @@ func (fd *netFD) ReadMsg(p []byte, oob []byte) (n, oobn, flags int, sa syscall.S
|
|||||||
var oserr os.Error
|
var oserr os.Error
|
||||||
for {
|
for {
|
||||||
var errno int
|
var errno int
|
||||||
n, oobn, flags, errno = syscall.Recvmsg(fd.sysfd, p, oob, sa, 0)
|
n, oobn, flags, sa, errno = syscall.Recvmsg(fd.sysfd, p, oob, 0)
|
||||||
if errno == syscall.EAGAIN && fd.rdeadline >= 0 {
|
if errno == syscall.EAGAIN && fd.rdeadline >= 0 {
|
||||||
pollserver.WaitRead(fd)
|
pollserver.WaitRead(fd)
|
||||||
continue
|
continue
|
||||||
|
@ -485,8 +485,8 @@ func Futimes(fd int, tv []Timeval) (errno int) {
|
|||||||
|
|
||||||
//sys fcntl(fd int, cmd int, arg int) (val int, errno int)
|
//sys fcntl(fd int, cmd int, arg int) (val int, errno int)
|
||||||
|
|
||||||
func Recvmsg(fd int, p, oob []byte, from Sockaddr, flags int) (n, oobn int, recvflags int, errno int) {
|
func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, errno int) {
|
||||||
return 0, 0, 0, EAFNOSUPPORT
|
return 0, 0, 0, nil, EAFNOSUPPORT
|
||||||
}
|
}
|
||||||
|
|
||||||
func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (errno int) {
|
func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (errno int) {
|
||||||
|
@ -450,7 +450,7 @@ func Sendto(fd int, p []byte, flags int, to Sockaddr) (errno int) {
|
|||||||
return sendto(fd, p, flags, ptr, n)
|
return sendto(fd, p, flags, ptr, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Recvmsg(fd int, p, oob []byte, from Sockaddr, flags int) (n, oobn int, recvflags int, errno int) {
|
func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, errno int) {
|
||||||
var msg Msghdr
|
var msg Msghdr
|
||||||
var rsa RawSockaddrAny
|
var rsa RawSockaddrAny
|
||||||
msg.Name = (*byte)(unsafe.Pointer(&rsa))
|
msg.Name = (*byte)(unsafe.Pointer(&rsa))
|
||||||
@ -477,6 +477,10 @@ func Recvmsg(fd int, p, oob []byte, from Sockaddr, flags int) (n, oobn int, recv
|
|||||||
}
|
}
|
||||||
oobn = int(msg.Controllen)
|
oobn = int(msg.Controllen)
|
||||||
recvflags = int(msg.Flags)
|
recvflags = int(msg.Flags)
|
||||||
|
// source address is only specified if the socket is unconnected
|
||||||
|
if rsa.Addr.Family != 0 {
|
||||||
|
from, errno = anyToSockaddr(&rsa)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user