// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Christian Niephaus <cni@berlios.de>
+// Stefan Bund <g0dil@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
prefix_ senf::RadiotapPacketType::optional_range
senf::RadiotapPacketType::nextPacketRange(packet p)
{
- size_type h (senf::bytes(p.parser()));
- size_type t (p->flagsPresent() && p->flags().fcsAtEnd() ? 4 : 0);
+ parser rtParser (p.parser());
+ size_type h (senf::bytes(rtParser));
+ size_type t (rtParser.flagsPresent() && rtParser.flags().fcsAtEnd() ? 4 : 0);
return p.size() <= h+t
? no_range()
: optional_range( range(p.data().begin() + h, p.data().end() - t) );
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Christian Niephaus <cni@berlios.de>
+// Stefan Bund <g0dil@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
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Christian Niephaus <cni@berlios.de>
+// Stefan Bund <g0dil@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
SENF_PARSER_INHERIT(WLANPacketParser);
- SENF_PARSER_GOTO(subtype);
- SENF_PARSER_SKIP_BITS(14); //<pkgdraw: hide
- SENF_PARSER_PRIVATE_BITFIELD ( dsBits, 2, unsigned ); //<pkgdraw: hide
- SENF_PARSER_SKIP ( 2, 2 ); //<pkgdraw: hide
+ protected:
+ typedef UIntFieldParser<6, 6+2> dsBits_t;
+ dsBits_t::value_type dsBits() const { return parse<dsBits_t>( 1); }
- SENF_PARSER_PRIVATE_FIELD ( addr1, MACAddressParser );
- SENF_PARSER_PRIVATE_FIELD ( addr2, MACAddressParser );
- SENF_PARSER_PRIVATE_FIELD ( addr3, MACAddressParser );
+ MACAddressParser addr1() const { return parse<MACAddressParser>( 4); }
+ MACAddressParser addr2() const { return parse<MACAddressParser>( 10); }
+ MACAddressParser addr3() const { return parse<MACAddressParser>( 16); }
//sequence Number and fragment number
//shift bits manually due to LSB
- SENF_PARSER_PRIVATE_BITFIELD ( seqNumber_1, 4, unsigned );
- SENF_PARSER_BITFIELD ( fragmentNumber, 4, unsigned );
- SENF_PARSER_PRIVATE_FIELD ( seqNumber_2, UInt8Parser );
+ typedef UIntFieldParser<0, 0+4> seqNumber_1_t;
+ seqNumber_1_t seqNumber_1() const { return parse<seqNumber_1_t>( 22); }
+
+ public:
+ typedef UIntFieldParser<4, 4+4> fragmentNumber_t;
+ fragmentNumber_t fragmentNumber() const { return parse<fragmentNumber_t>( 22); }
+
+ protected:
+ UInt8Parser seqNumber_2() const { return parse<UInt8Parser>( 23); }
+
+ public:
boost::uint16_t sequenceNumber() const {
return (uint16_t)(seqNumber_2()) << 4 | seqNumber_1();
};
void sequenceNumber(boost::uint16_t sn);
+ SENF_PARSER_GOTO_OFFSET( 24, 24);
+
// TODO fourth address field in case of WDS
// SENF_PARSER_PRIVATE_VARIANT (wds_, dsBits,
// ( novalue ( disable_addr4, VoidPacketParser ))
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
-prefix_ senf::Packet senf::Packet::checkNext()
+prefix_ senf::Packet senf::Packet::getNext()
const
{
- PacketInterpreterBase::optional_range r (ptr()->nextPacketRange());
- if (r && ! r->empty()) {
- factory_t factory (ptr()->nextPacketType());
- if (factory)
- return parseNextAs(factory);
- else
- return parseNextAs<DataPacket>();
- }
- return Packet();
+ factory_t factory (ptr()->nextPacketType());
+ if (factory)
+ return parseNextAs(factory);
+ else
+ return parseNextAs<DataPacket>();
}
-prefix_ senf::Packet senf::Packet::checkLast()
+prefix_ senf::Packet senf::Packet::getLast()
const
{
Packet p (*this);
const
{
PacketInterpreterBase::ptr p (ptr()->next());
- return !p && ptr()->nextPacketRange() ? checkNext() : Packet(p);
+ if (p) return Packet(p);
+ PacketInterpreterBase::optional_range r (ptr()->nextPacketRange());
+ return (r && ! r->empty()) ? getNext() : Packet();
}
prefix_ senf::Packet senf::Packet::next()
const
{
Packet p (ptr()->last());
- return p.next(nothrow) ? checkLast() : p;
+ return p.next(nothrow) ? getLast() : p;
}
prefix_ senf::Packet senf::Packet::parseNextAs(factory_t factory)
PacketInterpreterBase::ptr const & ptr() const;
private:
- Packet checkNext() const;
- Packet checkLast() const;
+ Packet getNext() const;
+ Packet getLast() const;
PacketInterpreterBase::ptr packet_;
senf::PacketTypeMixin<Self,void>::nextPacketRange(ConcretePacket<Self> const & p)
{
typename Self::size_type sz (Self::initHeadSize());
- ///\idea This if condition could be replaced with a compile time switch by checking, wether
+ ///\idea This if condition could be replaced with a compile time switch by checking, whether
/// (the function address) Self::initHeadSize is different from PacketTypeBase::initHeadSize
if (sz == PacketTypeBase::size_type(-1)) {
typename Self::size_type headsz (bytes(p.parser()));