gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

sys_zos.go (3595B)


      1 // Copyright 2020 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 package ipv6
      6 
      7 import (
      8 	"net"
      9 	"syscall"
     10 	"unsafe"
     11 
     12 	"golang.org/x/net/internal/iana"
     13 	"golang.org/x/net/internal/socket"
     14 
     15 	"golang.org/x/sys/unix"
     16 )
     17 
     18 var (
     19 	ctlOpts = [ctlMax]ctlOpt{
     20 		ctlHopLimit:   {unix.IPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit},
     21 		ctlPacketInfo: {unix.IPV6_PKTINFO, sizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo},
     22 		ctlPathMTU:    {unix.IPV6_PATHMTU, sizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU},
     23 	}
     24 
     25 	sockOpts = map[int]*sockOpt{
     26 		ssoTrafficClass:        {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_TCLASS, Len: 4}},
     27 		ssoHopLimit:            {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_UNICAST_HOPS, Len: 4}},
     28 		ssoMulticastInterface:  {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_IF, Len: 4}},
     29 		ssoMulticastHopLimit:   {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_HOPS, Len: 4}},
     30 		ssoMulticastLoopback:   {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_MULTICAST_LOOP, Len: 4}},
     31 		ssoReceiveTrafficClass: {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVTCLASS, Len: 4}},
     32 		ssoReceiveHopLimit:     {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVHOPLIMIT, Len: 4}},
     33 		ssoReceivePacketInfo:   {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPKTINFO, Len: 4}},
     34 		ssoReceivePathMTU:      {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_RECVPATHMTU, Len: 4}},
     35 		ssoChecksum:            {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.IPV6_CHECKSUM, Len: 4}},
     36 		ssoICMPFilter:          {Option: socket.Option{Level: iana.ProtocolIPv6ICMP, Name: unix.ICMP6_FILTER, Len: sizeofICMPv6Filter}},
     37 		ssoJoinGroup:           {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_JOIN_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq},
     38 		ssoLeaveGroup:          {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_LEAVE_GROUP, Len: sizeofGroupReq}, typ: ssoTypeGroupReq},
     39 		ssoJoinSourceGroup:     {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_JOIN_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
     40 		ssoLeaveSourceGroup:    {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_LEAVE_SOURCE_GROUP, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
     41 		ssoBlockSourceGroup:    {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_BLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
     42 		ssoUnblockSourceGroup:  {Option: socket.Option{Level: iana.ProtocolIPv6, Name: unix.MCAST_UNBLOCK_SOURCE, Len: sizeofGroupSourceReq}, typ: ssoTypeGroupSourceReq},
     43 	}
     44 )
     45 
     46 func (sa *sockaddrInet6) setSockaddr(ip net.IP, i int) {
     47 	sa.Family = syscall.AF_INET6
     48 	copy(sa.Addr[:], ip)
     49 	sa.Scope_id = uint32(i)
     50 }
     51 
     52 func (pi *inet6Pktinfo) setIfindex(i int) {
     53 	pi.Ifindex = uint32(i)
     54 }
     55 
     56 func (gr *groupReq) setGroup(grp net.IP) {
     57 	sa := (*sockaddrInet6)(unsafe.Pointer(&gr.Group))
     58 	sa.Family = syscall.AF_INET6
     59 	sa.Len = sizeofSockaddrInet6
     60 	copy(sa.Addr[:], grp)
     61 }
     62 
     63 func (gsr *groupSourceReq) setSourceGroup(grp, src net.IP) {
     64 	sa := (*sockaddrInet6)(unsafe.Pointer(&gsr.Group))
     65 	sa.Family = syscall.AF_INET6
     66 	sa.Len = sizeofSockaddrInet6
     67 	copy(sa.Addr[:], grp)
     68 	sa = (*sockaddrInet6)(unsafe.Pointer(&gsr.Source))
     69 	sa.Family = syscall.AF_INET6
     70 	sa.Len = sizeofSockaddrInet6
     71 	copy(sa.Addr[:], src)
     72 }