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