Debian Codegraph @

libgo/go/syscall/socket_aix.go

raw
1 // socket_aix.go -- Socket handling specific to AIX.
2
3 // Copyright 2017 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 package syscall
8
9 import "unsafe"
10
11 const SizeofSockaddrInet4 = 16
12 const SizeofSockaddrInet6 = 28
13 const SizeofSockaddrUnix = 1025
14 const SizeofSockaddrDatalink = 128
15
16 type RawSockaddrInet4 struct {
17 Len uint8
18 Family uint8
19 Port uint16
20 Addr [4]byte /* in_addr */
21 Zero [8]uint8
22 }
23
24 func (sa *RawSockaddrInet4) setLen() Socklen_t {
25 sa.Len = SizeofSockaddrInet4
26 return SizeofSockaddrInet4
27 }
28
29 type RawSockaddrInet6 struct {
30 Len uint8
31 Family uint8
32 Port uint16
33 Flowinfo uint32
34 Addr [16]byte /* in6_addr */
35 Scope_id uint32
36 }
37
38 func (sa *RawSockaddrInet6) setLen() Socklen_t {
39 sa.Len = SizeofSockaddrInet6
40 return SizeofSockaddrInet6
41 }
42
43 type RawSockaddrUnix struct {
44 Len uint8
45 Family uint8
46 Path [1023]int8
47 }
48
49 func (sa *RawSockaddrUnix) setLen(n int) {
50 sa.Len = uint8(3 + n) // 2 for Family, Len; 1 for NUL.
51 }
52
53 func (sa *RawSockaddrUnix) getLen() (int, error) {
54 // Some versions of AIX have a bug in getsockname (see IV78655).
55 // We can't rely on sa.Len being set correctly.
56 n := SizeofSockaddrUnix - 3 // substract leading Family, Len, terminating NUL.
57 for i := 0; i < n; i++ {
58 if sa.Path[i] == 0 {
59 n = i
60 break
61 }
62 }
63 return n, nil
64 }
65
66 func (sa *RawSockaddrUnix) adjustAbstract(sl Socklen_t) Socklen_t {
67 return sl
68 }
69
70 type RawSockaddr struct {
71 Len uint8
72 Family uint8
73 Data [14]int8
74 }
75
76 // BindToDevice binds the socket associated with fd to device.
77 func BindToDevice(fd int, device string) (err error) {
78 return ENOSYS
79 }
80
81 func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) {
82 return nil, EAFNOSUPPORT
83 }
84
85 func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) {
86 var value IPv6MTUInfo
87 vallen := Socklen_t(SizeofIPv6MTUInfo)
88 err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
89 return &value, err
90 }
91
92 type SockaddrDatalink struct {
93 Len uint8
94 Family uint8
95 Index uint16
96 Type uint8
97 Nlen uint8
98 Alen uint8
99 Slen uint8
100 Data [120]uint8
101 raw RawSockaddrDatalink
102 }
103
104 type RawSockaddrDatalink struct {
105 Len uint8
106 Family uint8
107 Index uint16
108 Type uint8
109 Nlen uint8
110 Alen uint8
111 Slen uint8
112 Data [120]uint8
113 }