socket_aix.go 2.3 KB

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