diff --git a/src/devices/wifi/mac-stations.cc b/src/devices/wifi/mac-stations.cc new file mode 100644 index 000000000..6c321aa7c --- /dev/null +++ b/src/devices/wifi/mac-stations.cc @@ -0,0 +1,54 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2005,2006 INRIA + * All rights reserved. + * + * 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: Mathieu Lacage + */ + +#include "mac-stations.h" +#include "mac-station.h" + +namespace ns3 { + +MacStations::MacStations () +{} + +MacStations::~MacStations () +{ + for (StationsI i = m_stations.begin (); i != m_stations.end (); i++) + { + delete (*i).second; + } + m_stations.erase (m_stations.begin (), m_stations.end ()); +} + +MacStation * +MacStations::Lookup (Mac48Address address) +{ + for (StationsI i = m_stations.begin (); i != m_stations.end (); i++) + { + if ((*i).first == address) + { + return (*i).second; + } + } + MacStation *station = CreateStation (); + m_stations.push_back (std::make_pair (address, station)); + return station; +} + +}; // namespace ns3 diff --git a/src/devices/wifi/mac-stations.h b/src/devices/wifi/mac-stations.h new file mode 100644 index 000000000..c95034e50 --- /dev/null +++ b/src/devices/wifi/mac-stations.h @@ -0,0 +1,48 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2005,2006 INRIA + * All rights reserved. + * + * 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: Mathieu Lacage + */ +#ifndef MAC_STATIONS_H +#define MAC_STATIONS_H + +#include +#include +#include "ns3/mac48-address.h" + +namespace ns3 { + +class MacStation; + +class MacStations { +public: + MacStations (); + virtual ~MacStations (); + + MacStation *Lookup (Mac48Address address); +private: + typedef std::list > Stations; + typedef std::list >::iterator StationsI; + virtual class MacStation *CreateStation (void) = 0; + Stations m_stations; +}; + +}; // namespace ns3 + + +#endif /* MAC_STATIONS_H */