INET Framework for OMNeT++/OMNEST
inet::GenericARP Class Reference

TODO GenericMACAddressCache. More...

#include <GenericARP.h>

Inheritance diagram for inet::GenericARP:
inet::IARP

Public Member Functions

 GenericARP ()
 
virtual ~GenericARP ()
 
virtual int numInitStages () const override
 
virtual MACAddress resolveL3Address (const L3Address &address, const InterfaceEntry *ie) override
 Tries to resolve the given network address to a MAC address. More...
 
virtual L3Address getL3AddressFor (const MACAddress &) const override
 Returns the Layer 3 address for the given MAC address. More...
 
- Public Member Functions inherited from inet::IARP
virtual ~IARP ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *msg) override
 
MACAddress mapUnicastAddress (L3Address addr)
 
MACAddress mapMulticastAddress (L3Address addr)
 
void sendPacketToNIC (cMessage *msg, InterfaceEntry *ie, const MACAddress &macAddress, int etherType)
 

Private Attributes

IInterfaceTableift = nullptr
 

Additional Inherited Members

- Static Public Attributes inherited from inet::IARP
static const simsignal_t initiatedARPResolutionSignal = cComponent::registerSignal("initiatedARPResolution")
 Signals used to publish ARP state changes. More...
 
static const simsignal_t completedARPResolutionSignal = cComponent::registerSignal("completedARPResolution")
 
static const simsignal_t failedARPResolutionSignal = cComponent::registerSignal("failedARPResolution")
 

Detailed Description

TODO GenericMACAddressCache.

  • translates L3 address to L2 addresses
  • uses global mapping (or table, or algorithm)
  • not a protocol – doesn't communicate

Constructor & Destructor Documentation

inet::GenericARP::GenericARP ( )
inline
46 {}
virtual inet::GenericARP::~GenericARP ( )
inlinevirtual
47 {}

Member Function Documentation

virtual L3Address inet::GenericARP::getL3AddressFor ( const MACAddress ) const
inlineoverridevirtual

Returns the Layer 3 address for the given MAC address.

If it is not available (not in the cache, pending resolution, or already expired), UNSPECIFIED_ADDRESS is returned.

Implements inet::IARP.

51 { throw cRuntimeError("getL3AddressFor() not implemented yet"); }
void inet::GenericARP::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
52 {
53  if (msg->isSelfMessage())
54  throw cRuntimeError("This module doesn't accept any self message");
55 
56  EV << "received a " << msg << " message, dropped\n";
57  delete msg;
58 }
void inet::GenericARP::initialize ( int  stage)
overrideprotectedvirtual
43 {
44  cSimpleModule::initialize(stage);
45 
46  if (stage == INITSTAGE_LOCAL) {
47  ift = getModuleFromPar<IInterfaceTable>(par("interfaceTableModule"), this);
48  }
49 }
IInterfaceTable * ift
Definition: GenericARP.h:43
Local initializations.
Definition: InitStages.h:35
MACAddress inet::GenericARP::mapMulticastAddress ( L3Address  addr)
protected

Referenced by resolveL3Address().

84 {
85  ASSERT(addr.isMulticast());
86 
87  MACAddress macAddr;
88  macAddr.setAddressByte(0, 0x01);
89  macAddr.setAddressByte(1, 0x00);
90  macAddr.setAddressByte(2, 0x5e);
91  // TODO:
92  // macAddr.setAddressByte(3, addr.getDByte(1) & 0x7f);
93  // macAddr.setAddressByte(4, addr.getDByte(2));
94  // macAddr.setAddressByte(5, addr.getDByte(3));
95  return macAddr;
96 }
MACAddress inet::GenericARP::mapUnicastAddress ( L3Address  addr)
protected

Referenced by resolveL3Address().

61 {
62  cModule *module;
63  switch (addr.getType()) {
64  case L3Address::MAC:
65  return addr.toMAC();
66 
68  module = getSimulation()->getModule(addr.toModuleId().getId());
69  break;
70 
72  module = getSimulation()->getModule(addr.toModulePath().getId());
73  break;
74 
75  default:
76  throw cRuntimeError("Unknown address type");
77  }
78  IInterfaceTable *interfaceTable = L3AddressResolver().findInterfaceTableOf(getContainingNode(module));
79  InterfaceEntry *interfaceEntry = interfaceTable->getInterfaceByInterfaceModule(module);
80  return interfaceEntry->getMacAddress();
81 }
Definition: L3Address.h:49
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
Definition: L3Address.h:50
Definition: L3Address.h:48
virtual int inet::GenericARP::numInitStages ( ) const
inlineoverridevirtual
48 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
MACAddress inet::GenericARP::resolveL3Address ( const L3Address address,
const InterfaceEntry ie 
)
overridevirtual

Tries to resolve the given network address to a MAC address.

If the MAC address is not yet resolved it returns an unspecified address and starts an address resolution procedure. A signal is emitted when the address resolution procedure terminates.

Implements inet::IARP.

32 {
33  if (address.isUnicast())
34  return mapUnicastAddress(address);
35  else if (address.isMulticast())
36  return mapMulticastAddress(address);
37  else if (address.isBroadcast())
39  throw cRuntimeError("address must be one of unicast or multicast or broadcast");
40 }
MACAddress mapUnicastAddress(L3Address addr)
Definition: GenericARP.cc:60
MACAddress mapMulticastAddress(L3Address addr)
Definition: GenericARP.cc:83
static const MACAddress BROADCAST_ADDRESS
The broadcast MAC address, ff:ff:ff:ff:ff:ff.
Definition: MACAddress.h:60
void inet::GenericARP::sendPacketToNIC ( cMessage *  msg,
InterfaceEntry ie,
const MACAddress macAddress,
int  etherType 
)
protected

Member Data Documentation

IInterfaceTable* inet::GenericARP::ift = nullptr
private

Referenced by initialize().


The documentation for this class was generated from the following files: