Debian Codegraph @

libgo/go/syscall/socket_irix.go

raw
1 // socket_irix.go -- Socket handling specific to IRIX 6.
2
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.
6
7 //go:build irix
8 // +build irix
9
10 package syscall
11
12 const SizeofSockaddrInet4 = 16
13 const SizeofSockaddrInet6 = 28
14 const SizeofSockaddrUnix = 110
15
16 type RawSockaddrInet4 struct {
17 Family uint16
18 Port uint16
19 Addr [4]byte /* in_addr */
20 Zero [8]uint8
21 }
22
23 func (sa *RawSockaddrInet4) setLen() Socklen_t {
24 return SizeofSockaddrInet4
25 }
26
27 type RawSockaddrInet6 struct {
28 Family uint16
29 Port uint16
30 Flowinfo uint32
31 Addr [16]byte /* in6_addr */
32 Scope_id uint32
33 }
34
35 func (sa *RawSockaddrInet6) setLen() Socklen_t {
36 return SizeofSockaddrInet6
37 }
38
39 type RawSockaddrUnix struct {
40 Family uint16
41 Path [108]int8
42 }
43
44 func (sa *RawSockaddrUnix) setLen(int) {
45 }
46
47 func (sa *RawSockaddrUnix) getLen() (int, error) {
48 if sa.Path[0] == 0 {
49 // "Abstract" Unix domain socket.
50 // Rewrite leading NUL as @ for textual display.
51 // (This is the standard convention.)
52 // Not friendly to overwrite in place,
53 // but the callers below don't care.
54 sa.Path[0] = '@'
55 }
56
57 // Assume path ends at NUL.
58 // This is not technically the GNU/Linux semantics for
59 // abstract Unix domain sockets--they are supposed
60 // to be uninterpreted fixed-size binary blobs--but
61 // everyone uses this convention.
62 n := 0
63 for n < len(sa.Path)-3 && sa.Path[n] != 0 {
64 n++
65 }
66
67 return n, nil
68 }
69
70 func (sa *RawSockaddrUnix) adjustAbstract(sl Socklen_t) Socklen_t {
71 return sl
72 }
73
74 type RawSockaddr struct {
75 Family uint16
76 Data [14]int8
77 }
78
79 // BindToDevice binds the socket associated with fd to device.
80 func BindToDevice(fd int, device string) (err error) {
81 return ENOSYS
82 }
83
84 // <netdb.h> only provides struct addrinfo, AI_* and EAI_* if _NO_XOPEN4
85 // && _NO_XOPEN5, but -D_XOPEN_SOURCE=500 is required for msg_control etc.
86 // in struct msghgr, so simply provide them here.
87 type Addrinfo struct {
88 Ai_flags int32
89 Ai_family int32
90 Ai_socktype int32
91 Ai_protocol int32
92 Ai_addrlen int32
93 Ai_canonname *uint8
94 Ai_addr *_sockaddr
95 Ai_next *Addrinfo
96 }
97
98 const (
99 AI_PASSIVE = 0x00000001
100 AI_CANONNAME = 0x00000002
101 AI_NUMERICHOST = 0x00000004
102 AI_NUMERICSERV = 0x00000008
103 AI_ALL = 0x00000100
104 AI_ADDRCONFIG = 0x00000400
105 AI_V4MAPPED = 0x00000800
106 AI_DEFAULT = (AI_V4MAPPED | AI_ADDRCONFIG)
107 )
108
109 const (
110 EAI_ADDRFAMILY = 1
111 EAI_AGAIN = 2
112 EAI_BADFLAGS = 3
113 EAI_FAIL = 4
114 EAI_FAMILY = 5
115 EAI_MEMORY = 6
116 EAI_NODATA = 7
117 EAI_NONAME = 8
118 EAI_SERVICE = 9
119 EAI_SOCKTYPE = 10
120 EAI_SYSTEM = 11
121 EAI_BADHINTS = 12
122 EAI_OVERFLOW = 13
123 EAI_MAX = 14
124 )
125
126 func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) {
127 return nil, EAFNOSUPPORT
128 }
129
130 // <netinet/in.h.h> only provides IPV6_* etc. if _NO_XOPEN4 && _NO_XOPEN5,
131 // so as above simply provide them here.
132 const (
133 IPV6_UNICAST_HOPS = 48
134 IPV6_MULTICAST_IF = IP_MULTICAST_IF
135 IPV6_MULTICAST_HOPS = IP_MULTICAST_TTL
136 IPV6_MULTICAST_LOOP = IP_MULTICAST_LOOP
137 )