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:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user