socket_irix.go 3.0 KB

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