golang.org/x/net@v0.25.1-0.20240516223405-c87a5b62e243/ipv6/sys_aix.go (about) 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 5 // Added for go1.11 compatibility 6 //go:build aix 7 8 package ipv6 9 10 import ( 11 "net" 12 "syscall" 13 "unsafe" 14 15 "golang.org/x/net/internal/iana" 16 "golang.org/x/net/internal/socket" 17 18 "golang.org/x/sys/unix" 19 ) 20 21 var ( 22 ctlOpts = [ctlMax]ctlOpt{ 23 ctlTrafficClass: {unix.IPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, 24 ctlHopLimit: {unix.IPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, 25 ctlPacketInfo: {unix.IPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, 26 ctlNextHop: {unix.IPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop}, 27 ctlPathMTU: {unix.IPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, 28 } 29 30 sockOpts = map[int]*sockOpt{ 31 ssoTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_TCLASS, Len: 4}}, 32 ssoHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_UNICAST_HOPS, Len: 4}}, 33 ssoMulticastInterface: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_IF, Len: 4}}, 34 ssoMulticastHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_HOPS, Len: 4}}, 35 ssoMulticastLoopback: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_LOOP, Len: 4}}, 36 ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVTCLASS, Len: 4}}, 37 ssoReceiveHopLimit: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVHOPLIMIT, Len: 4}}, 38 ssoReceivePacketInfo: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPKTINFO, Len: 4}}, 39 ssoReceivePathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPATHMTU, Len: 4}}, 40 ssoPathMTU: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}}, 41 ssoChecksum: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_CHECKSUM, Len: 4}}, 42 ssoICMPFilter: {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: unix.ICMP6_FILTER, Len: sizeofICMPv6Filter}}, 43 ssoJoinGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_JOIN_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, 44 ssoLeaveGroup: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_LEAVE_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq}, 45 } 46 ) 47 48 func (sa *sockaddrInet6) setSockaddr(ip net.IP, i int) { 49 sa.Len = sizeofSockaddrInet6 50 sa.Family = syscall.AF_INET6 51 copy(sa.Addr[:], ip) 52 sa.Scope_id = uint32(i) 53 } 54 55 func (pi *inet6Pktinfo) setIfindex(i int) { 56 pi.Ifindex = int32(i) 57 } 58 59 func (mreq *ipv6Mreq) setIfindex(i int) { 60 mreq.Interface = uint32(i) 61 } 62 63 func (gr *groupReq) setGroup(grp net.IP) { 64 sa := (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gr)) + 4)) 65 sa.Len = sizeofSockaddrInet6 66 sa.Family = syscall.AF_INET6 67 copy(sa.Addr[:], grp) 68 } 69 70 func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) { 71 sa := (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 4)) 72 sa.Len = sizeofSockaddrInet6 73 sa.Family = syscall.AF_INET6 74 copy(sa.Addr[:], grp) 75 sa = (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 132)) 76 sa.Len = sizeofSockaddrInet6 77 sa.Family = syscall.AF_INET6 78 copy(sa.Addr[:], src) 79 }