replace RefCountBase with SimpleRefCount<> to avoid duplicate refcounting implementations.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2008,2009 IITP RAS
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;
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.
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
18 * Author: Kirill Andreev <andreev@iitp.ru>
21 #ifndef WIFI_PREQ_INFORMATION_ELEMENT_H
22 #define WIFI_PREQ_INFORMATION_ELEMENT_H
26 #include "ns3/mac48-address.h"
27 #include "ns3/wifi-information-element-vector.h"
33 * \brief Describes an address unit in PREQ information element
34 * See 7.3.2.96 for more details
36 class DestinationAddressUnit : public SimpleRefCount<DestinationAddressUnit>
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);
46 Mac48Address GetDestinationAddress () const;
47 uint32_t GetDestSeqNumber () const;
52 Mac48Address m_destinationAddress;
53 uint32_t m_destSeqNumber;
55 friend bool operator== (const DestinationAddressUnit & a, const DestinationAddressUnit & b);
59 * \brief See 7.3.2.96 of 802.11s draft 2.07
61 class IePreq : public WifiInformationElement
67 * Add a destination address unit: flags, destination and sequence
70 void AddDestinationAddressElement (
73 Mac48Address dest_address,
74 uint32_t dest_seq_number
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 ();
85 * \brief In proactive case: need we send PREP
87 void SetNeedNotPrep ();
88 ///\name Setters for fields:
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);
99 ///\name Getters for fields:
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;
112 /// Handle TTL and Metric:
113 void DecrementTtl ();
114 void IncrementMetric (uint32_t metric);
116 * \brief Checks that preq's originator address equals to originator, and
117 * this preq is not proactive
119 bool MayAddAddress (Mac48Address originator);
120 bool IsFull () const;
122 * \name Inherited from WifiInformationElement
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;
133 * how many destinations we support
135 uint8_t m_maxSize; //TODO: make as an attrubute
137 * Fields of information element:
143 Mac48Address m_originatorAddress;
144 uint32_t m_originatorSeqNumber;
148 std::vector<Ptr<DestinationAddressUnit> > m_destinations;
150 friend bool operator== (const IePreq & a, const IePreq & b);
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);
157 } // namespace dot11s