mirror of
https://github.com/golang/go
synced 2024-11-27 05:01:19 -07:00
undo CL 107280044 / ee11f19bc514
preparing for the syscall package freeze. ««« original CL description syscall: consolidate, simplify socket options for Unix-like systems Also exposes common socket option functions on Solaris. Update #7174 Update #7175 LGTM=aram R=golang-codereviews, aram CC=golang-codereviews https://golang.org/cl/107280044 »»» LGTM=r R=r CC=golang-codereviews https://golang.org/cl/121880043
This commit is contained in:
parent
3bf75e691f
commit
678ba85e53
@ -309,6 +309,48 @@ func Getsockname(fd int) (sa Sockaddr, err error) {
|
||||
}
|
||||
|
||||
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||
|
||||
func GetsockoptByte(fd, level, opt int) (value byte, err error) {
|
||||
var n byte
|
||||
vallen := _Socklen(1)
|
||||
err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
|
||||
return n, err
|
||||
}
|
||||
|
||||
func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) {
|
||||
vallen := _Socklen(4)
|
||||
err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||
return value, err
|
||||
}
|
||||
|
||||
func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
|
||||
var value IPMreq
|
||||
vallen := _Socklen(SizeofIPMreq)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
|
||||
var value IPv6Mreq
|
||||
vallen := _Socklen(SizeofIPv6Mreq)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
|
||||
var value IPv6MTUInfo
|
||||
vallen := _Socklen(SizeofIPv6MTUInfo)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
|
||||
var value ICMPv6Filter
|
||||
vallen := _Socklen(SizeofICMPv6Filter)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||
//sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
|
||||
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||
|
@ -440,6 +440,19 @@ func Getsockname(fd int) (sa Sockaddr, err error) {
|
||||
return anyToSockaddr(&rsa)
|
||||
}
|
||||
|
||||
func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) {
|
||||
vallen := _Socklen(4)
|
||||
err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen)
|
||||
return value, err
|
||||
}
|
||||
|
||||
func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
|
||||
var value IPMreq
|
||||
vallen := _Socklen(SizeofIPMreq)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
|
||||
var value IPMreqn
|
||||
vallen := _Socklen(SizeofIPMreqn)
|
||||
@ -447,6 +460,27 @@ func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
|
||||
return &value, err
|
||||
}
|
||||
|
||||
func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
|
||||
var value IPv6Mreq
|
||||
vallen := _Socklen(SizeofIPv6Mreq)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
|
||||
var value IPv6MTUInfo
|
||||
vallen := _Socklen(SizeofIPv6MTUInfo)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
|
||||
return &value, err
|
||||
}
|
||||
|
||||
func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
|
||||
var value ICMPv6Filter
|
||||
vallen := _Socklen(SizeofICMPv6Filter)
|
||||
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(SizeofUcred)
|
||||
|
@ -207,6 +207,13 @@ func Getpeername(fd int) (sa Sockaddr, err error) {
|
||||
return anyToSockaddr(&rsa)
|
||||
}
|
||||
|
||||
func GetsockoptInt(fd, level, opt int) (value int, err error) {
|
||||
var n int32
|
||||
vallen := _Socklen(4)
|
||||
err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen)
|
||||
return int(n), err
|
||||
}
|
||||
|
||||
func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, err error) {
|
||||
var rsa RawSockaddrAny
|
||||
var len _Socklen = SizeofSockaddrAny
|
||||
@ -227,73 +234,24 @@ func Sendto(fd int, p []byte, flags int, to Sockaddr) (err error) {
|
||||
return sendto(fd, p, flags, ptr, n)
|
||||
}
|
||||
|
||||
func GetsockoptByte(fd, level, opt int) (byte, error) {
|
||||
var v byte
|
||||
l := _Socklen(1)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&v), &l)
|
||||
return v, err
|
||||
}
|
||||
|
||||
func GetsockoptInt(fd, level, opt int) (int, error) {
|
||||
var v int32
|
||||
l := _Socklen(4)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&v), &l)
|
||||
return int(v), err
|
||||
}
|
||||
|
||||
func GetsockoptInet4Addr(fd, level, opt int) ([4]byte, error) {
|
||||
var v [4]byte
|
||||
l := _Socklen(4)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&v[0]), &l)
|
||||
return v, err
|
||||
}
|
||||
|
||||
func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) {
|
||||
var v IPMreq
|
||||
l := _Socklen(SizeofIPMreq)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&v), &l)
|
||||
return &v, err
|
||||
}
|
||||
|
||||
func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) {
|
||||
var v IPv6Mreq
|
||||
l := _Socklen(SizeofIPv6Mreq)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&v), &l)
|
||||
return &v, err
|
||||
}
|
||||
|
||||
func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
|
||||
var v IPv6MTUInfo
|
||||
l := _Socklen(SizeofIPv6MTUInfo)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&v), &l)
|
||||
return &v, err
|
||||
}
|
||||
|
||||
func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) {
|
||||
var v ICMPv6Filter
|
||||
l := _Socklen(SizeofICMPv6Filter)
|
||||
err := getsockopt(fd, level, opt, unsafe.Pointer(&v), &l)
|
||||
return &v, err
|
||||
}
|
||||
|
||||
func SetsockoptByte(fd, level, opt int, value byte) error {
|
||||
func SetsockoptByte(fd, level, opt int, value byte) (err error) {
|
||||
return setsockopt(fd, level, opt, unsafe.Pointer(&value), 1)
|
||||
}
|
||||
|
||||
func SetsockoptInt(fd, level, opt int, value int) error {
|
||||
n := int32(value)
|
||||
func SetsockoptInt(fd, level, opt int, value int) (err error) {
|
||||
var n = int32(value)
|
||||
return setsockopt(fd, level, opt, unsafe.Pointer(&n), 4)
|
||||
}
|
||||
|
||||
func SetsockoptInet4Addr(fd, level, opt int, value [4]byte) error {
|
||||
func SetsockoptInet4Addr(fd, level, opt int, value [4]byte) (err error) {
|
||||
return setsockopt(fd, level, opt, unsafe.Pointer(&value[0]), 4)
|
||||
}
|
||||
|
||||
func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) error {
|
||||
func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) (err error) {
|
||||
return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPMreq)
|
||||
}
|
||||
|
||||
func SetsockoptIPv6Mreq(fd, level, opt int, mreq *IPv6Mreq) error {
|
||||
func SetsockoptIPv6Mreq(fd, level, opt int, mreq *IPv6Mreq) (err error) {
|
||||
return setsockopt(fd, level, opt, unsafe.Pointer(mreq), SizeofIPv6Mreq)
|
||||
}
|
||||
|
||||
@ -301,15 +259,15 @@ func SetsockoptICMPv6Filter(fd, level, opt int, filter *ICMPv6Filter) error {
|
||||
return setsockopt(fd, level, opt, unsafe.Pointer(filter), SizeofICMPv6Filter)
|
||||
}
|
||||
|
||||
func SetsockoptLinger(fd, level, opt int, l *Linger) error {
|
||||
func SetsockoptLinger(fd, level, opt int, l *Linger) (err error) {
|
||||
return setsockopt(fd, level, opt, unsafe.Pointer(l), SizeofLinger)
|
||||
}
|
||||
|
||||
func SetsockoptString(fd, level, opt int, s string) error {
|
||||
func SetsockoptString(fd, level, opt int, s string) (err error) {
|
||||
return setsockopt(fd, level, opt, unsafe.Pointer(&[]byte(s)[0]), uintptr(len(s)))
|
||||
}
|
||||
|
||||
func SetsockoptTimeval(fd, level, opt int, tv *Timeval) error {
|
||||
func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error) {
|
||||
return setsockopt(fd, level, opt, unsafe.Pointer(tv), unsafe.Sizeof(*tv))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user