/* Copyright (c) 1999 by Inria Lorraine.  All Rights Reserved */

/***
   NAME
     RawSocketImpl
   PURPOSE
     
   NOTES
     
   HISTORY
     chelius - Jul 25, 1999: Created.
     $Log: RawSocketImpl.java,v $
     Revision 1.1  2000/04/27 13:24:16  sdalu
     ajout jdk1.1

     Revision 1.2  2000/04/03 08:05:35  chelius
     Javadoc

     Revision 1.1.1.1  2000/02/08 16:31:59  chelius
     Initial import

     Revision 1.1.1.1  2000/02/01 11:10:47  chelius
     Mise sous CVS des sources de libnet6 for jdk1.2.*

     Revision 1.1.1.1  1999/07/25 15:01:57  chelius
     First release of the ipv6 packages for java

***/

package java.net;


import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InterruptedIOException;

/**
 * Abstract Icmp and raw socket implementation base class.
 * @author  Guillaume Chelius (IPv6 modifications)
 * @since  JDK1.2
 */
public abstract class RawSocketImpl implements SocketOptions {

    /**
     * The file descriptor object
     * @since   JDK1.2
     */
    protected FileDescriptor fd;

    /** 
     * The protocol of the socket 
     *
     */
    protected int protocol;

     /**
     * Creates a raw socket
     * @since   JDK1.2
     */
    protected abstract void create(int protocol) throws SocketException;

    /**
     * Binds a raw socket to a local address.
     * @since   JDK1.2
     */
    protected abstract void bind(InetAddress laddr) throws SocketException;
 
    /**
     * Sends a raw packet. The packet contains the data and the
     * destination address to send the packet to.
     * @param packet to be sent.
     * @since   JDK1.2
     */
    protected abstract void send(RawPacket p) throws IOException;

    /**
     * Peek at the packet to see who it is from.
     * @param return the address which the packet came from.
     * @since   JDK1.2
     */
    protected abstract void peek(InetAddress i) throws IOException;

    /**
     * Receive the raw packet.
     * @param Packet Received.
     * @since   JDK1.2
     */
    protected abstract void receive(RawPacket p) throws IOException;
 
   /**
     * Close the socket.
     * @since   JDK1.2
     */
    protected abstract void close();

    /**
     * Get the raw socket file descriptor
     * @since   JDK1.2
     */
    protected FileDescriptor getFileDescriptor() {
	return fd;
    }

    /**
     * Get the protocol value
     */
    protected int getProtocol() {
	return protocol;
    }

    /**
     * Set the Checksum option.
     * @param offset to place the checksum.
     * @since   JDK1.2
     */
    protected abstract void setChecksum(int offset) throws SocketException;

    /**
     * Get the Checksum option.
     * @since   JDK1.2
     */
    protected abstract int getChecksum() throws SocketException;

}




