25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

55 satır
1.3 KiB

  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 solaris
  5. package ipv6
  6. import (
  7. "net"
  8. "unsafe"
  9. "golang.org/x/net/internal/socket"
  10. )
  11. var compatFreeBSD32 bool // 386 emulation on amd64
  12. func (so *sockOpt) setGroupReq(c *socket.Conn, ifi *net.Interface, grp net.IP) error {
  13. var gr groupReq
  14. if ifi != nil {
  15. gr.Interface = uint32(ifi.Index)
  16. }
  17. gr.setGroup(grp)
  18. var b []byte
  19. if compatFreeBSD32 {
  20. var d [sizeofGroupReq + 4]byte
  21. s := (*[sizeofGroupReq]byte)(unsafe.Pointer(&gr))
  22. copy(d[:4], s[:4])
  23. copy(d[8:], s[4:])
  24. b = d[:]
  25. } else {
  26. b = (*[sizeofGroupReq]byte)(unsafe.Pointer(&gr))[:sizeofGroupReq]
  27. }
  28. return so.Set(c, b)
  29. }
  30. func (so *sockOpt) setGroupSourceReq(c *socket.Conn, ifi *net.Interface, grp, src net.IP) error {
  31. var gsr groupSourceReq
  32. if ifi != nil {
  33. gsr.Interface = uint32(ifi.Index)
  34. }
  35. gsr.setSourceGroup(grp, src)
  36. var b []byte
  37. if compatFreeBSD32 {
  38. var d [sizeofGroupSourceReq + 4]byte
  39. s := (*[sizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr))
  40. copy(d[:4], s[:4])
  41. copy(d[8:], s[4:])
  42. b = d[:]
  43. } else {
  44. b = (*[sizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr))[:sizeofGroupSourceReq]
  45. }
  46. return so.Set(c, b)
  47. }