Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __INET_ARP_H
00019 #define __INET_ARP_H
00020
00021 #include <stdio.h>
00022 #include <string.h>
00023 #include <vector>
00024 #include <map>
00025 #include <omnetpp.h>
00026 #include "IPAddress.h"
00027 #include "ARPPacket_m.h"
00028 #include "IPControlInfo.h"
00029 #include "IPDatagram.h"
00030 #include "IInterfaceTable.h"
00031 #include "InterfaceTableAccess.h"
00032 #include "IRoutingTable.h"
00033 #include "RoutingTableAccess.h"
00034
00035
00036
00040 class INET_API ARP : public cSimpleModule
00041 {
00042 public:
00043 struct ARPCacheEntry;
00044 typedef std::map<IPAddress, ARPCacheEntry*> ARPCache;
00045 typedef std::vector<cMessage*> MsgPtrVector;
00046
00047
00048
00049 struct ARPCacheEntry
00050 {
00051 InterfaceEntry *ie;
00052 bool pending;
00053 MACAddress macAddress;
00054 simtime_t lastUpdate;
00055 int numRetries;
00056 cMessage *timer;
00057 MsgPtrVector pendingPackets;
00058
00059 ARPCache::iterator myIter;
00060 };
00061
00062 protected:
00063 simtime_t retryTimeout;
00064 int retryCount;
00065 simtime_t cacheTimeout;
00066 bool doProxyARP;
00067
00068 long numResolutions;
00069 long numFailedResolutions;
00070 long numRequestsSent;
00071 long numRepliesSent;
00072
00073 ARPCache arpCache;
00074
00075 cQueue pendingQueue;
00076 int nicOutBaseGateId;
00077
00078 IInterfaceTable *ift;
00079 IRoutingTable *rt;
00080
00081 public:
00082 ARP() {}
00083 virtual ~ARP();
00084
00085 protected:
00086 virtual void initialize();
00087 virtual void handleMessage(cMessage *msg);
00088 virtual void finish();
00089
00090 virtual void processOutboundPacket(cMessage *msg);
00091 virtual void sendPacketToNIC(cMessage *msg, InterfaceEntry *ie, const MACAddress& macAddress);
00092
00093 virtual void initiateARPResolution(ARPCacheEntry *entry);
00094 virtual void sendARPRequest(InterfaceEntry *ie, IPAddress ipAddress);
00095 virtual void requestTimedOut(cMessage *selfmsg);
00096 virtual bool addressRecognized(IPAddress destAddr, InterfaceEntry *ie);
00097 virtual void processARPPacket(ARPPacket *arp);
00098 virtual void updateARPCache(ARPCacheEntry *entry, const MACAddress& macAddress);
00099
00100 virtual void dumpARPPacket(ARPPacket *arp);
00101 virtual void updateDisplayString();
00102
00103 };
00104
00105 #endif
00106