blob: 5a38798cc0cd99a59ca32a64a0c86d9bcfd59d35 [file] [log] [blame]
David K. Bainbridge215e0242017-09-05 23:18:24 -07001// 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
5package socket
6
7import "unsafe"
8
9func (h *msghdr) pack(vs []iovec, bs [][]byte, oob []byte, sa []byte) {
10 for i := range vs {
11 vs[i].set(bs[i])
12 }
13 h.setIov(vs)
14 if len(oob) > 0 {
15 h.setControl(oob)
16 }
17 if sa != nil {
18 h.Name = (*byte)(unsafe.Pointer(&sa[0]))
19 h.Namelen = uint32(len(sa))
20 }
21}
22
23func (h *msghdr) name() []byte {
24 if h.Name != nil && h.Namelen > 0 {
25 return (*[sizeofSockaddrInet6]byte)(unsafe.Pointer(h.Name))[:h.Namelen]
26 }
27 return nil
28}
29
30func (h *msghdr) controllen() int {
31 return int(h.Controllen)
32}
33
34func (h *msghdr) flags() int {
35 return int(h.Flags)
36}