re PR go/69966 (libgo: Port syscall.SetsockoptUcred from golang)

PR go/69966
    syscall: Add new Getsockopt functions.
    
    Add GetsockoptICMPv6Filter, GetsockoptIPv6MTUInfo, GetsockoptUcred as
    appropriate.  These functions exist in the master library.
    
    For GCC PR 69966.

    Reviewed-on: https://go-review.googlesource.com/19960

From-SVN: r233747
This commit is contained in:
Ian Lance Taylor 2016-02-26 17:36:00 +00:00
parent 9ece21a6c5
commit 6b2cd37bd9
5 changed files with 38 additions and 2 deletions

View File

@ -1,4 +1,4 @@
156f5f0152797ac2afe5f23803aeb3c7b8f8418e 3de822d11255d439fac9717897b017aae2de18c2
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.

View File

@ -251,6 +251,13 @@ func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
return &value, err return &value, err
} }
func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
var value ICMPv6Filter
vallen := Socklen_t(SizeofICMPv6Filter)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
//sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen Socklen_t) (err error) //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen Socklen_t) (err error)
//setsockopt(s _C_int, level _C_int, optname _C_int, val *byte, vallen Socklen_t) _C_int //setsockopt(s _C_int, level _C_int, optname _C_int, val *byte, vallen Socklen_t) _C_int

View File

@ -80,3 +80,10 @@ func BindToDevice(fd int, device string) (err error) {
func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) { func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) {
return nil, EAFNOSUPPORT return nil, EAFNOSUPPORT
} }
func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
var value IPv6MTUInfo
vallen := Socklen_t(SizeofIPv6MTUInfo)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}

View File

@ -168,6 +168,20 @@ func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) {
return nil, EAFNOSUPPORT return nil, EAFNOSUPPORT
} }
func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
var value IPv6MTUInfo
vallen := Socklen_t(SizeofIPv6MTUInfo)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
func GetsockoptUcred(fd, level, opt int) (*Ucred, error) {
var value Ucred
vallen := Socklen_t(SizeofUcred)
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
return &value, err
}
//sysnb EpollCreate(size int) (fd int, err error) //sysnb EpollCreate(size int) (fd int, err error)
//epoll_create(size _C_int) _C_int //epoll_create(size _C_int) _C_int

View File

@ -870,6 +870,14 @@ if ! grep 'type ICMPv6Filter ' ${OUT} > /dev/null 2>&1; then
echo 'type ICMPv6Filter struct { Data [8]uint32 }' >> ${OUT} echo 'type ICMPv6Filter struct { Data [8]uint32 }' >> ${OUT}
fi fi
# The ip6_mtuinfo struct.
grep '^type _ip6_mtuinfo ' gen-sysinfo.go | \
sed -e 's/_ip6_mtuinfo/IPv6MTUInfo/' \
-e 's/ip6m_addr/Addr/' \
-e 's/_sockaddr_in6/RawSockaddrInet6/' \
-e 's/ip6m_mtu/Mtu/' \
>> ${OUT}
# Try to guess the type to use for fd_set. # Try to guess the type to use for fd_set.
fd_set=`grep '^type _fd_set ' gen-sysinfo.go || true` fd_set=`grep '^type _fd_set ' gen-sysinfo.go || true`
fds_bits_type="_C_long" fds_bits_type="_C_long"
@ -1464,7 +1472,7 @@ set cmsghdr Cmsghdr ip_mreq IPMreq ip_mreqn IPMreqn ipv6_mreq IPv6Mreq \
msghdr Msghdr nlattr NlAttr nlmsgerr NlMsgerr nlmsghdr NlMsghdr \ msghdr Msghdr nlattr NlAttr nlmsgerr NlMsgerr nlmsghdr NlMsghdr \
rtattr RtAttr rtgenmsg RtGenmsg rtmsg RtMsg rtnexthop RtNexthop \ rtattr RtAttr rtgenmsg RtGenmsg rtmsg RtMsg rtnexthop RtNexthop \
sock_filter SockFilter sock_fprog SockFprog ucred Ucred \ sock_filter SockFilter sock_fprog SockFprog ucred Ucred \
icmp6_filter ICMPv6Filter icmp6_filter ICMPv6Filter ip6_mtuinfo IPv6MTUInfo
while test $# != 0; do while test $# != 0; do
nc=$1 nc=$1
ngo=$2 ngo=$2