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)
mathieu@242
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
mathieu@242
     2
/*
mathieu@242
     3
 * Copyright (c) 2006 INRIA
mathieu@242
     4
 *
mathieu@242
     5
 * This program is free software; you can redistribute it and/or modify
mathieu@242
     6
 * it under the terms of the GNU General Public License version 2 as
mathieu@242
     7
 * published by the Free Software Foundation;
mathieu@242
     8
 *
mathieu@242
     9
 * This program is distributed in the hope that it will be useful,
mathieu@242
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
mathieu@242
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
mathieu@242
    12
 * GNU General Public License for more details.
mathieu@242
    13
 *
mathieu@242
    14
 * You should have received a copy of the GNU General Public License
mathieu@242
    15
 * along with this program; if not, write to the Free Software
mathieu@242
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
mathieu@242
    17
 *
mathieu@242
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
mathieu@242
    19
 */
mathieu@752
    20
#ifndef ARP_L3_PROTOCOL_H
mathieu@752
    21
#define ARP_L3_PROTOCOL_H
mathieu@242
    22
mathieu@242
    23
#include <list>
mathieu@524
    24
#include "ns3/ipv4-address.h"
mathieu@1161
    25
#include "ns3/address.h"
mathieu@552
    26
#include "ns3/ptr.h"
mathieu@3152
    27
#include "ns3/traced-callback.h"
mathieu@242
    28
gjc@3172
    29
#include "ipv4-interface.h"
gjc@3172
    30
mathieu@242
    31
namespace ns3 {
mathieu@242
    32
mathieu@242
    33
class ArpCache;
mathieu@242
    34
class NetDevice;
mathieu@728
    35
class Node;
mathieu@242
    36
class Packet;
tjkopena@3021
    37
raj@632
    38
/**
tomh@3691
    39
 * \ingroup internetStack
tomh@3691
    40
 * \defgroup arp Arp
tomh@3691
    41
 *
tomh@3691
    42
 * This is an overview of Arp capabilities (write me).
tomh@3691
    43
 */
tomh@3691
    44
/**
tomh@3691
    45
 * \ingroup arp
raj@632
    46
 * \brief An implementation of the ARP protocol
raj@632
    47
 */
mathieu@1176
    48
class ArpL3Protocol : public Object
mathieu@242
    49
{
mathieu@242
    50
public:
mathieu@2251
    51
  static TypeId GetTypeId (void);
mathieu@294
    52
  static const uint16_t PROT_NUMBER;
mathieu@2595
    53
mathieu@2498
    54
  ArpL3Protocol ();
mathieu@1176
    55
  virtual ~ArpL3Protocol ();
mathieu@2592
    56
mathieu@2592
    57
  void SetNode (Ptr<Node> node);
mathieu@2592
    58
mathieu@3147
    59
  Ptr<ArpCache> CreateCache (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
mathieu@3147
    60
raj@632
    61
  /**
tomh@3499
    62
   * \brief Receive a packet
raj@632
    63
   */
mathieu@3548
    64
  void Receive(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to,
gjc@3448
    65
               NetDevice::PacketType packetType);
raj@632
    66
  /**
raj@632
    67
   * \brief Perform an ARP lookup
raj@632
    68
   * \param p
raj@632
    69
   * \param destination
raj@632
    70
   * \param device
mathieu@3185
    71
   * \param cache
raj@632
    72
   * \param hardwareDestination
raj@632
    73
   * \return 
raj@632
    74
   */
mathieu@1866
    75
  bool Lookup (Ptr<Packet> p, Ipv4Address destination, 
mathieu@568
    76
	       Ptr<NetDevice> device,
mathieu@3147
    77
               Ptr<ArpCache> cache,
mathieu@1161
    78
	       Address *hardwareDestination);
mathieu@513
    79
protected:
mathieu@513
    80
  virtual void DoDispose (void);
tomh@4472
    81
  /*
tomh@4472
    82
   * This function will notify other components connected to the node that a new stack member is now connected
tomh@4472
    83
   * This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
tomh@4472
    84
   */
tomh@4472
    85
  virtual void NotifyNewAggregate ();
mathieu@242
    86
private:
mathieu@3146
    87
  typedef std::list<Ptr<ArpCache> > CacheList;
mathieu@3146
    88
  Ptr<ArpCache> FindCache (Ptr<NetDevice> device);
mathieu@3146
    89
  void SendArpRequest (Ptr<const ArpCache>cache, Ipv4Address to);
boyko@4696
    90
  void SendArpReply (Ptr<const ArpCache> cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac);
mathieu@242
    91
  CacheList m_cacheList;
mathieu@728
    92
  Ptr<Node> m_node;
mathieu@3152
    93
  TracedCallback<Ptr<const Packet> > m_dropTrace;
mathieu@242
    94
};
mathieu@242
    95
mathieu@242
    96
}//namespace ns3
mathieu@242
    97
mathieu@242
    98
mathieu@752
    99
#endif /* ARP_L3_PROTOCOL_H */