src/internet-stack/arp-l3-protocol.h
changeset 3260 8c0ab08144e6
parent 3185 c859e129a934
child 3448 0bd851bb1225
equal deleted inserted replaced
3259:43b3f8ecd86d 3260:8c0ab08144e6
       
     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  * \brief An implementation of the ARP protocol
       
    40  */
       
    41 class ArpL3Protocol : public Object
       
    42 {
       
    43 public:
       
    44   static TypeId GetTypeId (void);
       
    45   static const uint16_t PROT_NUMBER;
       
    46 
       
    47   ArpL3Protocol ();
       
    48   virtual ~ArpL3Protocol ();
       
    49 
       
    50   void SetNode (Ptr<Node> node);
       
    51 
       
    52   Ptr<ArpCache> CreateCache (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
       
    53 
       
    54   /**
       
    55    * \brief Recieve a packet
       
    56    */
       
    57   void Receive(Ptr<NetDevice> device, Ptr<Packet> p, uint16_t protocol, const Address &from);
       
    58   /**
       
    59    * \brief Perform an ARP lookup
       
    60    * \param p
       
    61    * \param destination
       
    62    * \param device
       
    63    * \param cache
       
    64    * \param hardwareDestination
       
    65    * \return 
       
    66    */
       
    67   bool Lookup (Ptr<Packet> p, Ipv4Address destination, 
       
    68 	       Ptr<NetDevice> device,
       
    69                Ptr<ArpCache> cache,
       
    70 	       Address *hardwareDestination);
       
    71 protected:
       
    72   virtual void DoDispose (void);
       
    73 private:
       
    74   typedef std::list<Ptr<ArpCache> > CacheList;
       
    75   Ptr<ArpCache> FindCache (Ptr<NetDevice> device);
       
    76   void SendArpRequest (Ptr<const ArpCache>cache, Ipv4Address to);
       
    77   void SendArpReply (Ptr<const ArpCache> cache, Ipv4Address toIp, Address toMac);
       
    78   CacheList m_cacheList;
       
    79   Ptr<Node> m_node;
       
    80   TracedCallback<Ptr<const Packet> > m_dropTrace;
       
    81 };
       
    82 
       
    83 }//namespace ns3
       
    84 
       
    85 
       
    86 #endif /* ARP_L3_PROTOCOL_H */