diff -r 87eb2f77f661 -r 64084ae6cff1 src/devices/mesh/ie-vector.cc --- a/src/devices/mesh/ie-vector.cc Fri Jul 31 14:13:10 2009 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,212 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 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: Pavel Boyko - */ - -#include "ie-vector.h" -#include "ns3/test.h" -#include "ns3/packet.h" -// All information elements: -#include "dot11s/ie-dot11s-beacon-timing.h" -#include "dot11s/ie-dot11s-configuration.h" -#include "dot11s/ie-dot11s-id.h" -#include "dot11s/ie-dot11s-metric-report.h" -#include "dot11s/ie-dot11s-peer-management.h" -#include "dot11s/ie-dot11s-peering-protocol.h" -#include "dot11s/ie-dot11s-perr.h" -#include "dot11s/ie-dot11s-prep.h" -#include "dot11s/ie-dot11s-preq.h" -#include "dot11s/ie-dot11s-rann.h" - -namespace ns3 { -WifiInformationElementVector::WifiInformationElementVector () : - m_maxSize (1500) -{ -} -WifiInformationElementVector::~WifiInformationElementVector () -{ -} -void -WifiInformationElementVector::SetMaxSize (uint16_t size) -{ - m_maxSize = size; -} -WifiInformationElementVector::Iterator -WifiInformationElementVector::Begin () -{ - return m_elements.begin (); -} -WifiInformationElementVector::Iterator -WifiInformationElementVector::End () -{ - return m_elements.end (); -} -bool -WifiInformationElementVector::AddInformationElement (Ptr element) -{ - if (element->GetSerializedSize () + GetSize () > m_maxSize) - { - return false; - } - m_elements.push_back (element); - return true; -} -Ptr -WifiInformationElementVector::FindFirst (enum WifiElementId id) const -{ - for (IE_VECTOR::const_iterator i = m_elements.begin (); i != m_elements.end (); i++) - { - if ((*i)->ElementId () == id) - { - return (*i); - } - } - return 0; -} -WifiInformationElementVector -WifiInformationElementVector::DeserializePacket (Ptr packet) -{ - WifiInformationElementVector retval; - EmptyIe ie; - while (packet->PeekHeader (ie)) - { - Ptr newElement; - switch (ie.GetElementId ()) - { - case IE11S_MESH_CONFIGURATION: - newElement = Create (); - break; - case IE11S_MESH_ID: - newElement = Create (); - break; - case IE11S_LINK_METRIC_REPORT: - newElement = Create (); - break; - case IE11S_PEERING_MANAGEMENT: - newElement = Create (); - break; - case IE11S_BEACON_TIMING: - newElement = Create (); - break; - case IE11S_RANN: - newElement = Create (); - break; - case IE11S_PREQ: - newElement = Create (); - break; - case IE11S_PREP: - newElement = Create (); - break; - case IE11S_PERR: - newElement = Create (); - break; - case IE11S_MESH_PEERING_PROTOCOL_VERSION: - newElement = Create (); - break; - default: - NS_FATAL_ERROR ("Information element " << (uint16_t) ie.GetElementId () << " is not implemented"); - } - packet->RemoveHeader (*newElement); - if (!retval.AddInformationElement (newElement)) - { - NS_FATAL_ERROR ("Check max size for information element!"); - } - if (packet->GetSize () == 0) - { - return retval; - } - } - return retval; -} -Ptr -WifiInformationElementVector::MakePacket (bool sortByElementId) -{ - if (sortByElementId) - { - //TODO: sort - } - Ptr packet = Create (); - for (IE_VECTOR::const_iterator i = m_elements.begin (); i != m_elements.end (); i++) - { - packet->AddHeader (**i); - } - return packet; -} -uint32_t -WifiInformationElementVector::GetSize () const -{ - uint32_t size = 0; - for (IE_VECTOR::const_iterator i = m_elements.begin (); i != m_elements.end (); i++) - { - size += (*i)->GetSerializedSize (); - } - return size; -} -WifiInformationElementVector::EmptyIe::~EmptyIe () -{ -} -WifiInformationElementVector::EmptyIe::EmptyIe () : - m_elementId (0), m_length (0) -{ -} -TypeId -WifiInformationElementVector::EmptyIe::GetTypeId () -{ - static TypeId tid = TypeId ("ns3::WifiInformationElementVector::EmptyIe") - .SetParent
(); - return tid; -} -TypeId -WifiInformationElementVector::EmptyIe::GetInstanceTypeId () const -{ - return GetTypeId (); -} -uint8_t -WifiInformationElementVector::EmptyIe::GetLength () -{ - return m_length; -} -uint8_t -WifiInformationElementVector::EmptyIe::GetElementId () -{ - return m_elementId; -} -uint32_t -WifiInformationElementVector::EmptyIe::GetSerializedSize () const -{ - return 2; -} -void -WifiInformationElementVector::EmptyIe::Serialize (Buffer::Iterator start) const -{ - start.WriteU8 (m_elementId); - start.WriteU8 (m_length); -} -uint32_t -WifiInformationElementVector::EmptyIe::Deserialize (Buffer::Iterator start) -{ - Buffer::Iterator i = start; - m_elementId = i.ReadU8 (); - m_length = i.ReadU8 (); - return i.GetDistanceFrom (start); -} -void -WifiInformationElementVector::EmptyIe::Print (std::ostream &os) const -{ -} -}