1 // socket_irix.go -- Socket handling specific to IRIX 6.
3 // Copyright 2011 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
11 const SizeofSockaddrInet4
= 16
12 const SizeofSockaddrInet6
= 28
13 const SizeofSockaddrUnix
= 110
15 type RawSockaddrInet4
struct {
18 Addr
[4]byte /* in_addr */
22 func (sa
*RawSockaddrInet4
) setLen() Socklen_t
{
23 return SizeofSockaddrInet4
26 type RawSockaddrInet6
struct {
30 Addr
[16]byte /* in6_addr */
34 func (sa
*RawSockaddrInet6
) setLen() Socklen_t
{
35 return SizeofSockaddrInet6
38 type RawSockaddrUnix
struct {
43 func (sa
*RawSockaddrUnix
) setLen(int) {
46 func (sa
*RawSockaddrUnix
) getLen() (int, error
) {
48 // "Abstract" Unix domain socket.
49 // Rewrite leading NUL as @ for textual display.
50 // (This is the standard convention.)
51 // Not friendly to overwrite in place,
52 // but the callers below don't care.
56 // Assume path ends at NUL.
57 // This is not technically the GNU/Linux semantics for
58 // abstract Unix domain sockets--they are supposed
59 // to be uninterpreted fixed-size binary blobs--but
60 // everyone uses this convention.
62 for n
< len(sa
.Path
)-3 && sa
.Path
[n
] != 0 {
69 func (sa
*RawSockaddrUnix
) adjustAbstract(sl Socklen_t
) Socklen_t
{
73 type RawSockaddr
struct {
78 // BindToDevice binds the socket associated with fd to device.
79 func BindToDevice(fd
int, device
string) (err error
) {
83 // <netdb.h> only provides struct addrinfo, AI_* and EAI_* if _NO_XOPEN4
84 // && _NO_XOPEN5, but -D_XOPEN_SOURCE=500 is required for msg_control etc.
85 // in struct msghgr, so simply provide them here.
86 type Addrinfo
struct {
98 AI_PASSIVE
= 0x00000001
99 AI_CANONNAME
= 0x00000002
100 AI_NUMERICHOST
= 0x00000004
101 AI_NUMERICSERV
= 0x00000008
103 AI_ADDRCONFIG
= 0x00000400
104 AI_V4MAPPED
= 0x00000800
105 AI_DEFAULT
= (AI_V4MAPPED | AI_ADDRCONFIG
)
125 func anyToSockaddrOS(rsa
*RawSockaddrAny
) (Sockaddr
, error
) {
126 return nil, EAFNOSUPPORT
129 // <netinet/in.h.h> only provides IPV6_* etc. if _NO_XOPEN4 && _NO_XOPEN5,
130 // so as above simply provide them here.
132 IPV6_UNICAST_HOPS
= 48
133 IPV6_MULTICAST_IF
= IP_MULTICAST_IF
134 IPV6_MULTICAST_HOPS
= IP_MULTICAST_TTL
135 IPV6_MULTICAST_LOOP
= IP_MULTICAST_LOOP