payload_nocmsg.go (1444B)
1 // Copyright 2013 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 5 //go:build !aix && !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd && !solaris && !zos 6 // +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris,!zos 7 8 package ipv6 9 10 import "net" 11 12 // ReadFrom reads a payload of the received IPv6 datagram, from the 13 // endpoint c, copying the payload into b. It returns the number of 14 // bytes copied into b, the control message cm and the source address 15 // src of the received datagram. 16 func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { 17 if !c.ok() { 18 return 0, nil, nil, errInvalidConn 19 } 20 if n, src, err = c.PacketConn.ReadFrom(b); err != nil { 21 return 0, nil, nil, err 22 } 23 return 24 } 25 26 // WriteTo writes a payload of the IPv6 datagram, to the destination 27 // address dst through the endpoint c, copying the payload from b. It 28 // returns the number of bytes written. The control message cm allows 29 // the IPv6 header fields and the datagram path to be specified. The 30 // cm may be nil if control of the outgoing datagram is not required. 31 func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { 32 if !c.ok() { 33 return 0, errInvalidConn 34 } 35 if dst == nil { 36 return 0, errMissingAddress 37 } 38 return c.PacketConn.WriteTo(b, dst) 39 }