src/internet-stack/ipv4-l4-protocol.h
author Craig Dowell <craigdo@ee.washington.edu>
Tue, 09 Dec 2008 20:29:04 -0800
changeset 3997 a66553c56a8f
parent 3820 c04ecfdce1ef
permissions -rw-r--r--
make a pass through doxygen fixing errors
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
//
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
// Copyright (c) 2006 Georgia Tech Research Corporation
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
//
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
// This program is free software; you can redistribute it and/or modify
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
// it under the terms of the GNU General Public License version 2 as
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
// published by the Free Software Foundation;
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
//
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
// This program is distributed in the hope that it will be useful,
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
// GNU General Public License for more details.
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
//
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
// You should have received a copy of the GNU General Public License
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
// along with this program; if not, write to the Free Software
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
//
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
// Author: George F. Riley<riley@ece.gatech.edu>
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
//
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
// NS3 - Layer 4 Protocol base class
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
// George F. Riley, Georgia Tech, Spring 2007
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#ifndef IPV4_L4_PROTOCOL_H
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
#define IPV4_L4_PROTOCOL_H
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
498
5d5fe14d5751 make capabilities and sockets refcounted
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 496
diff changeset
    27
#include "ns3/object.h"
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    28
#include "ns3/ipv4-header.h"
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    29
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
namespace ns3 {
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
class Packet;
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
class Ipv4Address;
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    34
class Ipv4Interface;
407
d249fd346a7c doxygen for Ipv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    35
d249fd346a7c doxygen for Ipv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    36
/**
3266
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    37
 * \brief L4 Protocol abstract base class 
407
d249fd346a7c doxygen for Ipv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    38
 *
3266
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    39
 * This is an abstract base class for layer four protocols which use IPv4 as
1ae7df5cf87b Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents: 3260
diff changeset
    40
 * the network layer.
407
d249fd346a7c doxygen for Ipv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    41
 */  
498
5d5fe14d5751 make capabilities and sockets refcounted
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 496
diff changeset
    42
class Ipv4L4Protocol : public Object
5d5fe14d5751 make capabilities and sockets refcounted
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 496
diff changeset
    43
{
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
public:
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    45
  enum RxStatus {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    46
    RX_OK,
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    47
    RX_CSUM_FAILED,
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    48
    RX_ENDPOINT_UNREACH
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    49
  };
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    50
2498
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
    51
  static TypeId GetTypeId (void);
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
    52
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
  virtual ~Ipv4L4Protocol ();
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
407
d249fd346a7c doxygen for Ipv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    55
  /**
d249fd346a7c doxygen for Ipv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    56
   * \returns the protocol number of this protocol.
d249fd346a7c doxygen for Ipv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    57
   */
2498
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1866
diff changeset
    58
  virtual int GetProtocolNumber (void) const = 0;
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
  /**
407
d249fd346a7c doxygen for Ipv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    61
   * \param p packet to forward up
d249fd346a7c doxygen for Ipv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    62
   * \param source source address of packet received
d249fd346a7c doxygen for Ipv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    63
   * \param destination address of packet received
1524
3ead2b66f2e4 Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1341
diff changeset
    64
   * \param incomingInterface the Ipv4Interface on which the packet arrived
407
d249fd346a7c doxygen for Ipv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    65
   * 
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
   * Called from lower-level layers to send the packet up
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
   * in the stack. 
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
   */
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    69
  virtual enum RxStatus Receive(Ptr<Packet> p, 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    70
                                Ipv4Address const &source,
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    71
                                Ipv4Address const &destination,
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    72
                                Ptr<Ipv4Interface> incomingInterface) = 0;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    73
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    74
  /**
3997
a66553c56a8f make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents: 3820
diff changeset
    75
   * \param icmpSource the source address of the icmp message
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    76
   * \param icmpTtl the ttl of the icmp message
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    77
   * \param icmpType the 'type' field of the icmp message
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    78
   * \param icmpCode the 'code' field of the icmp message
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    79
   * \param icmpInfo extra information dependent on the icmp message
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    80
   *        generated by Icmpv4L4Protocol
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    81
   * \param payloadSource the source address of the packet which triggered
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    82
   *        the icmp message
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    83
   * \param payloadDestination the destination address of the packet which
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    84
   *        triggered the icmp message.
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    85
   * \param payload the first 8 bytes of the udp header of the packet
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    86
   *        which triggered the icmp message.
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    87
   */
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    88
  virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl,
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    89
                            uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    90
                            Ipv4Address payloadSource, Ipv4Address payloadDestination,
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 3588
diff changeset
    91
                            const uint8_t payload[8]);
234
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
};
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
} // Namespace ns3
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
6124bda39cb3 code from all trees.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
#endif