github.com/binkynet/BinkyNet@v1.12.1-0.20240421190447-da4e34c20be0/proto_vendor/golang.org/x/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  // +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  
    19  var (
    20  	ctlOpts = [ctlMax]ctlOpt{
    21  		ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass},
    22  		ctlHopLimit:     {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit},
    23  		ctlPacketInfo:   {sysIPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo},
    24  		ctlNextHop:      {sysIPV6_NEXTHOP, sizeofSockaddrInet6, marshalNextHop, parseNextHop},
    25  		ctlPathMTU:      {sysIPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU},
    26  	}
    27  
    28  	sockOpts = map[int]*sockOpt{
    29  		ssoTrafficClass:        {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_TCLASS, Len: 4}},
    30  		ssoHopLimit:            {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_UNICAST_HOPS, Len: 4}},
    31  		ssoMulticastInterface:  {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_IF, Len: 4}},
    32  		ssoMulticastHopLimit:   {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_HOPS, Len: 4}},
    33  		ssoMulticastLoopback:   {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_MULTICAST_LOOP, Len: 4}},
    34  		ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVTCLASS, Len: 4}},
    35  		ssoReceiveHopLimit:     {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVHOPLIMIT, Len: 4}},
    36  		ssoReceivePacketInfo:   {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPKTINFO, Len: 4}},
    37  		ssoReceivePathMTU:      {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_RECVPATHMTU, Len: 4}},
    38  		ssoPathMTU:             {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_PATHMTU, Len: sizeofIPv6Mtuinfo}},
    39  		ssoChecksum:            {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_CHECKSUM, Len: 4}},
    40  		ssoICMPFilter:          {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: sysICMP6_FILTER, Len: sizeofICMPv6Filter}},
    41  		ssoJoinGroup:           {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_JOIN_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq},
    42  		ssoLeaveGroup:          {Option: socket.Option{Level: iana.ProtocolIPv6, Name: sysIPV6_LEAVE_GROUP, Len: sizeofIPv6Mreq}, typ: ssoTypeIPMreq},
    43  	}
    44  )
    45  
    46  func (sa *sockaddrInet6) setSockaddr(ip net.IP, i int) {
    47  	sa.Len = sizeofSockaddrInet6
    48  	sa.Family = syscall.AF_INET6
    49  	copy(sa.Addr[:], ip)
    50  	sa.Scope_id = uint32(i)
    51  }
    52  
    53  func (pi *inet6Pktinfo) setIfindex(i int) {
    54  	pi.Ifindex = int32(i)
    55  }
    56  
    57  func (mreq *ipv6Mreq) setIfindex(i int) {
    58  	mreq.Interface = uint32(i)
    59  }
    60  
    61  func (gr *groupReq) setGroup(grp net.IP) {
    62  	sa := (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gr)) + 4))
    63  	sa.Len = sizeofSockaddrInet6
    64  	sa.Family = syscall.AF_INET6
    65  	copy(sa.Addr[:], grp)
    66  }
    67  
    68  func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) {
    69  	sa := (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 4))
    70  	sa.Len = sizeofSockaddrInet6
    71  	sa.Family = syscall.AF_INET6
    72  	copy(sa.Addr[:], grp)
    73  	sa = (*sockaddrInet6)(unsafe.Pointer(uintptr(unsafe.Pointer(gsr)) + 132))
    74  	sa.Len = sizeofSockaddrInet6
    75  	sa.Family = syscall.AF_INET6
    76  	copy(sa.Addr[:], src)
    77  }