github.com/slackhq/nebula@v1.9.0/udp/udp_linux_64.go (about) 1 //go:build linux && (amd64 || arm64 || ppc64 || ppc64le || mips64 || mips64le || s390x || riscv64 || loong64) && !android && !e2e_testing 2 // +build linux 3 // +build amd64 arm64 ppc64 ppc64le mips64 mips64le s390x riscv64 loong64 4 // +build !android 5 // +build !e2e_testing 6 7 package udp 8 9 import ( 10 "golang.org/x/sys/unix" 11 ) 12 13 type iovec struct { 14 Base *byte 15 Len uint64 16 } 17 18 type msghdr struct { 19 Name *byte 20 Namelen uint32 21 Pad0 [4]byte 22 Iov *iovec 23 Iovlen uint64 24 Control *byte 25 Controllen uint64 26 Flags int32 27 Pad1 [4]byte 28 } 29 30 type rawMessage struct { 31 Hdr msghdr 32 Len uint32 33 Pad0 [4]byte 34 } 35 36 func (u *StdConn) PrepareRawMessages(n int) ([]rawMessage, [][]byte, [][]byte) { 37 msgs := make([]rawMessage, n) 38 buffers := make([][]byte, n) 39 names := make([][]byte, n) 40 41 for i := range msgs { 42 buffers[i] = make([]byte, MTU) 43 names[i] = make([]byte, unix.SizeofSockaddrInet6) 44 45 //TODO: this is still silly, no need for an array 46 vs := []iovec{ 47 {Base: &buffers[i][0], Len: uint64(len(buffers[i]))}, 48 } 49 50 msgs[i].Hdr.Iov = &vs[0] 51 msgs[i].Hdr.Iovlen = uint64(len(vs)) 52 53 msgs[i].Hdr.Name = &names[i][0] 54 msgs[i].Hdr.Namelen = uint32(len(names[i])) 55 } 56 57 return msgs, buffers, names 58 }