2011-09-16 17:47:21 +02:00
|
|
|
// Copyright 2010 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// (Raw) IP sockets stubs for Plan 9
|
|
|
|
|
|
|
|
package net
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2012-01-25 22:54:22 +01:00
|
|
|
"time"
|
2011-09-16 17:47:21 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// IPConn is the implementation of the Conn and PacketConn
|
|
|
|
// interfaces for IP network connections.
|
|
|
|
type IPConn bool
|
|
|
|
|
2012-02-09 09:19:58 +01:00
|
|
|
// SetDeadline implements the Conn SetDeadline method.
|
2012-01-25 22:54:22 +01:00
|
|
|
func (c *IPConn) SetDeadline(t time.Time) error {
|
|
|
|
return os.EPLAN9
|
|
|
|
}
|
|
|
|
|
2012-02-09 09:19:58 +01:00
|
|
|
// SetReadDeadline implements the Conn SetReadDeadline method.
|
2012-01-25 22:54:22 +01:00
|
|
|
func (c *IPConn) SetReadDeadline(t time.Time) error {
|
|
|
|
return os.EPLAN9
|
|
|
|
}
|
|
|
|
|
2012-02-09 09:19:58 +01:00
|
|
|
// SetWriteDeadline implements the Conn SetWriteDeadline method.
|
2012-01-25 22:54:22 +01:00
|
|
|
func (c *IPConn) SetWriteDeadline(t time.Time) error {
|
|
|
|
return os.EPLAN9
|
|
|
|
}
|
|
|
|
|
2011-09-16 17:47:21 +02:00
|
|
|
// Implementation of the Conn interface - see Conn for documentation.
|
|
|
|
|
2012-02-01 20:26:59 +01:00
|
|
|
// Read implements the Conn Read method.
|
|
|
|
func (c *IPConn) Read(b []byte) (int, error) {
|
2011-09-16 17:47:21 +02:00
|
|
|
return 0, os.EPLAN9
|
|
|
|
}
|
|
|
|
|
2012-02-01 20:26:59 +01:00
|
|
|
// Write implements the Conn Write method.
|
|
|
|
func (c *IPConn) Write(b []byte) (int, error) {
|
2011-09-16 17:47:21 +02:00
|
|
|
return 0, os.EPLAN9
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close closes the IP connection.
|
2011-12-03 03:17:34 +01:00
|
|
|
func (c *IPConn) Close() error {
|
2011-09-16 17:47:21 +02:00
|
|
|
return os.EPLAN9
|
|
|
|
}
|
|
|
|
|
|
|
|
// LocalAddr returns the local network address.
|
|
|
|
func (c *IPConn) LocalAddr() Addr {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// RemoteAddr returns the remote network address, a *IPAddr.
|
|
|
|
func (c *IPConn) RemoteAddr() Addr {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// IP-specific methods.
|
|
|
|
|
2012-02-01 20:26:59 +01:00
|
|
|
// ReadFromIP reads a IP packet from c, copying the payload into b.
|
|
|
|
// It returns the number of bytes copied into b and the return address
|
|
|
|
// that was on the packet.
|
|
|
|
//
|
|
|
|
// ReadFromIP can be made to time out and return an error with
|
|
|
|
// Timeout() == true after a fixed time limit; see SetDeadline and
|
|
|
|
// SetReadDeadline.
|
|
|
|
func (c *IPConn) ReadFromIP(b []byte) (int, *IPAddr, error) {
|
|
|
|
return 0, nil, os.EPLAN9
|
|
|
|
}
|
|
|
|
|
|
|
|
// ReadFrom implements the PacketConn ReadFrom method.
|
|
|
|
func (c *IPConn) ReadFrom(b []byte) (int, Addr, error) {
|
|
|
|
return 0, nil, os.EPLAN9
|
2011-09-16 17:47:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// WriteToIP writes a IP packet to addr via c, copying the payload from b.
|
|
|
|
//
|
|
|
|
// WriteToIP can be made to time out and return
|
|
|
|
// an error with Timeout() == true after a fixed time limit;
|
2012-01-25 22:54:22 +01:00
|
|
|
// see SetDeadline and SetWriteDeadline.
|
2011-09-16 17:47:21 +02:00
|
|
|
// On packet-oriented connections, write timeouts are rare.
|
2012-02-01 20:26:59 +01:00
|
|
|
func (c *IPConn) WriteToIP(b []byte, addr *IPAddr) (int, error) {
|
2011-09-16 17:47:21 +02:00
|
|
|
return 0, os.EPLAN9
|
|
|
|
}
|
|
|
|
|
2012-02-01 20:26:59 +01:00
|
|
|
// WriteTo implements the PacketConn WriteTo method.
|
|
|
|
func (c *IPConn) WriteTo(b []byte, addr Addr) (int, error) {
|
2011-09-16 17:47:21 +02:00
|
|
|
return 0, os.EPLAN9
|
|
|
|
}
|
|
|
|
|
2012-01-25 21:56:26 +01:00
|
|
|
// DialIP connects to the remote address raddr on the network protocol netProto,
|
|
|
|
// which must be "ip", "ip4", or "ip6" followed by a colon and a protocol number or name.
|
2012-02-01 20:26:59 +01:00
|
|
|
func DialIP(netProto string, laddr, raddr *IPAddr) (*IPConn, error) {
|
2011-09-16 17:47:21 +02:00
|
|
|
return nil, os.EPLAN9
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListenIP listens for incoming IP packets addressed to the
|
|
|
|
// local address laddr. The returned connection c's ReadFrom
|
|
|
|
// and WriteTo methods can be used to receive and send IP
|
|
|
|
// packets with per-packet addressing.
|
2012-02-01 20:26:59 +01:00
|
|
|
func ListenIP(netProto string, laddr *IPAddr) (*IPConn, error) {
|
2011-09-16 17:47:21 +02:00
|
|
|
return nil, os.EPLAN9
|
|
|
|
}
|