You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

40 lines
852 B

  1. // Copyright 2017 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 dragonfly freebsd netbsd openbsd
  5. package socket
  6. import "unsafe"
  7. func (h *msghdr) pack(vs []iovec, bs [][]byte, oob []byte, sa []byte) {
  8. for i := range vs {
  9. vs[i].set(bs[i])
  10. }
  11. h.setIov(vs)
  12. if len(oob) > 0 {
  13. h.Control = (*byte)(unsafe.Pointer(&oob[0]))
  14. h.Controllen = uint32(len(oob))
  15. }
  16. if sa != nil {
  17. h.Name = (*byte)(unsafe.Pointer(&sa[0]))
  18. h.Namelen = uint32(len(sa))
  19. }
  20. }
  21. func (h *msghdr) name() []byte {
  22. if h.Name != nil && h.Namelen > 0 {
  23. return (*[sizeofSockaddrInet6]byte)(unsafe.Pointer(h.Name))[:h.Namelen]
  24. }
  25. return nil
  26. }
  27. func (h *msghdr) controllen() int {
  28. return int(h.Controllen)
  29. }
  30. func (h *msghdr) flags() int {
  31. return int(h.Flags)
  32. }