#include <boost/io/ios_state.hpp>
#define prefix_
+///////////////////////////////cc.p//////////////////////////////////////
+namespace {
+ #define DUMP_OPTIONAL_FIELD(name, sign, desc) \
+ if (p->has_##name()) \
+ os << senf::fieldName(desc) << sign( p->name()) \
+ << std::endl;
+}
prefix_ void senf::RadiotapPacketType::dump(packet p, std::ostream &os)
{
boost::io::ios_all_saver ias(os);
os << "Radiotap:\n"
- << senf::fieldName("version") << unsigned( p->version()) << "\n"
- << senf::fieldName("length") << unsigned( p->length()) << "\n";
- if (p->has_tsft())
- os << senf::fieldName("MAC timestamp") << unsigned( p->tsft()) << "\n";
- // TODO: flags
- if (p->has_rate())
- os << senf::fieldName("rate") << unsigned( p->rate()) << "\n";
- // TODO: channelOptions
- if (p->has_fhss())
- os << senf::fieldName("FHSS") << unsigned( p->fhss()) << "\n";
- if (p->has_dbmAntennaSignal())
- os << senf::fieldName("antenna signal (dBm)") << signed( p->dbmAntennaSignal()) << "\n";
- if (p->has_dbmAntennaNoise())
- os << senf::fieldName("antenna noise (dBm)") << signed( p->dbmAntennaNoise()) << "\n";
- if (p->has_lockQuality())
- os << senf::fieldName("lock quality") << unsigned( p->lockQuality()) << "\n";
- if (p->has_txAttenuation())
- os << senf::fieldName("tx attenuation") << unsigned( p->txAttenuation()) << "\n";
- if (p->has_dbTxAttenuation())
- os << senf::fieldName("tx attenuation (dB)") << unsigned( p->dbTxAttenuation()) << "\n";
- if (p->has_dbmTxAttenuation())
- os << senf::fieldName("tx attenuation (dBm)") << signed( p->dbmTxAttenuation()) << "\n";
- if (p->has_antenna())
- os << senf::fieldName("antenna") << unsigned( p->antenna()) << "\n";
- if (p->has_dbAntennaSignal())
- os << senf::fieldName("antenna signal (dB)") << unsigned( p->dbAntennaSignal()) << "\n";
- if (p->has_dbAntennaNoise())
- os << senf::fieldName("antenna noise (dB)") << unsigned( p->dbAntennaNoise()) << "\n";
+ << senf::fieldName("version") << unsigned( p->version()) << "\n"
+ << senf::fieldName("length") << unsigned( p->length()) << "\n";
+ // TODO: flags, channelOptions
+ DUMP_OPTIONAL_FIELD( tsft, unsigned, "MAC timestamp" );
+ DUMP_OPTIONAL_FIELD( rate, unsigned, "rate" );
+ DUMP_OPTIONAL_FIELD( fhss, unsigned, "FHSS" );
+ DUMP_OPTIONAL_FIELD( dbmAntennaSignal, signed, "antenna signal (dBm)" );
+ DUMP_OPTIONAL_FIELD( dbmAntennaNoise, signed, "antenna noise (dBm)" );
+ DUMP_OPTIONAL_FIELD( lockQuality, unsigned, "lock quality" );
+ DUMP_OPTIONAL_FIELD( txAttenuation, unsigned, "tx attenuation" );
+ DUMP_OPTIONAL_FIELD( dbTxAttenuation, unsigned, "tx attenuation (dB)" );
+ DUMP_OPTIONAL_FIELD( dbmTxAttenuation, signed, "tx attenuation (dBm)" );
+ DUMP_OPTIONAL_FIELD( antenna, unsigned, "antenna" );
+ DUMP_OPTIONAL_FIELD( dbAntennaSignal, unsigned, "antenna signal (dB)" );
+ DUMP_OPTIONAL_FIELD( dbAntennaNoise, unsigned, "antenna noise (dB)" );
if (p->has_headerFcs())
- os << senf::fieldName("FCS") << unsigned( p->fcs()) << "\n";
+ os << senf::fieldName("FCS") << unsigned( p->fcs()) << "\n";
}
prefix_ void senf::RadiotapPacketType::finalize(packet p)
: optional_range( range(p.data().begin() + h, p.data().end() - t) );
}
+///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// comment-column: 40
+// End:
SENF_PARSER_SKIP_BITS( 4 );
SENF_PARSER_BITFIELD_RO ( frameType, 2, unsigned );
SENF_PARSER_SKIP_BITS( 2 );
-
};
/** \brief Radiotap packet
#include "ICMPv6TypePacket.hh"
#define prefix_
+///////////////////////////////cc.p////////////////////////////////////////
+
namespace {
-//Implementing the ICMPv6 Type registry
- senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::ICMPv6ErrDestUnreachable>
- registerICMPv6ErrDestUnreachable (1);
- senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::ICMPv6ErrTooBig>
- registerICMPv6ErrTooBig (2);
- senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::ICMPv6ErrTimeExceeded>
- registerICMPv6ErrTimeExceeded (3);
- senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::ICMPv6ErrParamProblem>
- registerICMPv6ErrParamProblem (4);
- senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::ICMPv6EchoRequest>
- registerICMPv6EchoRequest (128);
- senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::ICMPv6EchoReply>
- registerICMPv6EchoReply (129);
- senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::MLDv2ListenerQuery>
- registerMLDv2ListenerQuery (130);
- senf::PacketRegistry<senf::ICMPTypes>::RegistrationProxy<senf::MLDv2ListenerReport>
- registerMLDv2ListenerReport (143);
+ SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 1, senf::ICMPv6ErrDestUnreachable );
+ SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 2, senf::ICMPv6ErrTooBig );
+ SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 3, senf::ICMPv6ErrTimeExceeded );
+ SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 4, senf::ICMPv6ErrParamProblem );
+ SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 128, senf::ICMPv6EchoRequest );
+ SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 129, senf::ICMPv6EchoReply );
+ SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 130, senf::MLDv2ListenerQuery );
+ SENF_PACKET_REGISTRY_REGISTER( senf::ICMPTypes, 143, senf::MLDv2ListenerReport );
}
prefix_ void senf::ICMPv6EchoRequestType::dump(packet p, std::ostream & os)
{
os << "ICMPv6 Echo Request:\n"
- << senf::fieldName("Identifier") << unsigned(p->identifier()) << "\n"
- << senf::fieldName("SequenceNumber") << unsigned(p->seqNr() ) << "\n";
+ << senf::fieldName("Identifier") << unsigned(p->identifier()) << "\n"
+ << senf::fieldName("SequenceNumber") << unsigned(p->seqNr() ) << "\n";
}
prefix_ void senf::ICMPv6EchoReplyType::dump(packet p, std::ostream & os)
{
os << "ICMPv6 Echo Reply:\n"
- << senf::fieldName("Identifier") << unsigned(p->identifier()) << "\n"
- << senf::fieldName("SequenceNumber") << unsigned(p->seqNr()) << "\n";
+ << senf::fieldName("Identifier") << unsigned(p->identifier()) << "\n"
+ << senf::fieldName("SequenceNumber") << unsigned(p->seqNr()) << "\n";
}
prefix_ void senf::ICMPv6ErrDestUnreachableType::dump(packet p, std::ostream & os)
prefix_ void senf::ICMPv6ErrTooBigType::dump(packet p, std::ostream & os)
{
os << "ICMPv6 Error Packet Too Big:\n"
- << senf::fieldName("MTU") << unsigned(p->mtu() ) << "\n";
+ << senf::fieldName("MTU") << unsigned(p->mtu() ) << "\n";
}
prefix_ void senf::ICMPv6ErrTimeExceededType::dump(packet p, std::ostream & os)
{
os << "ICMPv6 Error Time Exceeded:\n"
- << senf::fieldName("Unused(32Bit)") << unsigned(p->unused() ) << "\n";
+ << senf::fieldName("Unused(32Bit)") << unsigned(p->unused() ) << "\n";
}
prefix_ void senf::ICMPv6ErrParamProblemType::dump(packet p, std::ostream & os)
{
os << "ICMPv6 Error Parameter Problem:\n"
- << senf::fieldName("Pointer") << unsigned(p->pointer() ) << "\n";
+ << senf::fieldName("Pointer") << unsigned(p->pointer() ) << "\n";
}
prefix_ void senf::MLDv2ListenerQueryType::dump(packet p, std::ostream & os)
{
os << "ICMPv6 Multicast Listener Query:\n"
- << senf::fieldName("Max. ResponseCode") << unsigned(p->maxResponseCode()) << "\n"
- << senf::fieldName("Reserved(16Bit)") << unsigned(p->reserved()) << "\n"
- << senf::fieldName("Multicast Address") << p->mcAddress() << "\n"
- << senf::fieldName("Reserver(4Bit)") << unsigned(p->resv()) << "\n"
+ << senf::fieldName("Max. ResponseCode") << unsigned(p->maxResponseCode()) << "\n"
+ << senf::fieldName("Reserved(16Bit)") << unsigned(p->reserved()) << "\n"
+ << senf::fieldName("Multicast Address") << p->mcAddress() << "\n"
+ << senf::fieldName("Reserver(4Bit)") << unsigned(p->resv()) << "\n"
<< senf::fieldName("Suppress Router-Side Processing") << unsigned(p->sFlag()) << "\n"
<< senf::fieldName("Querier's Robustness Variable") << unsigned(p->qrv()) << "\n"
<< senf::fieldName("Querier's Query Interval Code") << unsigned(p->qqic()) << "\n"
senf::MLDv2ListenerQuery::Parser::srcAddresses_t::container c (p->srcAddresses());
senf::MLDv2ListenerQuery::Parser::srcAddresses_t::container::iterator i (c.begin());
for (unsigned int nr =1; i != c.end(); ++i, ++nr)
- os << " " << nr << ".) " << *i << "\n";
+ os << " " << nr << ".) " << *i << "\n";
os << "\n";
}
prefix_ void senf::MLDv2ListenerReportType::dump(packet p, std::ostream & os)
{
os << "ICMPv6 Multicast Listener Report Message:\n"
- << senf::fieldName("Reserved") << unsigned(p->reserved() )
+ << senf::fieldName("Reserved") << unsigned(p->reserved() )
<<"\n Multicast Address Records:\n";
senf::MLDv2ListenerReport::Parser::mcastAddrRecords_t::container cAddrR (p->mcastAddrRecords() );
senf::MLDv2ListenerReport::Parser::mcastAddrRecords_t::container::iterator iAddrR (cAddrR.begin() );
for (; iAddrR != cAddrR.end(); ++iAddrR) {
- os << senf::fieldName(" Record Type") << unsigned(iAddrR->recordType()) << "\n"
- << senf::fieldName(" Multicast Address") << iAddrR->mcAddress() << "\n"
- << " Source Addresses\n:";
+ os << senf::fieldName(" Record Type") << unsigned(iAddrR->recordType()) << "\n"
+ << senf::fieldName(" Multicast Address") << iAddrR->mcAddress() << "\n"
+ << " Source Addresses\n:";
senf::MLDv2AddressRecordParser::srcAddresses_t::container cSrcAddr (iAddrR->srcAddresses());
senf::MLDv2AddressRecordParser::srcAddresses_t::container::iterator iSrcAddr (cSrcAddr.begin());
for (;iSrcAddr != cSrcAddr.end();++iSrcAddr)
}
}
+///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+/** \file
+ \brief IPv6Extension-Options non-inline non-template implementation */
#include "IPv6ExtOptionType.hh"
// Custom includes
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
-prefix_ senf::PacketInterpreterBase::range senf::IPv6GenericOptionTLVParser::value() const {
+prefix_ senf::PacketInterpreterBase::range senf::IPv6GenericOptionTLVParser::value()
+ const
+{
senf::PacketData::iterator begin (boost::next(i(), 2 ));
return PacketInterpreterBase::range(begin, boost::next( begin, optionLength()) );
}
+///////////////////////////////cc.e////////////////////////////////////////
+#undef prefix_
+
// Local Variables:
// mode: c++
BOOST_CHECK_EQUAL( pICMPv6->checksum(), 0x50cc);
}
-BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_create)
+BOOST_AUTO_UNIT_TEST(ipv6Extensions_hopByHop_create)
{
- std::ostringstream oss (std::ostringstream::out);
+ std::ostringstream oss (std::ostringstream::out);
unsigned char HopByHop_packetData[] = {
//Ethernet
0x33 ,0x33 ,0x00 ,0x00 ,0x00 ,0x16 , //destination MAC
senf::detail::ListOptionTypeParser_Policy<ElementParser,AuxPolicy>::container_policy::
destruct(container_type & c)
{
- // data_iterator i (AuxPolicy::adjust(parser_type::get(p).i(), parser_type::get(p).state()));
+ //data_iterator i (AuxPolicy::adjust(parser_type::get(p).i(), parser_type::get(p).state()));
safe_data_iterator i (c.data(), c.i()) ;
safe_data_iterator e = i + realAux_;
unsigned int padBytes = 0;
{
boost::io::ios_all_saver ias(os);
os << "Real Time Protocol:\n"
- << senf::fieldName("version") << p->version() << "\n"
- << senf::fieldName("padding") << p->padding() << "\n"
- << senf::fieldName("extension") << p->extension() << "\n"
+ << senf::fieldName("version") << p->version() << "\n"
+ << senf::fieldName("padding") << p->padding() << "\n"
+ << senf::fieldName("extension") << p->extension() << "\n"
<< senf::fieldName("contributing source cnt") << p->csrcCount() << "\n"
- << senf::fieldName("marker") << p->marker() << "\n"
- << senf::fieldName("payload type") << p->payloadType() << " "<< ptName(p->payloadType() ) <<"\n"
- << senf::fieldName("sequence number") << p->seqNumber() << "\n"
- << senf::fieldName("timestamp") << p->timeStamp() << "\n"
- << senf::fieldName("sync source id") << p->synSourceId() << "\n";
+ << senf::fieldName("marker") << p->marker() << "\n"
+ << senf::fieldName("payload type") << p->payloadType() << " "
+ << ptName(p->payloadType() ) <<"\n"
+ << senf::fieldName("sequence number") << p->seqNumber() << "\n"
+ << senf::fieldName("timestamp") << p->timeStamp() << "\n"
+ << senf::fieldName("sync source id") << p->synSourceId() << "\n";
}
#undef prefix_
// Copyright (C) 2009
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
-// Dennis Goslar <dennis.goslar@inf.hochschule-bonn-rhein-sieg.de>
+// Dennis Goslar <dennis.goslar@inf.hochschule-bonn-rhein-sieg.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
// Copyright (C) 2009
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
-// Dennis Goslar <dennis.goslar@inf.hochschule-bonn-rhein-sieg.de>
+// Dennis Goslar <dennis.goslar@inf.hochschule-bonn-rhein-sieg.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
{
# include SENF_PARSER()
- SENF_PARSER_FIELD( source, UInt16Parser );
- SENF_PARSER_FIELD( destination, UInt16Parser );
- SENF_PARSER_FIELD( sequencenumber, UInt32Parser );
- SENF_PARSER_FIELD( acknowledgmentnumber, UInt32Parser );
+ SENF_PARSER_FIELD( source, UInt16Parser );
+ SENF_PARSER_FIELD( destination, UInt16Parser );
+ SENF_PARSER_FIELD( sequencenumber, UInt32Parser );
+ SENF_PARSER_FIELD( acknowledgmentnumber, UInt32Parser );
- SENF_PARSER_BITFIELD ( dataoffset, 4, unsigned );
- SENF_PARSER_PRIVATE_BITFIELD( reserved, 6, unsigned );
- SENF_PARSER_BITFIELD ( urgf, 1, bool );
+ SENF_PARSER_BITFIELD ( dataoffset, 4, unsigned );
+ SENF_PARSER_PRIVATE_BITFIELD( reserved, 6, unsigned );
+ SENF_PARSER_BITFIELD ( urgf, 1, bool );
SENF_PARSER_BITFIELD ( ackf, 1, bool );
SENF_PARSER_BITFIELD ( pshf, 1, bool );
SENF_PARSER_BITFIELD ( rstf, 1, bool );
// Copyright (C) 2009
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
-// Dennis Goslar <dennis.goslar@inf.hochschule-bonn-rhein-sieg.de>
+// Dennis Goslar <dennis.goslar@inf.hochschule-bonn-rhein-sieg.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
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
-//namespace {
-// senf::PacketRegistry<senf::EtherTypes>::RegistrationProxy<senf::EthVLanPacketType>
-// registerEthVLanPacket(0x8100);
-//}
-
-
prefix_ boost::uint32_t senf::SNDUPacketParser::calcCrc()
const
{