| 1 | 
         747 | 
         jeremybenn | 
         // 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 | 
          | 
          | 
         // (Raw) IP sockets stubs for Plan 9
  | 
      
      
         | 6 | 
          | 
          | 
          
  | 
      
      
         | 7 | 
          | 
          | 
         package net
  | 
      
      
         | 8 | 
          | 
          | 
          
  | 
      
      
         | 9 | 
          | 
          | 
         import (
  | 
      
      
         | 10 | 
          | 
          | 
                 "os"
  | 
      
      
         | 11 | 
          | 
          | 
                 "time"
  | 
      
      
         | 12 | 
          | 
          | 
         )
  | 
      
      
         | 13 | 
          | 
          | 
          
  | 
      
      
         | 14 | 
          | 
          | 
         // IPConn is the implementation of the Conn and PacketConn
  | 
      
      
         | 15 | 
          | 
          | 
         // interfaces for IP network connections.
  | 
      
      
         | 16 | 
          | 
          | 
         type IPConn bool
  | 
      
      
         | 17 | 
          | 
          | 
          
  | 
      
      
         | 18 | 
          | 
          | 
         // SetDeadline implements the Conn SetDeadline method.
  | 
      
      
         | 19 | 
          | 
          | 
         func (c *IPConn) SetDeadline(t time.Time) error {
  | 
      
      
         | 20 | 
          | 
          | 
                 return os.EPLAN9
  | 
      
      
         | 21 | 
          | 
          | 
         }
  | 
      
      
         | 22 | 
          | 
          | 
          
  | 
      
      
         | 23 | 
          | 
          | 
         // SetReadDeadline implements the Conn SetReadDeadline method.
  | 
      
      
         | 24 | 
          | 
          | 
         func (c *IPConn) SetReadDeadline(t time.Time) error {
  | 
      
      
         | 25 | 
          | 
          | 
                 return os.EPLAN9
  | 
      
      
         | 26 | 
          | 
          | 
         }
  | 
      
      
         | 27 | 
          | 
          | 
          
  | 
      
      
         | 28 | 
          | 
          | 
         // SetWriteDeadline implements the Conn SetWriteDeadline method.
  | 
      
      
         | 29 | 
          | 
          | 
         func (c *IPConn) SetWriteDeadline(t time.Time) error {
  | 
      
      
         | 30 | 
          | 
          | 
                 return os.EPLAN9
  | 
      
      
         | 31 | 
          | 
          | 
         }
  | 
      
      
         | 32 | 
          | 
          | 
          
  | 
      
      
         | 33 | 
          | 
          | 
         // Implementation of the Conn interface - see Conn for documentation.
  | 
      
      
         | 34 | 
          | 
          | 
          
  | 
      
      
         | 35 | 
          | 
          | 
         // Read implements the Conn Read method.
  | 
      
      
         | 36 | 
          | 
          | 
         func (c *IPConn) Read(b []byte) (int, error) {
  | 
      
      
         | 37 | 
          | 
          | 
                 return 0, os.EPLAN9
  | 
      
      
         | 38 | 
          | 
          | 
         }
  | 
      
      
         | 39 | 
          | 
          | 
          
  | 
      
      
         | 40 | 
          | 
          | 
         // Write implements the Conn Write method.
  | 
      
      
         | 41 | 
          | 
          | 
         func (c *IPConn) Write(b []byte) (int, error) {
  | 
      
      
         | 42 | 
          | 
          | 
                 return 0, os.EPLAN9
  | 
      
      
         | 43 | 
          | 
          | 
         }
  | 
      
      
         | 44 | 
          | 
          | 
          
  | 
      
      
         | 45 | 
          | 
          | 
         // Close closes the IP connection.
  | 
      
      
         | 46 | 
          | 
          | 
         func (c *IPConn) Close() error {
  | 
      
      
         | 47 | 
          | 
          | 
                 return os.EPLAN9
  | 
      
      
         | 48 | 
          | 
          | 
         }
  | 
      
      
         | 49 | 
          | 
          | 
          
  | 
      
      
         | 50 | 
          | 
          | 
         // LocalAddr returns the local network address.
  | 
      
      
         | 51 | 
          | 
          | 
         func (c *IPConn) LocalAddr() Addr {
  | 
      
      
         | 52 | 
          | 
          | 
                 return nil
  | 
      
      
         | 53 | 
          | 
          | 
         }
  | 
      
      
         | 54 | 
          | 
          | 
          
  | 
      
      
         | 55 | 
          | 
          | 
         // RemoteAddr returns the remote network address, a *IPAddr.
  | 
      
      
         | 56 | 
          | 
          | 
         func (c *IPConn) RemoteAddr() Addr {
  | 
      
      
         | 57 | 
          | 
          | 
                 return nil
  | 
      
      
         | 58 | 
          | 
          | 
         }
  | 
      
      
         | 59 | 
          | 
          | 
          
  | 
      
      
         | 60 | 
          | 
          | 
         // IP-specific methods.
  | 
      
      
         | 61 | 
          | 
          | 
          
  | 
      
      
         | 62 | 
          | 
          | 
         // ReadFromIP reads a IP packet from c, copying the payload into b.
  | 
      
      
         | 63 | 
          | 
          | 
         // It returns the number of bytes copied into b and the return address
  | 
      
      
         | 64 | 
          | 
          | 
         // that was on the packet.
  | 
      
      
         | 65 | 
          | 
          | 
         //
  | 
      
      
         | 66 | 
          | 
          | 
         // ReadFromIP can be made to time out and return an error with
  | 
      
      
         | 67 | 
          | 
          | 
         // Timeout() == true after a fixed time limit; see SetDeadline and
  | 
      
      
         | 68 | 
          | 
          | 
         // SetReadDeadline.
  | 
      
      
         | 69 | 
          | 
          | 
         func (c *IPConn) ReadFromIP(b []byte) (int, *IPAddr, error) {
  | 
      
      
         | 70 | 
          | 
          | 
                 return 0, nil, os.EPLAN9
  | 
      
      
         | 71 | 
          | 
          | 
         }
  | 
      
      
         | 72 | 
          | 
          | 
          
  | 
      
      
         | 73 | 
          | 
          | 
         // ReadFrom implements the PacketConn ReadFrom method.
  | 
      
      
         | 74 | 
          | 
          | 
         func (c *IPConn) ReadFrom(b []byte) (int, Addr, error) {
  | 
      
      
         | 75 | 
          | 
          | 
                 return 0, nil, os.EPLAN9
  | 
      
      
         | 76 | 
          | 
          | 
         }
  | 
      
      
         | 77 | 
          | 
          | 
          
  | 
      
      
         | 78 | 
          | 
          | 
         // WriteToIP writes a IP packet to addr via c, copying the payload from b.
  | 
      
      
         | 79 | 
          | 
          | 
         //
  | 
      
      
         | 80 | 
          | 
          | 
         // WriteToIP can be made to time out and return
  | 
      
      
         | 81 | 
          | 
          | 
         // an error with Timeout() == true after a fixed time limit;
  | 
      
      
         | 82 | 
          | 
          | 
         // see SetDeadline and SetWriteDeadline.
  | 
      
      
         | 83 | 
          | 
          | 
         // On packet-oriented connections, write timeouts are rare.
  | 
      
      
         | 84 | 
          | 
          | 
         func (c *IPConn) WriteToIP(b []byte, addr *IPAddr) (int, error) {
  | 
      
      
         | 85 | 
          | 
          | 
                 return 0, os.EPLAN9
  | 
      
      
         | 86 | 
          | 
          | 
         }
  | 
      
      
         | 87 | 
          | 
          | 
          
  | 
      
      
         | 88 | 
          | 
          | 
         // WriteTo implements the PacketConn WriteTo method.
  | 
      
      
         | 89 | 
          | 
          | 
         func (c *IPConn) WriteTo(b []byte, addr Addr) (int, error) {
  | 
      
      
         | 90 | 
          | 
          | 
                 return 0, os.EPLAN9
  | 
      
      
         | 91 | 
          | 
          | 
         }
  | 
      
      
         | 92 | 
          | 
          | 
          
  | 
      
      
         | 93 | 
          | 
          | 
         // DialIP connects to the remote address raddr on the network protocol netProto,
  | 
      
      
         | 94 | 
          | 
          | 
         // which must be "ip", "ip4", or "ip6" followed by a colon and a protocol number or name.
  | 
      
      
         | 95 | 
          | 
          | 
         func DialIP(netProto string, laddr, raddr *IPAddr) (*IPConn, error) {
  | 
      
      
         | 96 | 
          | 
          | 
                 return nil, os.EPLAN9
  | 
      
      
         | 97 | 
          | 
          | 
         }
  | 
      
      
         | 98 | 
          | 
          | 
          
  | 
      
      
         | 99 | 
          | 
          | 
         // ListenIP listens for incoming IP packets addressed to the
  | 
      
      
         | 100 | 
          | 
          | 
         // local address laddr.  The returned connection c's ReadFrom
  | 
      
      
         | 101 | 
          | 
          | 
         // and WriteTo methods can be used to receive and send IP
  | 
      
      
         | 102 | 
          | 
          | 
         // packets with per-packet addressing.
  | 
      
      
         | 103 | 
          | 
          | 
         func ListenIP(netProto string, laddr *IPAddr) (*IPConn, error) {
  | 
      
      
         | 104 | 
          | 
          | 
                 return nil, os.EPLAN9
  | 
      
      
         | 105 | 
          | 
          | 
         }
  |