src/node/icmp-socket.h
changeset 3852 9cf7ad0cac85
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/node/icmp-socket.h	Fri Nov 07 11:36:15 2008 -0800
     1.3 @@ -0,0 +1,177 @@
     1.4 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
     1.5 +/*
     1.6 + * Copyright (c) 2008 Louis Pasteur University
     1.7 + *
     1.8 + * This program is free software; you can redistribute it and/or modify
     1.9 + * it under the terms of the GNU General Public License version 2 as
    1.10 + * published by the Free Software Foundation;
    1.11 + *
    1.12 + * This program is distributed in the hope that it will be useful,
    1.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.15 + * GNU General Public License for more details.
    1.16 + *
    1.17 + * You should have received a copy of the GNU General Public License
    1.18 + * along with this program; if not, write to the Free Software
    1.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.20 + *
    1.21 + * Authors: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
    1.22 + */
    1.23 +
    1.24 +#ifndef ICMP_SOCKET_H
    1.25 +#define ICMP_SOCKET_H
    1.26 +
    1.27 +#include "socket.h"
    1.28 +#include "ns3/traced-callback.h"
    1.29 +#include "ns3/callback.h"
    1.30 +#include "ns3/ptr.h"
    1.31 +#include "ns3/object.h"
    1.32 +
    1.33 +namespace ns3 {
    1.34 +
    1.35 +class Node;
    1.36 +class Packet;
    1.37 +
    1.38 +/**
    1.39 + * \brief (abstract) base class of all IcmpSockets (for IPv4 or IPv6).
    1.40 + *
    1.41 + * This class exists solely for hosting IcmpSocket attributes that can
    1.42 + * be reused across different implementations.
    1.43 + */
    1.44 +class IcmpSocket : public Socket
    1.45 +{
    1.46 +  public:
    1.47 +    /**
    1.48 +     * \brief Get the UID of this class.
    1.49 +     * \return UID
    1.50 +     */
    1.51 +    static TypeId GetTypeId (void);
    1.52 +
    1.53 +    /**
    1.54 +     * \brief Constructor.
    1.55 +     */
    1.56 +    IcmpSocket (void);
    1.57 +
    1.58 +    /**
    1.59 +     * \brief Destructor.
    1.60 +     */
    1.61 +    virtual ~IcmpSocket (void);
    1.62 +
    1.63 +    /**
    1.64 +     * \brief Get the error.
    1.65 +     * \return the error.
    1.66 +     */
    1.67 +    virtual enum Socket::SocketErrno GetErrno (void) const = 0;
    1.68 +
    1.69 +    /**
    1.70 +     * \brief Get the node.
    1.71 +     * \return the node
    1.72 +     */
    1.73 +    virtual Ptr<Node> GetNode (void) const = 0;
    1.74 +
    1.75 +    /**
    1.76 +     * \brief Bind the socket.
    1.77 +     * \return 0 if OK, -1 otherwise
    1.78 +     */
    1.79 +    virtual int Bind (void) = 0;
    1.80 +
    1.81 +    /**
    1.82 +     * \brief Bind the socket on "addr".
    1.83 +     * \param addr address
    1.84 +     * \return 0 if OK, -1 otherwise
    1.85 +     */
    1.86 +    virtual int Bind (const Address &addr) = 0;
    1.87 +
    1.88 +    /**
    1.89 +     * \brief Close the socket.
    1.90 +     * \return 0 if OK, -1 otherwise
    1.91 +     */
    1.92 +    virtual int Close (void) = 0;
    1.93 +
    1.94 +    /**
    1.95 +     * \brief Shutdown the socket on send.
    1.96 +     * \return 0 if OK, -1 otherwise
    1.97 +     */
    1.98 +    virtual int ShutdownSend (void) = 0;
    1.99 +
   1.100 +    /**
   1.101 +     * \brief Shutdown the socket on receive.
   1.102 +     * \return 0 if OK, -1 otherwise
   1.103 +     */
   1.104 +    virtual int ShutdownRecv (void) = 0;
   1.105 +
   1.106 +    /**
   1.107 +     * \brief Connect to another node.
   1.108 +     * \param addr address
   1.109 +     * \return 0 if OK, -1 otherwise
   1.110 +     */
   1.111 +    virtual int Connect (const Address &addr) = 0;
   1.112 +
   1.113 +    /**
   1.114 +     * \brief Send a packet.
   1.115 +     * \param p the packet to send
   1.116 +     * \param flags flags
   1.117 +     * \return 0 if OK, -1 otherwise
   1.118 +     */		
   1.119 +    virtual int Send (Ptr<Packet> p, uint32_t flags) = 0;
   1.120 +
   1.121 +    /**
   1.122 +     * \brief Get the maximum message size available.
   1.123 +     * \return maximum message size
   1.124 +     * \warning size of a message that could be sent is limited by the link MTU.
   1.125 +     */
   1.126 +    virtual uint32_t GetTxAvailable (void) const = 0;
   1.127 +
   1.128 +    /**
   1.129 +     * \brief Send a packet to a node.
   1.130 +     * \param addr the address of the node
   1.131 +     * \param flags flags
   1.132 +     * \param p the packet to send
   1.133 +     * \return 0 if OK, -1 otherwise
   1.134 +     */
   1.135 +    virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address &addr) = 0;
   1.136 +
   1.137 +    /**
   1.138 +     * \brief Receive method.
   1.139 +     * \param maxSize maximum size we want to return
   1.140 +     * \param flags flags
   1.141 +     * \return a packet with at maximum maxSize size
   1.142 +     */
   1.143 +    virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags) = 0;
   1.144 +
   1.145 +    /**
   1.146 +     * \brief Receive method.
   1.147 +     * \param maxSize maximum size we want to return
   1.148 +     * \param flags flags
   1.149 +     * \param fromAddress sender address
   1.150 +     * \return a packet with at maximum maxSize size
   1.151 +     */
   1.152 +    virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, Address &fromAddress) = 0;
   1.153 +
   1.154 +    /**
   1.155 +     * \brief Get the size we could receive.
   1.156 +     * \return size we could receive at one moment
   1.157 +     */
   1.158 +    virtual uint32_t GetRxAvailable (void) const = 0;
   1.159 +
   1.160 +  private:
   1.161 +    /**
   1.162 +     * \brief Get the receive buffer size.
   1.163 +     * \return receive buffer size
   1.164 +     */
   1.165 +    virtual uint32_t GetRcvBufSize (void) const = 0;
   1.166 +
   1.167 +    /**
   1.168 +     * \brief Set the receive buffer size.
   1.169 +     * \param rcvBufSize size to set
   1.170 +     */
   1.171 +    virtual void SetRcvBufSize (uint32_t rcvBufSize) = 0;
   1.172 +
   1.173 +    /* FIXME : add ICMP basic attribute for socket */
   1.174 +    /* Indirect the attribute setting and getting through private virtual methods */
   1.175 +};
   1.176 +
   1.177 +} /* namespace ns3 */
   1.178 +
   1.179 +#endif /* ICMP_SOCKET_H */
   1.180 +