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// +build irix 8 9package syscall 10 11const SizeofSockaddrInet4 = 16 12const SizeofSockaddrInet6 = 28 13const SizeofSockaddrUnix = 110 14 15type RawSockaddrInet4 struct { 16 Family uint16 17 Port uint16 18 Addr [4]byte /* in_addr */ 19 Zero [8]uint8 20} 21 22func (sa *RawSockaddrInet4) setLen() Socklen_t { 23 return SizeofSockaddrInet4 24} 25 26type RawSockaddrInet6 struct { 27 Family uint16 28 Port uint16 29 Flowinfo uint32 30 Addr [16]byte /* in6_addr */ 31 Scope_id uint32 32} 33 34func (sa *RawSockaddrInet6) setLen() Socklen_t { 35 return SizeofSockaddrInet6 36} 37 38type RawSockaddrUnix struct { 39 Family uint16 40 Path [108]int8 41} 42 43func (sa *RawSockaddrUnix) setLen(int) { 44} 45 46func (sa *RawSockaddrUnix) getLen() (int, error) { 47 if sa.Path[0] == 0 { 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. 53 sa.Path[0] = '@' 54 } 55 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. 61 n := 0 62 for n < len(sa.Path)-3 && sa.Path[n] != 0 { 63 n++ 64 } 65 66 return n, nil 67} 68 69func (sa *RawSockaddrUnix) adjustAbstract(sl Socklen_t) Socklen_t { 70 return sl 71} 72 73type RawSockaddr struct { 74 Family uint16 75 Data [14]int8 76} 77 78// BindToDevice binds the socket associated with fd to device. 79func BindToDevice(fd int, device string) (err error) { 80 return ENOSYS 81} 82 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. 86type Addrinfo struct { 87 Ai_flags int32 88 Ai_family int32 89 Ai_socktype int32 90 Ai_protocol int32 91 Ai_addrlen int32 92 Ai_canonname *uint8 93 Ai_addr *_sockaddr 94 Ai_next *Addrinfo 95} 96 97const ( 98 AI_PASSIVE = 0x00000001 99 AI_CANONNAME = 0x00000002 100 AI_NUMERICHOST = 0x00000004 101 AI_NUMERICSERV = 0x00000008 102 AI_ALL = 0x00000100 103 AI_ADDRCONFIG = 0x00000400 104 AI_V4MAPPED = 0x00000800 105 AI_DEFAULT = (AI_V4MAPPED | AI_ADDRCONFIG) 106) 107 108const ( 109 EAI_ADDRFAMILY = 1 110 EAI_AGAIN = 2 111 EAI_BADFLAGS = 3 112 EAI_FAIL = 4 113 EAI_FAMILY = 5 114 EAI_MEMORY = 6 115 EAI_NODATA = 7 116 EAI_NONAME = 8 117 EAI_SERVICE = 9 118 EAI_SOCKTYPE = 10 119 EAI_SYSTEM = 11 120 EAI_BADHINTS = 12 121 EAI_OVERFLOW = 13 122 EAI_MAX = 14 123) 124 125func anyToSockaddrOS(rsa *RawSockaddrAny) (Sockaddr, error) { 126 return nil, EAFNOSUPPORT 127} 128 129// <netinet/in.h.h> only provides IPV6_* etc. if _NO_XOPEN4 && _NO_XOPEN5, 130// so as above simply provide them here. 131const ( 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 136) 137