diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-30 23:57:42 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-01-30 23:57:42 +0000 |
commit | 4a1a8596116c82aa93d6224ed945cb80ecb609b7 (patch) | |
tree | 3f7e5e9d1fb2eaaf942a44773b8e5fa8a8f538b1 /libgo/go/syscall/socket.go | |
parent | 842f302e919922421f5dcc87846e4aac358b0bc2 (diff) | |
download | gcc-4a1a8596116c82aa93d6224ed945cb80ecb609b7.zip gcc-4a1a8596116c82aa93d6224ed945cb80ecb609b7.tar.gz gcc-4a1a8596116c82aa93d6224ed945cb80ecb609b7.tar.bz2 |
syscall: Support socket control messages.
From-SVN: r183745
Diffstat (limited to 'libgo/go/syscall/socket.go')
-rw-r--r-- | libgo/go/syscall/socket.go | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/libgo/go/syscall/socket.go b/libgo/go/syscall/socket.go index 517b5b9..7a2e95c 100644 --- a/libgo/go/syscall/socket.go +++ b/libgo/go/syscall/socket.go @@ -17,12 +17,12 @@ import "unsafe" var SocketDisableIPv6 bool type Sockaddr interface { - sockaddr() (ptr *RawSockaddrAny, len Socklen_t, err error) // lowercase; only we can define Sockaddrs + sockaddr() (ptr *RawSockaddrAny, len Socklen_t, err error) // lowercase; only we can define Sockaddrs } type RawSockaddrAny struct { Addr RawSockaddr - Pad [12]int8 + Pad [12]int8 } const SizeofSockaddrAny = 0x1c @@ -30,7 +30,7 @@ const SizeofSockaddrAny = 0x1c type SockaddrInet4 struct { Port int Addr [4]byte - raw RawSockaddrInet4 + raw RawSockaddrInet4 } func (sa *SockaddrInet4) sockaddr() (*RawSockaddrAny, Socklen_t, error) { @@ -40,7 +40,7 @@ func (sa *SockaddrInet4) sockaddr() (*RawSockaddrAny, Socklen_t, error) { sa.raw.Family = AF_INET n := sa.raw.setLen() p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) - p[0] = byte(sa.Port>>8) + p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) for i := 0; i < len(sa.Addr); i++ { sa.raw.Addr[i] = sa.Addr[i] @@ -49,10 +49,10 @@ func (sa *SockaddrInet4) sockaddr() (*RawSockaddrAny, Socklen_t, error) { } type SockaddrInet6 struct { - Port int + Port int ZoneId uint32 - Addr [16]byte - raw RawSockaddrInet6 + Addr [16]byte + raw RawSockaddrInet6 } func (sa *SockaddrInet6) sockaddr() (*RawSockaddrAny, Socklen_t, error) { @@ -62,7 +62,7 @@ func (sa *SockaddrInet6) sockaddr() (*RawSockaddrAny, Socklen_t, error) { sa.raw.Family = AF_INET6 n := sa.raw.setLen() p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) - p[0] = byte(sa.Port>>8) + p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId for i := 0; i < len(sa.Addr); i++ { @@ -73,7 +73,7 @@ func (sa *SockaddrInet6) sockaddr() (*RawSockaddrAny, Socklen_t, error) { type SockaddrUnix struct { Name string - raw RawSockaddrUnix + raw RawSockaddrUnix } func (sa *SockaddrUnix) sockaddr() (*RawSockaddrAny, Socklen_t, error) { @@ -268,12 +268,12 @@ func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (err error) { } type Linger struct { - Onoff int32; - Linger int32; + Onoff int32 + Linger int32 } func SetsockoptLinger(fd, level, opt int, l *Linger) (err error) { - return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(l)), Socklen_t(unsafe.Sizeof(*l))); + return setsockopt(fd, level, opt, (*byte)(unsafe.Pointer(l)), Socklen_t(unsafe.Sizeof(*l))) } func SetsockoptIPMreq(fd, level, opt int, mreq *IPMreq) (err error) { @@ -405,3 +405,7 @@ func (iov *Iovec) SetLen(length int) { func (msghdr *Msghdr) SetControllen(length int) { msghdr.Controllen = Msghdr_controllen_t(length) } + +func (cmsg *Cmsghdr) SetLen(length int) { + cmsg.Len = Cmsghdr_len_t(length) +} |