github.com/llvm-mirror/llgo@v0.0.0-20190322182713-bf6f0a60fce1/third_party/gofrontend/libgo/go/syscall/socket_irix.go (about)

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