src/internet-stack/arp-l3-protocol.h
author Pavel Boyko <boyko@iitp.ru>
Thu Aug 06 10:23:12 2009 +0400 (2009-08-06)
changeset 4696 5ef92ccda11a
parent 4472 e20a31541404
child 4740 34acfd7ad508
permissions -rw-r--r--
Route lookup removed in ARP request (see bug 606)
     1 /* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     2 /*
     3  * Copyright (c) 2006 INRIA
     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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
    19  */
    20 #ifndef ARP_L3_PROTOCOL_H
    21 #define ARP_L3_PROTOCOL_H
    22 
    23 #include <list>
    24 #include "ns3/ipv4-address.h"
    25 #include "ns3/address.h"
    26 #include "ns3/ptr.h"
    27 #include "ns3/traced-callback.h"
    28 
    29 #include "ipv4-interface.h"
    30 
    31 namespace ns3 {
    32 
    33 class ArpCache;
    34 class NetDevice;
    35 class Node;
    36 class Packet;
    37 
    38 /**
    39  * \ingroup internetStack
    40  * \defgroup arp Arp
    41  *
    42  * This is an overview of Arp capabilities (write me).
    43  */
    44 /**
    45  * \ingroup arp
    46  * \brief An implementation of the ARP protocol
    47  */
    48 class ArpL3Protocol : public Object
    49 {
    50 public:
    51   static TypeId GetTypeId (void);
    52   static const uint16_t PROT_NUMBER;
    53 
    54   ArpL3Protocol ();
    55   virtual ~ArpL3Protocol ();
    56 
    57   void SetNode (Ptr<Node> node);
    58 
    59   Ptr<ArpCache> CreateCache (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
    60 
    61   /**
    62    * \brief Receive a packet
    63    */
    64   void Receive(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to,
    65                NetDevice::PacketType packetType);
    66   /**
    67    * \brief Perform an ARP lookup
    68    * \param p
    69    * \param destination
    70    * \param device
    71    * \param cache
    72    * \param hardwareDestination
    73    * \return 
    74    */
    75   bool Lookup (Ptr<Packet> p, Ipv4Address destination, 
    76 	       Ptr<NetDevice> device,
    77                Ptr<ArpCache> cache,
    78 	       Address *hardwareDestination);
    79 protected:
    80   virtual void DoDispose (void);
    81   /*
    82    * This function will notify other components connected to the node that a new stack member is now connected
    83    * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
    84    */
    85   virtual void NotifyNewAggregate ();
    86 private:
    87   typedef std::list<Ptr<ArpCache> > CacheList;
    88   Ptr<ArpCache> FindCache (Ptr<NetDevice> device);
    89   void SendArpRequest (Ptr<const ArpCache>cache, Ipv4Address to);
    90   void SendArpReply (Ptr<const ArpCache> cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac);
    91   CacheList m_cacheList;
    92   Ptr<Node> m_node;
    93   TracedCallback<Ptr<const Packet> > m_dropTrace;
    94 };
    95 
    96 }//namespace ns3
    97 
    98 
    99 #endif /* ARP_L3_PROTOCOL_H */