Add a NetDevice::SendFrom API, for sending packets with a custom source MAC address (a.k.a. MAC spoofing). Only implemented for CsmaNetDevice for now.

This commit is contained in:
Gustavo J. A. M. Carneiro
2008-07-04 18:03:26 +01:00
parent f3d8a5eb6d
commit df677111d4
9 changed files with 65 additions and 21 deletions

View File

@@ -215,6 +215,20 @@ public:
* \return whether the Send operation succeeded
*/
virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) = 0;
/**
* \param packet packet sent from above down to Network Device
* \param source source mac address (so called "MAC spoofing")
* \param dest mac address of the destination (already resolved)
* \param protocolNumber identifies the type of payload contained in
* this packet. Used to call the right L3Protocol when the packet
* is received.
*
* Called from higher layer to send packet into Network Device
* with the specified source and destination Addresses.
*
* \return whether the Send operation succeeded
*/
virtual bool SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber) = 0;
/**
* \returns the node base class which contains this network
* interface.

View File

@@ -151,6 +151,15 @@ SimpleNetDevice::Send(Ptr<Packet> packet, const Address& dest, uint16_t protocol
m_channel->Send (packet, protocolNumber, to, m_address, this);
return true;
}
bool
SimpleNetDevice::SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber)
{
Mac48Address to = Mac48Address::ConvertFrom (dest);
Mac48Address from = Mac48Address::ConvertFrom (source);
m_channel->Send (packet, protocolNumber, to, from, this);
return true;
}
Ptr<Node>
SimpleNetDevice::GetNode (void) const
{

View File

@@ -63,6 +63,7 @@ public:
virtual Address MakeMulticastAddress (Ipv4Address multicastGroup) const;
virtual bool IsPointToPoint (void) const;
virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
virtual bool SendFrom(Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
virtual Ptr<Node> GetNode (void) const;
virtual void SetNode (Ptr<Node> node);
virtual bool NeedsArp (void) const;