sockopt_ssmreq_unix.go 901 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2014 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. // +build darwin freebsd linux
  5. package ipv4
  6. import (
  7. "net"
  8. "os"
  9. "unsafe"
  10. "golang.org/x/net/internal/iana"
  11. )
  12. func setsockoptGroupReq(fd, name int, ifi *net.Interface, grp net.IP) error {
  13. var gr sysGroupReq
  14. if ifi != nil {
  15. gr.Interface = uint32(ifi.Index)
  16. }
  17. gr.setGroup(grp)
  18. return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&gr), sysSizeofGroupReq))
  19. }
  20. func setsockoptGroupSourceReq(fd, name int, ifi *net.Interface, grp, src net.IP) error {
  21. var gsr sysGroupSourceReq
  22. if ifi != nil {
  23. gsr.Interface = uint32(ifi.Index)
  24. }
  25. gsr.setSourceGroup(grp, src)
  26. return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&gsr), sysSizeofGroupSourceReq))
  27. }