src/internet/model/ipv6-l4-protocol.h
changeset 8660 4263961772e9
parent 8659 01b04e9fbee5
parent 7749 7458a10a17d1
child 8661 e7c0de1585b0
equal deleted inserted replaced
8659:01b04e9fbee5 8660:4263961772e9
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
       
     2 /*
       
     3  * Copyright (c) 2007-2009 Strasbourg 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  * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
       
    19  */
       
    20 
       
    21 #ifndef IPV6_L4_PROTOCOL_H
       
    22 #define IPV6_L4_PROTOCOL_H
       
    23 
       
    24 #include "ns3/object.h"
       
    25 #include "ns3/ipv6-header.h"
       
    26 
       
    27 namespace ns3
       
    28 {
       
    29 
       
    30 class Packet;
       
    31 class Ipv6Address;
       
    32 class Ipv6Interface;
       
    33 
       
    34 /**
       
    35  * \class Ipv6L4Protocol
       
    36  * \brief IPv6 L4 protocol abstract class
       
    37  */
       
    38 class Ipv6L4Protocol : public Object
       
    39 {
       
    40 public:
       
    41   /**
       
    42    * \enum RxStatus_e
       
    43    * \brief Status of receive.
       
    44    */
       
    45   enum RxStatus_e 
       
    46   {
       
    47     RX_OK, /**< Receive OK */
       
    48     RX_CSUM_FAILED, /**< Checksum of layer 4 protocol failed */
       
    49     RX_ENDPOINT_UNREACH /**< Destination unreachable */
       
    50   };
       
    51 
       
    52   /**
       
    53    * \brief Get the type identifier.
       
    54    * \return type identifier
       
    55    */
       
    56   static TypeId GetTypeId (void);
       
    57 
       
    58   /**
       
    59    * \brief Destructor.
       
    60    */
       
    61   virtual ~Ipv6L4Protocol ();
       
    62 
       
    63   /**
       
    64    * \brief Get the protocol number.
       
    65    * \return protocol number
       
    66    */
       
    67   virtual int GetProtocolNumber () const = 0;
       
    68 
       
    69   /**
       
    70    * \brief Receive method.
       
    71    *
       
    72    * Called from lower-level layers to send the packet up
       
    73    * in the stack.
       
    74    * \param p packet to forward up
       
    75    * \param src source address of packet received
       
    76    * \param dst address of packet received
       
    77    * \param incomingInterface the Ipv6Interface on which the packet arrived
       
    78    * \return status (OK, destination unreachable or checksum failed)
       
    79    */
       
    80   virtual enum RxStatus_e Receive (Ptr<Packet> p, Ipv6Address const &src, 
       
    81                                    Ipv6Address const &dst, 
       
    82                                    Ptr<Ipv6Interface> incomingInterface) = 0;
       
    83 
       
    84   /**
       
    85    * \brief ICMPv6 receive method.
       
    86    * \param icmpSource the source address of the ICMPv6 message
       
    87    * \param icmpTtl the ttl of the ICMPv6 message
       
    88    * \param icmpType the 'type' field of the ICMPv6 message
       
    89    * \param icmpCode the 'code' field of the ICMPv6 message
       
    90    * \param icmpInfo extra information dependent on the ICMPv6 message
       
    91    *        generated by Icmpv6L4Protocol
       
    92    * \param payloadSource the source address of the packet which triggered
       
    93    *        the ICMPv6 message
       
    94    * \param payloadDestination the destination address of the packet which
       
    95    *        triggered the ICMPv6 message.
       
    96    * \param payload the first 8 bytes of the UDP header of the packet
       
    97    *        which triggered the ICMPv6 message.
       
    98    */
       
    99   virtual void ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl,
       
   100                             uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
       
   101                             Ipv6Address payloadSource, Ipv6Address payloadDestination,
       
   102                             const uint8_t* payload);
       
   103 
       
   104 };
       
   105 
       
   106 } /* namespace ns3 */
       
   107 
       
   108 #endif /* IPV6_L4_PROTOCOL_H */
       
   109