--- /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 WLAN Information Elements public header */
+
+#ifndef HH_SENF_Packets_80211Bundle_InformationElements_
+#define HH_SENF_Packets_80211Bundle_InformationElements_ 1
+
+// Custom includes
+#include <senf/Packets/Packets.hh>
+
+//#include "InformationElements.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+
+ class WLANInfoElementParser : public PacketParserBase
+ {
+ public:
+# include SENF_PARSER()
+ SENF_PARSER_FIELD ( type, UInt8Parser );
+ SENF_PARSER_FIELD ( length, UInt8Parser );
+ SENF_PARSER_FINALIZE ( WLANInfoElementParser );
+ };
+
+ typedef GenericTLVParserBase<WLANInfoElementParser> WLANGenericInfoElementParser;
+
+}
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "InformationElements.cci"
+//#include "InformationElements.ct"
+//#include "InformationElements.cti"
+#endif
+
+\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:
-// $Id: WLANPacket.cc 1449 2009-09-25 23:03:48Z g0dil $
+// $Id$
//
-// Copyright (C) 2008
+// Copyright (C) 2009
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Christian Niephaus <cni@berlios.de>
+// 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
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-// Definition of non-inline non-template functions
+// Definition of 802.11 WLAN Beacon Packet non-inline non-template functions
// Custom includes
#include "WLANBeaconPacket.hh"
#include <boost/io/ios_state.hpp>
#define prefix_
-
-namespace {
-}
+///////////////////////////////cc.p////////////////////////////////////////
prefix_ void senf::WLANBeaconPacketType::dump(packet p, std::ostream &os)
{
<< senf::fieldName("timestamp") << unsigned( p->timestamp()) << "\n";
}
+///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
\f
// $Id$
//
-// Copyright (C) 2008
+// Copyright (C) 2009
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Christian Niephaus <cni@berlios.de>
+// 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
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** \file
- \brief 802.11 WLANPacket public header */
+ \brief 802.11 WLAN Beacon Packet public header */
#ifndef HH_SENF_Packets_80211Bundle_WLANBeaconPacket_
#define HH_SENF_Packets_80211Bundle_WLANBeaconPacket_ 1
+// Custom includes
#include <senf/Packets/Packets.hh>
+#include "InformationElements.hh"
+///////////////////////////////hh.p////////////////////////////////////////
+namespace senf {
-namespace senf
-{
-
- /** \brief 802.11 Beacon Frame parser
- (see IEEE 802.11-2007 standard - Chapter 7.2.3.1 Frame formats)
- <b>Re-ordering of bits due to host byte order</b>
-
- Frame base class.
- */
-
-// struct WLANBeaconPacketParser : public senf::PacketParserBase
-// {
-// #include SENF_PARSER();
-// SENF_PARSER_FIELD( elementId, UInt8Parser);
-// SENF_PARSER_FIELD( length, UInt8Parser);
-//
-// }
-
-
- struct WLANBeaconPacketParser : public senf::PacketParserBase
+ struct WLANBeaconPacketParser : public PacketParserBase
{
# include SENF_PARSER()
- SENF_PARSER_FIELD(timestamp, UInt64LSBParser);
- SENF_PARSER_FIELD(beaconInterval, UInt16LSBParser);
+ SENF_PARSER_FIELD( timestamp, UInt64LSBParser );
+ SENF_PARSER_FIELD( beaconInterval, UInt16LSBParser );
SENF_PARSER_SKIP(2,2); //capability flags
//SSID element
// SENF_PARSER_FIELD()
- SENF_PARSER_FINALIZE(WLANBeaconPacketParser);
+ SENF_PARSER_FINALIZE( WLANBeaconPacketParser );
};
\refWLANBeaconPacket
\par Fields:
- \ref WLANBeaconPacket_MgtFrameParser
- \image html WLANBeaconPacket.png
\ingroup protocolbundle_80211
*/
typedef ConcretePacket<WLANBeaconPacketType> WLANBeaconPacket;
-
}
-#endif /* HH_SENF_Packets_80211Bundle_WLANBeaconPacket_ */
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "WLANBeaconPacket.cci"
+//#include "WLANBeaconPacket.ct"
+//#include "WLANBeaconPacket.cti"
+#endif
\f
// Local Variables:
-// $Id: WLANPacket.test.cc 1317 2009-08-21 14:07:47Z g0dil $
+// $Id$
//
-// Copyright (C) 2008
+// Copyright (C) 2009
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Christian Niephaus <cni@berlios.de>
+// 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
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** \file
- \brief WLANPacket unit tests */
+ \brief 802.11 WLAN Beacon Packet unit tests */
// Custom includes
#include "WLANBeaconPacket.hh"
-#include <senf/Packets/Packets.hh>
#include <senf/Utils/auto_unit_test.hh>
#include <boost/test/test_tools.hpp>
///////////////////////////////cc.p////////////////////////////////////////
-/* test parser with a data frame */
+
BOOST_AUTO_UNIT_TEST(WLANBeaconPacket_packet)
{
unsigned char data[] = {
0x2c, 0x01, 0x11, 0x30, 0x01, 0x11, 0x34, 0x01, 0x17, 0x38, 0x01,
0x17, 0x3c, 0x01, 0x17, 0x40, 0x01, 0x17, 0x95, 0x01, 0x1e, 0x99,
0x01, 0x1e, 0x9d, 0x01, 0x1e, 0xa1, 0x01, 0x1e, 0xa5, 0x01, 0x1e, //Country information
- 0x20, 0x01, 0x00, //power contraint
+ 0x20, 0x01, 0x00, //power constraint
0xdd, 0x18, 0x00, 0x50, 0xf2, 0x02, 0x01, 0x01, 0x88, 0x00, 0x02,
0xa3, 0x00, 0x00, 0x27, 0xa4, 0x00, 0x00, 0x42, 0x43, 0x5e, 0x00,
0x62, 0x32, 0x2f, 0x00, //vendor specific
BOOST_CHECK_EQUAL( p->timestamp(), 0x0000009C4CAA303AuLL);
BOOST_CHECK_EQUAL( p->beaconInterval(), 100u);
-
}
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
\f
// Local Variables:
// mode: c++
Frame base class.
*/
- struct WLANPacketParser : public senf::PacketParserBase
+ struct WLANPacketParser : public PacketParserBase
{
# include SENF_PARSER()
\ingroup protocolbundle_80211
*/
struct WLANPacket_MgtFrameType
- : public senf::PacketTypeBase,
- public senf::PacketTypeMixin<WLANPacket_MgtFrameType>
+ : public PacketTypeBase,
+ public PacketTypeMixin<WLANPacket_MgtFrameType>
{
- typedef senf::PacketTypeMixin<WLANPacket_MgtFrameType> mixin;
- typedef senf::ConcretePacket<WLANPacket_MgtFrameType> packet;
+ typedef PacketTypeMixin<WLANPacket_MgtFrameType> mixin;
+ typedef ConcretePacket<WLANPacket_MgtFrameType> packet;
typedef WLANPacket_MgtFrameParser parser;
using mixin::init;
using mixin::initSize;
- using senf::PacketTypeBase::nextPacketRange;
+ using PacketTypeBase::nextPacketRange;
static void dump(packet p, std::ostream &os);
};
\ingroup protocolbundle_80211
*/
struct WLANPacket_CtrlFrameType
- : public senf::PacketTypeBase,
- public senf::PacketTypeMixin<WLANPacket_CtrlFrameType>
+ : public PacketTypeBase,
+ public PacketTypeMixin<WLANPacket_CtrlFrameType>
{
- typedef senf::PacketTypeMixin<WLANPacket_CtrlFrameType> mixin;
- typedef senf::ConcretePacket<WLANPacket_CtrlFrameType> packet;
+ typedef PacketTypeMixin<WLANPacket_CtrlFrameType> mixin;
+ typedef ConcretePacket<WLANPacket_CtrlFrameType> packet;
typedef WLANPacket_CtrlFrameParser parser;
using mixin::init;
using mixin::initSize;
- using senf::PacketTypeBase::nextPacketRange;
+ using PacketTypeBase::nextPacketRange;
static void dump(packet p, std::ostream &os);
};
\ingroup protocolbundle_80211
*/
struct WLANPacket_DataFrameType
- : public senf::PacketTypeBase,
- public senf::PacketTypeMixin<WLANPacket_DataFrameType>
+ : public PacketTypeBase,
+ public PacketTypeMixin<WLANPacket_DataFrameType>
{
- typedef senf::PacketTypeMixin<WLANPacket_DataFrameType> mixin;
- typedef senf::ConcretePacket<WLANPacket_DataFrameType> packet;
+ typedef PacketTypeMixin<WLANPacket_DataFrameType> mixin;
+ typedef ConcretePacket<WLANPacket_DataFrameType> packet;
typedef WLANPacket_DataFrameParser parser;
using mixin::init;
static void finalize(packet p);
};
- /** \brief Ethernet packet typedef */
+ /** \brief Ethernet packet typedef
+ \ingroup protocolbundle_default
+ */
typedef ConcretePacket<EthernetPacketType> EthernetPacket;
+
/** \brief Parse an ethernet VLAN tag
Parser interpreting the ethernet VLAN tag. Fields are
\ref IPv6RoutingPacket
\par Fields:
- \ref IPv6PRoutingPacketParser
+ \ref IPv6RoutingPacketParser
\par Associated registries:
\ref IpTypes
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** \file
- \brief StringParser inline non-template implementation */
+ \brief StringParser inline template implementation */
//#include "StringParser.ih"
#define prefix_ inline
///////////////////////////////cci.p///////////////////////////////////////
-prefix_ senf::StringParser::StringParser(data_iterator i, state_type s)
+template <class LengthParser>
+prefix_ senf::StringParser<LengthParser>::StringParser(data_iterator i, state_type s)
: PacketParserBase(i, s, init_bytes)
{}
-prefix_ senf::StringParser::size_type senf::StringParser::bytes()
+template <class LengthParser>
+prefix_ typename senf::StringParser<LengthParser>::size_type senf::StringParser<LengthParser>::bytes()
const
{
- return parse<UInt16Parser>(0)+2;
+ return length().value() + senf::bytes(length());
}
-prefix_ senf::StringParser::value_type senf::StringParser::value()
+template <class LengthParser>
+prefix_ typename senf::StringParser<LengthParser>::value_type senf::StringParser<LengthParser>::value()
const
{
validate(bytes());
- return std::string(i()+2, i()+bytes());
+ return std::string(i()+senf::bytes(length()), i()+bytes());
}
-prefix_ void senf::StringParser::value(value_type v)
+template <class LengthParser>
+prefix_ void senf::StringParser<LengthParser>::value(value_type v)
{
validate(bytes());
- resize(bytes(), v.size()+2);
+ resize(bytes(), v.size()+senf::bytes(length()));
parse<UInt16Parser>(0) = v.size();
- std::copy(v.begin(), v.end(), i()+2);
+ std::copy(v.begin(), v.end(), i()+senf::bytes(length()));
}
-prefix_ senf::StringParser::operator value_type()
+template <class LengthParser>
+prefix_ senf::StringParser<LengthParser>::operator value_type()
const
{
return value();
}
-prefix_ senf::StringParser const & senf::StringParser::operator=(value_type other)
+template <class LengthParser>
+prefix_ typename senf::StringParser<LengthParser> const & senf::StringParser<LengthParser>::operator=(value_type other)
{
value(other); return *this;
}
-prefix_ std::ostream & senf::operator<<(std::ostream & os, StringParser const & value)
+template <class LengthParser>
+prefix_ std::ostream & senf::operator<<(std::ostream & os, StringParser<LengthParser> const & value)
{
os << value.value();
return os;
namespace senf {
- struct StringParser
+ template <class LengthParser>
+ class StringParser
: public PacketParserBase
{
-
+ public:
StringParser(data_iterator i, state_type s);
///////////////////////////////////////////////////////////////////////////
+# include SENF_PARSER()
+ SENF_PARSER_PRIVATE_FIELD ( length, LengthParser );
+
typedef std::string value_type;
- static const size_type init_bytes = 2;
+ static const size_type init_bytes = senf::init_bytes<LengthParser>::value;
size_type bytes() const;
value_type value() const;
StringParser const & operator=(value_type other);
};
- std::ostream & operator<<(std::ostream & os, StringParser const & value);
+ template <class LengthParser>
+ std::ostream & operator<<(std::ostream & os, StringParser<LengthParser> const & value);
}
#endif
#if !defined(HH_SENF_Packets_Packets__decls_) && !defined(HH_SENF_Packets_StringParser_i_)
#define HH_SENF_Packets_StringParser_i_
-#include "StringParser.cci"
+//#include "StringParser.cci"
//#include "StringParser.ct"
-//#include "StringParser.cti"
+#include "StringParser.cti"
#endif
\f
namespace {
struct VoidPacket : public senf::PacketTypeBase
{};
+
+ typedef senf::StringParser<senf::UInt16Parser> MyStringParser;
}
BOOST_AUTO_UNIT_TEST(stringParser)
senf::PacketInterpreterBase::ptr p (senf::PacketInterpreter<VoidPacket>::create(data));
BOOST_CHECK_EQUAL( p->data().size(), 6u );
- BOOST_CHECK_EQUAL( senf::StringParser(p->data().begin(), &p->data()).value(), "TEST" );
+ BOOST_CHECK_EQUAL( MyStringParser(p->data().begin(), &p->data()).value(), "TEST" );
- senf::StringParser(p->data().begin(), &p->data()).value("Another Test");
+ MyStringParser(p->data().begin(), &p->data()).value("Another Test");
BOOST_CHECK_EQUAL( p->data().size(), 14u );
BOOST_CHECK_EQUAL( p->data()[0], 0u );
BOOST_CHECK_EQUAL( p->data()[1], 12u );
- BOOST_CHECK_EQUAL( senf::StringParser(p->data().begin(), &p->data()).value(), "Another Test" );
+ BOOST_CHECK_EQUAL( MyStringParser(p->data().begin(), &p->data()).value(), "Another Test" );
}
///////////////////////////////cc.e////////////////////////////////////////