Indent correctly IPv6 code.

This commit is contained in:
Sebastien Vincent
2009-12-30 14:22:25 +01:00
parent 6cb7afc694
commit 0752fbef6f
57 changed files with 8527 additions and 8528 deletions

View File

@@ -124,13 +124,13 @@ void Icmpv6Header::Serialize (Buffer::Iterator start) const
#endif
if (m_calcChecksum)
{
i = start;
uint16_t checksum = i.CalculateIpChecksum (i.GetSize (), m_checksum);
i = start;
i.Next (2);
i.WriteU16 (checksum);
}
{
i = start;
uint16_t checksum = i.CalculateIpChecksum (i.GetSize (), m_checksum);
i = start;
i.Next (2);
i.WriteU16 (checksum);
}
}
void Icmpv6Header::CalculatePseudoHeaderChecksum (Ipv6Address src, Ipv6Address dst, uint16_t length, uint8_t protocol)
@@ -192,7 +192,7 @@ Icmpv6NS::Icmpv6NS (Ipv6Address target)
/* test */
/*
m_reserved = 0xdeadbeef;
*/
*/
}
Icmpv6NS::~Icmpv6NS ()
@@ -244,13 +244,13 @@ void Icmpv6NS::Serialize (Buffer::Iterator start) const
i.Write (buff_target, 16);
if (m_calcChecksum)
{
i = start;
checksum = i.CalculateIpChecksum (i.GetSize (), m_checksum);
i = start;
i.Next (2);
i.WriteU16 (checksum);
}
{
i = start;
checksum = i.CalculateIpChecksum (i.GetSize (), m_checksum);
i = start;
i.Next (2);
i.WriteU16 (checksum);
}
}
uint32_t Icmpv6NS::Deserialize (Buffer::Iterator start)
@@ -371,32 +371,32 @@ void Icmpv6NA::Serialize (Buffer::Iterator start) const
i.WriteU16 (0);
if (m_flagR)
{
reserved |= (uint32_t)(1 << 31);
}
{
reserved |= (uint32_t)(1 << 31);
}
if (m_flagS)
{
reserved |= (uint32_t)(1<< 30);
}
{
reserved |= (uint32_t)(1<< 30);
}
if (m_flagO)
{
reserved |= (uint32_t)(1<< 29);
}
{
reserved |= (uint32_t)(1<< 29);
}
i.WriteHtonU32 (reserved);
m_target.Serialize (buff_target);
i.Write (buff_target, 16);
if (m_calcChecksum)
{
i = start;
checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ());
i = start;
i.Next (2);
i.WriteU16 (checksum);
}
{
i = start;
checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ());
i = start;
i.Next (2);
i.WriteU16 (checksum);
}
}
uint32_t Icmpv6NA::Deserialize (Buffer::Iterator start)
@@ -414,19 +414,19 @@ uint32_t Icmpv6NA::Deserialize (Buffer::Iterator start)
m_flagO = false;
if (m_reserved & (1 << 31))
{
m_flagR = true;
}
{
m_flagR = true;
}
if (m_reserved & (1 << 30))
{
m_flagS = true;
}
{
m_flagS = true;
}
if (m_reserved & (1 << 29))
{
m_flagO = true;
}
{
m_flagO = true;
}
i.Read (buf, 16);
m_target.Set (buf);
@@ -570,19 +570,19 @@ void Icmpv6RA::Serialize (Buffer::Iterator start) const
i.WriteU8 (m_curHopLimit);
if (m_flagM)
{
flags |= (uint8_t)(1<< 7);
}
{
flags |= (uint8_t)(1<< 7);
}
if (m_flagO)
{
flags |= (uint8_t)(1<< 6);
}
{
flags |= (uint8_t)(1<< 6);
}
if (m_flagH)
{
flags |= (uint8_t)(1<< 5);
}
{
flags |= (uint8_t)(1<< 5);
}
i.WriteU8 (flags);
i.WriteHtonU16 (GetLifeTime ());
i.WriteHtonU32 (GetReachableTime ());
@@ -610,19 +610,19 @@ uint32_t Icmpv6RA::Deserialize (Buffer::Iterator start)
m_flagH = false;
if (m_flags & (1 << 7))
{
m_flagM = true;
}
{
m_flagM = true;
}
if (m_flags & (1 << 6))
{
m_flagO = true;
}
{
m_flagO = true;
}
if (m_flags & (1 << 5))
{
m_flagH = true;
}
{
m_flagH = true;
}
SetLifeTime (i.ReadNtohU16 ());
SetReachableTime (i.ReadNtohU32 ());
SetRetransmissionTime (i.ReadNtohU32 ());
@@ -689,14 +689,14 @@ void Icmpv6RS::Serialize (Buffer::Iterator start) const
i.WriteHtonU32 (m_reserved);
if (m_calcChecksum)
{
i = start;
checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ());
i = start;
i.Next (2);
i.WriteU16 (checksum);
}
{
i = start;
checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ());
i = start;
i.Next (2);
i.WriteU16 (checksum);
}
}
uint32_t Icmpv6RS::Deserialize (Buffer::Iterator start)
@@ -800,14 +800,14 @@ void Icmpv6Redirection::Serialize (Buffer::Iterator start) const
i.Write (buff, 16);
if (m_calcChecksum)
{
i = start;
checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ());
{
i = start;
checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ());
i = start;
i.Next (2);
i.WriteU16 (checksum);
}
i = start;
i.Next (2);
i.WriteU16 (checksum);
}
}
uint32_t Icmpv6Redirection::Deserialize (Buffer::Iterator start)
@@ -912,13 +912,13 @@ void Icmpv6Echo::Serialize (Buffer::Iterator start) const
i.WriteHtonU16 (m_seq);
if (m_calcChecksum)
{
i = start;
checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ());
i = start;
i.Next (2);
i.WriteU16 (checksum);
}
{
i = start;
checksum = i.CalculateIpChecksum (i.GetSize (), GetChecksum ());
i = start;
i.Next (2);
i.WriteU16 (checksum);
}
}
uint32_t Icmpv6Echo::Deserialize (Buffer::Iterator start)
@@ -1215,7 +1215,7 @@ TypeId Icmpv6ParameterError::GetInstanceTypeId () const
Icmpv6ParameterError::Icmpv6ParameterError ()
: m_packet (0),
m_ptr (0)
m_ptr (0)
{
SetType (ICMPV6_ERROR_PARAMETER_ERROR);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -31,7 +31,7 @@
namespace ns3
{
class NetDevice;
class Node;
class Packet;
@@ -44,445 +44,445 @@ class NdiscCache;
*/
class Icmpv6L4Protocol : public Ipv6L4Protocol
{
public:
/**
* \brief Interface ID
*/
static TypeId GetTypeId ();
public:
/**
* \brief Interface ID
*/
static TypeId GetTypeId ();
/**
* \brief ICMPv6 protocol number (58).
*/
static const uint8_t PROT_NUMBER;
/**
* \brief ICMPv6 protocol number (58).
*/
static const uint8_t PROT_NUMBER;
/**
* \brief Neighbor Discovery router constants : max initial RA initial interval.
*/
static const uint8_t MAX_INITIAL_RTR_ADVERT_INTERVAL;
/**
* \brief Neighbor Discovery router constants : max initial RA initial interval.
*/
static const uint8_t MAX_INITIAL_RTR_ADVERT_INTERVAL;
/**
* \brief Neighbor Discovery router constants : max initial RA transmission.
*/
static const uint8_t MAX_INITIAL_RTR_ADVERTISEMENTS;
/**
* \brief Neighbor Discovery router constants : max initial RA transmission.
*/
static const uint8_t MAX_INITIAL_RTR_ADVERTISEMENTS;
/**
* \brief Neighbor Discovery router constants : max final RA transmission.
*/
static const uint8_t MAX_FINAL_RTR_ADVERTISEMENTS;
/**
* \brief Neighbor Discovery router constants : max final RA transmission.
*/
static const uint8_t MAX_FINAL_RTR_ADVERTISEMENTS;
/**
* \brief Neighbor Discovery router constants : min delay between RA.
*/
static const uint8_t MIN_DELAY_BETWEEN_RAS;
/**
* \brief Neighbor Discovery router constants : min delay between RA.
*/
static const uint8_t MIN_DELAY_BETWEEN_RAS;
/**
* \brief Neighbor Discovery router constants : max delay between RA.
*/
static const uint32_t MAX_RA_DELAY_TIME;
/**
* \brief Neighbor Discovery router constants : max delay between RA.
*/
static const uint32_t MAX_RA_DELAY_TIME;
/**
* \brief Neighbor Discovery host constants : max RS delay.
*/
static const uint8_t MAX_RTR_SOLICITATION_DELAY;
/**
* \brief Neighbor Discovery host constants : max RS delay.
*/
static const uint8_t MAX_RTR_SOLICITATION_DELAY;
/**
* \brief Neighbor Discovery host constants : RS interval.
*/
static const uint8_t RTR_SOLICITATION_INTERVAL;
/**
* \brief Neighbor Discovery host constants : RS interval.
*/
static const uint8_t RTR_SOLICITATION_INTERVAL;
/**
* \brief Neighbor Discovery host constants : max RS transmission.
*/
static const uint8_t MAX_RTR_SOLICITATIONS;
/**
* \brief Neighbor Discovery host constants : max RS transmission.
*/
static const uint8_t MAX_RTR_SOLICITATIONS;
/**
* \brief Neighbor Discovery node constants : max multicast solicitations.
*/
static const uint8_t MAX_MULTICAST_SOLICIT;
/**
* \brief Neighbor Discovery node constants : max multicast solicitations.
*/
static const uint8_t MAX_MULTICAST_SOLICIT;
/**
* \brief Neighbor Discovery node constants : max unicast solicitations.
*/
static const uint8_t MAX_UNICAST_SOLICIT;
/**
* \brief Neighbor Discovery node constants : max unicast solicitations.
*/
static const uint8_t MAX_UNICAST_SOLICIT;
/**
* \brief Neighbor Discovery node constants : max anycast delay.
*/
static const uint8_t MAX_ANYCAST_DELAY_TIME;
/**
* \brief Neighbor Discovery node constants : max anycast delay.
*/
static const uint8_t MAX_ANYCAST_DELAY_TIME;
/**
* \brief Neighbor Discovery node constants : max NA transmission.
*/
static const uint8_t MAX_NEIGHBOR_ADVERTISEMENT;
/**
* \brief Neighbor Discovery node constants : max NA transmission.
*/
static const uint8_t MAX_NEIGHBOR_ADVERTISEMENT;
/**
* \brief Neighbor Discovery node constants : reachable time.
*/
static const uint32_t REACHABLE_TIME;
/**
* \brief Neighbor Discovery node constants : reachable time.
*/
static const uint32_t REACHABLE_TIME;
/**
* \brief Neighbor Discovery node constants : retransmission timer.
*/
static const uint32_t RETRANS_TIMER;
/**
* \brief Neighbor Discovery node constants : retransmission timer.
*/
static const uint32_t RETRANS_TIMER;
/**
* \brief Neighbor Discovery node constants : delay for the first probe.
*/
static const uint8_t DELAY_FIRST_PROBE_TIME;
/**
* \brief Neighbor Discovery node constants : delay for the first probe.
*/
static const uint8_t DELAY_FIRST_PROBE_TIME;
/**
* \brief Neighbor Discovery node constants : min random factor.
*/
static const double MIN_RANDOM_FACTOR;
/**
* \brief Neighbor Discovery node constants : min random factor.
*/
static const double MIN_RANDOM_FACTOR;
/**
* \brief Neighbor Discovery node constants : max random factor.
*/
static const double MAX_RANDOM_FACTOR;
/**
* \brief Neighbor Discovery node constants : max random factor.
*/
static const double MAX_RANDOM_FACTOR;
/**
* \brief Get ICMPv6 protocol number.
* \return protocol number
*/
static uint16_t GetStaticProtocolNumber ();
/**
* \brief Get ICMPv6 protocol number.
* \return protocol number
*/
static uint16_t GetStaticProtocolNumber ();
/**
* \brief Constructor.
*/
Icmpv6L4Protocol ();
/**
* \brief Constructor.
*/
Icmpv6L4Protocol ();
/**
* \brief Destructor.
*/
virtual ~Icmpv6L4Protocol ();
/**
* \brief Destructor.
*/
virtual ~Icmpv6L4Protocol ();
/**
* \brief Set the node.
* \param node the node to set
*/
void SetNode (Ptr<Node> node);
/**
* \brief Set the node.
* \param node the node to set
*/
void SetNode (Ptr<Node> node);
/**
* \brief This method is called by AddAgregate and completes the aggregation
* by setting the node in the ICMPv6 stack and adding ICMPv6 factory to
* IPv6 stack connected to the node.
*/
void NotifyNewAggregate ();
/**
* \brief This method is called by AddAgregate and completes the aggregation
* by setting the node in the ICMPv6 stack and adding ICMPv6 factory to
* IPv6 stack connected to the node.
*/
void NotifyNewAggregate ();
/**
* \brief Get the protocol number.
* \return protocol number
*/
virtual int GetProtocolNumber () const;
/**
* \brief Get the protocol number.
* \return protocol number
*/
virtual int GetProtocolNumber () const;
/**
* \brief Get the version of the protocol.
* \return version
*/
virtual int GetVersion () const;
/**
* \brief Get the version of the protocol.
* \return version
*/
virtual int GetVersion () const;
/**
* \brief Send a packet via ICMPv6, note that packet already contains ICMPv6 header.
* \param packet the packet to send which contains ICMPv6 header
* \param src source address
* \param dst destination address
* \param ttl next hop limit
*/
void SendMessage (Ptr<Packet> packet, Ipv6Address src, Ipv6Address dst, uint8_t ttl);
/**
* \brief Send a packet via ICMPv6, note that packet already contains ICMPv6 header.
* \param packet the packet to send which contains ICMPv6 header
* \param src source address
* \param dst destination address
* \param ttl next hop limit
*/
void SendMessage (Ptr<Packet> packet, Ipv6Address src, Ipv6Address dst, uint8_t ttl);
/**
* \brief Send a packet via ICMPv6.
* \param packet the packet to send
* \param dst destination address
* \param icmpv6Hdr ICMPv6 header (needed to calculate checksum
* after source address is determined by routing stuff
* \param ttl next hop limit
*/
void SendMessage (Ptr<Packet> packet, Ipv6Address dst, Icmpv6Header& icmpv6Hdr, uint8_t ttl);
/**
* \brief Do the Duplication Address Detection (DAD).
* \param target target address
* \param interface interface
*/
void DoDAD (Ipv6Address target, Ptr<Ipv6Interface> interface);
/**
* \brief Send a packet via ICMPv6.
* \param packet the packet to send
* \param dst destination address
* \param icmpv6Hdr ICMPv6 header (needed to calculate checksum
* after source address is determined by routing stuff
* \param ttl next hop limit
*/
void SendMessage (Ptr<Packet> packet, Ipv6Address dst, Icmpv6Header& icmpv6Hdr, uint8_t ttl);
/**
* \brief Send a Neighbor Adverstisement.
* \param src source IPv6 address
* \param dst destination IPv6 address
* \param hardwareAddress our MAC address
* \param flags to set (4 = flag R, 2 = flag S, 3 = flag O)
*/
void SendNA (Ipv6Address src, Ipv6Address dst, Address* hardwareAddress, uint8_t flags);
/**
* \brief Do the Duplication Address Detection (DAD).
* \param target target address
* \param interface interface
*/
void DoDAD (Ipv6Address target, Ptr<Ipv6Interface> interface);
/**
* \brief Send a Echo Reply.
* \param src source IPv6 address
* \param dst destination IPv6 address
* \param id id of the packet
* \param seq sequence number
* \param data auxiliary data
*/
void SendEchoReply (Ipv6Address src, Ipv6Address dst, uint16_t id, uint16_t seq, Ptr<Packet> data);
/**
* \brief Send a Neighbor Adverstisement.
* \param src source IPv6 address
* \param dst destination IPv6 address
* \param hardwareAddress our MAC address
* \param flags to set (4 = flag R, 2 = flag S, 3 = flag O)
*/
void SendNA (Ipv6Address src, Ipv6Address dst, Address* hardwareAddress, uint8_t flags);
/**
* \brief Send a Neighbor Solicitation.
* \param src source IPv6 address
* \param dst destination IPv6 addresss
* \param target target IPv6 address
* \param hardwareAddress our mac address
*/
void SendNS (Ipv6Address src, Ipv6Address dst, Ipv6Address target, Address hardwareAddress);
/**
* \brief Send a Echo Reply.
* \param src source IPv6 address
* \param dst destination IPv6 address
* \param id id of the packet
* \param seq sequence number
* \param data auxiliary data
*/
void SendEchoReply (Ipv6Address src, Ipv6Address dst, uint16_t id, uint16_t seq, Ptr<Packet> data);
/**
* \brief Send an error Destination Unreachable.
* \param malformedPacket the malformed packet
* \param dst destination IPv6 address
* \param code code of the error
*/
void SendErrorDestinationUnreachable (Ptr<Packet> malformedPacket, Ipv6Address dst, uint8_t code);
/**
* \brief Send a Neighbor Solicitation.
* \param src source IPv6 address
* \param dst destination IPv6 addresss
* \param target target IPv6 address
* \param hardwareAddress our mac address
*/
void SendNS (Ipv6Address src, Ipv6Address dst, Ipv6Address target, Address hardwareAddress);
/**
* \brief Send an error Too Big.
* \param malformedPacket the malformed packet
* \param dst destination IPv6 address
* \param mtu the mtu
*/
void SendErrorTooBig (Ptr<Packet> malformedPacket, Ipv6Address dst, uint32_t mtu);
/**
* \brief Send an error Destination Unreachable.
* \param malformedPacket the malformed packet
* \param dst destination IPv6 address
* \param code code of the error
*/
void SendErrorDestinationUnreachable (Ptr<Packet> malformedPacket, Ipv6Address dst, uint8_t code);
/**
* \brief Send an error Time Exceeded.
* \param malformedPacket the malformed packet
* \param dst destination IPv6 address
* \param code code of the error
*/
void SendErrorTimeExceeded (Ptr<Packet> malformedPacket, Ipv6Address dst, uint8_t code);
/**
* \brief Send an error Too Big.
* \param malformedPacket the malformed packet
* \param dst destination IPv6 address
* \param mtu the mtu
*/
void SendErrorTooBig (Ptr<Packet> malformedPacket, Ipv6Address dst, uint32_t mtu);
/**
* \brief Send an error Parameter Error.
* \param malformedPacket the malformed packet
* \param dst destination IPv6 address
* \param code code of the error
* \param ptr byte of p where the error is located
*/
void SendErrorParameterError (Ptr<Packet> malformedPacket, Ipv6Address dst, uint8_t code, uint32_t ptr);
/**
* \brief Send an error Time Exceeded.
* \param malformedPacket the malformed packet
* \param dst destination IPv6 address
* \param code code of the error
*/
void SendErrorTimeExceeded (Ptr<Packet> malformedPacket, Ipv6Address dst, uint8_t code);
/**
* \brief Send an ICMPv6 Redirection.
* \param redirectedPacket the redirected packet
* \param dst destination IPv6 address
* \param redirTarget IPv6 target address for Icmpv6Redirection
* \param redirDestination IPv6 destination address for Icmpv6Redirection
* \param redirHardwareTarget L2 target address for Icmpv6OptionRdirected
*/
void SendRedirection (Ptr<Packet> redirectedPacket, Ipv6Address dst, Ipv6Address redirTarget, Ipv6Address redirDestination, Address redirHardwareTarget);
/**
* \brief Send an error Parameter Error.
* \param malformedPacket the malformed packet
* \param dst destination IPv6 address
* \param code code of the error
* \param ptr byte of p where the error is located
*/
void SendErrorParameterError (Ptr<Packet> malformedPacket, Ipv6Address dst, uint8_t code, uint32_t ptr);
/**
* \brief Forge a Neighbor Solicitation.
* \param src source IPv6 address
* \param dst destination IPv6 addresss
* \param target target IPv6 address
* \param hardwareAddress our mac address
* \return NS packet (with IPv6 header)
*/
Ptr<Packet> ForgeNS (Ipv6Address src, Ipv6Address dst, Ipv6Address target, Address hardwareAddress);
/**
* \brief Send an ICMPv6 Redirection.
* \param redirectedPacket the redirected packet
* \param dst destination IPv6 address
* \param redirTarget IPv6 target address for Icmpv6Redirection
* \param redirDestination IPv6 destination address for Icmpv6Redirection
* \param redirHardwareTarget L2 target address for Icmpv6OptionRdirected
*/
void SendRedirection (Ptr<Packet> redirectedPacket, Ipv6Address dst, Ipv6Address redirTarget, Ipv6Address redirDestination, Address redirHardwareTarget);
/**
* \brief Forge a Neighbor Advertisement.
* \param src source IPv6 address
* \param dst destination IPv6 addresss
* \param hardwareAddress our mac address
* \param flags flags (bitfield => R (4), S (2), O (1))
* \return NA packet (with IPv6 header)
*/
Ptr<Packet> ForgeNA (Ipv6Address src, Ipv6Address dst, Address* hardwareAddress, uint8_t flags);
/**
* \brief Forge a Neighbor Solicitation.
* \param src source IPv6 address
* \param dst destination IPv6 addresss
* \param target target IPv6 address
* \param hardwareAddress our mac address
* \return NS packet (with IPv6 header)
*/
Ptr<Packet> ForgeNS (Ipv6Address src, Ipv6Address dst, Ipv6Address target, Address hardwareAddress);
/**
* \brief Forge a Router Solicitation.
* \param src source IPv6 address
* \param dst destination IPv6 addresss
* \param hardwareAddress our mac address
* \return RS packet (with IPv6 header)
*/
Ptr<Packet> ForgeRS (Ipv6Address src, Ipv6Address dst, Address hardwareAddress);
/**
* \brief Forge a Neighbor Advertisement.
* \param src source IPv6 address
* \param dst destination IPv6 addresss
* \param hardwareAddress our mac address
* \param flags flags (bitfield => R (4), S (2), O (1))
* \return NA packet (with IPv6 header)
*/
Ptr<Packet> ForgeNA (Ipv6Address src, Ipv6Address dst, Address* hardwareAddress, uint8_t flags);
/**
* \brief Forge an Echo Request.
* \param src source address
* \param dst destination address
* \param id ID of the packet
* \param seq sequence number
* \param data the data
* \return Echo Request packet (without IPv6 header)
*/
Ptr<Packet> ForgeEchoRequest (Ipv6Address src, Ipv6Address dst, uint16_t id, uint16_t seq, Ptr<Packet> data);
/**
* \brief Forge a Router Solicitation.
* \param src source IPv6 address
* \param dst destination IPv6 addresss
* \param hardwareAddress our mac address
* \return RS packet (with IPv6 header)
*/
Ptr<Packet> ForgeRS (Ipv6Address src, Ipv6Address dst, Address hardwareAddress);
/**
* \brief Receive method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
virtual enum Ipv6L4Protocol::RxStatus_e Receive (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Forge an Echo Request.
* \param src source address
* \param dst destination address
* \param id ID of the packet
* \param seq sequence number
* \param data the data
* \return Echo Request packet (without IPv6 header)
*/
Ptr<Packet> ForgeEchoRequest (Ipv6Address src, Ipv6Address dst, uint16_t id, uint16_t seq, Ptr<Packet> data);
/**
* \brief Do the Duplication Address Detection.
* It consists in sending a NS with our IPv6 as target. If
* we received a NA with matched target address, we could not use the address,
* else the address pass from TENTATIVE to PERMANENT.
* \param addr IPv6 address to test
* \param interface interface
*/
void DoDad (Ipv6Address addr, Ptr<Ipv6Interface> interface);
/**
* \brief Receive method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
virtual enum Ipv6L4Protocol::RxStatus_e Receive (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Function called when DAD timeout.
* \param icmpv6 Icmpv6L4Protocol instance
* \param interface the interface
* \param addr the IPv6 address
*/
static void FunctionDadTimeout (Ptr<Icmpv6L4Protocol> icmpv6, Ipv6Interface* interface, Ipv6Address addr);
/**
* \brief Do the Duplication Address Detection.
* It consists in sending a NS with our IPv6 as target. If
* we received a NA with matched target address, we could not use the address,
* else the address pass from TENTATIVE to PERMANENT.
* \param addr IPv6 address to test
* \param interface interface
*/
void DoDad (Ipv6Address addr, Ptr<Ipv6Interface> interface);
/**
* \brief Lookup in the ND cache for the IPv6 address
* \param dst destination address
* \param device device
* \param cache the neighbor cache
* \param hardwareDestination hardware address
* \note Unlike other Lookup method, it does not send NS request!
*/
bool Lookup (Ipv6Address dst, Ptr<NetDevice> device, Ptr<NdiscCache> cache, Address* hardwareDestination);
/**
* \brief Function called when DAD timeout.
* \param icmpv6 Icmpv6L4Protocol instance
* \param interface the interface
* \param addr the IPv6 address
*/
static void FunctionDadTimeout (Ptr<Icmpv6L4Protocol> icmpv6, Ipv6Interface* interface, Ipv6Address addr);
/**
* \brief Lookup in the ND cache for the IPv6 address (similar as ARP protocol).
*
* It also send NS request to target and store the waiting packet.
* \param p the packet
* \param dst destination address
* \param device device
* \param cache the neighbor cache
* \param hardwareDestination hardware address
* \return true if the address is in the ND cache, the hardwareDestination is updated.
*/
bool Lookup (Ptr<Packet> p, Ipv6Address dst, Ptr<NetDevice> device, Ptr<NdiscCache> cache, Address* hardwareDestination);
/**
* \brief Lookup in the ND cache for the IPv6 address
* \param dst destination address
* \param device device
* \param cache the neighbor cache
* \param hardwareDestination hardware address
* \note Unlike other Lookup method, it does not send NS request!
*/
bool Lookup (Ipv6Address dst, Ptr<NetDevice> device, Ptr<NdiscCache> cache, Address* hardwareDestination);
/**
* \brief Send a Router Solicitation.
* \param src link-local source address
* \param dst destination address (usealy ff02::2 i.e all-routers)
* \param hardwareAddress link-layer address (SHOULD be included if src is not ::
*/
void SendRS (Ipv6Address src, Ipv6Address dst, Address hardwareAddress);
/**
* \brief Lookup in the ND cache for the IPv6 address (similar as ARP protocol).
*
* It also send NS request to target and store the waiting packet.
* \param p the packet
* \param dst destination address
* \param device device
* \param cache the neighbor cache
* \param hardwareDestination hardware address
* \return true if the address is in the ND cache, the hardwareDestination is updated.
*/
bool Lookup (Ptr<Packet> p, Ipv6Address dst, Ptr<NetDevice> device, Ptr<NdiscCache> cache, Address* hardwareDestination);
/**
* \brief Create a neighbor cache.
* \param device thet NetDevice
* \param interface the IPv6 interface
* \return a smart pointer of NdCache or 0 if problem
*/
Ptr<NdiscCache> CreateCache (Ptr<NetDevice> device, Ptr<Ipv6Interface> interface);
/**
* \brief Send a Router Solicitation.
* \param src link-local source address
* \param dst destination address (usealy ff02::2 i.e all-routers)
* \param hardwareAddress link-layer address (SHOULD be included if src is not ::
*/
void SendRS (Ipv6Address src, Ipv6Address dst, Address hardwareAddress);
/**
* \brief Is the node must do DAD.
* \return true if node has to do DAD.
*/
bool IsAlwaysDad () const;
/**
* \brief Create a neighbor cache.
* \param device thet NetDevice
* \param interface the IPv6 interface
* \return a smart pointer of NdCache or 0 if problem
*/
Ptr<NdiscCache> CreateCache (Ptr<NetDevice> device, Ptr<Ipv6Interface> interface);
protected:
/**
* \brief Dispose this object.
*/
virtual void DoDispose ();
/**
* \brief Is the node must do DAD.
* \return true if node has to do DAD.
*/
bool IsAlwaysDad () const;
private:
protected:
/**
* \brief Dispose this object.
*/
virtual void DoDispose ();
typedef std::list<Ptr<NdiscCache> > CacheList;
private:
/**
* \brief The node.
*/
Ptr<Node> m_node;
typedef std::list<Ptr<NdiscCache> > CacheList;
/**
* \brief A list of cache by device.
*/
CacheList m_cacheList;
/**
* \brief The node.
*/
Ptr<Node> m_node;
/**
* \brief Always do DAD ?
*/
bool m_alwaysDad;
/**
* \brief A list of cache by device.
*/
CacheList m_cacheList;
/**
* \brief Receive Neighbor Solicitation method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void HandleNS (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Always do DAD ?
*/
bool m_alwaysDad;
/**
* \brief Receive Router Solicitation method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void HandleRS (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Receive Neighbor Solicitation method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void HandleNS (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Receive Router Advertisement method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void HandleRA (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Receive Router Solicitation method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void HandleRS (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Receive Echo Request method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void HandleEchoRequest (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Receive Router Advertisement method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void HandleRA (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Receive Neighbor Advertisement method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void HandleNA (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Receive Echo Request method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void HandleEchoRequest (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Receive Redirection method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void HandleRedirection (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Receive Neighbor Advertisement method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void HandleNA (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Link layer address option processing.
* \param lla LLA option
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void ReceiveLLA (Icmpv6OptionLinkLayerAddress lla, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Receive Redirection method.
* \param p the packet
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void HandleRedirection (Ptr<Packet> p, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Get the cache corresponding to the device.
* \param device the device
*/
Ptr<NdiscCache> FindCache (Ptr<NetDevice> device);
/**
* \brief Link layer address option processing.
* \param lla LLA option
* \param src source address
* \param dst destination address
* \param interface the interface from which the packet is coming
*/
void ReceiveLLA (Icmpv6OptionLinkLayerAddress lla, Ipv6Address const &src, Ipv6Address const &dst, Ptr<Ipv6Interface> interface);
/**
* \brief Get the cache corresponding to the device.
* \param device the device
*/
Ptr<NdiscCache> FindCache (Ptr<NetDevice> device);
};
} /* namespace ns3 */

View File

@@ -28,173 +28,174 @@ NS_LOG_COMPONENT_DEFINE ("Ipv6AutoconfiguredPrefix");
namespace ns3
{
uint32_t Ipv6AutoconfiguredPrefix::m_prefixId = 0;
Ipv6AutoconfiguredPrefix::Ipv6AutoconfiguredPrefix (Ptr<Node> node, uint32_t interface, Ipv6Address prefix, Ipv6Prefix mask, uint32_t preferredLifeTime, uint32_t validLifeTime, Ipv6Address router)
{
m_node = node;
m_interface = interface;
m_validLifeTime = validLifeTime;
m_preferredLifeTime = preferredLifeTime;
m_id = m_prefixId;
m_prefixId ++;
m_preferred = false;
m_valid = false;
m_prefix = prefix;
m_mask = mask;
m_defaultGatewayRouter = router;
}
uint32_t Ipv6AutoconfiguredPrefix::m_prefixId = 0;
Ipv6AutoconfiguredPrefix::~Ipv6AutoconfiguredPrefix ()
{
}
Ipv6AutoconfiguredPrefix::Ipv6AutoconfiguredPrefix (Ptr<Node> node, uint32_t interface, Ipv6Address prefix, Ipv6Prefix mask, uint32_t preferredLifeTime, uint32_t validLifeTime, Ipv6Address router)
{
m_node = node;
m_interface = interface;
m_validLifeTime = validLifeTime;
m_preferredLifeTime = preferredLifeTime;
m_id = m_prefixId;
m_prefixId ++;
m_preferred = false;
m_valid = false;
m_prefix = prefix;
m_mask = mask;
m_defaultGatewayRouter = router;
}
void Ipv6AutoconfiguredPrefix::SetDefaultGatewayRouter (Ipv6Address router)
{
m_defaultGatewayRouter = router;
}
Ipv6AutoconfiguredPrefix::~Ipv6AutoconfiguredPrefix ()
{
}
Ipv6Address Ipv6AutoconfiguredPrefix::GetDefaultGatewayRouter () const
{
return m_defaultGatewayRouter;
}
void Ipv6AutoconfiguredPrefix::SetDefaultGatewayRouter (Ipv6Address router)
{
m_defaultGatewayRouter = router;
}
void Ipv6AutoconfiguredPrefix::SetInterface (uint32_t interface)
{
m_interface = interface;
}
Ipv6Address Ipv6AutoconfiguredPrefix::GetDefaultGatewayRouter () const
{
return m_defaultGatewayRouter;
}
uint32_t Ipv6AutoconfiguredPrefix::GetInterface () const
{
return m_interface;
}
void Ipv6AutoconfiguredPrefix::SetInterface (uint32_t interface)
{
m_interface = interface;
}
void Ipv6AutoconfiguredPrefix::SetPreferredLifeTime (uint32_t t)
{
m_preferredLifeTime = t;
}
uint32_t Ipv6AutoconfiguredPrefix::GetInterface () const
{
return m_interface;
}
uint32_t Ipv6AutoconfiguredPrefix::GetPreferredLifeTime () const
{
return m_preferredLifeTime;
}
void Ipv6AutoconfiguredPrefix::SetPreferredLifeTime (uint32_t t)
{
m_preferredLifeTime = t;
}
void Ipv6AutoconfiguredPrefix::SetValidLifeTime (uint32_t t)
{
m_validLifeTime = t;
}
uint32_t Ipv6AutoconfiguredPrefix::GetPreferredLifeTime () const
{
return m_preferredLifeTime;
}
uint32_t Ipv6AutoconfiguredPrefix::GetValidLifeTime () const
{
return m_validLifeTime;
}
void Ipv6AutoconfiguredPrefix::SetValidLifeTime (uint32_t t)
{
m_validLifeTime = t;
}
void Ipv6AutoconfiguredPrefix::MarkPreferredTime ()
{
m_preferred = true;
}
uint32_t Ipv6AutoconfiguredPrefix::GetValidLifeTime () const
{
return m_validLifeTime;
}
void Ipv6AutoconfiguredPrefix::MarkValidTime ()
{
m_preferred = false;
m_valid = true;
}
void Ipv6AutoconfiguredPrefix::MarkPreferredTime ()
{
m_preferred = true;
}
void Ipv6AutoconfiguredPrefix::FunctionPreferredTimeout ()
{
NS_LOG_INFO ("Preferred Time expired for " << m_prefix);
m_preferred = false;
MarkValidTime ();
StartValidTimer ();
}
void Ipv6AutoconfiguredPrefix::MarkValidTime ()
{
m_preferred = false;
m_valid = true;
}
void Ipv6AutoconfiguredPrefix::FunctionValidTimeout ()
{
NS_LOG_INFO ("Valid Time expired for " << m_prefix);
m_valid = false;
RemoveMe ();
}
void Ipv6AutoconfiguredPrefix::FunctionPreferredTimeout ()
{
NS_LOG_INFO ("Preferred Time expired for " << m_prefix);
m_preferred = false;
MarkValidTime ();
StartValidTimer ();
}
void Ipv6AutoconfiguredPrefix::StartPreferredTimer ()
{
NS_LOG_INFO ("Start PreferredTimer for " << m_prefix);
m_preferredTimer.SetFunction (&Ipv6AutoconfiguredPrefix::FunctionPreferredTimeout, this);
m_preferredTimer.SetDelay (Seconds (m_preferredLifeTime));
m_preferredTimer.Schedule ();
}
void Ipv6AutoconfiguredPrefix::FunctionValidTimeout ()
{
NS_LOG_INFO ("Valid Time expired for " << m_prefix);
m_valid = false;
RemoveMe ();
}
void Ipv6AutoconfiguredPrefix::StartValidTimer ()
{
NS_LOG_INFO ("Start ValidTimer for " << m_prefix);
m_validTimer.SetFunction (&Ipv6AutoconfiguredPrefix::FunctionValidTimeout, this);
m_validTimer.SetDelay (Seconds (m_validLifeTime - m_preferredLifeTime));
m_validTimer.Schedule ();
}
void Ipv6AutoconfiguredPrefix::StartPreferredTimer ()
{
NS_LOG_INFO ("Start PreferredTimer for " << m_prefix);
m_preferredTimer.SetFunction (&Ipv6AutoconfiguredPrefix::FunctionPreferredTimeout, this);
m_preferredTimer.SetDelay (Seconds (m_preferredLifeTime));
m_preferredTimer.Schedule ();
}
void Ipv6AutoconfiguredPrefix::StopPreferredTimer ()
{
NS_LOG_INFO ("Stop PreferredTimer for " << m_prefix);
m_preferredTimer.Cancel ();
}
void Ipv6AutoconfiguredPrefix::StartValidTimer ()
{
NS_LOG_INFO ("Start ValidTimer for " << m_prefix);
m_validTimer.SetFunction (&Ipv6AutoconfiguredPrefix::FunctionValidTimeout, this);
m_validTimer.SetDelay (Seconds (m_validLifeTime - m_preferredLifeTime));
m_validTimer.Schedule ();
}
void Ipv6AutoconfiguredPrefix::StopValidTimer ()
{
NS_LOG_INFO ("Stop ValidTimer for " << m_prefix);
m_validTimer.Cancel ();
}
void Ipv6AutoconfiguredPrefix::StopPreferredTimer ()
{
NS_LOG_INFO ("Stop PreferredTimer for " << m_prefix);
m_preferredTimer.Cancel ();
}
void Ipv6AutoconfiguredPrefix::RemoveMe ()
{
NS_LOG_INFO ("The prefix " << m_prefix << " will be removed on interface " << m_interface);
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
ipv6->RemoveAutoconfiguredAddress (m_interface, m_prefix, m_mask, m_defaultGatewayRouter);
}
void Ipv6AutoconfiguredPrefix::StopValidTimer ()
{
NS_LOG_INFO ("Stop ValidTimer for " << m_prefix);
m_validTimer.Cancel ();
}
void Ipv6AutoconfiguredPrefix::SetPreferred ()
{
m_preferred = true;
}
void Ipv6AutoconfiguredPrefix::RemoveMe ()
{
NS_LOG_INFO ("The prefix " << m_prefix << " will be removed on interface " << m_interface);
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
ipv6->RemoveAutoconfiguredAddress (m_interface, m_prefix, m_mask, m_defaultGatewayRouter);
}
void Ipv6AutoconfiguredPrefix::SetValid ()
{
m_preferred = false;
m_valid = true;
}
void Ipv6AutoconfiguredPrefix::SetPreferred ()
{
m_preferred = true;
}
uint32_t Ipv6AutoconfiguredPrefix::GetId () const
{
return m_id;
}
void Ipv6AutoconfiguredPrefix::SetValid ()
{
m_preferred = false;
m_valid = true;
}
bool Ipv6AutoconfiguredPrefix::IsPreferred () const
{
return m_preferred;
}
uint32_t Ipv6AutoconfiguredPrefix::GetId () const
{
return m_id;
}
bool Ipv6AutoconfiguredPrefix::IsValid () const
{
return m_valid;
}
bool Ipv6AutoconfiguredPrefix::IsPreferred () const
{
return m_preferred;
}
Ipv6Address Ipv6AutoconfiguredPrefix::GetPrefix () const
{
return m_prefix;
}
bool Ipv6AutoconfiguredPrefix::IsValid () const
{
return m_valid;
}
void Ipv6AutoconfiguredPrefix::SetPrefix (Ipv6Address prefix)
{
m_prefix = prefix;
}
Ipv6Address Ipv6AutoconfiguredPrefix::GetPrefix () const
{
return m_prefix;
}
Ipv6Prefix Ipv6AutoconfiguredPrefix::GetMask () const
{
return m_mask;
}
void Ipv6AutoconfiguredPrefix::SetPrefix (Ipv6Address prefix)
{
m_prefix = prefix;
}
void Ipv6AutoconfiguredPrefix::SetMask (Ipv6Prefix mask)
{
m_mask = mask;
}
Ipv6Prefix Ipv6AutoconfiguredPrefix::GetMask () const
{
return m_mask;
}
void Ipv6AutoconfiguredPrefix::SetMask (Ipv6Prefix mask)
{
m_mask = mask;
}
} /* namespace ns3 */

View File

@@ -39,239 +39,239 @@ namespace ns3
*/
class Ipv6AutoconfiguredPrefix : public Object
{
public:
/**
* \brief Constructor.
* \param node node
* \param interface interface index
* \param prefix IPv6 address
* \param mask bitmask prefix
* \param preferredLifeTime the preferred life time
* \param validLifeTime the valid life time
* \param router if it the prefix that configure the default gateway
*/
Ipv6AutoconfiguredPrefix (Ptr<Node> node, uint32_t interface, Ipv6Address prefix, Ipv6Prefix mask, uint32_t preferredLifeTime, uint32_t validLifeTime, Ipv6Address router = Ipv6Address ("::"));
public:
/**
* \brief Constructor.
* \param node node
* \param interface interface index
* \param prefix IPv6 address
* \param mask bitmask prefix
* \param preferredLifeTime the preferred life time
* \param validLifeTime the valid life time
* \param router if it the prefix that configure the default gateway
*/
Ipv6AutoconfiguredPrefix (Ptr<Node> node, uint32_t interface, Ipv6Address prefix, Ipv6Prefix mask, uint32_t preferredLifeTime, uint32_t validLifeTime, Ipv6Address router = Ipv6Address ("::"));
/**
* \brief Destructor.
*/
~Ipv6AutoconfiguredPrefix ();
/**
* \brief Destructor.
*/
~Ipv6AutoconfiguredPrefix ();
/**
* \brief Set the default gateway router.
* \param router IPv6 link-local address of the default router
*/
void SetDefaultGatewayRouter (Ipv6Address router);
/**
* \brief Set the default gateway router.
* \param router IPv6 link-local address of the default router
*/
void SetDefaultGatewayRouter (Ipv6Address router);
/**
* \brief Get the default gateway address.
* \return IPv6 link-local address of the default router
*/
Ipv6Address GetDefaultGatewayRouter () const;
/**
* \brief Get the default gateway address.
* \return IPv6 link-local address of the default router
*/
Ipv6Address GetDefaultGatewayRouter () const;
/**
* \brief Get the interface index.
* \return interface index
*/
uint32_t GetInterface () const;
/**
* \brief Get the interface index.
* \return interface index
*/
uint32_t GetInterface () const;
/**
* \brief Set the interface.
* \param interface interface index to set
*/
void SetInterface (uint32_t interface);
/**
* \brief Set the interface.
* \param interface interface index to set
*/
void SetInterface (uint32_t interface);
/**
* \brief Get the prefix preferred life time.
* \return preferred life time
*/
uint32_t GetPreferredLifeTime () const;
/**
* \brief Get the prefix preferred life time.
* \return preferred life time
*/
uint32_t GetPreferredLifeTime () const;
/**
* \brief Set the prefix preferred life time.
* \param p the prefix preferred life time
*/
void SetPreferredLifeTime (uint32_t p);
/**
* \brief Set the prefix preferred life time.
* \param p the prefix preferred life time
*/
void SetPreferredLifeTime (uint32_t p);
/**
* \brief Get the prefix valid life time.
* \return valid life time
*/
uint32_t GetValidLifeTime (void) const;
/**
* \brief Get the prefix valid life time.
* \return valid life time
*/
uint32_t GetValidLifeTime (void) const;
/**
* \brief Set the prefix valid life time.
* \param v the prefix valid life time
*/
void SetValidLifeTime (uint32_t v);
/**
* \brief Set the prefix valid life time.
* \param v the prefix valid life time
*/
void SetValidLifeTime (uint32_t v);
/**
* \brief Test if the prefix is preferred.
* \return true if prefix is in preferred state, false otherwise
*/
bool IsPreferred () const;
/**
* \brief Test if the prefix is preferred.
* \return true if prefix is in preferred state, false otherwise
*/
bool IsPreferred () const;
/**
* \brief Test if the prefix is valid.
* \return true if prefix is in valid state, false otherwise
*/
bool IsValid () const;
/**
* \brief Test if the prefix is valid.
* \return true if prefix is in valid state, false otherwise
*/
bool IsValid () const;
/**
* \brief Set the prefix as preferred.
*/
void SetPreferred ();
/**
* \brief Set the prefix as preferred.
*/
void SetPreferred ();
/**
* \brief Set the prefix as valid.
*/
void SetValid ();
/**
* \brief Set the prefix as valid.
*/
void SetValid ();
/**
* \brief Start the preferred timer.
*/
void StartPreferredTimer ();
/**
* \brief Start the preferred timer.
*/
void StartPreferredTimer ();
/**
* \brief Start the valid timer.
*/
void StartValidTimer ();
/**
* \brief Start the valid timer.
*/
void StartValidTimer ();
/**
* \brief Stop the preferred timer.
*/
void StopPreferredTimer ();
/**
* \brief Stop the preferred timer.
*/
void StopPreferredTimer ();
/**
* \brief Stop the valid timer.
*/
void StopValidTimer ();
/**
* \brief Stop the valid timer.
*/
void StopValidTimer ();
/**
* \brief Set the prefix as preferred.
*/
void MarkPreferredTime ();
/**
* \brief Set the prefix as preferred.
*/
void MarkPreferredTime ();
/**
* \brief Set the prefix as valid.
*/
void MarkValidTime ();
/**
* \brief Set the prefix as valid.
*/
void MarkValidTime ();
/**
* \brief Signal that the preferred time expired and start the valid timer.
*/
void FunctionPreferredTimeout ();
/**
* \brief Signal that the preferred time expired and start the valid timer.
*/
void FunctionPreferredTimeout ();
/**
* \brief Signal that the valid time expired.
*/
void FunctionValidTimeout ();
/**
* \brief Signal that the valid time expired.
*/
void FunctionValidTimeout ();
/**
* \brief Remove this prefix from the prefix list.
*/
void RemoveMe ();
/**
* \brief Remove this prefix from the prefix list.
*/
void RemoveMe ();
/**
* \brief Get the prefix identifier.
* \return id of the prefix.
*/
uint32_t GetId () const;
/**
* \brief Get the prefix identifier.
* \return id of the prefix.
*/
uint32_t GetId () const;
/**
* \brief Get the prefix address.
* \return prefix address
*/
Ipv6Address GetPrefix () const;
/**
* \brief Get the prefix address.
* \return prefix address
*/
Ipv6Address GetPrefix () const;
/**
* \brief Set the prefix address.
* \param prefix prefix address to set
*/
void SetPrefix (Ipv6Address prefix);
/**
* \brief Set the prefix address.
* \param prefix prefix address to set
*/
void SetPrefix (Ipv6Address prefix);
/**
* \brief Get the bitmask prefix.
* \return bitmask prefix
*/
Ipv6Prefix GetMask () const;
/**
* \brief Get the bitmask prefix.
* \return bitmask prefix
*/
Ipv6Prefix GetMask () const;
/**
* \brief Set the bitmask prefix.
* \param mask prefix
*/
void SetMask (Ipv6Prefix mask);
/**
* \brief Set the bitmask prefix.
* \param mask prefix
*/
void SetMask (Ipv6Prefix mask);
private:
/**
* \brief a static identifier.
*/
static uint32_t m_prefixId;
private:
/**
* \brief a static identifier.
*/
static uint32_t m_prefixId;
/**
* \brief the identifier of this prefix.
*/
uint32_t m_id;
/**
* \brief the identifier of this prefix.
*/
uint32_t m_id;
/**
* \brief The node.
*/
Ptr<Node> m_node;
/**
* \brief The node.
*/
Ptr<Node> m_node;
/**
* \brief The prefix IP6 address.
*/
Ipv6Address m_prefix;
/**
* \brief The prefix IP6 address.
*/
Ipv6Address m_prefix;
/**
* \brief The prefix bitmask (length).
*/
Ipv6Prefix m_mask;
/**
* \brief The prefix bitmask (length).
*/
Ipv6Prefix m_mask;
/**
* \brief Default gateway router.
*
* If the RA received also configured the default gateway,
* this variable has the link-local address. Otherwise this
* is "::"
*/
Ipv6Address m_defaultGatewayRouter;
/**
* \brief Default gateway router.
*
* If the RA received also configured the default gateway,
* this variable has the link-local address. Otherwise this
* is "::"
*/
Ipv6Address m_defaultGatewayRouter;
/**
* \brief The interface index (which is stored the address
* corresponding of the prefix).
*/
uint32_t m_interface;
/**
* \brief The interface index (which is stored the address
* corresponding of the prefix).
*/
uint32_t m_interface;
/**
* \brief the valid life time.
*/
uint32_t m_validLifeTime;
/**
* \brief the valid life time.
*/
uint32_t m_validLifeTime;
/**
* \brief the preferred life time.
*/
uint32_t m_preferredLifeTime;
/**
* \brief the preferred life time.
*/
uint32_t m_preferredLifeTime;
/**
* \brief true if the prefix is preferred.
*/
bool m_preferred;
/**
* \brief true if the prefix is preferred.
*/
bool m_preferred;
/**
* \brief true if the prefix is valid.
*/
bool m_valid;
/**
* \brief true if the prefix is valid.
*/
bool m_valid;
/**
* \brief the timer for preferred life time.
*/
Timer m_preferredTimer;
/**
* \brief the timer for preferred life time.
*/
Timer m_preferredTimer;
/**
* \brief the timer for valid life time.
*/
Timer m_validTimer;
/**
* \brief the timer for valid life time.
*/
Timer m_validTimer;
};
} /* namespace ns3 */

View File

@@ -37,10 +37,10 @@ Ipv6EndPointDemux::~Ipv6EndPointDemux ()
{
NS_LOG_FUNCTION_NOARGS ();
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++)
{
Ipv6EndPoint *endPoint = *i;
delete endPoint;
}
{
Ipv6EndPoint *endPoint = *i;
delete endPoint;
}
m_endPoints.clear ();
}
@@ -48,12 +48,12 @@ bool Ipv6EndPointDemux::LookupPortLocal (uint16_t port)
{
NS_LOG_FUNCTION (this << port);
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++)
{
if ((*i)->GetLocalPort () == port)
{
return true;
if ((*i)->GetLocalPort () == port)
{
return true;
}
}
}
return false;
}
@@ -61,13 +61,13 @@ bool Ipv6EndPointDemux::LookupLocal (Ipv6Address addr, uint16_t port)
{
NS_LOG_FUNCTION (this << addr << port);
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++)
{
if ((*i)->GetLocalPort () == port &&
(*i)->GetLocalAddress () == addr)
{
return true;
if ((*i)->GetLocalPort () == port &&
(*i)->GetLocalAddress () == addr)
{
return true;
}
}
}
return false;
}
@@ -76,10 +76,10 @@ Ipv6EndPoint* Ipv6EndPointDemux::Allocate ()
NS_LOG_FUNCTION_NOARGS ();
uint16_t port = AllocateEphemeralPort ();
if (port == 0)
{
NS_LOG_WARN ("Ephemeral port allocation failed.");
return 0;
}
{
NS_LOG_WARN ("Ephemeral port allocation failed.");
return 0;
}
Ipv6EndPoint *endPoint = new Ipv6EndPoint (Ipv6Address::GetAny (), port);
m_endPoints.push_back (endPoint);
NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints.");
@@ -91,10 +91,10 @@ Ipv6EndPoint* Ipv6EndPointDemux::Allocate (Ipv6Address address)
NS_LOG_FUNCTION (this << address);
uint16_t port = AllocateEphemeralPort ();
if (port == 0)
{
NS_LOG_WARN ("Ephemeral port allocation failed.");
return 0;
}
{
NS_LOG_WARN ("Ephemeral port allocation failed.");
return 0;
}
Ipv6EndPoint *endPoint = new Ipv6EndPoint (address, port);
m_endPoints.push_back (endPoint);
NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints.");
@@ -112,10 +112,10 @@ Ipv6EndPoint* Ipv6EndPointDemux::Allocate (Ipv6Address address, uint16_t port)
{
NS_LOG_FUNCTION (this << address << port);
if (LookupLocal (address, port))
{
NS_LOG_WARN ("Duplicate address/port; failing.");
return 0;
}
{
NS_LOG_WARN ("Duplicate address/port; failing.");
return 0;
}
Ipv6EndPoint *endPoint = new Ipv6EndPoint (address, port);
m_endPoints.push_back (endPoint);
NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints.");
@@ -123,21 +123,21 @@ Ipv6EndPoint* Ipv6EndPointDemux::Allocate (Ipv6Address address, uint16_t port)
}
Ipv6EndPoint* Ipv6EndPointDemux::Allocate (Ipv6Address localAddress, uint16_t localPort,
Ipv6Address peerAddress, uint16_t peerPort)
Ipv6Address peerAddress, uint16_t peerPort)
{
NS_LOG_FUNCTION (this << localAddress << localPort << peerAddress << peerPort);
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++)
{
if ((*i)->GetLocalPort () == localPort &&
(*i)->GetLocalAddress () == localAddress &&
(*i)->GetPeerPort () == peerPort &&
(*i)->GetPeerAddress () == peerAddress)
{
NS_LOG_WARN ("No way we can allocate this end-point.");
/* no way we can allocate this end-point. */
return 0;
if ((*i)->GetLocalPort () == localPort &&
(*i)->GetLocalAddress () == localAddress &&
(*i)->GetPeerPort () == peerPort &&
(*i)->GetPeerAddress () == peerAddress)
{
NS_LOG_WARN ("No way we can allocate this end-point.");
/* no way we can allocate this end-point. */
return 0;
}
}
}
Ipv6EndPoint *endPoint = new Ipv6EndPoint (localAddress, localPort);
endPoint->SetPeer (peerAddress, peerPort);
m_endPoints.push_back (endPoint);
@@ -151,14 +151,14 @@ void Ipv6EndPointDemux::DeAllocate (Ipv6EndPoint *endPoint)
{
NS_LOG_FUNCTION_NOARGS ();
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++)
{
if (*i == endPoint)
{
delete endPoint;
m_endPoints.erase (i);
break;
if (*i == endPoint)
{
delete endPoint;
m_endPoints.erase (i);
break;
}
}
}
}
/*
@@ -179,69 +179,69 @@ Ipv6EndPointDemux::EndPoints Ipv6EndPointDemux::Lookup (Ipv6Address daddr, uint1
NS_LOG_DEBUG ("Looking up endpoint for destination address " << daddr);
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++)
{
Ipv6EndPoint* endP = *i;
NS_LOG_DEBUG ("Looking at endpoint dport=" << endP->GetLocalPort ()
<< " daddr=" << endP->GetLocalAddress ()
<< " sport=" << endP->GetPeerPort ()
<< " saddr=" << endP->GetPeerAddress ());
if (endP->GetLocalPort () != dport)
{
NS_LOG_LOGIC ("Skipping endpoint " << &endP
<< " because endpoint dport "
<< endP->GetLocalPort ()
<< " does not match packet dport " << dport);
continue;
}
Ipv6EndPoint* endP = *i;
NS_LOG_DEBUG ("Looking at endpoint dport=" << endP->GetLocalPort ()
<< " daddr=" << endP->GetLocalAddress ()
<< " sport=" << endP->GetPeerPort ()
<< " saddr=" << endP->GetPeerAddress ());
if (endP->GetLocalPort () != dport)
{
NS_LOG_LOGIC ("Skipping endpoint " << &endP
<< " because endpoint dport "
<< endP->GetLocalPort ()
<< " does not match packet dport " << dport);
continue;
}
/* Ipv6Address incomingInterfaceAddr = incomingInterface->GetAddress (); */
NS_LOG_DEBUG ("dest addr " << daddr);
/* Ipv6Address incomingInterfaceAddr = incomingInterface->GetAddress (); */
NS_LOG_DEBUG ("dest addr " << daddr);
bool localAddressMatchesWildCard = endP->GetLocalAddress () == Ipv6Address::GetAny ();
bool localAddressMatchesExact = endP->GetLocalAddress () == daddr;
bool localAddressMatchesAllRouters = endP->GetLocalAddress () == Ipv6Address::GetAllRoutersMulticast ();
bool localAddressMatchesWildCard = endP->GetLocalAddress () == Ipv6Address::GetAny ();
bool localAddressMatchesExact = endP->GetLocalAddress () == daddr;
bool localAddressMatchesAllRouters = endP->GetLocalAddress () == Ipv6Address::GetAllRoutersMulticast ();
/* if no match here, keep looking */
if (!(localAddressMatchesExact || localAddressMatchesWildCard))
continue;
bool remotePeerMatchesExact = endP->GetPeerPort () == sport;
bool remotePeerMatchesWildCard = endP->GetPeerPort () == 0;
bool remoteAddressMatchesExact = endP->GetPeerAddress () == saddr;
bool remoteAddressMatchesWildCard = endP->GetPeerAddress () == Ipv6Address::GetAny ();
/* if no match here, keep looking */
if (!(localAddressMatchesExact || localAddressMatchesWildCard))
continue;
bool remotePeerMatchesExact = endP->GetPeerPort () == sport;
bool remotePeerMatchesWildCard = endP->GetPeerPort () == 0;
bool remoteAddressMatchesExact = endP->GetPeerAddress () == saddr;
bool remoteAddressMatchesWildCard = endP->GetPeerAddress () == Ipv6Address::GetAny ();
/* If remote does not match either with exact or wildcard,i
skip this one */
if (!(remotePeerMatchesExact || remotePeerMatchesWildCard))
continue;
if (!(remoteAddressMatchesExact || remoteAddressMatchesWildCard))
continue;
/* If remote does not match either with exact or wildcard,i
skip this one */
if (!(remotePeerMatchesExact || remotePeerMatchesWildCard))
continue;
if (!(remoteAddressMatchesExact || remoteAddressMatchesWildCard))
continue;
/* Now figure out which return list to add this one to */
if (localAddressMatchesWildCard &&
remotePeerMatchesWildCard &&
remoteAddressMatchesWildCard)
{ /* Only local port matches exactly */
retval1.push_back (endP);
/* Now figure out which return list to add this one to */
if (localAddressMatchesWildCard &&
remotePeerMatchesWildCard &&
remoteAddressMatchesWildCard)
{ /* Only local port matches exactly */
retval1.push_back (endP);
}
if ((localAddressMatchesExact || (localAddressMatchesAllRouters))&&
remotePeerMatchesWildCard &&
remoteAddressMatchesWildCard)
{ /* Only local port and local address matches exactly */
retval2.push_back (endP);
}
if (localAddressMatchesWildCard &&
remotePeerMatchesExact &&
remoteAddressMatchesExact)
{ /* All but local address */
retval3.push_back (endP);
}
if (localAddressMatchesExact &&
remotePeerMatchesExact &&
remoteAddressMatchesExact)
{ /* All 4 match */
retval4.push_back (endP);
}
}
if ((localAddressMatchesExact || (localAddressMatchesAllRouters))&&
remotePeerMatchesWildCard &&
remoteAddressMatchesWildCard)
{ /* Only local port and local address matches exactly */
retval2.push_back (endP);
}
if (localAddressMatchesWildCard &&
remotePeerMatchesExact &&
remoteAddressMatchesExact)
{ /* All but local address */
retval3.push_back (endP);
}
if (localAddressMatchesExact &&
remotePeerMatchesExact &&
remoteAddressMatchesExact)
{ /* All 4 match */
retval4.push_back (endP);
}
}
/* Here we find the most exact match */
if (!retval4.empty ()) return retval4;
@@ -256,37 +256,37 @@ Ipv6EndPoint* Ipv6EndPointDemux::SimpleLookup (Ipv6Address dst, uint16_t dport,
Ipv6EndPoint *generic = 0;
for (EndPointsI i = m_endPoints.begin () ; i != m_endPoints.end () ; i++)
{
uint32_t tmp = 0;
if ((*i)->GetLocalPort () != dport)
{
continue;
}
uint32_t tmp = 0;
if ((*i)->GetLocalAddress () == dst && (*i)->GetPeerPort () == sport &&
(*i)->GetPeerAddress () == src)
{
/* this is an exact match. */
return *i;
}
if ((*i)->GetLocalPort () != dport)
{
continue;
}
if ((*i)->GetLocalAddress () == Ipv6Address::GetAny ())
{
tmp ++;
}
if ((*i)->GetLocalAddress () == dst && (*i)->GetPeerPort () == sport &&
(*i)->GetPeerAddress () == src)
{
/* this is an exact match. */
return *i;
}
if ((*i)->GetPeerAddress () == Ipv6Address::GetAny ())
{
tmp ++;
}
if ((*i)->GetLocalAddress () == Ipv6Address::GetAny ())
{
tmp ++;
}
if (tmp < genericity)
{
generic = (*i);
genericity = tmp;
if ((*i)->GetPeerAddress () == Ipv6Address::GetAny ())
{
tmp ++;
}
if (tmp < genericity)
{
generic = (*i);
genericity = tmp;
}
}
}
return generic;
}
@@ -295,17 +295,17 @@ uint16_t Ipv6EndPointDemux::AllocateEphemeralPort ()
NS_LOG_FUNCTION_NOARGS ();
uint16_t port = m_ephemeral;
do
{
port++;
if (port == 65535)
{
port = 49152;
}
if (!LookupPortLocal (port))
{
return port;
}
} while (port != m_ephemeral);
port++;
if (port == 65535)
{
port = 49152;
}
if (!LookupPortLocal (port))
{
return port;
}
} while (port != m_ephemeral);
return 0;
}

View File

@@ -37,122 +37,122 @@ class Ipv6EndPoint;
*/
class Ipv6EndPointDemux
{
public:
typedef std::list<Ipv6EndPoint *>EndPoints;
typedef std::list<Ipv6EndPoint *>::iterator EndPointsI;
public:
typedef std::list<Ipv6EndPoint *>EndPoints;
typedef std::list<Ipv6EndPoint *>::iterator EndPointsI;
/**
* \brief Constructor.
*/
Ipv6EndPointDemux ();
/**
* \brief Constructor.
*/
Ipv6EndPointDemux ();
/**
* \brief Destructor.
*/
~Ipv6EndPointDemux ();
/**
* \brief Destructor.
*/
~Ipv6EndPointDemux ();
/**
* \brief Lookup for port local.
* \param port port to test
* \return true if a port local is in EndPoints, false otherwise
*/
bool LookupPortLocal (uint16_t port);
/**
* \brief Lookup for port local.
* \param port port to test
* \return true if a port local is in EndPoints, false otherwise
*/
bool LookupPortLocal (uint16_t port);
/**
* \brief Lookup for address and port.
* \param addr address to test
* \param port port to test
* \return true if there is a match in EndPoints, false otherwise
*/
bool LookupLocal (Ipv6Address addr, uint16_t port);
/**
* \brief Lookup for address and port.
* \param addr address to test
* \param port port to test
* \return true if there is a match in EndPoints, false otherwise
*/
bool LookupLocal (Ipv6Address addr, uint16_t port);
/**
* \brief lookup for a match with all the parameters.
* \param dst destination address to test
* \param dport destination port to test
* \param src source address to test
* \param sport source port to test
* \param incomingInterface the incoming interface
* \return list en IPv6EndPoints (could be 0 element)
*/
EndPoints Lookup (Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport, Ptr<Ipv6Interface> incomingInterface);
/**
* \brief lookup for a match with all the parameters.
* \param dst destination address to test
* \param dport destination port to test
* \param src source address to test
* \param sport source port to test
* \param incomingInterface the incoming interface
* \return list en IPv6EndPoints (could be 0 element)
*/
EndPoints Lookup (Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport, Ptr<Ipv6Interface> incomingInterface);
/**
* \brief Simple lookup for a four-tuple match.
* \param dst destination address to test
* \param dport destination port to test
* \param src source address to test
* \param sport source port to test
* \return match or 0 if not found
*/
Ipv6EndPoint* SimpleLookup (Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport);
/**
* \brief Simple lookup for a four-tuple match.
* \param dst destination address to test
* \param dport destination port to test
* \param src source address to test
* \param sport source port to test
* \return match or 0 if not found
*/
Ipv6EndPoint* SimpleLookup (Ipv6Address dst, uint16_t dport, Ipv6Address src, uint16_t sport);
/**
* \brief Allocate a Ipv6EndPoint.
* \return an empty Ipv6EndPoint instance
*/
Ipv6EndPoint *Allocate (void);
/**
* \brief Allocate a Ipv6EndPoint.
* \return an empty Ipv6EndPoint instance
*/
Ipv6EndPoint *Allocate (void);
/**
* \brief Allocate a Ipv6EndPoint.
* \param address IPv6 address
* \return an Ipv6EndPoint instance
*/
Ipv6EndPoint *Allocate (Ipv6Address address);
/**
* \brief Allocate a Ipv6EndPoint.
* \param address IPv6 address
* \return an Ipv6EndPoint instance
*/
Ipv6EndPoint *Allocate (Ipv6Address address);
/**
* \brief Allocate a Ipv6EndPoint.
* \param port local port
* \return an Ipv6EndPoint instance
*/
Ipv6EndPoint *Allocate (uint16_t port);
/**
* \brief Allocate a Ipv6EndPoint.
* \param port local port
* \return an Ipv6EndPoint instance
*/
Ipv6EndPoint *Allocate (uint16_t port);
/**
* \brief Allocate a Ipv6EndPoint.
* \param address local address
* \param port local port
* \return an Ipv6EndPoint instance
*/
Ipv6EndPoint *Allocate (Ipv6Address address, uint16_t port);
/**
* \brief Allocate a Ipv6EndPoint.
* \param address local address
* \param port local port
* \return an Ipv6EndPoint instance
*/
Ipv6EndPoint *Allocate (Ipv6Address address, uint16_t port);
/**
* \brief Allocate a Ipv6EndPoint.
* \param localAddress local address
* \param localPort local port
* \param peerAddress peer address
* \param peerPort peer port
* \return an Ipv6EndPoint instance
*/
Ipv6EndPoint *Allocate (Ipv6Address localAddress, uint16_t localPort, Ipv6Address peerAddress, uint16_t peerPort);
/**
* \brief Allocate a Ipv6EndPoint.
* \param localAddress local address
* \param localPort local port
* \param peerAddress peer address
* \param peerPort peer port
* \return an Ipv6EndPoint instance
*/
Ipv6EndPoint *Allocate (Ipv6Address localAddress, uint16_t localPort, Ipv6Address peerAddress, uint16_t peerPort);
/**
* \brief Remove a end point.
* \param endPoint the end point to remove
*/
void DeAllocate (Ipv6EndPoint *endPoint);
/**
* \brief Remove a end point.
* \param endPoint the end point to remove
*/
void DeAllocate (Ipv6EndPoint *endPoint);
/**
* \brief Get the entire list of end points registered.
* \return list of Ipv6EndPoint
*/
EndPoints GetEndPoints () const;
/**
* \brief Get the entire list of end points registered.
* \return list of Ipv6EndPoint
*/
EndPoints GetEndPoints () const;
private:
/**
* \brief Allocate a ephemeral port.
* \return a port
*/
uint16_t AllocateEphemeralPort ();
private:
/**
* \brief Allocate a ephemeral port.
* \return a port
*/
uint16_t AllocateEphemeralPort ();
/**
* \brief The ephemeral port.
*/
uint16_t m_ephemeral;
/**
* \brief The ephemeral port.
*/
uint16_t m_ephemeral;
/**
* \brief A list of IPv6 end points.
*/
EndPoints m_endPoints;
/**
* \brief A list of IPv6 end points.
*/
EndPoints m_endPoints;
};
} /* namespace ns3 */

View File

@@ -45,7 +45,7 @@ TypeId Ipv6ExtensionHeader::GetInstanceTypeId () const
}
Ipv6ExtensionHeader::Ipv6ExtensionHeader ()
: m_nextHeader (0),
: m_nextHeader (0),
m_length (0),
m_data (0)
{
@@ -121,7 +121,7 @@ uint32_t Ipv6ExtensionHeader::Deserialize (Buffer::Iterator start)
}
OptionField::OptionField (uint32_t optionsOffset)
: m_optionData (0),
: m_optionData (0),
m_optionsOffset (optionsOffset)
{
}
@@ -325,7 +325,7 @@ TypeId Ipv6ExtensionFragmentHeader::GetInstanceTypeId () const
}
Ipv6ExtensionFragmentHeader::Ipv6ExtensionFragmentHeader ()
: m_offset (0),
: m_offset (0),
m_identification (0)
{
}
@@ -416,7 +416,7 @@ TypeId Ipv6ExtensionRoutingHeader::GetInstanceTypeId () const
}
Ipv6ExtensionRoutingHeader::Ipv6ExtensionRoutingHeader ()
: m_typeRouting (0),
: m_typeRouting (0),
m_segmentsLeft (0)
{
}
@@ -495,7 +495,7 @@ TypeId Ipv6ExtensionLooseRoutingHeader::GetInstanceTypeId () const
}
Ipv6ExtensionLooseRoutingHeader::Ipv6ExtensionLooseRoutingHeader ()
: m_routersAddress (0)
: m_routersAddress (0)
{
}

File diff suppressed because it is too large Load Diff

View File

@@ -523,7 +523,7 @@ void Ipv6ExtensionFragment::GetFragments (Ptr<Packet> packet, uint32_t maxFragme
}
Ipv6ExtensionFragment::Fragments::Fragments ()
: m_moreFragment (0)
: m_moreFragment (0)
{
}

View File

@@ -70,31 +70,31 @@ void Ipv6Interface::DoDispose ()
void Ipv6Interface::DoSetup ()
{
NS_LOG_FUNCTION_NOARGS ();
if (m_node == 0 || m_device == 0)
{
return;
}
{
return;
}
/* set up link-local address */
if (!DynamicCast<LoopbackNetDevice> (m_device)) /* no autoconf for ip6-localhost */
{
Address addr = GetDevice ()->GetAddress ();
{
Address addr = GetDevice ()->GetAddress ();
if (Mac48Address::IsMatchingType (addr))
{
Ipv6InterfaceAddress ifaddr = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac48Address::ConvertFrom (addr)), Ipv6Prefix (64));
AddAddress (ifaddr);
if (Mac48Address::IsMatchingType (addr))
{
Ipv6InterfaceAddress ifaddr = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac48Address::ConvertFrom (addr)), Ipv6Prefix (64));
AddAddress (ifaddr);
}
else
{
NS_ASSERT_MSG (false, "IPv6 autoconf for this kind of address not implemented.");
}
}
else
{
NS_ASSERT_MSG (false, "IPv6 autoconf for this kind of address not implemented.");
}
}
else
{
return; /* no NDISC cache for ip6-localhost */
}
{
return; /* no NDISC cache for ip6-localhost */
}
Ptr<Icmpv6L4Protocol> icmpv6 = m_node->GetObject<Ipv6L3Protocol> ()->GetIcmpv6 ();
m_ndCache = icmpv6->CreateCache (m_device, this);
@@ -149,9 +149,9 @@ void Ipv6Interface::SetUp ()
NS_LOG_FUNCTION_NOARGS ();
if (m_ifup)
{
return;
}
{
return;
}
m_ifup = true;
}
@@ -181,30 +181,30 @@ bool Ipv6Interface::AddAddress (Ipv6InterfaceAddress iface)
/* DAD handling */
if (!addr.IsAny ())
{
for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it)
{
if ((*it).GetAddress () == addr)
{
return false;
}
}
for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it)
{
if ((*it).GetAddress () == addr)
{
return false;
}
}
m_addresses.push_back (iface);
if (!addr.IsAny () || !addr.IsLocalhost ())
{
/* DAD handling */
Ptr<Icmpv6L4Protocol> icmpv6 = m_node->GetObject<Ipv6L3Protocol> ()->GetIcmpv6 ();
m_addresses.push_back (iface);
if (icmpv6 && icmpv6->IsAlwaysDad ())
{
Simulator::Schedule (Seconds (0.), &Icmpv6L4Protocol::DoDAD, icmpv6, addr, this);
Simulator::Schedule (Seconds (1.), &Icmpv6L4Protocol::FunctionDadTimeout, icmpv6, this, addr);
}
if (!addr.IsAny () || !addr.IsLocalhost ())
{
/* DAD handling */
Ptr<Icmpv6L4Protocol> icmpv6 = m_node->GetObject<Ipv6L3Protocol> ()->GetIcmpv6 ();
if (icmpv6 && icmpv6->IsAlwaysDad ())
{
Simulator::Schedule (Seconds (0.), &Icmpv6L4Protocol::DoDAD, icmpv6, addr, this);
Simulator::Schedule (Seconds (1.), &Icmpv6L4Protocol::FunctionDadTimeout, icmpv6, this, addr);
}
}
return true;
}
return true;
}
/* bad address */
return false;
@@ -216,12 +216,12 @@ Ipv6InterfaceAddress Ipv6Interface::GetLinkLocalAddress () const
NS_LOG_FUNCTION_NOARGS ();
for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it)
{
if ((*it).GetAddress ().IsLinkLocal ())
{
return (*it);
if ((*it).GetAddress ().IsLinkLocal ())
{
return (*it);
}
}
}
NS_ASSERT_MSG (false, "No link-local address on interface " << this);
Ipv6InterfaceAddress addr;
return addr; /* quiet compiler */
@@ -233,16 +233,16 @@ Ipv6InterfaceAddress Ipv6Interface::GetAddress (uint32_t index) const
uint32_t i = 0;
if (m_addresses.size () > index)
{
for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it)
{
if (i == index)
{
return (*it);
}
i++;
for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it)
{
if (i == index)
{
return (*it);
}
i++;
}
}
}
NS_ASSERT_MSG (false, "Address " << index << " not found");
Ipv6InterfaceAddress addr;
@@ -261,22 +261,22 @@ Ipv6InterfaceAddress Ipv6Interface::RemoveAddress (uint32_t index)
uint32_t i = 0;
if (m_addresses.size () < index)
{
NS_ASSERT_MSG (false, "Try to remove index that don't exist in Ipv6Interface::RemoveAddress");
}
for (Ipv6InterfaceAddressListI it = m_addresses.begin () ; it != m_addresses.end () ; ++it)
{
if (i == index)
{
Ipv6InterfaceAddress iface = (*it);
m_addresses.erase (it);
return iface;
NS_ASSERT_MSG (false, "Try to remove index that don't exist in Ipv6Interface::RemoveAddress");
}
for (Ipv6InterfaceAddressListI it = m_addresses.begin () ; it != m_addresses.end () ; ++it)
{
if (i == index)
{
Ipv6InterfaceAddress iface = (*it);
m_addresses.erase (it);
return iface;
}
i++;
}
i++;
}
NS_ASSERT_MSG (false, "Address " << index << " not found");
Ipv6InterfaceAddress addr;
return addr; /* quiet compiler */
@@ -285,18 +285,18 @@ Ipv6InterfaceAddress Ipv6Interface::RemoveAddress (uint32_t index)
Ipv6InterfaceAddress Ipv6Interface::GetAddressMatchingDestination (Ipv6Address dst)
{
NS_LOG_FUNCTION (this << dst);
for (Ipv6InterfaceAddressList::const_iterator it = m_addresses.begin () ; it != m_addresses.end () ; ++it)
{
Ipv6InterfaceAddress ifaddr = (*it);
if (ifaddr.GetPrefix ().IsMatch (ifaddr.GetAddress (), dst))
{
return ifaddr;
}
}
Ipv6InterfaceAddress ifaddr = (*it);
/* NS_ASSERT_MSG (false, "Not matching address."); */
if (ifaddr.GetPrefix ().IsMatch (ifaddr.GetAddress (), dst))
{
return ifaddr;
}
}
/* NS_ASSERT_MSG (false, "Not matching address."); */
Ipv6InterfaceAddress ret;
return ret; /* quiet compiler */
}
@@ -307,69 +307,69 @@ void Ipv6Interface::Send (Ptr<Packet> p, Ipv6Address dest)
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
if (!IsUp ())
{
return;
}
{
return;
}
/* check if destination is localhost (::1) */
if (DynamicCast<LoopbackNetDevice> (m_device))
{
/* XXX additional checks needed here (such as whether multicast
* goes to loopback)?
*/
m_device->Send (p, m_device->GetBroadcast (), Ipv6L3Protocol::PROT_NUMBER);
return;
}
{
/* XXX additional checks needed here (such as whether multicast
* goes to loopback)?
*/
m_device->Send (p, m_device->GetBroadcast (), Ipv6L3Protocol::PROT_NUMBER);
return;
}
/* check if destination is for one of our interface */
for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it)
{
if (dest == (*it).GetAddress ())
{
ipv6->Receive (m_device, p, Ipv6L3Protocol::PROT_NUMBER,
m_device->GetBroadcast (),
m_device->GetBroadcast (),
NetDevice::PACKET_HOST // note: linux uses PACKET_LOOPBACK here
);
return;
if (dest == (*it).GetAddress ())
{
ipv6->Receive (m_device, p, Ipv6L3Protocol::PROT_NUMBER,
m_device->GetBroadcast (),
m_device->GetBroadcast (),
NetDevice::PACKET_HOST // note: linux uses PACKET_LOOPBACK here
);
return;
}
}
}
/* other address */
if (m_device->NeedsArp ())
{
NS_LOG_LOGIC ("Needs ARP" << " " << dest);
Ptr<Icmpv6L4Protocol> icmpv6 = ipv6->GetIcmpv6 ();
Address hardwareDestination;
bool found = false;
NS_ASSERT (icmpv6);
if (dest.IsMulticast ())
{
NS_LOG_LOGIC ("IsMulticast");
NS_ASSERT_MSG (m_device->IsMulticast (), "Ipv6Interface::SendTo (): Sending multicast packet over non-multicast device");
NS_LOG_LOGIC ("Needs ARP" << " " << dest);
Ptr<Icmpv6L4Protocol> icmpv6 = ipv6->GetIcmpv6 ();
Address hardwareDestination;
bool found = false;
hardwareDestination = m_device->GetMulticast (dest);
found = true;
}
else
{
NS_LOG_LOGIC ("NDISC Lookup");
found = icmpv6->Lookup (p, dest, GetDevice (), m_ndCache, &hardwareDestination);
}
NS_ASSERT (icmpv6);
if (found)
{
NS_LOG_LOGIC ("Address Resolved. Send.");
m_device ->Send (p, hardwareDestination, Ipv6L3Protocol::PROT_NUMBER);
if (dest.IsMulticast ())
{
NS_LOG_LOGIC ("IsMulticast");
NS_ASSERT_MSG (m_device->IsMulticast (), "Ipv6Interface::SendTo (): Sending multicast packet over non-multicast device");
hardwareDestination = m_device->GetMulticast (dest);
found = true;
}
else
{
NS_LOG_LOGIC ("NDISC Lookup");
found = icmpv6->Lookup (p, dest, GetDevice (), m_ndCache, &hardwareDestination);
}
if (found)
{
NS_LOG_LOGIC ("Address Resolved. Send.");
m_device ->Send (p, hardwareDestination, Ipv6L3Protocol::PROT_NUMBER);
}
}
}
else
{
NS_LOG_LOGIC ("Doesn't need ARP");
m_device->Send (p, m_device->GetBroadcast (), Ipv6L3Protocol::PROT_NUMBER);
}
{
NS_LOG_LOGIC ("Doesn't need ARP");
m_device->Send (p, m_device->GetBroadcast (), Ipv6L3Protocol::PROT_NUMBER);
}
}
void Ipv6Interface::SetCurHopLimit (uint8_t curHopLimit)
@@ -425,13 +425,13 @@ void Ipv6Interface::SetState (Ipv6Address address, Ipv6InterfaceAddress::State_e
NS_LOG_FUNCTION (this << address << state);
for (Ipv6InterfaceAddressListI it = m_addresses.begin () ; it != m_addresses.end () ; ++it)
{
if ((*it).GetAddress () == address)
{
(*it).SetState (state);
return;
if ((*it).GetAddress () == address)
{
(*it).SetState (state);
return;
}
}
}
/* not found, maybe address has expired */
}
@@ -440,13 +440,13 @@ void Ipv6Interface::SetNsDadUid (Ipv6Address address, uint32_t uid)
NS_LOG_FUNCTION (this << address << uid);
for (Ipv6InterfaceAddressListI it = m_addresses.begin () ; it != m_addresses.end () ; ++it)
{
if ((*it).GetAddress () == address)
{
(*it).SetNsDadUid (uid);
return;
if ((*it).GetAddress () == address)
{
(*it).SetNsDadUid (uid);
return;
}
}
}
/* not found, maybe address has expired */
}

View File

@@ -48,271 +48,271 @@ class NdiscCache;
*/
class Ipv6Interface : public Object
{
public:
/**
* \brief Get the type ID
* \return type ID
*/
static TypeId GetTypeId ();
public:
/**
* \brief Get the type ID
* \return type ID
*/
static TypeId GetTypeId ();
/**
* \brief Constructs an Ipv6Interface.
*/
Ipv6Interface ();
/**
* \brief Constructs an Ipv6Interface.
*/
Ipv6Interface ();
/**
* \brief Destructor.
*/
virtual ~Ipv6Interface ();
/**
* \brief Destructor.
*/
virtual ~Ipv6Interface ();
/**
* \brief Set node associated with interface.
* \param node node
*/
void SetNode (Ptr<Node> node);
/**
* \brief Set node associated with interface.
* \param node node
*/
void SetNode (Ptr<Node> node);
/**
* \brief Set the NetDevice.
* \param device NetDevice
*/
void SetDevice (Ptr<NetDevice> device);
/**
* \brief Set the NetDevice.
* \param device NetDevice
*/
void SetDevice (Ptr<NetDevice> device);
/**
* \brief Get the NetDevice.
* \return the NetDevice associated with this interface
*/
virtual Ptr<NetDevice> GetDevice () const;
/**
* \brief Get the NetDevice.
* \return the NetDevice associated with this interface
*/
virtual Ptr<NetDevice> GetDevice () const;
/**
* \brief Set the metric.
* \param metric configured routing metric (cost) of this interface
*/
void SetMetric (uint16_t metric);
/**
* \brief Set the metric.
* \param metric configured routing metric (cost) of this interface
*/
void SetMetric (uint16_t metric);
/**
* \brief Get the metric
* \return the metric
*/
uint16_t GetMetric () const;
/**
* \brief Get the metric
* \return the metric
*/
uint16_t GetMetric () const;
/**
* \brief Is the interface UP ?
* \return true if interface is enabled, false otherwise.
*/
bool IsUp () const;
/**
* \brief Is the interface UP ?
* \return true if interface is enabled, false otherwise.
*/
bool IsUp () const;
/**
* \brief Is the interface DOWN ?
* \return true if interface is disabled, false otherwise.
*/
bool IsDown () const;
/**
* \brief Is the interface DOWN ?
* \return true if interface is disabled, false otherwise.
*/
bool IsDown () const;
/**
* \brief Enable this interface.
*/
void SetUp ();
/**
* \brief Enable this interface.
*/
void SetUp ();
/**
* \brief Disable this interface.
*/
void SetDown ();
/**
* \brief Disable this interface.
*/
void SetDown ();
/**
* \brief If the interface allows forwarding packets.
* \return true if forwarding is enabled, false otherwise
*/
bool IsForwarding () const;
/**
* \brief If the interface allows forwarding packets.
* \return true if forwarding is enabled, false otherwise
*/
bool IsForwarding () const;
/**
* \brief Set forwarding enabled or not.
* \param forward forwarding state
*/
void SetForwarding (bool forward);
/**
* \brief Set forwarding enabled or not.
* \param forward forwarding state
*/
void SetForwarding (bool forward);
/**
* \brief Set the current hop limit.
* \param curHopLimit the value to set
*/
void SetCurHopLimit (uint8_t curHopLimit);
/**
* \brief Set the current hop limit.
* \param curHopLimit the value to set
*/
void SetCurHopLimit (uint8_t curHopLimit);
/**
* \brief Get the current hop limit value.
* \return current hop limit
*/
uint8_t GetCurHopLimit () const;
/**
* \brief Get the current hop limit value.
* \return current hop limit
*/
uint8_t GetCurHopLimit () const;
/**
* \brief Set the base reachable time.
* \param baseReachableTime the value to set
*/
void SetBaseReachableTime (uint16_t baseReachableTime);
/**
* \brief Set the base reachable time.
* \param baseReachableTime the value to set
*/
void SetBaseReachableTime (uint16_t baseReachableTime);
/**
* \brief Get the base reachable time.
* \return base reachable time
*/
uint16_t GetBaseReachableTime () const;
/**
* \brief Get the base reachable time.
* \return base reachable time
*/
uint16_t GetBaseReachableTime () const;
/**
* \brief Set the reachable time.
* \param reachableTime value to set
*/
void SetReachableTime (uint16_t reachableTime);
/**
* \brief Set the reachable time.
* \param reachableTime value to set
*/
void SetReachableTime (uint16_t reachableTime);
/**
* \brief Get the reachable time.
* \return reachable time
*/
uint16_t GetReachableTime () const;
/**
* \brief Get the reachable time.
* \return reachable time
*/
uint16_t GetReachableTime () const;
/**
* \brief Set the retransmission timer.
* \param retransTimer value to set
*/
void SetRetransTimer (uint16_t retransTimer);
/**
* \brief Set the retransmission timer.
* \param retransTimer value to set
*/
void SetRetransTimer (uint16_t retransTimer);
/**
* \brief Get the retransmission timer.
* \return retransmission timer
*/
uint16_t GetRetransTimer () const;
/**
* \brief Get the retransmission timer.
* \return retransmission timer
*/
uint16_t GetRetransTimer () const;
/**
* \brief Send a packet through this interface.
* \param p packet to send
* \param dest next hop address of packet.
*
* \note This method will eventually call the private SendTo
* method which must be implemented by subclasses.
*/
void Send (Ptr<Packet> p, Ipv6Address dest);
/**
* \brief Send a packet through this interface.
* \param p packet to send
* \param dest next hop address of packet.
*
* \note This method will eventually call the private SendTo
* method which must be implemented by subclasses.
*/
void Send (Ptr<Packet> p, Ipv6Address dest);
/**
* \brief Add an IPv6 address.
* \param iface address to add
* \return true if address was added, false otherwise
*/
bool AddAddress (Ipv6InterfaceAddress iface);
/**
* \brief Get link-local address from IPv6 interface.
* \return link-local Ipv6InterfaceAddress, assert if not found
*/
Ipv6InterfaceAddress GetLinkLocalAddress () const;
/**
* \brief Add an IPv6 address.
* \param iface address to add
* \return true if address was added, false otherwise
*/
bool AddAddress (Ipv6InterfaceAddress iface);
/**
* \brief Get an address from IPv6 interface.
* \param index index
* \return Ipv6InterfaceAddress address whose index is i
*/
Ipv6InterfaceAddress GetAddress (uint32_t index) const;
/**
* \brief Get link-local address from IPv6 interface.
* \return link-local Ipv6InterfaceAddress, assert if not found
*/
Ipv6InterfaceAddress GetLinkLocalAddress () const;
/**
* \brief Get an address which is in the same network prefix as destination.
* \param dst destination address
* \return Corresponding Ipv6InterfaceAddress or assert if not found
*/
Ipv6InterfaceAddress GetAddressMatchingDestination (Ipv6Address dst);
/**
* \brief Get an address from IPv6 interface.
* \param index index
* \return Ipv6InterfaceAddress address whose index is i
*/
Ipv6InterfaceAddress GetAddress (uint32_t index) const;
/**
* \brief Get number of addresses on this IPv6 interface.
* \return number of address
*/
uint32_t GetNAddresses (void) const;
/**
* \brief Remove an address from interface.
* \param index index to remove
* \return Ipv6InterfaceAddress address whose index is index
*/
Ipv6InterfaceAddress RemoveAddress (uint32_t index);
/**
* \brief Update state of an interface address.
* \param address IPv6 address
* \param state new state
*/
void SetState (Ipv6Address address, Ipv6InterfaceAddress::State_e state);
/**
* \brief Get an address which is in the same network prefix as destination.
* \param dst destination address
* \return Corresponding Ipv6InterfaceAddress or assert if not found
*/
Ipv6InterfaceAddress GetAddressMatchingDestination (Ipv6Address dst);
/**
* \brief Update NS DAD packet UID of an interface address.
* \param address IPv6 address
* \param uid packet UID
*/
void SetNsDadUid (Ipv6Address address, uint32_t uid);
/**
* \brief Get number of addresses on this IPv6 interface.
* \return number of address
*/
uint32_t GetNAddresses (void) const;
protected:
/**
* \brief Dispose this object.
*/
virtual void DoDispose ();
/**
* \brief Remove an address from interface.
* \param index index to remove
* \return Ipv6InterfaceAddress address whose index is index
*/
Ipv6InterfaceAddress RemoveAddress (uint32_t index);
private:
typedef std::list<Ipv6InterfaceAddress> Ipv6InterfaceAddressList;
typedef std::list<Ipv6InterfaceAddress>::iterator Ipv6InterfaceAddressListI;
typedef std::list<Ipv6InterfaceAddress>::const_iterator Ipv6InterfaceAddressListCI;
/**
* \brief Update state of an interface address.
* \param address IPv6 address
* \param state new state
*/
void SetState (Ipv6Address address, Ipv6InterfaceAddress::State_e state);
/**
* \brief Initialize interface.
*/
void DoSetup ();
/**
* \brief Update NS DAD packet UID of an interface address.
* \param address IPv6 address
* \param uid packet UID
*/
void SetNsDadUid (Ipv6Address address, uint32_t uid);
/**
* \brief The addresses assigned to this interface.
*/
Ipv6InterfaceAddressList m_addresses;
protected:
/**
* \brief Dispose this object.
*/
virtual void DoDispose ();
/**
* \brief The state of this interface.
*/
bool m_ifup;
private:
typedef std::list<Ipv6InterfaceAddress> Ipv6InterfaceAddressList;
typedef std::list<Ipv6InterfaceAddress>::iterator Ipv6InterfaceAddressListI;
typedef std::list<Ipv6InterfaceAddress>::const_iterator Ipv6InterfaceAddressListCI;
/**
* \brief Forwarding state.
*/
bool m_forwarding;
/**
* \brief Initialize interface.
*/
void DoSetup ();
/**
* \brief The metric.
*/
uint16_t m_metric;
/**
* \brief The addresses assigned to this interface.
*/
Ipv6InterfaceAddressList m_addresses;
/**
* \brief Node associated with this interface.
*/
Ptr<Node> m_node;
/**
* \brief The state of this interface.
*/
bool m_ifup;
/**
* \brief NetDevice associated with this interface.
*/
Ptr<NetDevice> m_device;
/**
* \brief Forwarding state.
*/
bool m_forwarding;
/**
* \brief Neighbor cache.
*/
Ptr<NdiscCache> m_ndCache;
/**
* \brief The metric.
*/
uint16_t m_metric;
/**
* \brief Current hop limit.
*/
uint8_t m_curHopLimit;
/**
* \brief Node associated with this interface.
*/
Ptr<Node> m_node;
/**
* \brief Base value used for computing the random reachable time value (in millisecond).
*/
uint16_t m_baseReachableTime;
/**
* \brief NetDevice associated with this interface.
*/
Ptr<NetDevice> m_device;
/**
* \brief Reachable time (in millisecond).
* The time a neighbor is considered reachable after receiving a reachability confirmation.
*/
uint16_t m_reachableTime;
/**
* \brief Neighbor cache.
*/
Ptr<NdiscCache> m_ndCache;
/**
* \brief Retransmission timer (in millisecond).
* Time between retransmission of NS.
*/
uint16_t m_retransTimer;
/**
* \brief Current hop limit.
*/
uint8_t m_curHopLimit;
/**
* \brief Base value used for computing the random reachable time value (in millisecond).
*/
uint16_t m_baseReachableTime;
/**
* \brief Reachable time (in millisecond).
* The time a neighbor is considered reachable after receiving a reachability confirmation.
*/
uint16_t m_reachableTime;
/**
* \brief Retransmission timer (in millisecond).
* Time between retransmission of NS.
*/
uint16_t m_retransTimer;
};
} /* namespace ns3 */

File diff suppressed because it is too large Load Diff

View File

@@ -57,461 +57,461 @@ class Ipv6AutoconfiguredPrefix;
*/
class Ipv6L3Protocol : public Ipv6
{
public:
/**
* \brief Get the type ID of this class.
* \return type ID
*/
static TypeId GetTypeId ();
public:
/**
* \brief Get the type ID of this class.
* \return type ID
*/
static TypeId GetTypeId ();
/**
* \brief The protocol number for IPv6 (0x86DD).
*/
static const uint16_t PROT_NUMBER;
/**
* \brief The protocol number for IPv6 (0x86DD).
*/
static const uint16_t PROT_NUMBER;
/**
* \enum DropReason
* \brief Reason why a packet has been dropped.
*/
enum DropReason
{
DROP_TTL_EXPIRED = 1, /**< Packet TTL has expired */
DROP_NO_ROUTE, /**< No route to host */
DROP_INTERFACE_DOWN, /**< Interface is down so can not send packet */
DROP_ROUTE_ERROR, /**< Route error */
DROP_UNKNOWN_PROTOCOL, /**< Unkown L4 protocol */
};
/**
* \brief Constructor.
*/
Ipv6L3Protocol ();
/**
* \enum DropReason
* \brief Reason why a packet has been dropped.
*/
enum DropReason
{
DROP_TTL_EXPIRED = 1, /**< Packet TTL has expired */
DROP_NO_ROUTE, /**< No route to host */
DROP_INTERFACE_DOWN, /**< Interface is down so can not send packet */
DROP_ROUTE_ERROR, /**< Route error */
DROP_UNKNOWN_PROTOCOL, /**< Unkown L4 protocol */
};
/**
* \brief Destructor.
*/
virtual ~Ipv6L3Protocol ();
/**
* \brief Set node for this stack.
* \param node node to set
*/
void SetNode (Ptr<Node> node);
/**
* \brief Constructor.
*/
Ipv6L3Protocol ();
/**
* \brief Add an L4 protocol.
* \param protocol L4 protocol
*/
void Insert (Ptr<Ipv6L4Protocol> protocol);
/**
* \brief Destructor.
*/
virtual ~Ipv6L3Protocol ();
/**
* \brief Remove an L4 protocol.
* \param protocol L4 protocol to remove
*/
void Remove (Ptr<Ipv6L4Protocol> protocol);
/**
* \brief Set node for this stack.
* \param node node to set
*/
void SetNode (Ptr<Node> node);
/**
* \brief Get L4 protocol by protocol number.
* \param protocolNumber protocol number
* \return corresponding Ipv6L4Protocol or 0 if not found
*/
Ptr<Ipv6L4Protocol> GetProtocol (int protocolNumber) const;
/**
* \brief Add an L4 protocol.
* \param protocol L4 protocol
*/
void Insert (Ptr<Ipv6L4Protocol> protocol);
/**
* \brief Create raw IPv6 socket.
* \return newly raw socket
*/
Ptr<Socket> CreateRawSocket ();
/**
* \brief Remove an L4 protocol.
* \param protocol L4 protocol to remove
*/
void Remove (Ptr<Ipv6L4Protocol> protocol);
/**
* \brief Remove raw IPv6 socket.
* \param socket socket to remove
*/
void DeleteRawSocket (Ptr<Socket> socket);
/**
* \brief Get L4 protocol by protocol number.
* \param protocolNumber protocol number
* \return corresponding Ipv6L4Protocol or 0 if not found
*/
Ptr<Ipv6L4Protocol> GetProtocol (int protocolNumber) const;
/**
* \brief Set the default TTL.
* \param ttl TTL to set
*/
void SetDefaultTtl (uint8_t ttl);
/**
* \brief Create raw IPv6 socket.
* \return newly raw socket
*/
Ptr<Socket> CreateRawSocket ();
/**
* \brief Receive method when a packet arrive in the stack.
* This method removes IPv6 header and forward up to L4 protocol.
*
* \param device network device
* \param p the packet
* \param protocol next header value
* \param from address of the correspondant
* \param to address of the destination
* \param packetType type of the packet
*/
void Receive (Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType);
/**
* \brief Remove raw IPv6 socket.
* \param socket socket to remove
*/
void DeleteRawSocket (Ptr<Socket> socket);
/**
* \brief Higher-level layers call this method to send a packet
* down the stack to the MAC and PHY layers.
*
* \param packet packet to send
* \param source source address of packet
* \param destination address of packet
* \param protocol number of packet
* \param route route to take
*/
void Send (Ptr<Packet> packet, Ipv6Address source, Ipv6Address destination, uint8_t protocol, Ptr<Ipv6Route> route);
/**
* \brief Set routing protocol for this stack.
* \param routingProtocol IPv6 routing protocol to set
*/
void SetRoutingProtocol (Ptr<Ipv6RoutingProtocol> routingProtocol);
/**
* \brief Set the default TTL.
* \param ttl TTL to set
*/
void SetDefaultTtl (uint8_t ttl);
/**
* \brief Get current routing protocol used.
* \return routing protocol
*/
Ptr<Ipv6RoutingProtocol> GetRoutingProtocol () const;
/**
* \brief Receive method when a packet arrive in the stack.
* This method removes IPv6 header and forward up to L4 protocol.
*
* \param device network device
* \param p the packet
* \param protocol next header value
* \param from address of the correspondant
* \param to address of the destination
* \param packetType type of the packet
*/
void Receive (Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType);
/**
* \brief Add IPv6 interface for a device.
* \param device net device
* \return interface index
*/
uint32_t AddInterface (Ptr<NetDevice> device);
/**
* \brief Higher-level layers call this method to send a packet
* down the stack to the MAC and PHY layers.
*
* \param packet packet to send
* \param source source address of packet
* \param destination address of packet
* \param protocol number of packet
* \param route route to take
*/
void Send (Ptr<Packet> packet, Ipv6Address source, Ipv6Address destination, uint8_t protocol, Ptr<Ipv6Route> route);
/**
* \brief Get an interface.
* \param i interface index
* \return IPv6 interface pointer
*/
Ptr<Ipv6Interface> GetInterface (uint32_t i) const;
/**
* \brief Get current number of interface on this stack.
* \return number of interface registered
*/
uint32_t GetNInterfaces () const;
/**
* \brief Set routing protocol for this stack.
* \param routingProtocol IPv6 routing protocol to set
*/
void SetRoutingProtocol (Ptr<Ipv6RoutingProtocol> routingProtocol);
/**
* \brief Get interface index which has specified IPv6 address
* \param addr IPv6 address
* \return interface index or -1 if not found
*/
int32_t GetInterfaceForAddress (Ipv6Address addr) const;
/**
* \brief Get current routing protocol used.
* \return routing protocol
*/
Ptr<Ipv6RoutingProtocol> GetRoutingProtocol () const;
/**
* \brief Get interface index which match specified address/prefix.
* \param addr IPv6 address
* \param mask IPv6 prefix (mask)
* \return interface index or -1 if not found
*/
int32_t GetInterfaceForPrefix (Ipv6Address addr, Ipv6Prefix mask) const;
/**
* \brief Add IPv6 interface for a device.
* \param device net device
* \return interface index
*/
uint32_t AddInterface (Ptr<NetDevice> device);
/**
* \brief Get interface index which is on a specified net device.
* \param device net device
*/
int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const;
/**
* \brief Get an interface.
* \param i interface index
* \return IPv6 interface pointer
*/
Ptr<Ipv6Interface> GetInterface (uint32_t i) const;
/**
* \brief Add an address on interface.
* \param i interface index
* \param address to add
*/
bool AddAddress (uint32_t i, Ipv6InterfaceAddress address);
/**
* \brief Get current number of interface on this stack.
* \return number of interface registered
*/
uint32_t GetNInterfaces () const;
/**
* \brief Get an address.
* \param interfaceIndex interface index
* \param addressIndex address index on the interface
* \return Ipv6InterfaceAddress or assert if not found
*/
Ipv6InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const;
/**
* \brief Get interface index which has specified IPv6 address
* \param addr IPv6 address
* \return interface index or -1 if not found
*/
int32_t GetInterfaceForAddress (Ipv6Address addr) const;
/**
* \brief Get number of address for an interface.
* \param interface interface index
* \return number of address
*/
uint32_t GetNAddresses (uint32_t interface) const;
/**
* \brief Get interface index which match specified address/prefix.
* \param addr IPv6 address
* \param mask IPv6 prefix (mask)
* \return interface index or -1 if not found
*/
int32_t GetInterfaceForPrefix (Ipv6Address addr, Ipv6Prefix mask) const;
/**
* \brief Remove an address from an interface.
* \param interfaceIndex interface index
* \param addressIndex address index on the interface
*/
bool RemoveAddress (uint32_t interfaceIndex, uint32_t addressIndex);
/**
* \brief Set metric for an interface.
* \param i index
* \param metric
*/
void SetMetric (uint32_t i, uint16_t metric);
/**
* \brief Get interface index which is on a specified net device.
* \param device net device
*/
int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const;
/**
* \brief Get metric for an interface.
* \param i index
* \return metric
*/
uint16_t GetMetric (uint32_t i) const;
/**
* \brief Add an address on interface.
* \param i interface index
* \param address to add
*/
bool AddAddress (uint32_t i, Ipv6InterfaceAddress address);
/**
* \brief Get MTU for an interface.
* \param i index
* \return MTU
*/
uint16_t GetMtu (uint32_t i) const;
/**
* \brief Get an address.
* \param interfaceIndex interface index
* \param addressIndex address index on the interface
* \return Ipv6InterfaceAddress or assert if not found
*/
Ipv6InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const;
/**
* \brief Is specified interface up ?
* \param i interface index
*/
bool IsUp (uint32_t i) const;
/**
* \brief Get number of address for an interface.
* \param interface interface index
* \return number of address
*/
uint32_t GetNAddresses (uint32_t interface) const;
/**
* \brief Set an interface up.
* \param i interface index
*/
void SetUp (uint32_t i);
/**
* \brief Remove an address from an interface.
* \param interfaceIndex interface index
* \param addressIndex address index on the interface
*/
bool RemoveAddress (uint32_t interfaceIndex, uint32_t addressIndex);
/**
* \brief set an interface down.
* \param i interface index
*/
void SetDown (uint32_t i);
/**
* \brief Set metric for an interface.
* \param i index
* \param metric
*/
void SetMetric (uint32_t i, uint16_t metric);
/**
* \brief Is interface allows forwarding ?
* \param i interface index
*/
bool IsForwarding (uint32_t i) const;
/**
* \brief Get metric for an interface.
* \param i index
* \return metric
*/
uint16_t GetMetric (uint32_t i) const;
/**
* \brief Enable or disable forwarding on interface
* \param i interface index
* \param val true = enable forwarding, false = disable
*/
void SetForwarding (uint32_t i, bool val);
/**
* \brief Get MTU for an interface.
* \param i index
* \return MTU
*/
uint16_t GetMtu (uint32_t i) const;
/**
* \brief Get device by index.
* \param i device index on this stack
* \return NetDevice pointer
*/
Ptr<NetDevice> GetNetDevice (uint32_t i);
/**
* \brief Get ICMPv6 protocol.
* \return Icmpv6L4Protocol pointer
*/
Ptr<Icmpv6L4Protocol> GetIcmpv6 () const;
/**
* \brief Is specified interface up ?
* \param i interface index
*/
bool IsUp (uint32_t i) const;
/**
* \brief Add an autoconfigured address with RA information.
* \param interface interface index
* \param network network prefix
* \param mask network mask
* \param flags flags of the prefix information option (home agent, ...)
* \param validTime valid time of the prefix
* \param preferredTime preferred time of the prefix
* \param defaultRouter default router address
*/
void AddAutoconfiguredAddress (uint32_t interface, Ipv6Address network, Ipv6Prefix mask, uint8_t flags, uint32_t validTime, uint32_t preferredTime, Ipv6Address defaultRouter = Ipv6Address::GetZero ());
/**
* \brief Set an interface up.
* \param i interface index
*/
void SetUp (uint32_t i);
/**
* \brief Remove an autoconfigured address.
*
* Typically it is used when an autoconfigured address expires.
* \param interface interface index
* \param network network prefix
* \param mask network mask
* \param defaultRouter gateway
*/
void RemoveAutoconfiguredAddress (uint32_t interface, Ipv6Address network, Ipv6Prefix mask, Ipv6Address defaultRouter);
/**
* \brief set an interface down.
* \param i interface index
*/
void SetDown (uint32_t i);
/**
* \brief Register the IPv6 Extensions.
*/
virtual void RegisterExtensions ();
/**
* \brief Is interface allows forwarding ?
* \param i interface index
*/
bool IsForwarding (uint32_t i) const;
/**
* \brief Register the IPv6 Options.
*/
virtual void RegisterOptions ();
/**
* \brief Enable or disable forwarding on interface
* \param i interface index
* \param val true = enable forwarding, false = disable
*/
void SetForwarding (uint32_t i, bool val);
protected:
/**
* \brief Dispose object.
*/
virtual void DoDispose ();
/**
* \brief Get device by index.
* \param i device index on this stack
* \return NetDevice pointer
*/
Ptr<NetDevice> GetNetDevice (uint32_t i);
/**
* \brief Notify other components connected to the node that a new stack member is now connected.
*
* This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
*/
virtual void NotifyNewAggregate ();
/**
* \brief Get ICMPv6 protocol.
* \return Icmpv6L4Protocol pointer
*/
Ptr<Icmpv6L4Protocol> GetIcmpv6 () const;
private:
/* for unit-tests */
friend class Ipv6L3ProtocolTestCase;
friend class Ipv6ExtensionLooseRouting;
/**
* \brief Add an autoconfigured address with RA information.
* \param interface interface index
* \param network network prefix
* \param mask network mask
* \param flags flags of the prefix information option (home agent, ...)
* \param validTime valid time of the prefix
* \param preferredTime preferred time of the prefix
* \param defaultRouter default router address
*/
void AddAutoconfiguredAddress (uint32_t interface, Ipv6Address network, Ipv6Prefix mask, uint8_t flags, uint32_t validTime, uint32_t preferredTime, Ipv6Address defaultRouter = Ipv6Address::GetZero ());
typedef std::list<Ptr<Ipv6Interface> > Ipv6InterfaceList;
typedef std::list<Ptr<Ipv6RawSocketImpl> > SocketList;
typedef std::list<Ptr<Ipv6L4Protocol> > L4List_t;
/**
* \brief Remove an autoconfigured address.
*
* Typically it is used when an autoconfigured address expires.
* \param interface interface index
* \param network network prefix
* \param mask network mask
* \param defaultRouter gateway
*/
void RemoveAutoconfiguredAddress (uint32_t interface, Ipv6Address network, Ipv6Prefix mask, Ipv6Address defaultRouter);
typedef std::list< Ptr<Ipv6AutoconfiguredPrefix> > Ipv6AutoconfiguredPrefixList;
typedef std::list< Ptr<Ipv6AutoconfiguredPrefix> >::iterator Ipv6AutoconfiguredPrefixListI;
/**
* \brief Register the IPv6 Extensions.
*/
virtual void RegisterExtensions ();
/**
* \brief Callback to trace TX (transmission) packets.
*/
TracedCallback<Ptr<const Packet>, uint32_t> m_txTrace;
/**
* \brief Callback to trace RX (reception) packets.
*/
TracedCallback<Ptr<const Packet>, uint32_t> m_rxTrace;
/**
* \brief Callback to trace drop packets.
*/
TracedCallback<const Ipv6Header &, Ptr<const Packet>, DropReason, uint32_t> m_dropTrace;
/**
* \brief Register the IPv6 Options.
*/
virtual void RegisterOptions ();
/**
* \brief Copy constructor.
* \param o object to copy
*/
Ipv6L3Protocol (const Ipv6L3Protocol& o);
/**
* \brief Copy constructor.
* \param o object to copy
*/
Ipv6L3Protocol &operator = (const Ipv6L3Protocol& o);
protected:
/**
* \brief Dispose object.
*/
virtual void DoDispose ();
/**
* \brief Construct an IPv6 header.
* \param src source IPv6 address
* \param dst destination IPv6 address
* \param protocol L4 protocol
* \param payloadSize payload size
* \param ttl TTL
* \return newly created IPv6 header
*/
Ipv6Header BuildHeader (Ipv6Address src, Ipv6Address dst, uint8_t protocol,
uint16_t payloadSize, uint8_t ttl);
/**
* \brief Notify other components connected to the node that a new stack member is now connected.
*
* This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
*/
virtual void NotifyNewAggregate ();
/**
* \brief Send packet with route.
* \param route route
* \param packet packet to send
* \param ipHeader IPv6 header to add to the packet
*/
void SendRealOut (Ptr<Ipv6Route> route, Ptr<Packet> packet, Ipv6Header const& ipHeader);
private:
/* for unit-tests */
friend class Ipv6L3ProtocolTestCase;
friend class Ipv6ExtensionLooseRouting;
/**
* \brief Forward a packet.
* \param rtentry route
* \param p packet to forward
* \param header IPv6 header to add to the packet
*/
void IpForward (Ptr<Ipv6Route> rtentry, Ptr<const Packet> p, const Ipv6Header& header);
typedef std::list<Ptr<Ipv6Interface> > Ipv6InterfaceList;
typedef std::list<Ptr<Ipv6RawSocketImpl> > SocketList;
typedef std::list<Ptr<Ipv6L4Protocol> > L4List_t;
/**
* \brief Forward a packet in multicast.
* \param mrtentry route
* \param p packet to forward
* \param header IPv6 header to add to the packet
*/
void IpMulticastForward (Ptr<Ipv6MulticastRoute> mrtentry, Ptr<const Packet> p, const Ipv6Header& header);
typedef std::list< Ptr<Ipv6AutoconfiguredPrefix> > Ipv6AutoconfiguredPrefixList;
typedef std::list< Ptr<Ipv6AutoconfiguredPrefix> >::iterator Ipv6AutoconfiguredPrefixListI;
/**
* \brief Deliver a packet.
* \param p packet delivered
* \param ip IPv6 header
* \param iif input interface packet was received
*/
void LocalDeliver (Ptr<const Packet> p, Ipv6Header const& ip, uint32_t iif);
/**
* \brief Fallback when no route is found.
* \param p packet
* \param ipHeader IPv6 header
* \param sockErrno error number
*/
void RouteInputError (Ptr<const Packet> p, const Ipv6Header& ipHeader, Socket::SocketErrno sockErrno);
/**
* \brief Callback to trace TX (transmission) packets.
*/
TracedCallback<Ptr<const Packet>, uint32_t> m_txTrace;
/**
* \brief Add an IPv6 interface to the stack.
* \param interface interface to add
* \return index of newly added interface
*/
uint32_t AddIpv6Interface (Ptr<Ipv6Interface> interface);
/**
* \brief Callback to trace RX (reception) packets.
*/
TracedCallback<Ptr<const Packet>, uint32_t> m_rxTrace;
/**
* \brief Setup loopback interface.
*/
void SetupLoopback ();
/**
* \brief Callback to trace drop packets.
*/
TracedCallback<const Ipv6Header &, Ptr<const Packet>, DropReason, uint32_t> m_dropTrace;
/**
* \brief Set IPv6 forwarding state.
* \param forward IPv6 forwarding enabled or not
*/
virtual void SetIpForward (bool forward);
/**
* \brief Copy constructor.
* \param o object to copy
*/
Ipv6L3Protocol (const Ipv6L3Protocol& o);
/**
* \brief Get IPv6 forwarding state.
* \return forwarding state (enabled or not)
*/
virtual bool GetIpForward () const;
/**
* \brief Copy constructor.
* \param o object to copy
*/
Ipv6L3Protocol &operator = (const Ipv6L3Protocol& o);
/**
* \brief Node attached to stack.
*/
Ptr<Node> m_node;
/**
* \brief Construct an IPv6 header.
* \param src source IPv6 address
* \param dst destination IPv6 address
* \param protocol L4 protocol
* \param payloadSize payload size
* \param ttl TTL
* \return newly created IPv6 header
*/
Ipv6Header BuildHeader (Ipv6Address src, Ipv6Address dst, uint8_t protocol,
uint16_t payloadSize, uint8_t ttl);
/**
* \brief Forwarding packets (i.e. router mode) state.
*/
bool m_ipForward;
/**
* \brief Send packet with route.
* \param route route
* \param packet packet to send
* \param ipHeader IPv6 header to add to the packet
*/
void SendRealOut (Ptr<Ipv6Route> route, Ptr<Packet> packet, Ipv6Header const& ipHeader);
/**
* \brief List of transport protocol.
*/
L4List_t m_protocols;
/**
* \brief Forward a packet.
* \param rtentry route
* \param p packet to forward
* \param header IPv6 header to add to the packet
*/
void IpForward (Ptr<Ipv6Route> rtentry, Ptr<const Packet> p, const Ipv6Header& header);
/**
* \brief List of IPv6 interfaces.
*/
Ipv6InterfaceList m_interfaces;
/**
* \brief Forward a packet in multicast.
* \param mrtentry route
* \param p packet to forward
* \param header IPv6 header to add to the packet
*/
void IpMulticastForward (Ptr<Ipv6MulticastRoute> mrtentry, Ptr<const Packet> p, const Ipv6Header& header);
/**
* \brief Number of IPv6 interfaces managed by the stack.
*/
uint32_t m_nInterfaces;
/**
* \brief Deliver a packet.
* \param p packet delivered
* \param ip IPv6 header
* \param iif input interface packet was received
*/
void LocalDeliver (Ptr<const Packet> p, Ipv6Header const& ip, uint32_t iif);
/**
* \brief Default TTL for outgoing packets.
*/
uint8_t m_defaultTtl;
/**
* \brief Fallback when no route is found.
* \param p packet
* \param ipHeader IPv6 header
* \param sockErrno error number
*/
void RouteInputError (Ptr<const Packet> p, const Ipv6Header& ipHeader, Socket::SocketErrno sockErrno);
/**
* \brief Routing protocol.
*/
Ptr<Ipv6RoutingProtocol> m_routingProtocol;
/**
* \brief Add an IPv6 interface to the stack.
* \param interface interface to add
* \return index of newly added interface
*/
uint32_t AddIpv6Interface (Ptr<Ipv6Interface> interface);
/**
* \brief List of IPv6 raw sockets.
*/
SocketList m_sockets;
/**
* \brief Setup loopback interface.
*/
void SetupLoopback ();
/**
* \brief List of IPv6 prefix received from RA.
*/
Ipv6AutoconfiguredPrefixList m_prefixes;
/**
* \brief Set IPv6 forwarding state.
* \param forward IPv6 forwarding enabled or not
*/
virtual void SetIpForward (bool forward);
/**
* \brief Get IPv6 forwarding state.
* \return forwarding state (enabled or not)
*/
virtual bool GetIpForward () const;
/**
* \brief Node attached to stack.
*/
Ptr<Node> m_node;
/**
* \brief Forwarding packets (i.e. router mode) state.
*/
bool m_ipForward;
/**
* \brief List of transport protocol.
*/
L4List_t m_protocols;
/**
* \brief List of IPv6 interfaces.
*/
Ipv6InterfaceList m_interfaces;
/**
* \brief Number of IPv6 interfaces managed by the stack.
*/
uint32_t m_nInterfaces;
/**
* \brief Default TTL for outgoing packets.
*/
uint8_t m_defaultTtl;
/**
* \brief Routing protocol.
*/
Ptr<Ipv6RoutingProtocol> m_routingProtocol;
/**
* \brief List of IPv6 raw sockets.
*/
SocketList m_sockets;
/**
* \brief List of IPv6 prefix received from RA.
*/
Ipv6AutoconfiguredPrefixList m_prefixes;
};
} /* namespace ns3 */

View File

@@ -37,69 +37,69 @@ class Ipv6Interface;
*/
class Ipv6L4Protocol : public Object
{
public:
/**
* \enum RxStatus_e
* \brief Status of receive.
*/
enum RxStatus_e
{
RX_OK, /**< Receive OK */
RX_CSUM_FAILED, /**< Checksum of layer 4 protocol failed */
RX_ENDPOINT_UNREACH /**< Destination unreachable */
};
public:
/**
* \enum RxStatus_e
* \brief Status of receive.
*/
enum RxStatus_e
{
RX_OK, /**< Receive OK */
RX_CSUM_FAILED, /**< Checksum of layer 4 protocol failed */
RX_ENDPOINT_UNREACH /**< Destination unreachable */
};
/**
* \brief Get the type identifier.
* \return type identifier
*/
static TypeId GetTypeId (void);
/**
* \brief Get the type identifier.
* \return type identifier
*/
static TypeId GetTypeId (void);
/**
* \brief Destructor.
*/
virtual ~Ipv6L4Protocol ();
/**
* \brief Destructor.
*/
virtual ~Ipv6L4Protocol ();
/**
* \brief Get the protocol number.
* \return protocol number
*/
virtual int GetProtocolNumber () const = 0;
/**
* \brief Get the protocol number.
* \return protocol number
*/
virtual int GetProtocolNumber () const = 0;
/**
* \brief Receive method.
*
* Called from lower-level layers to send the packet up
* in the stack.
* \param p packet to forward up
* \param src source address of packet received
* \param dst address of packet received
* \param incomingInterface the Ipv6Interface on which the packet arrived
* \return status (OK, destination unreachable or checksum failed)
*/
virtual enum RxStatus_e Receive (Ptr<Packet> p, Ipv6Address const &src,
Ipv6Address const &dst,
Ptr<Ipv6Interface> incomingInterface) = 0;
/**
* \brief Receive method.
*
* Called from lower-level layers to send the packet up
* in the stack.
* \param p packet to forward up
* \param src source address of packet received
* \param dst address of packet received
* \param incomingInterface the Ipv6Interface on which the packet arrived
* \return status (OK, destination unreachable or checksum failed)
*/
virtual enum RxStatus_e Receive (Ptr<Packet> p, Ipv6Address const &src,
Ipv6Address const &dst,
Ptr<Ipv6Interface> incomingInterface) = 0;
/**
* \brief ICMPv6 receive method.
* \param icmpSource the source address of the ICMPv6 message
* \param icmpTtl the ttl of the ICMPv6 message
* \param icmpType the 'type' field of the ICMPv6 message
* \param icmpCode the 'code' field of the ICMPv6 message
* \param icmpInfo extra information dependent on the ICMPv6 message
* generated by Icmpv6L4Protocol
* \param payloadSource the source address of the packet which triggered
* the ICMPv6 message
* \param payloadDestination the destination address of the packet which
* triggered the ICMPv6 message.
* \param payload the first 8 bytes of the UDP header of the packet
* which triggered the ICMPv6 message.
*/
virtual void ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl,
uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
Ipv6Address payloadSource, Ipv6Address payloadDestination,
const uint8_t* payload);
/**
* \brief ICMPv6 receive method.
* \param icmpSource the source address of the ICMPv6 message
* \param icmpTtl the ttl of the ICMPv6 message
* \param icmpType the 'type' field of the ICMPv6 message
* \param icmpCode the 'code' field of the ICMPv6 message
* \param icmpInfo extra information dependent on the ICMPv6 message
* generated by Icmpv6L4Protocol
* \param payloadSource the source address of the packet which triggered
* the ICMPv6 message
* \param payloadDestination the destination address of the packet which
* triggered the ICMPv6 message.
* \param payload the first 8 bytes of the UDP header of the packet
* which triggered the ICMPv6 message.
*/
virtual void ReceiveIcmp (Ipv6Address icmpSource, uint8_t icmpTtl,
uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
Ipv6Address payloadSource, Ipv6Address payloadDestination,
const uint8_t* payload);
};

View File

@@ -45,7 +45,7 @@ TypeId Ipv6OptionHeader::GetInstanceTypeId () const
}
Ipv6OptionHeader::Ipv6OptionHeader ()
: m_type (0),
: m_type (0),
m_length (0)
{
}
@@ -315,7 +315,7 @@ TypeId Ipv6OptionRouterAlertHeader::GetInstanceTypeId () const
}
Ipv6OptionRouterAlertHeader::Ipv6OptionRouterAlertHeader ()
: m_value (0)
: m_value (0)
{
SetLength (2);
}

View File

@@ -44,15 +44,15 @@ TypeId Ipv6RawSocketImpl::GetTypeId ()
static TypeId tid = TypeId ("ns3::Ipv6RawSocketImpl")
.SetParent<Socket> ()
.AddAttribute ("Protocol", "Protocol number to match.",
UintegerValue (0),
MakeUintegerAccessor (&Ipv6RawSocketImpl::m_protocol),
MakeUintegerChecker<uint16_t> ())
UintegerValue (0),
MakeUintegerAccessor (&Ipv6RawSocketImpl::m_protocol),
MakeUintegerChecker<uint16_t> ())
.AddAttribute ("IcmpFilter", "Any ICMPv6 header whose type field matches a bit in this filter is dropped.",
UintegerValue (0),
MakeUintegerAccessor (&Ipv6RawSocketImpl::m_icmpFilter),
MakeUintegerChecker<uint32_t> ())
UintegerValue (0),
MakeUintegerAccessor (&Ipv6RawSocketImpl::m_icmpFilter),
MakeUintegerChecker<uint32_t> ())
;
return tid;
return tid;
}
Ipv6RawSocketImpl::Ipv6RawSocketImpl ()
@@ -100,10 +100,10 @@ int Ipv6RawSocketImpl::Bind (const Address& address)
NS_LOG_FUNCTION (this << address);
if (!Inet6SocketAddress::IsMatchingType (address))
{
m_err = Socket::ERROR_INVAL;
return -1;
}
{
m_err = Socket::ERROR_INVAL;
return -1;
}
Inet6SocketAddress ad = Inet6SocketAddress::ConvertFrom (address);
m_src = ad.GetIpv6 ();
return 0;
@@ -127,11 +127,11 @@ int Ipv6RawSocketImpl::Close ()
{
NS_LOG_FUNCTION_NOARGS ();
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
if (ipv6)
{
ipv6->DeleteRawSocket (this);
}
{
ipv6->DeleteRawSocket (this);
}
return 0;
}
@@ -152,12 +152,12 @@ int Ipv6RawSocketImpl::ShutdownRecv ()
int Ipv6RawSocketImpl::Connect (const Address& address)
{
NS_LOG_FUNCTION (this << address);
if (!Inet6SocketAddress::IsMatchingType (address))
{
m_err = Socket::ERROR_INVAL;
return -1;
}
{
m_err = Socket::ERROR_INVAL;
return -1;
}
Inet6SocketAddress ad = Inet6SocketAddress::ConvertFrom (address);
m_dst = ad.GetIpv6 ();
@@ -183,61 +183,61 @@ int Ipv6RawSocketImpl::SendTo (Ptr<Packet> p, uint32_t flags, const Address& toA
NS_LOG_FUNCTION (this << p << flags << toAddress);
if (!Inet6SocketAddress::IsMatchingType (toAddress))
{
m_err = Socket::ERROR_INVAL;
return -1;
}
{
m_err = Socket::ERROR_INVAL;
return -1;
}
if (m_shutdownSend)
{
return 0;
}
{
return 0;
}
Inet6SocketAddress ad = Inet6SocketAddress::ConvertFrom (toAddress);
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
Ipv6Address dst = ad.GetIpv6 ();
if (ipv6->GetRoutingProtocol ())
{
Ipv6Header hdr;
hdr.SetDestinationAddress (dst);
SocketErrno err = ERROR_NOTERROR;
Ptr<Ipv6Route> route = 0;
Ptr<NetDevice> oif (0); /*specify non-zero if bound to a source address */
if (!m_src.IsAny ())
{
int32_t index = ipv6->GetInterfaceForAddress (m_src);
NS_ASSERT (index >= 0);
oif = ipv6->GetNetDevice (index);
}
Ipv6Header hdr;
hdr.SetDestinationAddress (dst);
SocketErrno err = ERROR_NOTERROR;
Ptr<Ipv6Route> route = 0;
Ptr<NetDevice> oif (0); /*specify non-zero if bound to a source address */
route = ipv6->GetRoutingProtocol ()->RouteOutput (p, hdr, oif, err);
if (route)
{
NS_LOG_LOGIC ("Route exists");
if (m_protocol == Icmpv6L4Protocol::GetStaticProtocolNumber ())
{
/* calculate checksum here for ICMPv6 echo request (sent by ping6)
* as we cannot determine source IPv6 address at application level
*/
if (*p->PeekData () == Icmpv6Header::ICMPV6_ECHO_REQUEST)
if (!m_src.IsAny ())
{
Icmpv6Echo hdr (1);
p->RemoveHeader (hdr);
hdr.CalculatePseudoHeaderChecksum (route->GetSource (), dst, p->GetSize () + hdr.GetSerializedSize (), Icmpv6L4Protocol::GetStaticProtocolNumber ());
p->AddHeader (hdr);
int32_t index = ipv6->GetInterfaceForAddress (m_src);
NS_ASSERT (index >= 0);
oif = ipv6->GetNetDevice (index);
}
}
ipv6->Send (p, route->GetSource (), dst, m_protocol, route);
route = ipv6->GetRoutingProtocol ()->RouteOutput (p, hdr, oif, err);
if (route)
{
NS_LOG_LOGIC ("Route exists");
if (m_protocol == Icmpv6L4Protocol::GetStaticProtocolNumber ())
{
/* calculate checksum here for ICMPv6 echo request (sent by ping6)
* as we cannot determine source IPv6 address at application level
*/
if (*p->PeekData () == Icmpv6Header::ICMPV6_ECHO_REQUEST)
{
Icmpv6Echo hdr (1);
p->RemoveHeader (hdr);
hdr.CalculatePseudoHeaderChecksum (route->GetSource (), dst, p->GetSize () + hdr.GetSerializedSize (), Icmpv6L4Protocol::GetStaticProtocolNumber ());
p->AddHeader (hdr);
}
}
ipv6->Send (p, route->GetSource (), dst, m_protocol, route);
}
else
{
NS_LOG_DEBUG ("No route, dropped!");
}
}
else
{
NS_LOG_DEBUG ("No route, dropped!");
}
}
return 0;
}
@@ -251,24 +251,24 @@ Ptr<Packet> Ipv6RawSocketImpl::Recv (uint32_t maxSize, uint32_t flags)
Ptr<Packet> Ipv6RawSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress)
{
NS_LOG_FUNCTION (this << maxSize << flags << fromAddress);
if (m_data.empty ())
{
return 0;
}
{
return 0;
}
/* get packet */
struct Data data = m_data.front ();
m_data.pop_front ();
if (data.packet->GetSize () > maxSize)
{
Ptr<Packet> first = data.packet->CreateFragment (0, maxSize);
data.packet->RemoveAtStart (maxSize);
m_data.push_front (data);
return first;
}
{
Ptr<Packet> first = data.packet->CreateFragment (0, maxSize);
data.packet->RemoveAtStart (maxSize);
m_data.push_front (data);
return first;
}
fromAddress = Inet6SocketAddress (data.fromIp, data.fromProtocol);
return data.packet;
}
@@ -285,9 +285,9 @@ uint32_t Ipv6RawSocketImpl::GetRxAvailable () const
uint32_t rx = 0;
for (std::list<Data>::const_iterator it = m_data.begin () ; it != m_data.end () ; ++it)
{
rx+= (it->packet)->GetSize ();
}
{
rx+= (it->packet)->GetSize ();
}
return rx;
}
@@ -297,39 +297,39 @@ bool Ipv6RawSocketImpl::ForwardUp (Ptr<const Packet> p, Ipv6Header hdr, Ptr<NetD
NS_LOG_FUNCTION (this << *p << hdr << device);
if (m_shutdownRecv)
{
return false;
}
{
return false;
}
if ((m_src == Ipv6Address::GetAny () || hdr.GetDestinationAddress () == m_src) &&
(m_dst == Ipv6Address::GetAny () || hdr.GetSourceAddress () == m_dst) &&
hdr.GetNextHeader () == m_protocol)
{
Ptr<Packet> copy = p->Copy ();
if (m_protocol == Icmpv6L4Protocol::GetStaticProtocolNumber ())
(m_dst == Ipv6Address::GetAny () || hdr.GetSourceAddress () == m_dst) &&
hdr.GetNextHeader () == m_protocol)
{
/* filter */
Icmpv6Header icmpHeader;
copy->PeekHeader (icmpHeader);
uint8_t type = icmpHeader.GetType ();
Ptr<Packet> copy = p->Copy ();
if ((1 << type) & m_icmpFilter)
{
/* packet filtered */
return false;
}
if (m_protocol == Icmpv6L4Protocol::GetStaticProtocolNumber ())
{
/* filter */
Icmpv6Header icmpHeader;
copy->PeekHeader (icmpHeader);
uint8_t type = icmpHeader.GetType ();
if ((1 << type) & m_icmpFilter)
{
/* packet filtered */
return false;
}
}
copy->AddHeader (hdr);
struct Data data;
data.packet = copy;
data.fromIp = hdr.GetSourceAddress ();
data.fromProtocol = hdr.GetNextHeader ();
m_data.push_back (data);
NotifyDataRecv ();
return true;
}
copy->AddHeader (hdr);
struct Data data;
data.packet = copy;
data.fromIp = hdr.GetSourceAddress ();
data.fromProtocol = hdr.GetNextHeader ();
m_data.push_back (data);
NotifyDataRecv ();
return true;
}
return false;
}

View File

@@ -29,7 +29,7 @@
namespace ns3
{
class NetDevice;
class Node;
@@ -39,214 +39,214 @@ class Node;
*/
class Ipv6RawSocketImpl : public Socket
{
public:
/**
* \brief Get the type ID of this class.
* \return type ID
*/
static TypeId GetTypeId ();
public:
/**
* \brief Get the type ID of this class.
* \return type ID
*/
static TypeId GetTypeId ();
/**
* \brief Constructor.
*/
Ipv6RawSocketImpl ();
/**
* \brief Destructor.
*/
virtual ~Ipv6RawSocketImpl ();
/**
* \brief Constructor.
*/
Ipv6RawSocketImpl ();
/**
* \brief Set the node.
* \param node node to set
*/
void SetNode (Ptr<Node> node);
/**
* \brief Destructor.
*/
virtual ~Ipv6RawSocketImpl ();
/**
* \brief Get last error number.
* \return error number
*/
virtual enum Socket::SocketErrno GetErrno () const;
/**
* \brief Set the node.
* \param node node to set
*/
void SetNode (Ptr<Node> node);
/**
* \brief Get node.
* \return node associated with this raw socket.
*/
virtual Ptr<Node> GetNode () const;
/**
* \brief Get last error number.
* \return error number
*/
virtual enum Socket::SocketErrno GetErrno () const;
/**
* \brief Bind the socket to address.
* \param address bind to this address
* \return 0 if success, -1 otherwise
*/
virtual int Bind (const Address& address);
/**
* \brief Get node.
* \return node associated with this raw socket.
*/
virtual Ptr<Node> GetNode () const;
/**
* \brief Bind socket.
* \return 0 if success, -1 otherwise
*/
virtual int Bind ();
/**
* \brief Bind the socket to address.
* \param address bind to this address
* \return 0 if success, -1 otherwise
*/
virtual int Bind (const Address& address);
/**
* \brief Get socket address.
* \param address socket address if method success
* \return 0 if success, -1 otherwise
*/
virtual int GetSockName (Address& address) const;
/**
* \brief Bind socket.
* \return 0 if success, -1 otherwise
*/
virtual int Bind ();
/**
* \brief Close the socket.
* \return 0 if success, -1 otherwise
*/
virtual int Close ();
/**
* \brief Get socket address.
* \param address socket address if method success
* \return 0 if success, -1 otherwise
*/
virtual int GetSockName (Address& address) const;
/**
* \brief Shutdown send capability.
* \return 0 if success, -1 otherwise
*/
virtual int ShutdownSend ();
/**
* \brief Close the socket.
* \return 0 if success, -1 otherwise
*/
virtual int Close ();
/**
* \brief Shutdown receive capability.
* \return 0 if success, -1 otherwise
*/
virtual int ShutdownRecv ();
/**
* \brief Connect to address.
* \param address address
* \return 0 if success, -1 otherwise
*/
virtual int Connect (const Address& address);
/**
* \brief Shutdown send capability.
* \return 0 if success, -1 otherwise
*/
virtual int ShutdownSend ();
/**
* \brief Listen.
* \return 0 if success, -1 otherwise
*/
virtual int Listen ();
/**
* \brief Shutdown receive capability.
* \return 0 if success, -1 otherwise
*/
virtual int ShutdownRecv ();
/**
* \brief Get TX size available.
* \return TX size
*/
virtual uint32_t GetTxAvailable () const;
/**
* \brief Connect to address.
* \param address address
* \return 0 if success, -1 otherwise
*/
virtual int Connect (const Address& address);
/**
* \brief Get RX size available.
* \return RX size
*/
virtual uint32_t GetRxAvailable () const;
/**
* \brief Listen.
* \return 0 if success, -1 otherwise
*/
virtual int Listen ();
/**
* \brief Send a packet.
* \param p packet to send
* \param flags additionnal flags
* \return 0 if success, -1 otherwise
*/
virtual int Send (Ptr<Packet> p, uint32_t flags);
/**
* \brief Send a packet.
* \param p packet to send
* \param flags additionnal flags
* \param toAddress destination address
* \return 0 if success, -1 otherwise
*/
virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address& toAddress);
/**
* \brief Get TX size available.
* \return TX size
*/
virtual uint32_t GetTxAvailable () const;
/**
* \brief Receive packet.
* \param maxSize maximum size
* \param flags additionnal flags
* \return packet received
*/
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
/**
* \brief Receive packet.
* \param maxSize maximum size
* \param flags additionnal flags
* \param fromAddress source address
* \return packet received
*/
virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress);
/**
* \brief Set protocol field.
* \param protocol protocol to set
*/
void SetProtocol (uint16_t protocol);
/**
* \brief Forward up to receive method.
* \param p packet
* \param hdr IPv6 header
* \param device device
* \return true if forwarded, false otherwise
*/
bool ForwardUp (Ptr<const Packet> p, Ipv6Header hdr, Ptr<NetDevice> device);
/**
* \brief Get RX size available.
* \return RX size
*/
virtual uint32_t GetRxAvailable () const;
private:
/**
* \struct Data
* \brief IPv6 raw data and additionnal information.
*/
struct Data
/**
* \brief Send a packet.
* \param p packet to send
* \param flags additionnal flags
* \return 0 if success, -1 otherwise
*/
virtual int Send (Ptr<Packet> p, uint32_t flags);
/**
* \brief Send a packet.
* \param p packet to send
* \param flags additionnal flags
* \param toAddress destination address
* \return 0 if success, -1 otherwise
*/
virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address& toAddress);
/**
* \brief Receive packet.
* \param maxSize maximum size
* \param flags additionnal flags
* \return packet received
*/
virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
/**
* \brief Receive packet.
* \param maxSize maximum size
* \param flags additionnal flags
* \param fromAddress source address
* \return packet received
*/
virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress);
/**
* \brief Set protocol field.
* \param protocol protocol to set
*/
void SetProtocol (uint16_t protocol);
/**
* \brief Forward up to receive method.
* \param p packet
* \param hdr IPv6 header
* \param device device
* \return true if forwarded, false otherwise
*/
bool ForwardUp (Ptr<const Packet> p, Ipv6Header hdr, Ptr<NetDevice> device);
private:
/**
* \struct Data
* \brief IPv6 raw data and additionnal information.
*/
struct Data
{
Ptr<Packet> packet; /**< Packet data */
Ipv6Address fromIp; /**< Source address */
uint16_t fromProtocol; /**< Protocol used */
};
/**
* \brief Dispose object.
*/
virtual void DoDispose ();
/**
* \brief Dispose object.
*/
virtual void DoDispose ();
/**
* \brief Last error number.
*/
enum Socket::SocketErrno m_err;
/**
* \brief Node.
*/
Ptr<Node> m_node;
/**
* \brief Last error number.
*/
enum Socket::SocketErrno m_err;
/**
* \brief Source address.
*/
Ipv6Address m_src;
/**
* \brief Node.
*/
Ptr<Node> m_node;
/**
* \brief Destination address.
*/
Ipv6Address m_dst;
/**
* \brief Source address.
*/
Ipv6Address m_src;
/**
* \brief Protocol.
*/
uint16_t m_protocol;
/**
* \brief Destination address.
*/
Ipv6Address m_dst;
/**
* \brief Packet waiting to be processed.
*/
std::list<struct Data> m_data;
/**
* \brief Protocol.
*/
uint16_t m_protocol;
/**
* \brief Flag to shutdown send capability.
*/
bool m_shutdownSend;
/**
* \brief Flag to shutdown receive capability.
*/
bool m_shutdownRecv;
/**
* \brief Packet waiting to be processed.
*/
std::list<struct Data> m_data;
/**
* \brief ICMPv6 filter.
*/
uint32_t m_icmpFilter;
/**
* \brief Flag to shutdown send capability.
*/
bool m_shutdownSend;
/**
* \brief Flag to shutdown receive capability.
*/
bool m_shutdownRecv;
/**
* \brief ICMPv6 filter.
*/
uint32_t m_icmpFilter;
};
} /* namespace ns3 */

View File

@@ -37,10 +37,10 @@ TypeId NdiscCache::GetTypeId ()
static TypeId tid = TypeId ("ns3::NdiscCache")
.SetParent<Object> ()
.AddAttribute ("UnresolvedQueueSize",
"Size of the queue for packets pending an NA reply.",
UintegerValue (DEFAULT_UNRES_QLEN),
MakeUintegerAccessor (&NdiscCache::m_unresQlen),
MakeUintegerChecker<uint32_t> ())
"Size of the queue for packets pending an NA reply.",
UintegerValue (DEFAULT_UNRES_QLEN),
MakeUintegerAccessor (&NdiscCache::m_unresQlen),
MakeUintegerChecker<uint32_t> ())
;
return tid;
}
@@ -89,10 +89,10 @@ NdiscCache::Entry* NdiscCache::Lookup (Ipv6Address dst)
NS_LOG_FUNCTION (this << dst);
if (m_ndCache.find (dst) != m_ndCache.end ())
{
NdiscCache::Entry* entry = m_ndCache[dst];
return entry;
}
{
NdiscCache::Entry* entry = m_ndCache[dst];
return entry;
}
return 0;
}
@@ -110,27 +110,27 @@ NdiscCache::Entry* NdiscCache::Add (Ipv6Address to)
void NdiscCache::Remove (NdiscCache::Entry* entry)
{
NS_LOG_FUNCTION_NOARGS ();
for (CacheI i = m_ndCache.begin () ; i != m_ndCache.end () ; i++)
{
if ((*i).second == entry)
{
m_ndCache.erase (i);
entry->ClearWaitingPacket ();
delete entry;
return;
if ((*i).second == entry)
{
m_ndCache.erase (i);
entry->ClearWaitingPacket ();
delete entry;
return;
}
}
}
}
void NdiscCache::Flush ()
{
NS_LOG_FUNCTION_NOARGS ();
for (CacheI i = m_ndCache.begin () ; i != m_ndCache.end () ; i++)
{
delete (*i).second; /* delete the pointer NdiscCache::Entry */
}
{
delete (*i).second; /* delete the pointer NdiscCache::Entry */
}
m_ndCache.erase (m_ndCache.begin (), m_ndCache.end ());
}
@@ -178,11 +178,11 @@ void NdiscCache::Entry::AddWaitingPacket (Ptr<Packet> p)
NS_LOG_FUNCTION (this << p);
if (m_waiting.size () >= m_ndCache->GetUnresQlen ())
{
/* we store only m_unresQlen packet => first packet in first packet remove */
/* XXX report packet as 'dropped' */
m_waiting.remove (0);
}
{
/* we store only m_unresQlen packet => first packet in first packet remove */
/* XXX report packet as 'dropped' */
m_waiting.remove (0);
}
m_waiting.push_back (p);
}
@@ -207,42 +207,42 @@ void NdiscCache::Entry::FunctionRetransmitTimeout ()
/* determine source address */
if (m_ipv6Address.IsLinkLocal ())
{
addr = m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();;
}
else if (!m_ipv6Address.IsAny ())
{
addr = m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress ();
if (addr.IsAny ()) /* maybe address has expired */
{
/* delete the entry */
m_ndCache->Remove (this);
return;
addr = m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();;
}
else if (!m_ipv6Address.IsAny ())
{
addr = m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress ();
if (addr.IsAny ()) /* maybe address has expired */
{
/* delete the entry */
m_ndCache->Remove (this);
return;
}
}
}
if (GetNSRetransmit () < icmpv6->MAX_MULTICAST_SOLICIT)
{
IncNSRetransmit ();
icmpv6->SendNS (addr, Ipv6Address::MakeSolicitedAddress (m_ipv6Address), m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ());
/* arm the timer again */
StartRetransmitTimer ();
}
else
{
Ptr<Packet> malformedPacket = m_waiting.front ();
if (malformedPacket == 0)
{
malformedPacket = Create<Packet> ();
}
IncNSRetransmit ();
icmpv6->SendErrorDestinationUnreachable (malformedPacket, addr, Icmpv6Header::ICMPV6_ADDR_UNREACHABLE);
/* delete the entry */
m_ndCache->Remove (this);
}
icmpv6->SendNS (addr, Ipv6Address::MakeSolicitedAddress (m_ipv6Address), m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ());
/* arm the timer again */
StartRetransmitTimer ();
}
else
{
Ptr<Packet> malformedPacket = m_waiting.front ();
if (malformedPacket == 0)
{
malformedPacket = Create<Packet> ();
}
icmpv6->SendErrorDestinationUnreachable (malformedPacket, addr, Icmpv6Header::ICMPV6_ADDR_UNREACHABLE);
/* delete the entry */
m_ndCache->Remove (this);
}
}
void NdiscCache::Entry::FunctionDelayTimeout ()
@@ -255,24 +255,24 @@ void NdiscCache::Entry::FunctionDelayTimeout ()
this->MarkProbe ();
if (m_ipv6Address.IsLinkLocal ())
{
addr = m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();
}
else if (!m_ipv6Address.IsAny ())
{
addr = m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress ();
if (addr.IsAny ()) /* maybe address has expired */
{
/* delete the entry */
m_ndCache->Remove (this);
addr = m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();
}
else if (!m_ipv6Address.IsAny ())
{
addr = m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress ();
if (addr.IsAny ()) /* maybe address has expired */
{
/* delete the entry */
m_ndCache->Remove (this);
return;
}
}
else
{
/* should not happen */
return;
}
}
else
{
/* should not happen */
return;
}
Ptr<Packet> p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ());
m_ndCache->GetDevice ()->Send (p, this->GetMacAddress (), Ipv6L3Protocol::PROT_NUMBER);
@@ -289,42 +289,42 @@ void NdiscCache::Entry::FunctionProbeTimeout ()
Ptr<Icmpv6L4Protocol> icmpv6 = ipv6->GetIcmpv6 ();
if (GetNSRetransmit () < icmpv6->MAX_UNICAST_SOLICIT)
{
Ipv6Address addr;
if (m_ipv6Address.IsLinkLocal ())
{
addr = m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();
}
else if (!m_ipv6Address.IsAny ())
{
addr = m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress ();
if (addr.IsAny ()) /* maybe address has expired */
{
/* delete the entry */
m_ndCache->Remove (this);
return;
}
}
else
{
/* should not happen */
return;
}
Ipv6Address addr;
IncNSRetransmit ();
/* icmpv6->SendNS (m_ndCache->GetInterface ()->GetLinkLocalAddress (), m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); */
Ptr<Packet> p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ());
m_ndCache->GetDevice ()->Send (p, this->GetMacAddress (), Ipv6L3Protocol::PROT_NUMBER);
if (m_ipv6Address.IsLinkLocal ())
{
addr = m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();
}
else if (!m_ipv6Address.IsAny ())
{
addr = m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress ();
if (addr.IsAny ()) /* maybe address has expired */
{
/* delete the entry */
m_ndCache->Remove (this);
return;
}
}
else
{
/* should not happen */
return;
}
/* arm the timer again */
StartProbeTimer ();
}
IncNSRetransmit ();
/* icmpv6->SendNS (m_ndCache->GetInterface ()->GetLinkLocalAddress (), m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); */
Ptr<Packet> p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ());
m_ndCache->GetDevice ()->Send (p, this->GetMacAddress (), Ipv6L3Protocol::PROT_NUMBER);
/* arm the timer again */
StartProbeTimer ();
}
else
{
/* delete the entry */
m_ndCache->Remove (this);
}
{
/* delete the entry */
m_ndCache->Remove (this);
}
}
void NdiscCache::Entry::SetIpv6Address (Ipv6Address ipv6Address)
@@ -428,9 +428,9 @@ void NdiscCache::Entry::MarkIncomplete (Ptr<Packet> p)
m_state = INCOMPLETE;
if (p)
{
m_waiting.push_back (p);
}
{
m_waiting.push_back (p);
}
}
std::list<Ptr<Packet> > NdiscCache::Entry::MarkReachable (Address mac)

View File

@@ -45,412 +45,412 @@ class Ipv6Interface;
*/
class NdiscCache : public Object
{
public:
class Entry;
/**
* \brief Get the type ID
* \return type ID
*/
static TypeId GetTypeId ();
/**
* \brief Default value for unres qlen.
*/
static const uint32_t DEFAULT_UNRES_QLEN = 3;
/**
* \brief Constructor.
*/
NdiscCache ();
/**
* \brief Destructor.
*/
~NdiscCache ();
/**
* \brief Get the NetDevice associated with this cache.
* \return NetDevice
*/
Ptr<NetDevice> GetDevice () const;
/**
* \brief Get the Ipv6Interface associated with this cache.
*/
Ptr<Ipv6Interface> GetInterface () const;
/**
* \brief Lookup in the cache.
* \param dst destination address
* \return the entry if found, 0 otherwise
*/
NdiscCache::Entry* Lookup (Ipv6Address dst);
/**
* \brief Add an entry.
* \param to address to add
* \return an new Entry
*/
NdiscCache::Entry* Add (Ipv6Address to);
/**
* \brief Delete an entry.
* \param entry pointer to delete from the list.
*/
void Remove (NdiscCache::Entry* entry);
/**
* \brief Flush the cache.
*/
void Flush ();
/**
* \brief Set the max number of waiting packet.
* \param unresQlen value to set
*/
void SetUnresQlen (uint32_t unresQlen);
/**
* \brief Get the max number of waiting packet.
* \return max number
*/
uint32_t GetUnresQlen ();
/**
* \brief Set the device and interface.
* \param device the device
* \param interface the IPv6 interface
*/
void SetDevice (Ptr<NetDevice> device, Ptr<Ipv6Interface> interface);
/**
* \class Entry
* \brief A record that holds information about an NdiscCache entry.
*/
class Entry
{
public:
class Entry;
/**
* \brief Get the type ID
* \return type ID
*/
static TypeId GetTypeId ();
/**
* \brief Default value for unres qlen.
*/
static const uint32_t DEFAULT_UNRES_QLEN = 3;
/**
* \brief Constructor.
* \param nd The NdiscCache this entry belongs to.
*/
NdiscCache ();
Entry (NdiscCache* nd);
/**
* \brief Destructor.
* \brief Changes the state to this entry to INCOMPLETE.
* \param p packet that wait to be sent
*/
~NdiscCache ();
void MarkIncomplete (Ptr<Packet> p);
/**
* \brief Get the NetDevice associated with this cache.
* \return NetDevice
* \brief Changes the state to this entry to REACHABLE.
* \param mac MAC address
* \return the list of packet waiting
*/
Ptr<NetDevice> GetDevice () const;
std::list<Ptr<Packet> > MarkReachable (Address mac);
/**
* \brief Get the Ipv6Interface associated with this cache.
* \brief Changes the state to this entry to PROBE.
*/
Ptr<Ipv6Interface> GetInterface () const;
void MarkProbe ();
/**
* \brief Lookup in the cache.
* \param dst destination address
* \return the entry if found, 0 otherwise
* \brief Changes the state to this entry to STALE.
* \param mac L2 address
* \return the list of packet waiting
*/
NdiscCache::Entry* Lookup (Ipv6Address dst);
std::list<Ptr<Packet> > MarkStale (Address mac);
/**
* \brief Add an entry.
* \param to address to add
* \return an new Entry
* \brief Changes the state to this entry to STALE.
*/
NdiscCache::Entry* Add (Ipv6Address to);
void MarkStale ();
/**
* \brief Delete an entry.
* \param entry pointer to delete from the list.
* \brief Changes the state to this entry to REACHABLE.
*/
void Remove (NdiscCache::Entry* entry);
void MarkReachable ();
/**
* \brief Flush the cache.
* \brief Change the state to this entry to DELAY.
*/
void Flush ();
void MarkDelay ();
/**
* \brief Set the max number of waiting packet.
* \param unresQlen value to set
* \brief Add a packet (or replace old value) in the queue.
* \param p packet to add
*/
void SetUnresQlen (uint32_t unresQlen);
void AddWaitingPacket (Ptr<Packet> p);
/**
* \brief Get the max number of waiting packet.
* \return max number
* \brief Clear the waiting packet list.
*/
uint32_t GetUnresQlen ();
void ClearWaitingPacket ();
/**
* \brief Set the device and interface.
* \param device the device
* \param interface the IPv6 interface
* \brief Is the entry STALE
* \return true if the entry is in STALE state, false otherwise
*/
void SetDevice (Ptr<NetDevice> device, Ptr<Ipv6Interface> interface);
bool IsStale () const;
/**
* \class Entry
* \brief A record that holds information about an NdiscCache entry.
* \brief Is the entry REACHABLE
* \return true if the entry is in REACHABLE state, false otherwise
*/
class Entry
{
public:
/**
* \brief Constructor.
* \param nd The NdiscCache this entry belongs to.
*/
Entry (NdiscCache* nd);
bool IsReachable () const;
/**
* \brief Changes the state to this entry to INCOMPLETE.
* \param p packet that wait to be sent
*/
void MarkIncomplete (Ptr<Packet> p);
/**
* \brief Is the entry DELAY
* \return true if the entry is in DELAY state, false otherwise
*/
bool IsDelay () const;
/**
* \brief Changes the state to this entry to REACHABLE.
* \param mac MAC address
* \return the list of packet waiting
*/
std::list<Ptr<Packet> > MarkReachable (Address mac);
/**
* \brief Is the entry INCOMPLETE
* \return true if the entry is in INCOMPLETE state, false otherwise
*/
bool IsIncomplete () const;
/**
* \brief Changes the state to this entry to PROBE.
*/
void MarkProbe ();
/**
* \brief Is the entry PROBE
* \return true if the entry is in PROBE state, false otherwise
*/
bool IsProbe () const;
/**
* \brief Changes the state to this entry to STALE.
* \param mac L2 address
* \return the list of packet waiting
*/
std::list<Ptr<Packet> > MarkStale (Address mac);
/**
* \brief Get the MAC address of this entry.
* \return the L2 address
*/
Address GetMacAddress () const;
/**
* \brief Changes the state to this entry to STALE.
*/
void MarkStale ();
/**
* \brief Set the MAC address of this entry.
* \param mac the MAC address to set
*/
void SetMacAddress (Address mac);
/**
* \brief Changes the state to this entry to REACHABLE.
*/
void MarkReachable ();
/**
* \brief If the entry is a host or a router.
* \return true if the node is a router, 0 if it is a host
*/
bool IsRouter () const;
/**
* \brief Change the state to this entry to DELAY.
*/
void MarkDelay ();
/**
* \brief Set the node type.
* \param router true is a router, false means a host
*/
void SetRouter (bool router);
/**
* \brief Add a packet (or replace old value) in the queue.
* \param p packet to add
*/
void AddWaitingPacket (Ptr<Packet> p);
/**
* \brief Get the number of NS retransmit.
* \return number of NS that have been retransmit
*/
uint8_t GetNSRetransmit () const;
/**
* \brief Clear the waiting packet list.
*/
void ClearWaitingPacket ();
/**
* \brief Increment NS retransmit.
*/
void IncNSRetransmit ();
/**
* \brief Is the entry STALE
* \return true if the entry is in STALE state, false otherwise
*/
bool IsStale () const;
/**
* \brief Reset NS retransmit (=0).
*/
void ResetNSRetransmit ();
/**
* \brief Is the entry REACHABLE
* \return true if the entry is in REACHABLE state, false otherwise
*/
bool IsReachable () const;
/**
* \brief Get the time of last reachability confirmation.
* \return time
*/
Time GetLastReachabilityConfirmation () const;
/**
* \brief Is the entry DELAY
* \return true if the entry is in DELAY state, false otherwise
*/
bool IsDelay () const;
/**
* \brief Update the time of last reachability confirmation.
*/
void UpdateLastReachabilityconfirmation ();
/**
* \brief Is the entry INCOMPLETE
* \return true if the entry is in INCOMPLETE state, false otherwise
*/
bool IsIncomplete () const;
/**
* \brief Start the reachable timer.
*/
void StartReachableTimer ();
/**
* \brief Is the entry PROBE
* \return true if the entry is in PROBE state, false otherwise
*/
bool IsProbe () const;
/**
* \brief Stop the reachable timer.
*/
void StopReachableTimer ();
/**
* \brief Get the MAC address of this entry.
* \return the L2 address
*/
Address GetMacAddress () const;
/**
* \brief Start retransmit timer.
*/
void StartRetransmitTimer ();
/**
* \brief Set the MAC address of this entry.
* \param mac the MAC address to set
*/
void SetMacAddress (Address mac);
/**
* \brief Stop retransmit timer.
*/
void StopRetransmitTimer ();
/**
* \brief If the entry is a host or a router.
* \return true if the node is a router, 0 if it is a host
*/
bool IsRouter () const;
/**
* \brief Start probe timer.
*/
void StartProbeTimer ();
/**
* \brief Set the node type.
* \param router true is a router, false means a host
*/
void SetRouter (bool router);
/**
* \brief Stop probe timer.
*/
void StopProbeTimer ();
/**
* \brief Get the number of NS retransmit.
* \return number of NS that have been retransmit
*/
uint8_t GetNSRetransmit () const;
/**
* \brief Start delay timer.
*/
void StartDelayTimer ();
/**
* \brief Increment NS retransmit.
*/
void IncNSRetransmit ();
/**
* \brief Stop delay timer.
*/
void StopDelayTimer ();
/**
* \brief Reset NS retransmit (=0).
*/
void ResetNSRetransmit ();
/**
* \brief Function called when reachable timer timeout.
*/
void FunctionReachableTimeout ();
/**
* \brief Get the time of last reachability confirmation.
* \return time
*/
Time GetLastReachabilityConfirmation () const;
/**
* \brief Function called when retransmit timer timeout.
* It verify that the NS retransmit has reached the max so discard the entry
* otherwise it retransmit a NS.
*/
void FunctionRetransmitTimeout ();
/**
* \brief Update the time of last reachability confirmation.
*/
void UpdateLastReachabilityconfirmation ();
/**
* \brief Function called when probe timer timeout.
*/
void FunctionProbeTimeout ();
/**
* \brief Start the reachable timer.
*/
void StartReachableTimer ();
/**
* \brief Function called when delay timer timeout.
*/
void FunctionDelayTimeout ();
/**
* \brief Stop the reachable timer.
*/
void StopReachableTimer ();
/**
* \brief Start retransmit timer.
*/
void StartRetransmitTimer ();
/**
* \brief Stop retransmit timer.
*/
void StopRetransmitTimer ();
/**
* \brief Start probe timer.
*/
void StartProbeTimer ();
/**
* \brief Stop probe timer.
*/
void StopProbeTimer ();
/**
* \brief Start delay timer.
*/
void StartDelayTimer ();
/**
* \brief Stop delay timer.
*/
void StopDelayTimer ();
/**
* \brief Function called when reachable timer timeout.
*/
void FunctionReachableTimeout ();
/**
* \brief Function called when retransmit timer timeout.
* It verify that the NS retransmit has reached the max so discard the entry
* otherwise it retransmit a NS.
*/
void FunctionRetransmitTimeout ();
/**
* \brief Function called when probe timer timeout.
*/
void FunctionProbeTimeout ();
/**
* \brief Function called when delay timer timeout.
*/
void FunctionDelayTimeout ();
/**
* \brief Set the IPv6 address.
* \param ipv6Address IPv6 address
*/
void SetIpv6Address (Ipv6Address ipv6Address);
private:
/**
* \brief The IPv6 address.
*/
Ipv6Address m_ipv6Address;
/**
* \brief The Entry state enumeration.
*/
enum NdiscCacheEntryState_e
{
INCOMPLETE, /**< No mapping between IPv6 and L2 addresses */
REACHABLE, /**< Mapping exists between IPv6 and L2 addresses */
STALE, /**< Mapping is stale */
DELAY, /**< Try to wait contact from remote host */
PROBE /**< Try to contact IPv6 address to know again its L2 address */
};
/**
* \brief The state of the entry.
*/
NdiscCacheEntryState_e m_state;
/**
* \brief the NdiscCache associated.
*/
NdiscCache* m_ndCache;
/**
* \brief The MAC address.
*/
Address m_macAddress;
/**
* \brief The list of packet waiting.
*/
std::list<Ptr<Packet> > m_waiting;
/**
* \brief Type of node (router or host).
*/
bool m_router;
/**
* \brief Reachable timer (used for NUD in REACHABLE state).
*/
Timer m_reachableTimer;
/**
* \brief Retransmission timer (used for NUD in INCOMPLETE state).
*/
Timer m_retransTimer;
/**
* \brief Probe timer (used for NUD in PROBE state).
*/
Timer m_probeTimer;
/**
* \brief Delay timer (used for NUD when in DELAY state).
*/
Timer m_delayTimer;
/**
* \brief Last time we see a reachability confirmation.
*/
Time m_lastReachabilityConfirmation;
/**
* \brief Number of NS retransmission.
*/
uint8_t m_nsRetransmit;
};
/**
* \brief Set the IPv6 address.
* \param ipv6Address IPv6 address
*/
void SetIpv6Address (Ipv6Address ipv6Address);
private:
typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash> Cache;
typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash>::iterator CacheI;
/**
* \brief The IPv6 address.
*/
Ipv6Address m_ipv6Address;
/**
* \brief Copy constructor.
* \param a cache to copy
* \brief The Entry state enumeration.
*/
NdiscCache (NdiscCache const &a);
/**
* \brief Equal operator.
* \param a cache to copy
*/
NdiscCache& operator= (NdiscCache const &a);
enum NdiscCacheEntryState_e
{
INCOMPLETE, /**< No mapping between IPv6 and L2 addresses */
REACHABLE, /**< Mapping exists between IPv6 and L2 addresses */
STALE, /**< Mapping is stale */
DELAY, /**< Try to wait contact from remote host */
PROBE /**< Try to contact IPv6 address to know again its L2 address */
};
/**
* \brief Dispose this object.
* \brief The state of the entry.
*/
void DoDispose ();
NdiscCacheEntryState_e m_state;
/**
* \brief The NetDevice.
* \brief the NdiscCache associated.
*/
Ptr<NetDevice> m_device;
NdiscCache* m_ndCache;
/**
* \brief the interface.
* \brief The MAC address.
*/
Ptr<Ipv6Interface> m_interface;
Address m_macAddress;
/**
* \brief A list of Entry.
* \brief The list of packet waiting.
*/
Cache m_ndCache;
std::list<Ptr<Packet> > m_waiting;
/**
* \brief Max number of packet stored in m_waiting.
* \brief Type of node (router or host).
*/
uint32_t m_unresQlen;
bool m_router;
/**
* \brief Reachable timer (used for NUD in REACHABLE state).
*/
Timer m_reachableTimer;
/**
* \brief Retransmission timer (used for NUD in INCOMPLETE state).
*/
Timer m_retransTimer;
/**
* \brief Probe timer (used for NUD in PROBE state).
*/
Timer m_probeTimer;
/**
* \brief Delay timer (used for NUD when in DELAY state).
*/
Timer m_delayTimer;
/**
* \brief Last time we see a reachability confirmation.
*/
Time m_lastReachabilityConfirmation;
/**
* \brief Number of NS retransmission.
*/
uint8_t m_nsRetransmit;
};
private:
typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash> Cache;
typedef sgi::hash_map<Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash>::iterator CacheI;
/**
* \brief Copy constructor.
* \param a cache to copy
*/
NdiscCache (NdiscCache const &a);
/**
* \brief Equal operator.
* \param a cache to copy
*/
NdiscCache& operator= (NdiscCache const &a);
/**
* \brief Dispose this object.
*/
void DoDispose ();
/**
* \brief The NetDevice.
*/
Ptr<NetDevice> m_device;
/**
* \brief the interface.
*/
Ptr<Ipv6Interface> m_interface;
/**
* \brief A list of Entry.
*/
Cache m_ndCache;
/**
* \brief Max number of packet stored in m_waiting.
*/
uint32_t m_unresQlen;
};
} /* namespace ns3 */