1 // socket_aix.go -- Socket handling specific to AIX.
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.
11 const SizeofSockaddrInet4
= 16
12 const SizeofSockaddrInet6
= 28
13 const SizeofSockaddrUnix
= 1025
15 type RawSockaddrInet4
struct {
19 Addr
[4]byte /* in_addr */
23 func (sa
*RawSockaddrInet4
) setLen() Socklen_t
{
24 sa
.Len
= SizeofSockaddrInet4
25 return SizeofSockaddrInet4
28 type RawSockaddrInet6
struct {
33 Addr
[16]byte /* in6_addr */
37 func (sa
*RawSockaddrInet6
) setLen() Socklen_t
{
38 sa
.Len
= SizeofSockaddrInet6
39 return SizeofSockaddrInet6
42 type RawSockaddrUnix
struct {
48 func (sa
*RawSockaddrUnix
) setLen(n
int) {
49 sa
.Len
= uint8(3 + n
) // 2 for Family, Len; 1 for NUL.
52 func (sa
*RawSockaddrUnix
) getLen() (int, error
) {
53 // Some versions of AIX have a bug in getsockname (see IV78655).
54 // We can't rely on sa.Len being set correctly.
55 n
:= SizeofSockaddrUnix
- 3 // substract leading Family, Len, terminating NUL.
56 for i
:= 0; i
< n
; i
++ {
65 func (sa
*RawSockaddrUnix
) adjustAbstract(sl Socklen_t
) Socklen_t
{
69 type RawSockaddr
struct {
75 // BindToDevice binds the socket associated with fd to device.
76 func BindToDevice(fd
int, device
string) (err error
) {
80 func anyToSockaddrOS(rsa
*RawSockaddrAny
) (Sockaddr
, error
) {
81 return nil, EAFNOSUPPORT
84 func GetsockoptIPv6MTUInfo(fd
, level
, opt
int) (*IPv6MTUInfo
, error
) {
86 vallen
:= Socklen_t(SizeofIPv6MTUInfo
)
87 err
:= getsockopt(fd
, level
, opt
, unsafe
.Pointer(&value
), &vallen
)