sys_asmreq.go 694 B

12345678910111213141516171819202122232425
  1. // Copyright 2013 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. //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows
  5. // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows
  6. package ipv6
  7. import (
  8. "net"
  9. "unsafe"
  10. "golang.org/x/net/internal/socket"
  11. )
  12. func (so *sockOpt) setIPMreq(c *socket.Conn, ifi *net.Interface, grp net.IP) error {
  13. var mreq ipv6Mreq
  14. copy(mreq.Multiaddr[:], grp)
  15. if ifi != nil {
  16. mreq.setIfindex(ifi.Index)
  17. }
  18. b := (*[sizeofIPv6Mreq]byte)(unsafe.Pointer(&mreq))[:sizeofIPv6Mreq]
  19. return so.Set(c, b)
  20. }