From e418326f6ac10ffe0fc2cf6ccbb4c349cdeff2c7 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Fri, 5 Jun 2009 16:06:25 +0400 Subject: [PATCH] Mesh id cosmetic fixes --- src/devices/mesh/dot11s/dot11s-helper.cc | 2 +- src/devices/mesh/dot11s/ie-dot11s-id.cc | 15 +++++++++------ src/devices/mesh/dot11s/ie-dot11s-id.h | 3 +-- src/devices/mesh/dot11s/peer-link-frame.cc | 6 +++--- .../mesh/dot11s/peer-management-protocol.cc | 4 ++-- .../mesh/dot11s/peer-management-protocol.h | 2 +- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/devices/mesh/dot11s/dot11s-helper.cc b/src/devices/mesh/dot11s/dot11s-helper.cc index 417518cdf..1a63574b7 100644 --- a/src/devices/mesh/dot11s/dot11s-helper.cc +++ b/src/devices/mesh/dot11s/dot11s-helper.cc @@ -117,7 +117,7 @@ MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c, std:: // Install 802.11s protocols Ptr pmp = CreateObject (); - pmp->SetMeshId("mesh",4); + pmp->SetMeshId("mesh"); bool install_ok = pmp->Install (mp); NS_ASSERT (install_ok); diff --git a/src/devices/mesh/dot11s/ie-dot11s-id.cc b/src/devices/mesh/dot11s/ie-dot11s-id.cc index c98eb2448..54f52ed18 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-id.cc +++ b/src/devices/mesh/dot11s/ie-dot11s-id.cc @@ -30,16 +30,19 @@ IeMeshId::IeMeshId () m_meshId[i] = 0; } } -IeMeshId::IeMeshId (char const meshId[32], uint8_t length) +IeMeshId::IeMeshId (std::string s) { - NS_ASSERT (length <= 32); + NS_ASSERT (s.size () < 32); + const char *meshid = s.c_str (); uint8_t len = 0; - while (len < length) + while (*meshid != 0 && len < 32) { - m_meshId[len] = meshId[len]; + m_meshId[len] = *meshid; + meshid++; len++; } - while (len < 32) + NS_ASSERT (len <= 32); + while (len < 33) { m_meshId[len] = 0; len++; @@ -148,7 +151,7 @@ bool IeMeshIdBist::RunTests () bool result(true); // create test information element - IeMeshId a("qwerty",6); + IeMeshId a("qwerty"); result = result && TestRoundtripSerialization (a); return result; } diff --git a/src/devices/mesh/dot11s/ie-dot11s-id.h b/src/devices/mesh/dot11s/ie-dot11s-id.h index 0be00e2de..042f27d01 100644 --- a/src/devices/mesh/dot11s/ie-dot11s-id.h +++ b/src/devices/mesh/dot11s/ie-dot11s-id.h @@ -36,8 +36,7 @@ class IeMeshId : public WifiInformationElement public: // broadcast meshId IeMeshId (); - //IeMeshId (char const meshId[32]); - IeMeshId (char const meshId[32], uint8_t length); + IeMeshId (std::string s); bool IsEqual (IeMeshId const &o) const; bool IsBroadcast (void) const; diff --git a/src/devices/mesh/dot11s/peer-link-frame.cc b/src/devices/mesh/dot11s/peer-link-frame.cc index 5cfa7034b..faf91e95e 100644 --- a/src/devices/mesh/dot11s/peer-link-frame.cc +++ b/src/devices/mesh/dot11s/peer-link-frame.cc @@ -204,7 +204,7 @@ bool PeerLinkFrameStartBist::RunTests () fields.capability = 0; fields.aid = 101; fields.reasonCode = 12; - fields.meshId = IeMeshId("qwertyuiop", 10); + fields.meshId = IeMeshId("qwertyuiop"); a.SetPlinkFrameStart(fields); Ptr packet = Create (); packet->AddHeader (a); @@ -220,7 +220,7 @@ bool PeerLinkFrameStartBist::RunTests () fields.capability = 0; fields.aid = 1234; fields.reasonCode = 12; - fields.meshId = IeMeshId("qwerty", 6); + fields.meshId = IeMeshId("qwerty"); a.SetPlinkFrameStart(fields); Ptr packet = Create (); packet->AddHeader (a); @@ -235,7 +235,7 @@ bool PeerLinkFrameStartBist::RunTests () fields.subtype = (uint8_t)(WifiMeshActionHeader::PEER_LINK_CLOSE); fields.capability = 0; fields.aid = 10; - fields.meshId = IeMeshId("qqq", 3); + fields.meshId = IeMeshId("qqq"); fields.reasonCode = 12; a.SetPlinkFrameStart(fields); Ptr packet = Create (); diff --git a/src/devices/mesh/dot11s/peer-management-protocol.cc b/src/devices/mesh/dot11s/peer-management-protocol.cc index 316d6adf7..104bb4971 100644 --- a/src/devices/mesh/dot11s/peer-management-protocol.cc +++ b/src/devices/mesh/dot11s/peer-management-protocol.cc @@ -479,9 +479,9 @@ PeerManagementProtocol::GetMeshId () const return m_meshId; } void -PeerManagementProtocol::SetMeshId(char const meshId[32], uint8_t length) +PeerManagementProtocol::SetMeshId(std::string s) { - m_meshId = Create (meshId, length); + m_meshId = Create (s); } Mac48Address PeerManagementProtocol::GetAddress () diff --git a/src/devices/mesh/dot11s/peer-management-protocol.h b/src/devices/mesh/dot11s/peer-management-protocol.h index e520ee842..c250b20da 100644 --- a/src/devices/mesh/dot11s/peer-management-protocol.h +++ b/src/devices/mesh/dot11s/peer-management-protocol.h @@ -137,7 +137,7 @@ public: Mac48Address GetAddress (); ///\Needed to fill mesh configuration uint8_t GetNumberOfLinks (); - void SetMeshId (char const meshId[32], uint8_t length); + void SetMeshId (std::string s); Ptr GetMeshId() const; ///\brief: Report statistics void Report (std::ostream &) const;