OSDN Git Service

new repo
[bytom/vapor.git] / vendor / golang.org / x / net / ipv6 / payload_nocmsg.go
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 // +build nacl plan9 windows
6
7 package ipv6
8
9 import (
10         "net"
11         "syscall"
12 )
13
14 // ReadFrom reads a payload of the received IPv6 datagram, from the
15 // endpoint c, copying the payload into b. It returns the number of
16 // bytes copied into b, the control message cm and the source address
17 // src of the received datagram.
18 func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) {
19         if !c.ok() {
20                 return 0, nil, nil, syscall.EINVAL
21         }
22         if n, src, err = c.PacketConn.ReadFrom(b); err != nil {
23                 return 0, nil, nil, err
24         }
25         return
26 }
27
28 // WriteTo writes a payload of the IPv6 datagram, to the destination
29 // address dst through the endpoint c, copying the payload from b. It
30 // returns the number of bytes written. The control message cm allows
31 // the IPv6 header fields and the datagram path to be specified. The
32 // cm may be nil if control of the outgoing datagram is not required.
33 func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) {
34         if !c.ok() {
35                 return 0, syscall.EINVAL
36         }
37         if dst == nil {
38                 return 0, errMissingAddress
39         }
40         return c.PacketConn.WriteTo(b, dst)
41 }