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