src/node/icmp-socket.h
author vincent@clarinet.u-strasbg.fr
Fri Nov 07 11:36:15 2008 -0800 (2008-11-07)
changeset 3852 9cf7ad0cac85
permissions -rw-r--r--
Initial IPv6 capability
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     2 /*
     3  * Copyright (c) 2008 Louis Pasteur University
     4  *
     5  * This program is free software; you can redistribute it and/or modify
     6  * it under the terms of the GNU General Public License version 2 as
     7  * published by the Free Software Foundation;
     8  *
     9  * This program is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12  * GNU General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU General Public License
    15  * along with this program; if not, write to the Free Software
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    17  *
    18  * Authors: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
    19  */
    20 
    21 #ifndef ICMP_SOCKET_H
    22 #define ICMP_SOCKET_H
    23 
    24 #include "socket.h"
    25 #include "ns3/traced-callback.h"
    26 #include "ns3/callback.h"
    27 #include "ns3/ptr.h"
    28 #include "ns3/object.h"
    29 
    30 namespace ns3 {
    31 
    32 class Node;
    33 class Packet;
    34 
    35 /**
    36  * \brief (abstract) base class of all IcmpSockets (for IPv4 or IPv6).
    37  *
    38  * This class exists solely for hosting IcmpSocket attributes that can
    39  * be reused across different implementations.
    40  */
    41 class IcmpSocket : public Socket
    42 {
    43   public:
    44     /**
    45      * \brief Get the UID of this class.
    46      * \return UID
    47      */
    48     static TypeId GetTypeId (void);
    49 
    50     /**
    51      * \brief Constructor.
    52      */
    53     IcmpSocket (void);
    54 
    55     /**
    56      * \brief Destructor.
    57      */
    58     virtual ~IcmpSocket (void);
    59 
    60     /**
    61      * \brief Get the error.
    62      * \return the error.
    63      */
    64     virtual enum Socket::SocketErrno GetErrno (void) const = 0;
    65 
    66     /**
    67      * \brief Get the node.
    68      * \return the node
    69      */
    70     virtual Ptr<Node> GetNode (void) const = 0;
    71 
    72     /**
    73      * \brief Bind the socket.
    74      * \return 0 if OK, -1 otherwise
    75      */
    76     virtual int Bind (void) = 0;
    77 
    78     /**
    79      * \brief Bind the socket on "addr".
    80      * \param addr address
    81      * \return 0 if OK, -1 otherwise
    82      */
    83     virtual int Bind (const Address &addr) = 0;
    84 
    85     /**
    86      * \brief Close the socket.
    87      * \return 0 if OK, -1 otherwise
    88      */
    89     virtual int Close (void) = 0;
    90 
    91     /**
    92      * \brief Shutdown the socket on send.
    93      * \return 0 if OK, -1 otherwise
    94      */
    95     virtual int ShutdownSend (void) = 0;
    96 
    97     /**
    98      * \brief Shutdown the socket on receive.
    99      * \return 0 if OK, -1 otherwise
   100      */
   101     virtual int ShutdownRecv (void) = 0;
   102 
   103     /**
   104      * \brief Connect to another node.
   105      * \param addr address
   106      * \return 0 if OK, -1 otherwise
   107      */
   108     virtual int Connect (const Address &addr) = 0;
   109 
   110     /**
   111      * \brief Send a packet.
   112      * \param p the packet to send
   113      * \param flags flags
   114      * \return 0 if OK, -1 otherwise
   115      */		
   116     virtual int Send (Ptr<Packet> p, uint32_t flags) = 0;
   117 
   118     /**
   119      * \brief Get the maximum message size available.
   120      * \return maximum message size
   121      * \warning size of a message that could be sent is limited by the link MTU.
   122      */
   123     virtual uint32_t GetTxAvailable (void) const = 0;
   124 
   125     /**
   126      * \brief Send a packet to a node.
   127      * \param addr the address of the node
   128      * \param flags flags
   129      * \param p the packet to send
   130      * \return 0 if OK, -1 otherwise
   131      */
   132     virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address &addr) = 0;
   133 
   134     /**
   135      * \brief Receive method.
   136      * \param maxSize maximum size we want to return
   137      * \param flags flags
   138      * \return a packet with at maximum maxSize size
   139      */
   140     virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
   141 
   142     /**
   143      * \brief Receive method.
   144      * \param maxSize maximum size we want to return
   145      * \param flags flags
   146      * \param fromAddress sender address
   147      * \return a packet with at maximum maxSize size
   148      */
   149     virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress) = 0;
   150 
   151     /**
   152      * \brief Get the size we could receive.
   153      * \return size we could receive at one moment
   154      */
   155     virtual uint32_t GetRxAvailable (void) const = 0;
   156 
   157   private:
   158     /**
   159      * \brief Get the receive buffer size.
   160      * \return receive buffer size
   161      */
   162     virtual uint32_t GetRcvBufSize (void) const = 0;
   163 
   164     /**
   165      * \brief Set the receive buffer size.
   166      * \param rcvBufSize size to set
   167      */
   168     virtual void SetRcvBufSize (uint32_t rcvBufSize) = 0;
   169 
   170     /* FIXME : add ICMP basic attribute for socket */
   171     /* Indirect the attribute setting and getting through private virtual methods */
   172 };
   173 
   174 } /* namespace ns3 */
   175 
   176 #endif /* ICMP_SOCKET_H */
   177