A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
arp-l3-protocol.h
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/net-device.h"
26 #include "ns3/address.h"
27 #include "ns3/ptr.h"
28 #include "ns3/traced-callback.h"
29 
30 namespace ns3 {
31 
32 class ArpCache;
33 class NetDevice;
34 class Node;
35 class Packet;
36 class Ipv4Interface;
37 
48 class ArpL3Protocol : public Object
49 {
50 public:
51  static TypeId GetTypeId (void);
52  static const uint16_t PROT_NUMBER = 0x0806;
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 
64  void Receive (Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to,
65  NetDevice::PacketType packetType);
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  ArpL3Protocol (const ArpL3Protocol &o);
89  ArpL3Protocol &operator = (const ArpL3Protocol &o);
90  Ptr<ArpCache> FindCache (Ptr<NetDevice> device);
91  void SendArpRequest (Ptr<const ArpCache>cache, Ipv4Address to);
92  void SendArpReply (Ptr<const ArpCache> cache, Ipv4Address myIp, Ipv4Address toIp, Address toMac);
93  CacheList m_cacheList;
94  Ptr<Node> m_node;
96 };
97 
98 } // namespace ns3
99 
100 
101 #endif /* ARP_L3_PROTOCOL_H */
void Receive(Ptr< NetDevice > device, Ptr< const Packet > p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Receive a packet.
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
a polymophic address class
Definition: address.h:86
virtual void NotifyNewAggregate()
virtual void DoDispose(void)
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
bool Lookup(Ptr< Packet > p, Ipv4Address destination, Ptr< NetDevice > device, Ptr< ArpCache > cache, Address *hardwareDestination)
Perform an ARP lookup.
An implementation of the ARP protocol.
a base class which provides memory management and object aggregation
Definition: object.h:63
a unique identifier for an interface.
Definition: type-id.h:44