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 MESH_ID_H
22 #define MESH_ID_H
23 
24 #include <stdint.h>
25 #include "ns3/buffer.h"
26 #include "ns3/mesh-information-element-vector.h"
27 
28 namespace ns3 {
29 namespace dot11s {
30 
31 /**
32  * \brief a IEEE 802.11 Mesh ID element (Section 8.4.2.101 of IEEE 802.11-2012)
33  * \see attribute_IeMeshId
34  */
35 class IeMeshId : public WifiInformationElement
36 {
37 public:
38   // broadcast meshId
39   IeMeshId ();
40   /**
41    * Constructor
42    *
43    * \param s reference id
44    */
45   IeMeshId (std::string s);
46 
47   /**
48    * Equality test
49    * \param o another IeMeshId
50    * \returns true if equal
51    */
52   bool IsEqual (IeMeshId const &o) const;
53   /**
54    * Return true if broadcast (if first octet of Mesh ID is zero)
55    * \returns true if broadcast
56    */
57   bool IsBroadcast (void) const;
58   //uint32_t GetLength (void) const;
59   /**
60    * Peek the IeMeshId as a string value
61    * \returns the mesh ID as a string
62    */
63   char *PeekString (void) const;
64 
65   // Inherited from WifiInformationElement
66   virtual WifiInformationElementId ElementId () const;
67   virtual void SerializeInformationField (Buffer::Iterator i) const;
68   virtual uint8_t DeserializeInformationField (Buffer::Iterator start, uint8_t length);
69   virtual void Print (std::ostream& os) const;
70   virtual uint8_t GetInformationFieldSize () const;
71 
72 private:
73   uint8_t m_meshId[33]; ///< mesh ID
74   /**
75    * equality operator
76    *
77    * \param a lhs
78    * \param b lhs
79    * \returns true if equal
80    */
81   friend bool operator== (const IeMeshId & a, const IeMeshId & b);
82 
83 };
84 
85 /**
86  * \brief Stream insertion operator.
87  *
88  * \param [in] os The reference to the output stream.
89  * \param [in] meshId The IeMeshId object.
90  * \returns The reference to the output stream.
91  */
92 std::ostream &operator << (std::ostream &os, const IeMeshId &meshId);
93 
94 
95 } // namespace dot11s
96 } // namespace ns3
97 #endif /* MESH_ID_H */
98