00001 // -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- 00002 // 00003 // Copyright (c) 2006 Georgia Tech Research Corporation 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License version 2 as 00007 // published by the Free Software Foundation; 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 // 00018 // Author: George F. Riley<riley@ece.gatech.edu> 00019 // 00020 00021 // NS3 - Layer 4 Protocol base class 00022 // George F. Riley, Georgia Tech, Spring 2007 00023 00024 #ifndef IPV4_L4_PROTOCOL_H 00025 #define IPV4_L4_PROTOCOL_H 00026 00027 #include "ns3/object.h" 00028 #include "ns3/ipv4-header.h" 00029 00030 namespace ns3 { 00031 00032 class Packet; 00033 class Ipv4Address; 00034 class Ipv4Interface; 00035 00036 /** 00037 * \brief L4 Protocol abstract base class 00038 * 00039 * This is an abstract base class for layer four protocols which use IPv4 as 00040 * the network layer. 00041 */ 00042 class Ipv4L4Protocol : public Object 00043 { 00044 public: 00045 enum RxStatus { 00046 RX_OK, 00047 RX_CSUM_FAILED, 00048 RX_ENDPOINT_UNREACH 00049 }; 00050 00051 static TypeId GetTypeId (void); 00052 00053 virtual ~Ipv4L4Protocol (); 00054 00055 /** 00056 * \returns the protocol number of this protocol. 00057 */ 00058 virtual int GetProtocolNumber (void) const = 0; 00059 00060 /** 00061 * \param p packet to forward up 00062 * \param source source address of packet received 00063 * \param destination address of packet received 00064 * \param incomingInterface the Ipv4Interface on which the packet arrived 00065 * 00066 * Called from lower-level layers to send the packet up 00067 * in the stack. 00068 */ 00069 virtual enum RxStatus Receive(Ptr<Packet> p, 00070 Ipv4Address const &source, 00071 Ipv4Address const &destination, 00072 Ptr<Ipv4Interface> incomingInterface) = 0; 00073 00074 /** 00075 * \param icmpSource the source address of the icmp message 00076 * \param icmpTtl the ttl of the icmp message 00077 * \param icmpType the 'type' field of the icmp message 00078 * \param icmpCode the 'code' field of the icmp message 00079 * \param icmpInfo extra information dependent on the icmp message 00080 * generated by Icmpv4L4Protocol 00081 * \param payloadSource the source address of the packet which triggered 00082 * the icmp message 00083 * \param payloadDestination the destination address of the packet which 00084 * triggered the icmp message. 00085 * \param payload the first 8 bytes of the udp header of the packet 00086 * which triggered the icmp message. 00087 */ 00088 virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, 00089 uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, 00090 Ipv4Address payloadSource, Ipv4Address payloadDestination, 00091 const uint8_t payload[8]); 00092 }; 00093 00094 } // Namespace ns3 00095 00096 #endif