The IPv4 representation of a network interface. More...
#include <ipv4-interface.h>
Public Member Functions | |
Ipv4Interface () | |
virtual | ~Ipv4Interface () |
bool | AddAddress (Ipv4InterfaceAddress address) |
Ipv4InterfaceAddress | GetAddress (uint32_t index) const |
Ptr< ArpCache > | GetArpCache () const |
Ptr< NetDevice > | GetDevice (void) const |
uint16_t | GetMetric (void) const |
uint32_t | GetNAddresses (void) const |
bool | IsDown (void) const |
bool | IsForwarding (void) const |
bool | IsUp (void) const |
Ipv4InterfaceAddress | RemoveAddress (uint32_t index) |
void | Send (Ptr< Packet > p, Ipv4Address dest) |
void | SetArpCache (Ptr< ArpCache >) |
void | SetDevice (Ptr< NetDevice > device) |
void | SetDown (void) |
void | SetForwarding (bool val) |
void | SetMetric (uint16_t metric) |
void | SetNode (Ptr< Node > node) |
void | SetUp (void) |
![]() | |
Object () | |
virtual | ~Object () |
void | AggregateObject (Ptr< Object > other) |
void | Dispose (void) |
AggregateIterator | GetAggregateIterator (void) const |
virtual TypeId | GetInstanceTypeId (void) const |
template<typename T > | |
Ptr< T > | GetObject (void) const |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
void | Start (void) |
![]() | |
SimpleRefCount () | |
SimpleRefCount (const SimpleRefCount &o) | |
uint32_t | GetReferenceCount (void) const |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
void | Ref (void) const |
void | Unref (void) const |
![]() | |
virtual | ~ObjectBase () |
void | GetAttribute (std::string name, AttributeValue &value) const |
bool | GetAttributeFailSafe (std::string name, AttributeValue &attribute) const |
void | SetAttribute (std::string name, const AttributeValue &value) |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
This method returns the TypeId associated to ns3::Ipv4Interface. |
Protected Member Functions | |
virtual void | DoDispose (void) |
![]() | |
Object (const Object &o) | |
virtual void | DoStart (void) |
virtual void | NotifyNewAggregate (void) |
Private Types | |
typedef std::list < Ipv4InterfaceAddress > | Ipv4InterfaceAddressList |
typedef std::list < Ipv4InterfaceAddress > ::const_iterator | Ipv4InterfaceAddressListCI |
typedef std::list < Ipv4InterfaceAddress > ::iterator | Ipv4InterfaceAddressListI |
Private Member Functions | |
void | DoSetup (void) |
Private Attributes | |
Ptr< ArpCache > | m_cache |
Ptr< NetDevice > | m_device |
bool | m_forwarding |
Ipv4InterfaceAddressList | m_ifaddrs |
bool | m_ifup |
uint16_t | m_metric |
Ptr< Node > | m_node |
The IPv4 representation of a network interface.
This class roughly corresponds to the struct in_device of Linux; the main purpose is to provide address-family specific information (addresses) about an interface.
By default, Ipv4 interface are created in the "down" state no IP addresses. Before becoming useable, the user must add an address of some type and invoke Setup on them.
Definition at line 49 of file ipv4-interface.h.
|
private |
Definition at line 159 of file ipv4-interface.h.
|
private |
Definition at line 160 of file ipv4-interface.h.
|
private |
Definition at line 161 of file ipv4-interface.h.
ns3::Ipv4Interface::Ipv4Interface | ( | ) |
By default, Ipv4 interface are created in the "down" state with no IP addresses. Before becoming useable, the user must invoke SetUp on them once an Ipv4 address and mask have been set.
Definition at line 60 of file ipv4-interface.cc.
References NS_LOG_FUNCTION.
|
virtual |
Definition at line 71 of file ipv4-interface.cc.
References NS_LOG_FUNCTION_NOARGS.
bool ns3::Ipv4Interface::AddAddress | ( | Ipv4InterfaceAddress | address | ) |
address | The Ipv4InterfaceAddress to add to the interface |
Definition at line 289 of file ipv4-interface.cc.
References m_ifaddrs, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::Ipv4L3Protocol::AddAddress().
|
protectedvirtual |
This method is called by Object::Dispose or by the object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.
It is safe to call GetObject from within this method.
Reimplemented from ns3::Object.
Definition at line 77 of file ipv4-interface.cc.
References m_device, m_node, and NS_LOG_FUNCTION_NOARGS.
|
private |
Definition at line 100 of file ipv4-interface.cc.
References ns3::Object::GetObject(), m_cache, m_device, m_node, and ns3::NetDevice::NeedsArp().
Referenced by SetDevice(), and SetNode().
Ipv4InterfaceAddress ns3::Ipv4Interface::GetAddress | ( | uint32_t | index | ) | const |
index | Index of Ipv4InterfaceAddress to return |
Definition at line 297 of file ipv4-interface.cc.
References m_ifaddrs, NS_ASSERT, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::Ipv4L3Protocol::GetAddress(), and ns3::Ipv4EndPointDemux::Lookup().
Definition at line 141 of file ipv4-interface.cc.
References m_cache.
Referenced by ns3::dsr::DsrRouting::DoDispose(), GetTypeId(), and ns3::dsr::DsrRouting::Start().
Definition at line 115 of file ipv4-interface.cc.
References m_device.
Referenced by ns3::Ipv4RawSocketImpl::ForwardUp(), ns3::UdpSocketImpl::ForwardUp(), ns3::Ipv4L3Protocol::GetMtu(), ns3::Ipv4L3Protocol::GetNetDevice(), ns3::Ipv4EndPointDemux::Lookup(), ns3::Ipv4L3Protocol::Receive(), ns3::Ipv4L3Protocol::Send(), and ns3::Ipv4L3Protocol::SendRealOut().
uint16_t ns3::Ipv4Interface::GetMetric | ( | void | ) | const |
Note: This is synonymous to the Metric value that ifconfig prints out. It is used by ns-3 global routing, but other routing daemons may choose to ignore it.
Definition at line 128 of file ipv4-interface.cc.
References m_metric, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::Ipv4L3Protocol::GetMetric().
uint32_t ns3::Ipv4Interface::GetNAddresses | ( | void | ) | const |
Definition at line 282 of file ipv4-interface.cc.
References m_ifaddrs, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::Ipv4L3Protocol::GetNAddresses(), and ns3::Ipv4EndPointDemux::Lookup().
|
static |
This method returns the TypeId associated to ns3::Ipv4Interface.
This object is accessible through the following paths with Config::Set and Config::Connect:
Attributes defined for this type:
No TraceSources defined for this type.
Reimplemented from ns3::Object.
Definition at line 40 of file ipv4-interface.cc.
References GetArpCache(), SetArpCache(), and ns3::TypeId::SetParent().
bool ns3::Ipv4Interface::IsDown | ( | void | ) | const |
Definition at line 159 of file ipv4-interface.cc.
References m_ifup, and NS_LOG_FUNCTION_NOARGS.
bool ns3::Ipv4Interface::IsForwarding | ( | void | ) | const |
Definition at line 180 of file ipv4-interface.cc.
References m_forwarding, and NS_LOG_FUNCTION_NOARGS.
bool ns3::Ipv4Interface::IsUp | ( | void | ) | const |
These are IP interface states and may be distinct from NetDevice states, such as found in real implementations (where the device may be down but IP interface state is still up).
These are IP interface states and may be distinct from NetDevice states, such as found in real implementations (where the device may be down but IP interface state is still up).
Definition at line 152 of file ipv4-interface.cc.
References m_ifup, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::Ipv4L3Protocol::IsUp(), ns3::Ipv4L3Protocol::Receive(), Send(), and ns3::Ipv4L3Protocol::SendRealOut().
Ipv4InterfaceAddress ns3::Ipv4Interface::RemoveAddress | ( | uint32_t | index | ) |
index | Index of Ipv4InterfaceAddress to remove |
Definition at line 318 of file ipv4-interface.cc.
References m_ifaddrs, NS_ASSERT_MSG, and NS_LOG_FUNCTION_NOARGS.
void ns3::Ipv4Interface::Send | ( | Ptr< Packet > | p, |
Ipv4Address | dest | ||
) |
p | packet to send |
dest | next hop address of packet. |
This method will eventually call the private SendTo method which must be implemented by subclasses.
Definition at line 194 of file ipv4-interface.cc.
References ns3::NetDevice::GetBroadcast(), ns3::NetDevice::GetMulticast(), ns3::Object::GetObject(), ns3::Ipv4Address::IsBroadcast(), ns3::Ipv4Address::IsMulticast(), ns3::NetDevice::IsMulticast(), ns3::Ipv4Address::IsSubnetDirectedBroadcast(), IsUp(), m_cache, m_device, m_ifaddrs, m_node, ns3::NetDevice::NeedsArp(), NS_ASSERT_MSG, NS_LOG_FUNCTION, NS_LOG_LOGIC, ns3::NetDevice::PACKET_HOST, ns3::Ipv4L3Protocol::PROT_NUMBER, ns3::Ipv4L3Protocol::Receive(), and ns3::NetDevice::Send().
Referenced by ns3::Ipv4L3Protocol::Send(), and ns3::Ipv4L3Protocol::SendRealOut().
Definition at line 135 of file ipv4-interface.cc.
References m_cache.
Referenced by GetTypeId().
Definition at line 93 of file ipv4-interface.cc.
References DoSetup(), and m_device.
void ns3::Ipv4Interface::SetDown | ( | void | ) |
Disable this interface
Definition at line 173 of file ipv4-interface.cc.
References m_ifup, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::Ipv4L3Protocol::SetDown().
void ns3::Ipv4Interface::SetForwarding | ( | bool | val | ) |
val | Whether to enable or disable IP forwarding for input datagrams |
Definition at line 187 of file ipv4-interface.cc.
References m_forwarding, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::Ipv4L3Protocol::SetForwarding().
void ns3::Ipv4Interface::SetMetric | ( | uint16_t | metric | ) |
metric | configured routing metric (cost) of this interface |
Note: This is synonymous to the Metric value that ifconfig prints out. It is used by ns-3 global routing, but other routing daemons choose to ignore it.
Definition at line 121 of file ipv4-interface.cc.
References m_metric, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::SetMetric().
Definition at line 86 of file ipv4-interface.cc.
References DoSetup(), and m_node.
void ns3::Ipv4Interface::SetUp | ( | void | ) |
Enable this interface
Definition at line 166 of file ipv4-interface.cc.
References m_ifup, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::Ipv4L3Protocol::SetUp().
Definition at line 169 of file ipv4-interface.h.
Referenced by DoSetup(), GetArpCache(), Send(), and SetArpCache().
Definition at line 168 of file ipv4-interface.h.
Referenced by DoDispose(), DoSetup(), GetDevice(), Send(), and SetDevice().
|
private |
Definition at line 164 of file ipv4-interface.h.
Referenced by IsForwarding(), and SetForwarding().
|
private |
Definition at line 166 of file ipv4-interface.h.
Referenced by AddAddress(), GetAddress(), GetNAddresses(), RemoveAddress(), and Send().
|
private |
|
private |
Definition at line 165 of file ipv4-interface.h.
Referenced by GetMetric(), and SetMetric().
Definition at line 167 of file ipv4-interface.h.
Referenced by DoDispose(), DoSetup(), Send(), and SetNode().