OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2008,2009 IITP RAS |
| 4 * |
| 5 * This program is free software; you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 2 as |
| 7 * published by the Free Software Foundation; |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software |
| 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 * |
| 18 * Author: Kirill Andreev <andreev@iitp.ru> |
| 19 */ |
| 20 |
| 21 #ifndef WIFI_PREQ_INFORMATION_ELEMENT_H |
| 22 #define WIFI_PREQ_INFORMATION_ELEMENT_H |
| 23 |
| 24 #include <vector> |
| 25 |
| 26 #include "ns3/mac48-address.h" |
| 27 #include "ns3/wifi-information-element-vector.h" |
| 28 |
| 29 namespace ns3 { |
| 30 namespace dot11s { |
| 31 /** |
| 32 * \ingroup dot11s |
| 33 * \brief Describes an address unit in PREQ information element |
| 34 * See 7.3.2.96 for more details |
| 35 */ |
| 36 class DestinationAddressUnit : public RefCountBase |
| 37 { |
| 38 public: |
| 39 DestinationAddressUnit (); |
| 40 void SetFlags (bool doFlag, bool rfFlag, bool usnFlag); |
| 41 void SetDestinationAddress (Mac48Address dest_address); |
| 42 void SetDestSeqNumber (uint32_t dest_seq_number); |
| 43 bool IsDo (); |
| 44 bool IsRf (); |
| 45 bool IsUsn (); |
| 46 Mac48Address GetDestinationAddress () const; |
| 47 uint32_t GetDestSeqNumber () const; |
| 48 private: |
| 49 bool m_do; |
| 50 bool m_rf; |
| 51 bool m_usn; |
| 52 Mac48Address m_destinationAddress; |
| 53 uint32_t m_destSeqNumber; |
| 54 |
| 55 friend bool operator== (const DestinationAddressUnit & a, const DestinationAdd
ressUnit & b); |
| 56 }; |
| 57 /** |
| 58 * \ingroup dot11s |
| 59 * \brief See 7.3.2.96 of 802.11s draft 2.07 |
| 60 */ |
| 61 class IePreq : public WifiInformationElement |
| 62 { |
| 63 public: |
| 64 IePreq (); |
| 65 ~IePreq (); |
| 66 /** |
| 67 * Add a destination address unit: flags, destination and sequence |
| 68 * number |
| 69 */ |
| 70 void AddDestinationAddressElement ( |
| 71 bool doFlag, |
| 72 bool rfFlag, |
| 73 Mac48Address dest_address, |
| 74 uint32_t dest_seq_number |
| 75 ); |
| 76 /// Delete a destination address unit by destination |
| 77 void DelDestinationAddressElement (Mac48Address dest_address); |
| 78 /// Clear PREQ: remove all destinations |
| 79 void ClearDestinationAddressElements (); |
| 80 /// Get all destinations, which are stored in PREQ: |
| 81 std::vector<Ptr<DestinationAddressUnit> > GetDestinationList (); |
| 82 /// SetProper flags which indicate that PREQ is unicast |
| 83 void SetUnicastPreq (); |
| 84 /* |
| 85 * \brief In proactive case: need we send PREP |
| 86 */ |
| 87 void SetNeedNotPrep (); |
| 88 ///\name Setters for fields: |
| 89 ///\{ |
| 90 void SetHopcount (uint8_t hopcount); |
| 91 void SetTTL (uint8_t ttl); |
| 92 void SetPreqID (uint32_t id); |
| 93 void SetOriginatorAddress (Mac48Address originator_address); |
| 94 void SetOriginatorSeqNumber (uint32_t originator_seq_number); |
| 95 void SetLifetime (uint32_t lifetime); |
| 96 void SetMetric (uint32_t metric); |
| 97 void SetDestCount (uint8_t dest_count); |
| 98 ///\} |
| 99 ///\name Getters for fields: |
| 100 ///\{ |
| 101 bool IsUnicastPreq () const; |
| 102 bool IsNeedNotPrep () const; |
| 103 uint8_t GetHopCount () const; |
| 104 uint8_t GetTtl ()const ; |
| 105 uint32_t GetPreqID () const; |
| 106 Mac48Address GetOriginatorAddress () const; |
| 107 uint32_t GetOriginatorSeqNumber () const; |
| 108 uint32_t GetLifetime () const; |
| 109 uint32_t GetMetric () const; |
| 110 uint8_t GetDestCount () const; |
| 111 ///\} |
| 112 /// Handle TTL and Metric: |
| 113 void DecrementTtl (); |
| 114 void IncrementMetric (uint32_t metric); |
| 115 /* |
| 116 * \brief Checks that preq's originator address equals to originator, and |
| 117 * this preq is not proactive |
| 118 */ |
| 119 bool MayAddAddress (Mac48Address originator); |
| 120 bool IsFull () const; |
| 121 /** |
| 122 * \name Inherited from WifiInformationElement |
| 123 * \{ |
| 124 */ |
| 125 virtual WifiElementId ElementId () const; |
| 126 virtual void SerializeInformation (Buffer::Iterator i) const; |
| 127 virtual uint8_t DeserializeInformation (Buffer::Iterator i, uint8_t length); |
| 128 virtual uint8_t GetInformationSize () const; |
| 129 virtual void Print (std::ostream& os) const; |
| 130 ///\} |
| 131 private: |
| 132 /** |
| 133 * how many destinations we support |
| 134 */ |
| 135 uint8_t m_maxSize; //TODO: make as an attrubute |
| 136 /** |
| 137 * Fields of information element: |
| 138 */ |
| 139 uint8_t m_flags; |
| 140 uint8_t m_hopCount; |
| 141 uint8_t m_ttl; |
| 142 uint32_t m_preqId; |
| 143 Mac48Address m_originatorAddress; |
| 144 uint32_t m_originatorSeqNumber; |
| 145 uint32_t m_lifetime; |
| 146 uint32_t m_metric; |
| 147 uint8_t m_destCount; |
| 148 std::vector<Ptr<DestinationAddressUnit> > m_destinations; |
| 149 |
| 150 friend bool operator== (const IePreq & a, const IePreq & b); |
| 151 }; |
| 152 |
| 153 bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit
& b); |
| 154 bool operator== (const IePreq & a, const IePreq & b); |
| 155 std::ostream &operator << (std::ostream &os, const IePreq &preq); |
| 156 |
| 157 } // namespace dot11s |
| 158 } //namespace ns3 |
| 159 #endif |
| 160 |
OLD | NEW |