|
|
| 678 |
return; |
678 |
return; |
| 679 |
} |
679 |
} |
| 680 |
|
680 |
|
|
|
681 |
void |
| 682 |
Ipv4L3ClickProtocol::SendWithHeader (Ptr<Packet> packet, |
| 683 |
Ipv4Header ipHeader, |
| 684 |
Ptr<Ipv4Route> route) |
| 685 |
{ |
| 686 |
NS_LOG_FUNCTION (this << packet << ipHeader << route); |
| 687 |
|
| 688 |
Ptr<Ipv4ClickRouting> click = DynamicCast<Ipv4ClickRouting> (m_routingProtocol); |
| 689 |
if (Node::ChecksumEnabled ()) |
| 690 |
{ |
| 691 |
ipHeader.EnableChecksum (); |
| 692 |
} |
| 693 |
packet->AddHeader (ipHeader); |
| 694 |
click->Send (packet->Copy (), ipHeader.GetSource (), ipHeader.GetDestination ()); |
| 695 |
} |
| 696 |
|
| 681 |
void |
697 |
void |
| 682 |
Ipv4L3ClickProtocol::SendDown (Ptr<Packet> p, int ifid) |
698 |
Ipv4L3ClickProtocol::SendDown (Ptr<Packet> p, int ifid) |
| 683 |
{ |
699 |
{ |
|
|
| 716 |
const Address &to, NetDevice::PacketType packetType) |
732 |
const Address &to, NetDevice::PacketType packetType) |
| 717 |
{ |
733 |
{ |
| 718 |
NS_LOG_FUNCTION (this << device << p << from << to); |
734 |
NS_LOG_FUNCTION (this << device << p << from << to); |
|
|
735 |
Ptr<Packet> packetForRawSocket = p->Copy (); |
| 736 |
|
| 737 |
if (protocol == Ipv4L3ClickProtocol::PROT_NUMBER) |
| 738 |
{ |
| 739 |
uint32_t interface = 0; |
| 740 |
Ptr<Ipv4Interface> ipv4Interface; |
| 741 |
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); |
| 742 |
i != m_interfaces.end (); |
| 743 |
i++, interface++) |
| 744 |
{ |
| 745 |
ipv4Interface = *i; |
| 746 |
if (ipv4Interface->GetDevice () == device) |
| 747 |
{ |
| 748 |
if (ipv4Interface->IsUp ()) |
| 749 |
{ |
| 750 |
break; |
| 751 |
} |
| 752 |
else |
| 753 |
{ |
| 754 |
NS_LOG_LOGIC ("Dropping received packet -- interface is down"); |
| 755 |
return; |
| 756 |
} |
| 757 |
} |
| 758 |
} |
| 759 |
|
| 760 |
Ipv4Header ipHeader; |
| 761 |
if (Node::ChecksumEnabled ()) |
| 762 |
{ |
| 763 |
ipHeader.EnableChecksum (); |
| 764 |
} |
| 765 |
packetForRawSocket->RemoveHeader (ipHeader); |
| 766 |
|
| 767 |
|
| 768 |
for (SocketList::iterator i = m_sockets.begin (); i != m_sockets.end (); ++i) |
| 769 |
{ |
| 770 |
NS_LOG_LOGIC ("Forwarding to raw socket"); |
| 771 |
Ptr<Ipv4RawSocketImpl> socket = *i; |
| 772 |
socket->ForwardUp (packetForRawSocket, ipHeader, ipv4Interface); |
| 773 |
} |
| 774 |
} |
| 775 |
|
| 719 |
Ptr<Packet> packet = p->Copy (); |
776 |
Ptr<Packet> packet = p->Copy (); |
| 720 |
|
777 |
|
| 721 |
// Add an ethernet frame. This allows |
778 |
// Add an ethernet frame. This allows |