sys_aix.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright 2019 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Added for go1.11 compatibility
  5. // +build aix
  6. package ipv6
  7. import (
  8. "net"
  9. "syscall"
  10. "unsafe"
  11. "golang.org/x/net/internal/iana"
  12. "golang.org/x/net/internal/socket"
  13. )
  14. var (
  15. ctlOpts = [ctlMax]ctlOpt{
  16. ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass},
  17. ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit},
  18. ctlPacketInfo: {sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo},
  19. ctlNextHop: {sysIPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop},
  20. ctlPathMTU: {sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU},
  21. }
  22. sockOpts = map[int]*sockOpt{
  23. ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_TCLASS, Len: 4}},
  24. ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_UNICAST_HOPS, Len: 4}},
  25. ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_IF, Len: 4}},
  26. ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_HOPS, Len: 4}},
  27. ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_LOOP, Len: 4}},
  28. ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVTCLASS, Len: 4}},
  29. ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVHOPLIMIT, Len: 4}},
  30. ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPKTINFO, Len: 4}},
  31. ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPATHMTU, Len: 4}},
  32. ssoPathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}},
  33. ssoChecksum: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_CHECKSUM, Len: 4}},
  34. ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: sysICMP6_FILTER, Len: sizeofICMPv6Filter}},
  35. ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_JOIN_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq},
  36. ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_LEAVE_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq},
  37. }
  38. )
  39. func (sa *sockaddrInet6) setSockaddr(ip net.IP, i int) {
  40. sa.Len = sizeofSockaddrInet6
  41. sa.Family = syscall.AF_INET6
  42. copy(sa.Addr[:], ip)
  43. sa.Scope_id = uint32(i)
  44. }
  45. func (pi *inet6Pktinfo) setIfindex(i int) {
  46. pi.Ifindex = int32(i)
  47. }
  48. func (mreq *ipv6Mreq) setIfindex(i int) {
  49. mreq.Interface = uint32(i)
  50. }
  51. func (gr *groupReq) setGroup(grp net.IP) {
  52. sa := (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gr)) + 4))
  53. sa.Len = sizeofSockaddrInet6
  54. sa.Family = syscall.AF_INET6
  55. copy(sa.Addr[:], grp)
  56. }
  57. func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) {
  58. sa := (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 4))
  59. sa.Len = sizeofSockaddrInet6
  60. sa.Family = syscall.AF_INET6
  61. copy(sa.Addr[:], grp)
  62. sa = (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 132))
  63. sa.Len = sizeofSockaddrInet6
  64. sa.Family = syscall.AF_INET6
  65. copy(sa.Addr[:], src)
  66. }