Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1570)

Unified Diff: src/devices/mesh/dot11s/ie-dot11s-id.cc

Issue 88094: 802.11s mesh stack model (Closed)
Patch Set: Review finished by Mathieu, ready to merge Created 14 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/devices/mesh/dot11s/ie-dot11s-id.h ('k') | src/devices/mesh/dot11s/ie-dot11s-metric-report.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/devices/mesh/dot11s/ie-dot11s-id.cc
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/devices/mesh/dot11s/ie-dot11s-id.cc
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Kirill Andreev <andreev@iitp.ru>
+ */
+
+#include "ie-dot11s-id.h"
+#include "ns3/assert.h"
+
+namespace ns3 {
+namespace dot11s {
+IeMeshId::IeMeshId ()
+{
+ for (uint8_t i = 0; i < 32; i++)
+ {
+ m_meshId[i] = 0;
+ }
+}
+IeMeshId::IeMeshId (std::string s)
+{
+ NS_ASSERT (s.size () < 32);
+ const char *meshid = s.c_str ();
+ uint8_t len = 0;
+ while (*meshid != 0 && len < 32)
+ {
+ m_meshId[len] = *meshid;
+ meshid++;
+ len++;
+ }
+ NS_ASSERT (len <= 32);
+ while (len < 33)
+ {
+ m_meshId[len] = 0;
+ len++;
+ }
+}
+WifiElementId
+IeMeshId::ElementId () const
+{
+ return IE11S_MESH_ID;
+}
+bool
+IeMeshId::IsEqual (IeMeshId const &o) const
+{
+ uint8_t i = 0;
+ while (i < 32 && m_meshId[i] == o.m_meshId[i] && m_meshId[i] != 0)
+ {
+ i++;
+ }
+ if (m_meshId[i] != o.m_meshId[i])
+ {
+ return false;
+ }
+ return true;
+}
+bool
+IeMeshId::IsBroadcast (void) const
+{
+ if (m_meshId[0] == 0)
+ {
+ return true;
+ }
+ return false;
+}
+char *
+IeMeshId::PeekString (void) const
+{
+ return (char *) m_meshId;
+}
+uint8_t
+IeMeshId::GetInformationSize (void) const
+{
+ uint8_t size = 0;
+ while (m_meshId[size] != 0 && size < 32)
+ {
+ size++;
+ }
+ NS_ASSERT (size <= 32);
+ return size;
+}
+void
+IeMeshId::SerializeInformation (Buffer::Iterator i) const
+{
+ uint8_t size = 0;
+ while (m_meshId[size] != 0 && size < 32)
+ {
+ i.WriteU8 (m_meshId[size]);
+ size++;
+ }
+}
+uint8_t
+IeMeshId::DeserializeInformation (Buffer::Iterator start, uint8_t length)
+{
+ Buffer::Iterator i = start;
+ NS_ASSERT (length <= 32);
+ i.Read (m_meshId, length);
+ m_meshId[length] = 0;
+ return i.GetDistanceFrom (start);
+}
+void
+IeMeshId::Print (std::ostream& os) const
+{
+ os << std::endl << "<information_element id=" << ElementId () << ">" << std::endl;
+ os << "meshId = " << PeekString ();
+ os << "</information_element>" << std::endl;
+}
+bool
+operator== (const IeMeshId & a, const IeMeshId & b)
+{
+ bool result (true);
+ uint8_t size = 0;
+
+ while (size < 32)
+ {
+ result = result && (a.m_meshId[size] == b.m_meshId[size]);
+ if (a.m_meshId[size] == 0)
+ {
+ return result;
+ }
+ size++;
+ }
+ return result;
+}
+std::ostream &
+operator << (std::ostream &os, const IeMeshId &a)
+{
+ a.Print (os);
+ return os;
+}
+} //namespace dot11s
+} // namespace ns3
« no previous file with comments | « src/devices/mesh/dot11s/ie-dot11s-id.h ('k') | src/devices/mesh/dot11s/ie-dot11s-metric-report.h » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b