github.com/yanyiwu/go@v0.0.0-20150106053140-03d6637dbb7f/src/net/iprawsock_plan9.go (about)

     1  // Copyright 2010 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  package net
     6  
     7  import (
     8  	"syscall"
     9  	"time"
    10  )
    11  
    12  // IPConn is the implementation of the Conn and PacketConn interfaces
    13  // for IP network connections.
    14  type IPConn struct {
    15  	conn
    16  }
    17  
    18  // ReadFromIP reads an IP packet from c, copying the payload into b.
    19  // It returns the number of bytes copied into b and the return address
    20  // that was on the packet.
    21  //
    22  // ReadFromIP can be made to time out and return an error with
    23  // Timeout() == true after a fixed time limit; see SetDeadline and
    24  // SetReadDeadline.
    25  func (c *IPConn) ReadFromIP(b []byte) (int, *IPAddr, error) {
    26  	return 0, nil, syscall.EPLAN9
    27  }
    28  
    29  // ReadFrom implements the PacketConn ReadFrom method.
    30  func (c *IPConn) ReadFrom(b []byte) (int, Addr, error) {
    31  	return 0, nil, syscall.EPLAN9
    32  }
    33  
    34  // ReadMsgIP reads a packet from c, copying the payload into b and the
    35  // associated out-of-band data into oob.  It returns the number of
    36  // bytes copied into b, the number of bytes copied into oob, the flags
    37  // that were set on the packet and the source address of the packet.
    38  func (c *IPConn) ReadMsgIP(b, oob []byte) (n, oobn, flags int, addr *IPAddr, err error) {
    39  	return 0, 0, 0, nil, syscall.EPLAN9
    40  }
    41  
    42  // WriteToIP writes an IP packet to addr via c, copying the payload
    43  // from b.
    44  //
    45  // WriteToIP can be made to time out and return an error with
    46  // Timeout() == true after a fixed time limit; see SetDeadline and
    47  // SetWriteDeadline.  On packet-oriented connections, write timeouts
    48  // are rare.
    49  func (c *IPConn) WriteToIP(b []byte, addr *IPAddr) (int, error) {
    50  	return 0, syscall.EPLAN9
    51  }
    52  
    53  // WriteTo implements the PacketConn WriteTo method.
    54  func (c *IPConn) WriteTo(b []byte, addr Addr) (int, error) {
    55  	return 0, syscall.EPLAN9
    56  }
    57  
    58  // WriteMsgIP writes a packet to addr via c, copying the payload from
    59  // b and the associated out-of-band data from oob.  It returns the
    60  // number of payload and out-of-band bytes written.
    61  func (c *IPConn) WriteMsgIP(b, oob []byte, addr *IPAddr) (n, oobn int, err error) {
    62  	return 0, 0, syscall.EPLAN9
    63  }
    64  
    65  // DialIP connects to the remote address raddr on the network protocol
    66  // netProto, which must be "ip", "ip4", or "ip6" followed by a colon
    67  // and a protocol number or name.
    68  func DialIP(netProto string, laddr, raddr *IPAddr) (*IPConn, error) {
    69  	return dialIP(netProto, laddr, raddr, noDeadline)
    70  }
    71  
    72  func dialIP(netProto string, laddr, raddr *IPAddr, deadline time.Time) (*IPConn, error) {
    73  	return nil, syscall.EPLAN9
    74  }
    75  
    76  // ListenIP listens for incoming IP packets addressed to the local
    77  // address laddr.  The returned connection's ReadFrom and WriteTo
    78  // methods can be used to receive and send IP packets with per-packet
    79  // addressing.
    80  func ListenIP(netProto string, laddr *IPAddr) (*IPConn, error) {
    81  	return nil, syscall.EPLAN9
    82  }