src/internet-node/ipv4-l4-protocol.h
changeset 524 082ffdd8fbd7
parent 513 b7c7ea629de9
child 559 f000b19c95e3
equal deleted inserted replaced
523:eb380b33ae24 524:082ffdd8fbd7
       
     1 // -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
       
     2 //
       
     3 // Copyright (c) 2006 Georgia Tech Research Corporation
       
     4 // All rights reserved.
       
     5 //
       
     6 // This program is free software; you can redistribute it and/or modify
       
     7 // it under the terms of the GNU General Public License version 2 as
       
     8 // published by the Free Software Foundation;
       
     9 //
       
    10 // This program is distributed in the hope that it will be useful,
       
    11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    13 // GNU General Public License for more details.
       
    14 //
       
    15 // You should have received a copy of the GNU General Public License
       
    16 // along with this program; if not, write to the Free Software
       
    17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    18 //
       
    19 // Author: George F. Riley<riley@ece.gatech.edu>
       
    20 //
       
    21 
       
    22 // NS3 - Layer 4 Protocol base class
       
    23 // George F. Riley, Georgia Tech, Spring 2007
       
    24 
       
    25 #ifndef IPV4_L4_PROTOCOL_H
       
    26 #define IPV4_L4_PROTOCOL_H
       
    27 
       
    28 #include "ns3/object.h"
       
    29 
       
    30 namespace ns3 {
       
    31 
       
    32 class Node;
       
    33 class Packet;
       
    34 class Ipv4Address;
       
    35 class TraceResolver;
       
    36 class TraceContext;
       
    37 
       
    38 /**
       
    39  * \brief L4 Protocol base class 
       
    40  *
       
    41  * All subclasses must implement:
       
    42  *   - Ipv4L4Protocol::Copy
       
    43  *   - Ipv4L4Protocol::CreateTraceResolver
       
    44  *
       
    45  * If you want to implement a new L4 protocol, all you have to do is
       
    46  * implement a subclass of this base class and add it to an L4Demux.
       
    47  */  
       
    48 class Ipv4L4Protocol : public Object
       
    49 {
       
    50 public:
       
    51   Ipv4L4Protocol(int protocolNumber, int version);
       
    52   virtual ~Ipv4L4Protocol ();
       
    53 
       
    54   /**
       
    55    * \returns the protocol number of this protocol.
       
    56    */
       
    57   int GetProtocolNumber (void) const;
       
    58   /**
       
    59    * \returns the version number of this protocol.
       
    60    */
       
    61   int GetVersion() const;
       
    62 
       
    63   virtual TraceResolver *CreateTraceResolver (TraceContext const &context) = 0;
       
    64 
       
    65   /**
       
    66    * \param p packet to forward up
       
    67    * \param source source address of packet received
       
    68    * \param destination address of packet received
       
    69    * 
       
    70    * Called from lower-level layers to send the packet up
       
    71    * in the stack. 
       
    72    */
       
    73   virtual void Receive(Packet& p, 
       
    74                        Ipv4Address const &source,
       
    75                        Ipv4Address const &destination) = 0;
       
    76 protected:
       
    77   virtual void DoDispose (void);
       
    78 private:
       
    79   int m_protocolNumber;
       
    80   int m_version;
       
    81 };
       
    82 
       
    83 } // Namespace ns3
       
    84 
       
    85 #endif