21 #include "ie-dot11s-preq.h" 
   22 #include "ns3/address-utils.h" 
   23 #include "ns3/assert.h" 
   24 #include "ns3/packet.h" 
   31 DestinationAddressUnit::DestinationAddressUnit () :
 
   32   m_do (false), m_rf (false), m_usn (false), m_destinationAddress (Mac48Address ()), m_destSeqNumber (0)
 
   36 DestinationAddressUnit::SetFlags (
bool doFlag, 
bool rfFlag, 
bool usnFlag)
 
   44 DestinationAddressUnit::SetDestSeqNumber (uint32_t dest_seq_number)
 
   46   m_destSeqNumber = dest_seq_number;
 
   47   if (m_destSeqNumber != 0)
 
   53 DestinationAddressUnit::SetDestinationAddress (Mac48Address dest_address)
 
   55   m_destinationAddress = dest_address;
 
   58 DestinationAddressUnit::IsDo ()
 
   64 DestinationAddressUnit::IsRf ()
 
   69 DestinationAddressUnit::IsUsn ()
 
   74 DestinationAddressUnit::GetDestSeqNumber ()
 const 
   76   return m_destSeqNumber;
 
   79 DestinationAddressUnit::GetDestinationAddress ()
 const 
   81   return m_destinationAddress;
 
   90   m_maxSize (32), m_flags (0), m_hopCount (0), m_ttl (0), m_preqId (0), m_originatorAddress (
 
   91     Mac48Address::GetBroadcast ()), m_originatorSeqNumber (0), m_lifetime (0), m_metric (0),
 
  107 IePreq::SetNeedNotPrep ()
 
  112 IePreq::SetHopcount (uint8_t hopcount)
 
  114   m_hopCount = hopcount;
 
  117 IePreq::SetTTL (uint8_t ttl)
 
  122 IePreq::SetPreqID (uint32_t preq_id)
 
  127 IePreq::SetMetric (uint32_t metric)
 
  132 IePreq::SetOriginatorAddress (Mac48Address originator_address)
 
  134   m_originatorAddress = originator_address;
 
  137 IePreq::SetOriginatorSeqNumber (uint32_t originator_seq_number)
 
  139   m_originatorSeqNumber = originator_seq_number;
 
  142 IePreq::SetLifetime (uint32_t lifetime)
 
  144   m_lifetime = lifetime;
 
  147 IePreq::SetDestCount (uint8_t dest_count)
 
  149   m_destCount = dest_count;
 
  152 IePreq::IsUnicastPreq ()
 const 
  157 IePreq::IsNeedNotPrep ()
 const 
  162 IePreq::GetHopCount ()
 const 
  167 IePreq::GetTtl ()
 const 
  172 IePreq::GetPreqID ()
 const 
  177 IePreq::GetMetric ()
 const 
  182 IePreq::GetOriginatorAddress ()
 const 
  184   return m_originatorAddress;
 
  187 IePreq::GetOriginatorSeqNumber ()
 const 
  189   return m_originatorSeqNumber;
 
  192 IePreq::GetLifetime ()
 const 
  198 IePreq::GetDestCount ()
 const 
  209 IePreq::IncrementMetric (uint32_t metric)
 
  220   WriteTo (i, m_originatorAddress);
 
  227        != m_destinations.end (); j++)
 
  243       WriteTo (i, (*j)->GetDestinationAddress ());
 
  260   ReadFrom (i, m_originatorAddress);
 
  264   m_destCount = i.
ReadU8 ();
 
  265   for (
int j = 0; j < m_destCount; j++)
 
  270       bool usnFlag = 
false;
 
  271       uint8_t flags = i.
ReadU8 ();
 
  272       if (flags & (1 << 0))
 
  276       if (flags & (1 << 1))
 
  280       if (flags & (1 << 2))
 
  284       new_element->SetFlags (doFlag, rfFlag, usnFlag);
 
  287       new_element->SetDestinationAddress (addr);
 
  289       m_destinations.push_back (new_element);
 
  312       retval += (m_destCount * 11);
 
  319   os << std::endl << 
"<information_element id=" << 
ElementId () << 
">" << std::endl;
 
  320   os << 
" originator address  = " << m_originatorAddress << std::endl;
 
  321   os << 
" TTL                 = " << (uint16_t) m_ttl << std::endl;
 
  322   os << 
" hop count           = " << (uint16_t) m_hopCount << std::endl;
 
  323   os << 
" metric              = " << m_metric << std::endl;
 
  324   os << 
" seqno               = " << m_originatorSeqNumber << std::endl;
 
  325   os << 
" lifetime            = " << m_lifetime << std::endl;
 
  326   os << 
" preq ID             = " << m_preqId << std::endl;
 
  327   os << 
" Destinations are:" << std::endl;
 
  328   for (
int j = 0; j < m_destCount; j++)
 
  330       os << 
"    " << m_destinations[j]->GetDestinationAddress () << std::endl;
 
  332   os << 
"</information_element>" << std::endl;
 
  334 std::vector<Ptr<DestinationAddressUnit> >
 
  337   return m_destinations;
 
  341                                       uint32_t dest_seq_number)
 
  344        != m_destinations.end (); i++)
 
  346       if ((*i)->GetDestinationAddress () == dest_address)
 
  353   new_element->SetFlags (doFlag, rfFlag, (dest_seq_number == 0));
 
  354   new_element->SetDestinationAddress (dest_address);
 
  355   new_element->SetDestSeqNumber (dest_seq_number);
 
  356   m_destinations.push_back (new_element);
 
  363        != m_destinations.end (); i++)
 
  365       if ((*i)->GetDestinationAddress () == dest_address)
 
  367           m_destinations.erase (i);
 
  377        != m_destinations.end (); j++)
 
  381   m_destinations.clear ();
 
  387   return (a.m_do == b.m_do && a.m_rf == b.m_rf && a.m_usn == b.m_usn && a.m_destinationAddress
 
  388           == b.m_destinationAddress && a.m_destSeqNumber == b.m_destSeqNumber);
 
  393   bool ok = (a.
m_flags == b.
m_flags && a.m_hopCount == b.m_hopCount && a.m_ttl == b.m_ttl && a.m_preqId
 
  394              == b.m_preqId && a.m_originatorAddress == b.m_originatorAddress && a.m_originatorSeqNumber
 
  395              == b.m_originatorSeqNumber && a.m_lifetime == b.m_lifetime && a.m_metric == b.m_metric && a.m_destCount
 
  402   if (a.m_destinations.size () != b.m_destinations.size ())
 
  406   for (
size_t i = 0; i < a.m_destinations.size (); ++i)
 
  408       if (!(*(PeekPointer (a.m_destinations[i])) == *(PeekPointer (b.m_destinations[i]))))
 
  416 IePreq::MayAddAddress (Mac48Address originator)
 
  418   if (m_originatorAddress != originator)
 
  433 IePreq::IsFull ()
 const 
smart pointer class similar to boost::intrusive_ptr 
#define NS_ASSERT(condition)
uint32_t GetDistanceFrom(Iterator const &o) const 
iterator in a Buffer instance 
virtual void Print(std::ostream &os) const 
In addition, a subclass may optionally override the following... 
virtual WifiInformationElementId ElementId() const 
Own unique Element ID. 
See 7.3.2.96 of 802.11s draft 2.07. 
void ClearDestinationAddressElements()
Clear PREQ: remove all destinations. 
static Mac48Address GetBroadcast(void)
virtual uint8_t DeserializeInformationField(Buffer::Iterator i, uint8_t length)
std::ostream & operator<<(std::ostream &os, const Angles &a)
void AddDestinationAddressElement(bool doFlag, bool rfFlag, Mac48Address dest_address, uint32_t dest_seq_number)
void DelDestinationAddressElement(Mac48Address dest_address)
Delete a destination address unit by destination. 
virtual void SerializeInformationField(Buffer::Iterator i) const 
std::vector< Ptr< DestinationAddressUnit > > GetDestinationList()
Get all destinations, which are stored in PREQ: 
void SetUnicastPreq()
SetProper flags which indicate that PREQ is unicast. 
void WriteU8(uint8_t data)
virtual uint8_t GetInformationFieldSize() const 
uint8_t WifiInformationElementId
Describes an address unit in PREQ information element See 7.3.2.96 for more details. 
uint32_t ReadLsbtohU32(void)
void WriteHtolsbU32(uint32_t data)