--- /dev/null
+// $Id$
+//
+// Copyright (C) 2009
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Thorsten Horstmann <tho@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// 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.
+
+/** \file
+ \brief InformationElements non-inline non-template implementation */
+
+#include "InformationElements.hh"
+//#include "InformationElements.ih"
+
+// Custom includes
+
+//#include "InformationElements.cc.mpp"
+#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
+SENF_PACKET_TLV_REGISTRY_REGISTER( senf::WLANInfoElementParser, senf::WLANSSIDInfoElementParser);
+SENF_PACKET_TLV_REGISTRY_REGISTER( senf::WLANInfoElementParser, senf::WLANPowerConstraintInfoElementParser);
+SENF_PACKET_TLV_REGISTRY_REGISTER( senf::WLANInfoElementParser, senf::WLANSupportedRatesInfoElementParser);
+
+
+prefix_ void senf::WLANPowerConstraintInfoElementParser::dump(std::ostream & os)
+ const
+{
+ os << " WLAN PowerConstraint Information Element\n"
+ << " type: " << unsigned(type()) << "\n"
+ << " length: " << unsigned(length()) << "\n"
+ << " value: " << unsigned(value()) << "\n";
+}
+
+prefix_ void senf::WLANSSIDInfoElementParser::dump(std::ostream & os)
+ const
+{
+ os << " WLAN SSID Information Element\n"
+ << " type: " << unsigned(type()) << "\n"
+ << " length: " << unsigned(length()) << "\n"
+ << " value: " << value() << "\n";
+}
+
+prefix_ void senf::WLANSupportedRatesInfoElementParser::dump(std::ostream & os)
+ const
+{
+ os << " WLAN SupportedRates Information Element\n"
+ << " type: " << unsigned(type()) << "\n"
+ << " length: " << unsigned(length()) << "\n"
+ << " value: ToDo!\n";
+}
+
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
type() = typeId;
}
static const type_t::value_type typeId = 0x00u;
+
+ void dump(std::ostream & os) const;
};
struct WLANSupportedRatesInfoElementParser
type() = typeId;
}
static const type_t::value_type typeId = 0x01u;
+
+ void dump(std::ostream & os) const;
};
struct WLANPowerConstraintInfoElementParser
length() = 1;
}
static const type_t::value_type typeId = 0x20u;
+
+ void dump(std::ostream & os) const;
};
}
prefix_ void senf::WLANBeaconPacketType::dump(packet p, std::ostream &os)
{
boost::io::ios_all_saver ias(os);
- os << "WLAN Beacon:\n"
- << senf::fieldName("timestamp") << unsigned( p->timestamp()) << "\n";
+ os << "WLAN beacon frame:\n"
+ << senf::fieldName("timestamp") << unsigned( p->timestamp()) << "\n"
+ << senf::fieldName("beaconInterval") << unsigned( p->beaconInterval()) << "\n";
+ p->ssidIE().dump( os);
+ p->supportedRatesIE().dump( os);
+ os << " Optional Information Elements:\n";
+ typedef parser::ieList_t::container ieListContainer_t;
+ ieListContainer_t ieListContainer (p->ieList());
+ for (ieListContainer_t::iterator i = ieListContainer.begin(); i != ieListContainer.end(); ++i)
+ (*i).dump( os);
}
///////////////////////////////cc.e////////////////////////////////////////
static void dump(packet p, std::ostream &os);
};
+ /** \brief WLAN Beacon frame packet typedef
+ \ingroup protocolbundle_80211
+ */
typedef ConcretePacket<WLANBeaconPacketType> WLANBeaconPacket;
}
++i;
BOOST_CHECK_EQUAL( i->type(), 0xdd); //vendor specific
BOOST_CHECK_EQUAL( i->length(), 0x18);
- BOOST_CHECK_EQUAL( boost::size(i->value()), 0x18);
+ BOOST_CHECK_EQUAL( boost::size(i->value()), 0x18);
+
unsigned char value[] = {
0x00, 0x50, 0xf2, 0x02, 0x01, 0x01, 0x88, 0x00,
0x02, 0xa3, 0x00, 0x00, 0x27, 0xa4, 0x00, 0x00,
};
SENF_CHECK_EQUAL_COLLECTIONS( value, value+sizeof(value),
boost::begin(i->value()), boost::end(i->value()) );
+
+ p.dump(std::cout);
}
BOOST_AUTO_UNIT_TEST(WLANBeaconPacket_create)
static void dump(packet p, std::ostream &os);
};
+ /** \brief WLAN Management frame packet typedef
+ \ingroup protocolbundle_80211
+ */
typedef WLANPacket_MgtFrameType::packet WLANPacket_MgtFrame;
///////////////////////////////////////////////////////////////////////////
static void dump(packet p, std::ostream &os);
};
+ /** \brief WLAN Control frame packet typedef
+ \ingroup protocolbundle_80211
+ */
typedef WLANPacket_CtrlFrameType::packet WLANPacket_CtrlFrame;
///////////////////////////////////////////////////////////////////////////
static void dump(packet p, std::ostream &os);
};
+ /** \brief WLAN Data frame packet typedef
+ \ingroup protocolbundle_80211
+ */
typedef WLANPacket_DataFrameType::packet WLANPacket_DataFrame;
}
}
template <class Base>
-prefix_ void senf::GenericTLVParserBase<Base>::dump(std::ostream & os)
- const
-{
- boost::io::ios_all_saver ias(os);
- os << "GenericTLVParser<" << prettyName(typeid(Base)) << ">\n"
- << " type: " << senf::format::dumpint(this->type()) << "\n"
- << " length: " << senf::format::dumpint(this->length()) << "\n"
- << " value:\n";
- hexdump(value().begin(), value().end(), os);
-}
-
-template <class Base>
template <class ForwardReadableRange>
prefix_ void senf::GenericTLVParserBase<Base>::value_(ForwardReadableRange const &range)
{
template <typename Parser>
prefix_ void senf::GenericTLVParserRegistry<BaseParser>::registerParser()
{
- typename Map::iterator i (map_.find( Parser::typeId ));
- if (i == map_.end() ) {
- typename BaseParser::type_t::value_type k (Parser::typeId);
- map_.insert(k , new detail::GenericTLVParserRegistry_Entry<BaseParser, Parser>() );
- }
+ typename BaseParser::type_t::value_type key (Parser::typeId+0);
+ typename Map::iterator i (map_.find( key ));
+ if (i == map_.end() )
+ map_.insert(key, new detail::GenericTLVParserRegistry_Entry<BaseParser, Parser>() );
}
template <class BaseParser>
prefix_ void senf::GenericTLVParserRegistry<BaseParser>::dump(
- std::ostream & os, GenericTLVParserBase<BaseParser> const & parser)
+ GenericTLVParserBase<BaseParser> const & parser, std::ostream & os)
{
typename Map::iterator i (map_.find( parser.type()));
- if (i == map_.end())
- parser.dump(os);
+ if (i == map_.end()) {
+ boost::io::ios_all_saver ias(os);
+ os << " GenericTLVParser<" << prettyName(typeid(BaseParser)) << ">\n"
+ << " type: " << senf::format::dumpint(parser.type()) << "\n"
+ << " length: " << senf::format::dumpint(parser.length()) << "\n"
+ << " value:\n";
+ hexdump(parser.value().begin(), parser.value().end(), os);
+ }
else
- (i->second)->dump(os, parser);
+ (i->second)->dump(parser, os);
}
///////////////////////////////ct.e////////////////////////////////////////
return *static_cast<Base const *>(this);
}
+template <class Base>
+prefix_ void senf::GenericTLVParserBase<Base>::dump(std::ostream & os)
+ const
+{
+ GenericTLVParserRegistry<Base>::instance().dump(*this, os);
+}
+
#ifndef DOXYGEN
template <class Base>
template <class BaseParser, class Parser>
prefix_ void senf::detail::GenericTLVParserRegistry_Entry<BaseParser, Parser>::dump(
- std::ostream & os, GenericTLVParserBase<BaseParser> const & parser)
+ GenericTLVParserBase<BaseParser> const & parser, std::ostream & os)
{
(parser.template as<Parser>()).dump(os);
}
+
+///////////////////////////////////////////////////////////////////////////
+// senf::GenericTLVParserRegistry<BaseParser>::RegistrationProxy<PacketParser>
+
+template <class BaseParser>
+template <class PacketParser>
+prefix_ senf::GenericTLVParserRegistry<BaseParser>::RegistrationProxy<PacketParser>::RegistrationProxy()
+{
+ GenericTLVParserRegistry<BaseParser>::instance().registerParser<PacketParser>();
+};
+
///////////////////////////////cti.e///////////////////////////////////////
#undef prefix_
namespace detail {
template <class BaseParser>
struct GenericTLVParserRegistry_EntryBase {
- virtual void dump(std::ostream & os, GenericTLVParserBase<BaseParser> const & parser) = 0;
+ virtual void dump(GenericTLVParserBase<BaseParser> const & parser, std::ostream & os) = 0;
};
template <class BaseParser, class Parser>
struct GenericTLVParserRegistry_Entry
: GenericTLVParserRegistry_EntryBase<BaseParser>
{
- virtual void dump(std::ostream & os, GenericTLVParserBase<BaseParser> const & parser);
+ virtual void dump(GenericTLVParserBase<BaseParser> const & parser, std::ostream & os);
};
}
using senf::singleton<GenericTLVParserRegistry<BaseParser> >::instance;
friend class senf::singleton<GenericTLVParserRegistry<BaseParser> >;
+ template <class PacketParser>
+ struct RegistrationProxy {
+ RegistrationProxy();
+ };
+
template <typename Parser>
void registerParser();
- void dump(std::ostream & os, GenericTLVParserBase<BaseParser> const & parser);
+ void dump(GenericTLVParserBase<BaseParser> const & parser, std::ostream & os);
};
+
+# define SENF_PACKET_TLV_REGISTRY_REGISTER( BaseTLVParser, ConreteTLVParser ) \
+ namespace { \
+ senf::GenericTLVParserRegistry<BaseTLVParser> \
+ ::RegistrationProxy<ConreteTLVParser> \
+ BOOST_PP_CAT(tlvparserRegistration_, __LINE__); \
+ }
+
}
-
///////////////////////////////hh.e////////////////////////////////////////
//#include "GenericTLV.cci"
#include "GenericTLV.ct"
// $Id$
//
-// Copyright (C) 2008
+// Copyright (C) 2009
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
-// @AUTHOR@
+// Thorsten Horstmann <tho@berlios.de>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// Custom includes
#include "GenericTLV.hh"
-#include <senf/Utils/hexdump.hh>
#include <senf/Utils/auto_unit_test.hh>
#include <boost/test/test_tools.hpp>
type() = typeId;
length_() = 4;
}
- static type_t::value_type const typeId;
+ static type_t::value_type const typeId = 0x42;
void dump(std::ostream & os) const {
boost::io::ios_all_saver ias(os);
- os << "MyConcreteTLVParser\n"
- << " type: " << senf::format::dumpint(type()) << "\n"
- << " length: " << senf::format::dumpint(length()) << "\n"
- << " value: " << senf::format::dumpint(myValue()) << "\n";
+ os << " MyConcreteTLVParser\n"
+ << " type: " << senf::format::dumpint(type()) << "\n"
+ << " length: " << senf::format::dumpint(length()) << "\n"
+ << " value: " << senf::format::dumpint(myValue()) << "\n";
}
};
- MyConcreteTLVParser::type_t::value_type const MyConcreteTLVParser::typeId = 0x42;
class MyTestPacketParser
: public senf::PacketParserBase
conreteTLVParser.myValue() << 0xffff;
p.finalizeThis();
- typedef senf::GenericTLVParserRegistry<MyTLVParserBase> MyTLVParserRegistry;
-
std::stringstream ss;
- MyTLVParserRegistry::instance().dump(ss, *tlvContainer.begin());
- BOOST_CHECK_EQUAL( ss.str().substr(0,56), "GenericTLVParser<(anonymous namespace)::MyTLVParserBase>" );
+ (*tlvContainer.begin()).dump( ss);
+ BOOST_CHECK_EQUAL( ss.str().substr(0,58),
+ " GenericTLVParser<(anonymous namespace)::MyTLVParserBase>" );
- MyTLVParserRegistry::instance().registerParser<MyConcreteTLVParser>();
+ senf::GenericTLVParserRegistry<MyTLVParserBase>::instance()
+ .registerParser<MyConcreteTLVParser>();
ss.str(""); ss.clear();
- MyTLVParserRegistry::instance().dump(ss, *tlvContainer.begin());
- BOOST_CHECK_EQUAL( ss.str().substr(0,19), "MyConcreteTLVParser" );
+ (*tlvContainer.begin()).dump( ss);
+ BOOST_CHECK_EQUAL( ss.str().substr(0,21), " MyConcreteTLVParser" );
}