From: g0dil Date: Thu, 23 Jul 2009 18:54:42 +0000 (+0000) Subject: Cleanup: Remove TAB chars and std::cerr debug output X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=44d9219e6dbfc94f8a6d40a352b2d01eff6fca7c;p=senf.git Cleanup: Remove TAB chars and std::cerr debug output Packets: Clean up output formatting in all dump() members Packets/80211Bundle: RadiotapPacket: Use length header field to get header size Packets/80211Bundle: Move FCS from WLANPacket to RadiotapPacket Packets/80211Bundle: Replace WLANPacket variant parsing by three separate packet types for control, management and data frames Packets/80211Bundle: complete dump() members Utils/Console: Implement 'ls' command and move old 'ls' to 'll' Scheduler: ClockService: Handle unset (that is 0) clock_type value explicitly in senf::ClockSservice::abstime() git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1277 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/PPI/SocketSink.cc b/PPI/SocketSink.cc index f3b724d..ef3dbc4 100644 --- a/PPI/SocketSink.cc +++ b/PPI/SocketSink.cc @@ -49,7 +49,8 @@ prefix_ void senf::ppi::IPv4SourceForcingDgramWriter::destination(senf::INet4Soc } prefix_ void senf::ppi::IPv4SourceForcingDgramWriter::operator()(Handle handle, - Packet const & packet){ + Packet const & packet) +{ sendtoandfrom( handle.fd(), reinterpret_cast (&*packet.data().begin()), @@ -121,7 +122,7 @@ prefix_ void senf::ppi::IPv6SourceForcingDgramWriter::destination(senf::INet6Soc } prefix_ void senf::ppi::IPv6SourceForcingDgramWriter::operator()(Handle handle, - Packet const & packet){ + Packet const & packet){ sendtoandfrom( handle.fd(), reinterpret_cast (&*packet.data().begin()), diff --git a/Packets/80211Bundle/RadiotapPacket.cc b/Packets/80211Bundle/RadiotapPacket.cc index bf4407c..028c9c1 100644 --- a/Packets/80211Bundle/RadiotapPacket.cc +++ b/Packets/80211Bundle/RadiotapPacket.cc @@ -35,47 +35,60 @@ prefix_ void senf::RadiotapPacketType::dump(packet p, std::ostream &os) { boost::io::ios_all_saver ias(os); os << "Radiotap:\n" - << " Version : " << unsigned( p->version()) << "\n" - << " Length : " << unsigned( p->length()) << "\n"; + << " version : " << unsigned( p->version()) << "\n" + << " length : " << unsigned( p->length()) << "\n"; if (p->has_tsft()) - os << " MAC timestamp : " << unsigned( p->tsft()) << "\n"; + os << " MAC timestamp : " << unsigned( p->tsft()) << "\n"; // TODO: flags if (p->has_rate()) - os << " Rate : " << unsigned( p->rate()) << "\n"; + os << " rate : " << unsigned( p->rate()) << "\n"; // TODO: channelOptions if (p->has_fhss()) - os << " FHSS : " << unsigned( p->fhss()) << "\n"; + os << " FHSS : " << unsigned( p->fhss()) << "\n"; if (p->has_dbmAntennaSignal()) - os << " Antenna Signal (dBm): " << signed( p->dbmAntennaSignal()) << "\n"; + os << " antenna signal (dBm) : " << signed( p->dbmAntennaSignal()) << "\n"; if (p->has_dbmAntennaNoise()) - os << " Antenna Noise (dBm) : " << signed( p->dbmAntennaNoise()) << "\n"; + os << " antenna noise (dBm) : " << signed( p->dbmAntennaNoise()) << "\n"; if (p->has_lockQuality()) - os << " Lock Quality : " << unsigned( p->lockQuality()) << "\n"; + os << " lock quality : " << unsigned( p->lockQuality()) << "\n"; if (p->has_txAttenuation()) - os << " txAttenuation : " << unsigned( p->txAttenuation()) << "\n"; + os << " tx attenuation : " << unsigned( p->txAttenuation()) << "\n"; if (p->has_dbTxAttenuation()) - os << " dbTxAttenuation : " << unsigned( p->dbTxAttenuation()) << "\n"; + os << " tx attenuation (dB) : " << unsigned( p->dbTxAttenuation()) << "\n"; if (p->has_dbmTxAttenuation()) - os << " dbmTxAttenuation : " << signed( p->dbmTxAttenuation()) << "\n"; + os << " tx attenuation (dBm) : " << signed( p->dbmTxAttenuation()) << "\n"; if (p->has_antenna()) - os << " Antenna : " << unsigned( p->antenna()) << "\n"; + os << " antenna : " << unsigned( p->antenna()) << "\n"; if (p->has_dbAntennaSignal()) - os << " Antenna Signal (dB) : " << unsigned( p->dbAntennaSignal()) << "\n"; + os << " antenna signal (dB) : " << unsigned( p->dbAntennaSignal()) << "\n"; if (p->has_dbAntennaNoise()) - os << " Antenna Noise (dB) : " << unsigned( p->dbAntennaNoise()) << "\n"; - if (p->has_fcs()) - os << " FCS : " << unsigned( p->fcs()) << "\n"; + os << " antenna noise (dB) : " << unsigned( p->dbAntennaNoise()) << "\n"; + if (p->has_headerFcs()) + os << " FCS : " << unsigned( p->fcs()) << "\n"; } prefix_ void senf::RadiotapPacketType::finalize(packet p) { - p->length() << senf::bytes( p.parser()); + p->length() << p->calculateSize(); } prefix_ senf::PacketInterpreterBase::factory_t senf::RadiotapPacketType::nextPacketType(packet p) { - return WLANPacket::factory(); + static factory_t frameTypeFactory[] = { WLANPacket_MgtFrame::factory(), + WLANPacket_CtrlFrame::factory(), + WLANPacket_DataFrame::factory(), + no_factory() }; + return frameTypeFactory[p->frameType()]; } +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); + return p.size() < h+t + ? no_range() + : optional_range( range(p.data().begin() + h, p.data().end() - t) ); +} #undef prefix_ diff --git a/Packets/80211Bundle/RadiotapPacket.hh b/Packets/80211Bundle/RadiotapPacket.hh index ebea567..c6fe53c 100644 --- a/Packets/80211Bundle/RadiotapPacket.hh +++ b/Packets/80211Bundle/RadiotapPacket.hh @@ -42,7 +42,7 @@ namespace senf SENF_PARSER_BITFIELD ( shortGI, 1, bool ); SENF_PARSER_BITFIELD ( badFCS, 1, bool ); SENF_PARSER_BITFIELD ( padding, 1, bool ); - SENF_PARSER_BITFIELD ( fcsPresent, 1, bool ); + SENF_PARSER_BITFIELD_RO ( fcsAtEnd, 1, bool ); // Cannot change this (change packet size) SENF_PARSER_BITFIELD ( fragmentation, 1, bool ); SENF_PARSER_BITFIELD ( wep, 1, bool ); SENF_PARSER_BITFIELD ( shortPreamble, 1, bool ); @@ -120,7 +120,7 @@ namespace senf SENF_PARSER_BITFIELD_RO ( flagsPresent, 1, bool ); SENF_PARSER_BITFIELD_RO ( tsftPresent, 1, bool ); SENF_PARSER_SKIP_BITS ( 1 ); //currently unused bits - SENF_PARSER_BITFIELD_RO ( fcsPresent, 1, bool ); + SENF_PARSER_BITFIELD_RO ( headerFcsPresent, 1, bool ); SENF_PARSER_BITFIELD_RO ( dbAntennaNoisePresent, 1, bool ); SENF_PARSER_BITFIELD_RO ( dbAntennaSignalPresent, 1, bool ); SENF_PARSER_BITFIELD_RO ( antennaPresent, 1, bool ); @@ -132,6 +132,8 @@ namespace senf SENF_PARSER_BITFIELD ( extendedBitmaskPresent, 1, bool ); SENF_PARSER_SKIP_BITS ( 7 ); //currently unused bits + SENF_PARSER_LABEL( headerEnd_ ); + /* * Radiotap data * parsing data according to present flags @@ -170,14 +172,32 @@ namespace senf OPTIONAL_FIELD ( antenna, UInt8Parser ); OPTIONAL_FIELD ( dbAntennaSignal, UInt8Parser ); OPTIONAL_FIELD ( dbAntennaNoise, UInt8Parser ); - SKIP_OPTIONAL_PADDING ( fcsPresent(), dbAntennaNoise, 4 ); - OPTIONAL_FIELD ( fcs, UInt32Parser ); + SKIP_OPTIONAL_PADDING ( headerFcsPresent(), dbAntennaNoise, 4 ); + OPTIONAL_FIELD ( headerFcs, UInt32Parser ); + + SENF_PARSER_LABEL( packetEnd_ ); + + size_type calculateSize() { return packetEnd__offset(); } + + // Ouch ... changing the flags().fcsAtEnd() field needs to resize the packet ... !!! + // Need to think, if I can do this with a variant parser ... + SENF_PARSER_CUSTOM_FIELD( fcs, senf::UInt32Parser, 0, 0 ) { + return parse(data().end()-4); + } SENF_PARSER_INIT() { version() = 0; } + // The headers length is to be taken from the 'length' value + SENF_PARSER_GOTO_OFFSET( length(), headerEnd__init_bytes ); + SENF_PARSER_FINALIZE( RadiotapPacketParser ); + + SENF_PARSER_SKIP_BITS( 4 ); + SENF_PARSER_BITFIELD_RO ( frameType, 2, unsigned ); + SENF_PARSER_SKIP_BITS( 2 ); + }; /** \brief Radiotap packet @@ -201,16 +221,27 @@ namespace senf typedef ConcretePacket packet; typedef RadiotapPacketParser parser; - using mixin::nextPacketRange; using mixin::init; using mixin::initSize; static void dump(packet p, std::ostream &os); static void finalize(packet p); static factory_t nextPacketType(packet p); + static optional_range nextPacketRange(packet p); }; typedef ConcretePacket RadiotapPacket; } #endif + + +// 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: diff --git a/Packets/80211Bundle/RadiotapPacket.test.cc b/Packets/80211Bundle/RadiotapPacket.test.cc index 3a0cb0b..c537bc4 100644 --- a/Packets/80211Bundle/RadiotapPacket.test.cc +++ b/Packets/80211Bundle/RadiotapPacket.test.cc @@ -38,7 +38,8 @@ BOOST_AUTO_UNIT_TEST(RadiotapPacket_packet) 0x00 ,0x00 ,0x1a ,0x00, 0x6f, 0x18, 0x00, 0x00, 0x02, 0xe6, 0x8a, 0xdf, 0x12, 0x00, 0x00, 0x00, 0x12, 0x0c, 0xc8, 0x14, 0x40, 0x01, 0xc3, 0xa0, - 0x02, 0x23 + 0x02, 0x23, + 0x00, 0x00, 0x00, 0x00, }; senf::RadiotapPacket p (senf::RadiotapPacket::create(data)); @@ -77,7 +78,7 @@ BOOST_AUTO_UNIT_TEST(RadiotapPacket_packet) BOOST_CHECK_EQUAL( p->flags().shortPreamble(), true); BOOST_CHECK_EQUAL( p->flags().wep(), false); BOOST_CHECK_EQUAL( p->flags().fragmentation(), false); - BOOST_CHECK_EQUAL( p->flags().fcsPresent(), true); + BOOST_CHECK_EQUAL( p->flags().fcsAtEnd(), true); BOOST_CHECK_EQUAL( p->flags().padding(), false); BOOST_CHECK_EQUAL( p->flags().badFCS(), false); BOOST_CHECK_EQUAL( p->flags().shortGI(), false); @@ -104,7 +105,7 @@ BOOST_AUTO_UNIT_TEST(RadiotapPacket_create) unsigned char data[] = { 0x00 ,0x00 ,0x1a ,0x00, 0x6f, 0x18, 0x00, 0x00, 0x02, 0xe6, 0x8a, 0xdf, 0x12, 0x00, 0x00, 0x00, - 0x12, 0x0c, 0xc8, 0x14, 0x40, 0x01, 0xc3, 0xa0, + 0x02, 0x0c, 0xc8, 0x14, 0x40, 0x01, 0xc3, 0xa0, 0x02, 0x23 }; @@ -129,7 +130,7 @@ BOOST_AUTO_UNIT_TEST(RadiotapPacket_create) SENF_CHECK_NO_THROW( p->flags().shortPreamble() = true); SENF_CHECK_NO_THROW( p->flags().wep() = false); SENF_CHECK_NO_THROW( p->flags().fragmentation() = false); - SENF_CHECK_NO_THROW( p->flags().fcsPresent() = true); + // SENF_CHECK_NO_THROW( p->flags().fcsAtEnd() = true); SENF_CHECK_NO_THROW( p->flags().padding() = false); SENF_CHECK_NO_THROW( p->flags().badFCS() = false); SENF_CHECK_NO_THROW( p->flags().shortGI() = false); @@ -151,15 +152,19 @@ BOOST_AUTO_UNIT_TEST(RadiotapPacket_create) p.finalizeAll(); BOOST_CHECK_EQUAL( p->length(), 26u ); - BOOST_CHECK( equal( p.data().begin(), p.data().end(), data )); + BOOST_CHECK_EQUAL_COLLECTIONS( p.data().begin(), p.data().end(), + data, data+sizeof(data)/sizeof(data[0]) ); } BOOST_AUTO_UNIT_TEST(RadiotapPacket_packet_ath9k) { /* radiotap packet from ath9k with atheros card*/ unsigned char data[] = { - 0x00, 0x00, 0x20, 0x00, 0x6f, 0x48, 0x00, 0x00, 0x87, 0xbb, 0x91, 0x7c, 0x3b, 0x00, 0x00, 0x00, - 0x00, 0x04, 0x85, 0x09, 0x80, 0x04, 0xb2, 0xa1, 0x00, 0x00, 0x00, 0x00, 0xd5, 0x1a, 0xf7, 0x94 + 0x00, 0x00, 0x20, 0x00, 0x6f, 0x48, 0x00, 0x00, + 0x87, 0xbb, 0x91, 0x7c, 0x3b, 0x00, 0x00, 0x00, + 0x00, 0x04, 0x85, 0x09, 0x80, 0x04, 0xb2, 0xa1, + 0x00, 0x00, 0x00, 0x00, 0xd5, 0x1a, 0xf7, 0x94, + 0x00, 0x00, 0x00, 0x00, }; senf::RadiotapPacket p (senf::RadiotapPacket::create(data)); @@ -169,9 +174,18 @@ BOOST_AUTO_UNIT_TEST(RadiotapPacket_packet_ath9k) BOOST_CHECK_EQUAL( p->dbmAntennaSignal(), -78); BOOST_CHECK_EQUAL( p->dbmAntennaNoise(), -95); - BOOST_CHECK_EQUAL( p->fcs(), 0xd51af794); + BOOST_CHECK_EQUAL( p->headerFcs(), 0xd51af794); BOOST_CHECK_EQUAL( p->antenna(), 0u); - - } + + +// 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: diff --git a/Packets/80211Bundle/WLANPacket.cc b/Packets/80211Bundle/WLANPacket.cc index c704f6d..413d229 100644 --- a/Packets/80211Bundle/WLANPacket.cc +++ b/Packets/80211Bundle/WLANPacket.cc @@ -25,20 +25,65 @@ // Custom includes #include "WLANPacket.hh" #include "../../Packets/Packets.hh" -#include "../DefaultBundle/LlcSnapPacket.hh" #include #define prefix_ +namespace { + + void dumpBase(senf::WLANPacketParser const & p, std::ostream & os) + { + os << " version : " << unsigned(p.version()) <<"\n" + << " type : " << unsigned(p.type()) << "\n" + << " subtype : " << unsigned(p.subtype()) << "\n" + << " flags :"; + if ( p.toDS() ) os << " toDS"; + if ( p.fromDS() ) os << " fromDS"; + if ( p.moreFrag() ) os << " moreFrag"; + if ( p.retry() ) os << " retry"; + if ( p.pwrMgt() ) os << " pwrMgt"; + if ( p.moreData() ) os << " moreData"; + if ( p.protectedFrame() ) os << " protected"; + if ( p.order() ) os << " order"; + + if ( !(p.toDS() || p.fromDS() || p.moreFrag() || p.retry() || p.pwrMgt() || + p.moreData() || p.protectedFrame() || p.order()) ) + os << " none"; + os << "\n" + << " duration : " << unsigned(p.duration()) << "\n"; + } +} + +prefix_ void senf::WLANPacket_MgtFrameType::dump(packet p, std::ostream &os) +{ + boost::io::ios_all_saver ias(os); + os << "802.11 MAC Mangement Frame:\n"; + dumpBase(p.parser(), os); + os << " destination : " << p->destinationAddress() << "\n" + << " source : " << p->sourceAddress() << "\n" + << " bss id : " << p->bssid() << "\n" + << " sequence number : " << p->sequenceNumber() << "\n" + << " fragment number : " << p->fragmentNumber() << "\n"; +} + +prefix_ void senf::WLANPacket_CtrlFrameType::dump(packet p, std::ostream &os) +{ + boost::io::ios_all_saver ias(os); + os << "802.11 MAC Control Frame:\n"; + dumpBase(p.parser(), os); + os << " receiver : " << p->receiverAddress() << "\n"; + if (p->is_rts()) + os << " source : " << p->sourceAddress() << "\n"; +} + prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::destinationAddress() const { switch (dsBits()) { case 0 : - case 2 : - return addr1(); + case 2 : return addr1(); + default: return addr3(); } - return addr3(); } prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::sourceAddress() @@ -47,19 +92,11 @@ prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::sourceAddress() switch (dsBits()) { case 0 : - case 1 : - return addr2(); - break; - case 2 : - return addr3(); - break; -//TODO wds frames -// case 3: -// return addr4(); + case 1 : return addr2(); + // TODO wds frames + // case 3 : return addr4(); + default: return addr3(); } - //just to avoid compiler warning - //TODO - return addr1(); } prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::bssid() @@ -67,74 +104,42 @@ prefix_ senf::MACAddressParser senf::WLANPacket_DataFrameParser::bssid() { switch (dsBits()) { - case 0 : - return addr3(); - break; - case 1 : - return addr1(); - break; - case 2: - return addr2(); + case 0 : return addr3(); + case 1 : return addr1(); + default: return addr2(); } - //just to avoid compiler warning - //TODO - return addr1(); } -prefix_ senf::PacketInterpreterBase::factory_t senf::WLANPacketType::nextPacketType(packet p) -{ - if (p->is_dataFrame() && (p->subtype()==0 || p->subtype()==8)) //data frame and subtype is Data or QoS Data - return LlcSnapPacket::factory(); - return no_factory(); -} - -prefix_ senf::PacketInterpreterBase::optional_range senf::WLANPacketType::nextPacketRange(packet p) -{ - if (p->is_dataFrame()) { - size_type sz = 24; //header length of wlan data frame (WDS is not considered) - if (p->subtype()==8) //subtype QoSData - sz+=2; //2 bytes for QoS field - return range( - boost::next(p.data().begin(),sz), - boost::prior(p.data().end(),4) ); //-4 bytes FCS - } - //TODO beacon frame payload - return no_range(); -} - -prefix_ void senf::WLANPacketType::dump(packet p, std::ostream &os) +prefix_ void senf::WLANPacket_DataFrameType::dump(packet p, std::ostream &os) { boost::io::ios_all_saver ias(os); - os << "802.11 MAC Frame:\n" - << " Type : " << unsigned( p->type()) << "\n" - << " Subtype : " << unsigned( p->subtype()) << "\n" - << " Retransmission : " << unsigned( p->retry()) << "\n" - << " Duration : " << unsigned( p->duration()) << "\n"; - if (p->is_mgtFrame()) { - os << " Management-Frame:\n" - << " BSSID : " << p->mgtFrame().bssid() << "\n" - << " Destination Address : " << p->mgtFrame().destinationAddress() << "\n" - << " Source Address : " << p->mgtFrame().sourceAddress() << "\n" - << " Sequence Number : " << unsigned( p->mgtFrame().sequenceNumber()) << "\n" - << " Fragment Number : " << unsigned( p->mgtFrame().fragmentNumber()) << "\n"; - } - if (p->is_ctrlFrame()) { - os << " Control-Frame "; - if (p->ctrlFrame().is_cts()) os << "(CTS):\n"; - if (p->ctrlFrame().is_ack()) os << "(ACK):\n"; - if (p->ctrlFrame().is_rts()) os << "(RTS):\n"; - os << " Receiver Address : " << p->ctrlFrame().receiverAddress() << "\n"; - if (p->ctrlFrame().is_rts()) - os << " Source Address : " << p->ctrlFrame().sourceAddress() << "\n"; - } - if (p->is_dataFrame()) { - os << " Data-Frame:\n" - << " Sequence Number : " << unsigned( p->dataFrame().sequenceNumber()) << "\n" - << " Fragment Number : " << unsigned( p->dataFrame().fragmentNumber()) << "\n"; - } -}; - - - + os << "802.11 MAC Data Frame:\n"; + dumpBase(p.parser(), os); + os << " destination : " << p->destinationAddress(); + if (p->dsBits()==0 || p->dsBits()==2) os << " (receiver)"; + os << "\n" + << " source : " << p->sourceAddress(); + if (p->dsBits()==0 || p->dsBits()==1) os << " (transmitter)"; + os << "\n" + << " bss id : " << p->bssid(); + if (p->dsBits()==1) os << " (receiver)"; + else if (p->dsBits()!=0) os << " (transmitter)"; + os << "\n" + << " sequence number : " << p->sequenceNumber() << "\n" + << " fragment number : " << p->fragmentNumber() << "\n"; + if (p->has_qosField()) + os << " QOS data : " << p->qosField() << "\n"; +} #undef prefix_ + + +// 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: diff --git a/Packets/80211Bundle/WLANPacket.hh b/Packets/80211Bundle/WLANPacket.hh index bbed6ea..c632aa5 100644 --- a/Packets/80211Bundle/WLANPacket.hh +++ b/Packets/80211Bundle/WLANPacket.hh @@ -28,23 +28,53 @@ #include "../../Packets/Packets.hh" #include "../DefaultBundle/EthernetPacket.hh" +#include "../DefaultBundle/LlcSnapPacket.hh" namespace senf { - /** \brief Management frame parser - * Re-ordering of bits due to LSB byte order + /** \brief 802.11 Frame parser + (see IEEE 802.11-2007 standard - Chapter 7 Frame formats) + Re-ordering of bits due to host byte order + Frame base class. */ - struct WLANPacket_MgtFrameParser : public senf::PacketParserBase + struct WLANPacketParser : public senf::PacketParserBase { - # include SENF_FIXED_PARSER() + # include SENF_PARSER() + + /* + * Frame control field + * re-ordering of fields due to the byte order + */ + SENF_PARSER_BITFIELD_RO ( subtype, 4, unsigned ); + SENF_PARSER_BITFIELD_RO ( type, 2, unsigned ); + SENF_PARSER_BITFIELD ( version, 2, unsigned ); + SENF_PARSER_BITFIELD ( order, 1, bool ); + SENF_PARSER_BITFIELD ( protectedFrame, 1, bool ); + SENF_PARSER_BITFIELD ( moreData, 1, bool ); + SENF_PARSER_BITFIELD ( pwrMgt, 1, bool ); + SENF_PARSER_BITFIELD ( retry, 1, bool ); + SENF_PARSER_BITFIELD ( moreFrag, 1, bool ); + SENF_PARSER_BITFIELD ( fromDS, 1, bool ); + SENF_PARSER_BITFIELD ( toDS, 1, bool ); + + SENF_PARSER_FIELD ( duration, UInt16LSBParser ); + + SENF_PARSER_FINALIZE(WLANPacketParser); + }; + + /////////////////////////////////////////////////////////////////////////// + + /** \brief Management frame parser + Re-ordering of bits due to LSB byte order + */ + struct WLANPacket_MgtFrameParser : public WLANPacketParser + { + # include SENF_PARSER() + + SENF_PARSER_INHERIT(WLANPacketParser); - SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned ); // + { + typedef senf::PacketTypeMixin mixin; + typedef senf::ConcretePacket packet; + typedef WLANPacket_MgtFrameParser parser; + + using mixin::init; + using mixin::initSize; + using senf::PacketTypeBase::nextPacketRange; + + static void dump(packet p, std::ostream &os); + }; + + typedef WLANPacket_MgtFrameType::packet WLANPacket_MgtFrame; + + /////////////////////////////////////////////////////////////////////////// + /** \brief Control frame parser - * Re-ordering of bits due to LSB byte order - * - * currently only CTS, RTS and ACK control frames are supported + Re-ordering of bits due to LSB byte order + currently only CTS, RTS and ACK control frames are supported */ - struct WLANPacket_CtrlFrameParser : public senf::PacketParserBase + struct WLANPacket_CtrlFrameParser : public WLANPacketParser { # include SENF_PARSER() - SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned ); // + { + typedef senf::PacketTypeMixin mixin; + typedef senf::ConcretePacket packet; + typedef WLANPacket_CtrlFrameParser parser; + + using mixin::init; + using mixin::initSize; + using senf::PacketTypeBase::nextPacketRange; + + static void dump(packet p, std::ostream &os); }; - /** \brief Data frame parser - * Re-ordering of bits due to LSB byte order + typedef WLANPacket_CtrlFrameType::packet WLANPacket_CtrlFrame; + /////////////////////////////////////////////////////////////////////////// + + /** \brief Data frame parser + Re-ordering of bits due to LSB byte order */ - struct WLANPacket_DataFrameParser : public senf::PacketParserBase + struct WLANPacket_DataFrameParser : public WLANPacketParser { # include SENF_PARSER() - SENF_PARSER_PRIVATE_BITFIELD ( subtype, 4, unsigned ); //Re-ordering of bits due to LSB byte order - - */ - struct WLANPacketParser : public senf::PacketParserBase - { - # include SENF_PARSER() - - /* - * Frame control field - * re-ordering of fields due to the byte order - */ - SENF_PARSER_BITFIELD_RO ( subtype, 4, unsigned ); - SENF_PARSER_BITFIELD_RO ( type, 2, unsigned ); - SENF_PARSER_BITFIELD ( version, 2, unsigned ); - SENF_PARSER_BITFIELD ( order, 1, bool ); - SENF_PARSER_BITFIELD ( protectedFrame, 1, bool ); - SENF_PARSER_BITFIELD ( moreData, 1, bool ); - SENF_PARSER_BITFIELD ( pwrMgt, 1, bool ); - SENF_PARSER_BITFIELD ( retry, 1, bool ); - SENF_PARSER_BITFIELD ( moreFrag, 1, bool ); - SENF_PARSER_BITFIELD ( fromDS, 1, bool ); - SENF_PARSER_BITFIELD ( toDS, 1, bool ); - - SENF_PARSER_FIELD ( duration, UInt16LSBParser ); - - SENF_PARSER_GOTO( subtype ); // subparsers need to know the subtype - SENF_PARSER_VARIANT ( frameType_, type, - ( ids( mgtFrame, is_mgtFrame, init_mgtFrame, WLANPacket_MgtFrameParser )) - ( ids( ctrlFrame, is_ctrlFrame, init_ctrlFrame, WLANPacket_CtrlFrameParser )) - ( ids( dataFrame, is_dataFrame, init_dataFrame, WLANPacket_DataFrameParser )) - ( novalue( reserved, WLANPacket_CtrlFrameParser )) ); - - SENF_PARSER_CUSTOM_FIELD( fcs, senf::UInt32Parser, fcs_t::fixed_bytes, fcs_t::fixed_bytes) { - return parse( data().size()-4 ); } - - SENF_PARSER_FINALIZE(WLANPacketParser); - - SENF_PARSER_INIT() { - version() = 0; - } - - //Problems can occur with old madwifi and ath5k. Some frames only - //contains two byte FCS instead of four. -// UInt32Parser fcs() const { return parse( data().size()-4 ); } + friend class WLANPacket_DataFrameType; }; - /** \brief WLAN packet + /** \brief WLAN Data frame packet \par Packet type (typedef): - \ref WLANPacket + \ref WLANPacket_DataFrame \par Fields: - \ref WLANPacketParser - \image html WLANPacket.png + \ref WLANPacket_DataFrameParser + \image html WLANPacket_DataFrame.png \ingroup protocolbundle_80211 */ - struct WLANPacketType + struct WLANPacket_DataFrameType : public senf::PacketTypeBase, - public senf::PacketTypeMixin + public senf::PacketTypeMixin { - typedef senf::PacketTypeMixin mixin; - typedef senf::ConcretePacket packet; - typedef WLANPacketParser parser; - + typedef senf::PacketTypeMixin mixin; + typedef senf::ConcretePacket packet; + typedef WLANPacket_DataFrameParser parser; using mixin::init; using mixin::initSize; -// using senf::PacketTypeBase::nextPacketRange; - static optional_range nextPacketRange(packet p); - static factory_t nextPacketType(packet p); + using mixin::nextPacketRange; + + static factory_t nextPacketType(packet p) { + return p->subtype() == 0 || p->subtype() == 8 + ? LlcSnapPacket::factory() + : no_factory(); + } static void dump(packet p, std::ostream &os); -// static PacketParserBase::size_type initSize(); }; - typedef senf::ConcretePacket WLANPacket; + typedef WLANPacket_DataFrameType::packet WLANPacket_DataFrame; } - #endif /* HH_SENF_Packets_80211Bundle_WLANPacket_ */ + + +// 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: diff --git a/Packets/80211Bundle/WLANPacket.test.cc b/Packets/80211Bundle/WLANPacket.test.cc index 5f10603..608fbda 100644 --- a/Packets/80211Bundle/WLANPacket.test.cc +++ b/Packets/80211Bundle/WLANPacket.test.cc @@ -41,11 +41,9 @@ BOOST_AUTO_UNIT_TEST(WLANPacket_dataFrame_packet) 0x06, 0xb0, 0x00, 0x18, 0x4d, 0x6e, 0x78, 0x48, 0x30, 0x00, 0x01, 0x00, 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, //llc header - 0x38, 0x39, 0x30, 0x31 //trailer }; - - senf::WLANPacket p (senf::WLANPacket::create(data)); + senf::WLANPacket_DataFrame p (senf::WLANPacket_DataFrame::create(data)); BOOST_CHECK_EQUAL( p->version(), 0u ); BOOST_CHECK_EQUAL( p->type(), 2u ); @@ -61,30 +59,25 @@ BOOST_AUTO_UNIT_TEST(WLANPacket_dataFrame_packet) BOOST_CHECK_EQUAL( p->duration(), 0u ); - BOOST_CHECK_EQUAL( - p->dataFrame().destinationAddress().value(), + BOOST_CHECK_EQUAL( p->destinationAddress().value(), senf::MACAddress::from_string("00:18:4d:6e:78:48") ); - BOOST_CHECK_EQUAL( - p->dataFrame().sourceAddress().value(), - senf::MACAddress::from_string("00:0b:6b:57:06:b0") ); - BOOST_CHECK_EQUAL( - p->dataFrame().bssid().value(), - senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); - - BOOST_CHECK_EQUAL( - p->dataFrame().bssid().value(), - p->dataFrame().receiverAddress().value() ); - BOOST_CHECK_EQUAL( - p->dataFrame().transmitterAddress().value(), - p->dataFrame().sourceAddress().value() ); - - BOOST_CHECK_EQUAL( p->dataFrame().sequenceNumber(), 3u ); - BOOST_CHECK_EQUAL( p->dataFrame().fragmentNumber(), 0u ); + BOOST_CHECK_EQUAL( p->sourceAddress().value(), + senf::MACAddress::from_string("00:0b:6b:57:06:b0") ); + BOOST_CHECK_EQUAL (p->bssid().value(), + senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); + + BOOST_CHECK_EQUAL( p->bssid().value(), + p->receiverAddress().value() ); + BOOST_CHECK_EQUAL( p->transmitterAddress().value(), + p->sourceAddress().value() ); + + BOOST_CHECK_EQUAL( p->sequenceNumber(), 3u ); + BOOST_CHECK_EQUAL( p->fragmentNumber(), 0u ); std::ostringstream oss (std::ostringstream::out); - SENF_CHECK_NO_THROW( p.dump( oss)); + SENF_CHECK_NO_THROW( p.dump(oss) ); - BOOST_CHECK( p.next()); + BOOST_REQUIRE( p.next(senf::nothrow) ); BOOST_CHECK( p.next().is() ); } @@ -92,10 +85,9 @@ BOOST_AUTO_UNIT_TEST(WLANPacket_dataFrame_packet) /* test parser with creating a data frame*/ BOOST_AUTO_UNIT_TEST(WLANPacket_dataFrame_create) { - senf::WLANPacket p (senf::WLANPacket::create()); + senf::WLANPacket_DataFrame p (senf::WLANPacket_DataFrame::create()); - SENF_CHECK_NO_THROW( p->init_dataFrame() ); - SENF_CHECK_NO_THROW( p->dataFrame().bssid() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); + SENF_CHECK_NO_THROW( p->bssid() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); BOOST_CHECK_EQUAL( p->type(), 2u ); } @@ -122,10 +114,10 @@ BOOST_AUTO_UNIT_TEST(WLANPacket_beaconFrame_packet) 0xa3, 0x40, 0x00, 0x27, 0xa4, 0x00, 0x00, 0x42, 0x43, 0x5e, 0x00, 0x62, 0x32, 0x2f, 0x00, 0xa0, 0x00, 0xdd, 0x09, 0x00, 0x03, 0x7f, 0x01, 0x01, - 0x00, 0x24, 0xff, 0x7f, 0x87, 0x07, 0x1f, 0xf5, + 0x00, 0x24, 0xff, 0x7f, }; - senf::WLANPacket p (senf::WLANPacket::create(data)); + senf::WLANPacket_MgtFrame p (senf::WLANPacket_MgtFrame::create(data)); BOOST_CHECK_EQUAL( p->version(), 0u ); BOOST_CHECK_EQUAL( p->type(), 0u ); @@ -140,39 +132,31 @@ BOOST_AUTO_UNIT_TEST(WLANPacket_beaconFrame_packet) BOOST_CHECK_EQUAL( p->order(), false ); BOOST_CHECK_EQUAL( p->duration(), 0u ); - BOOST_CHECK_EQUAL( p->is_mgtFrame(), true ); + BOOST_CHECK_EQUAL( p->destinationAddress().value(), + senf::MACAddress::from_string("ff:ff:ff:ff:ff:ff") ); + BOOST_CHECK_EQUAL( p->sourceAddress().value(), + senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); + BOOST_CHECK_EQUAL( p->bssid().value(), + senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); - BOOST_CHECK_EQUAL( - p->mgtFrame().destinationAddress().value(), - senf::MACAddress::from_string("ff:ff:ff:ff:ff:ff") ); - BOOST_CHECK_EQUAL( - p->mgtFrame().sourceAddress().value(), - senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); - BOOST_CHECK_EQUAL( - p->mgtFrame().bssid().value(), - senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); - - BOOST_CHECK_EQUAL( p->mgtFrame().sequenceNumber(), 302u ); - BOOST_CHECK_EQUAL( p->mgtFrame().fragmentNumber(), 0u ); - - BOOST_CHECK_EQUAL( p->fcs(), 0x87071ff5 ); + BOOST_CHECK_EQUAL( p->sequenceNumber(), 302u ); + BOOST_CHECK_EQUAL( p->fragmentNumber(), 0u ); } /* test parser with creating a beacon frame*/ BOOST_AUTO_UNIT_TEST(WLANPacket_mgtFrame_create) { - senf::WLANPacket p (senf::WLANPacket::create()); + senf::WLANPacket_MgtFrame p (senf::WLANPacket_MgtFrame::create()); - SENF_CHECK_NO_THROW( p->init_mgtFrame() ); SENF_CHECK_NO_THROW( - p->mgtFrame().destinationAddress() = senf::MACAddress::from_string("ff:ff:ff:ff:ff:ff") + p->destinationAddress() = senf::MACAddress::from_string("ff:ff:ff:ff:ff:ff") ); SENF_CHECK_NO_THROW( - p->mgtFrame().sourceAddress() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") + p->sourceAddress() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); SENF_CHECK_NO_THROW( - p->mgtFrame().bssid() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") + p->bssid() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c") ); BOOST_CHECK_EQUAL( p->type(), 0u ); @@ -183,11 +167,12 @@ BOOST_AUTO_UNIT_TEST(WLANPacket_mgtFrame_create) BOOST_AUTO_UNIT_TEST(WLANPacket_ctrlFrame_packet) { unsigned char data[] = { - 0xd4, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x6b, 0x57, - 0x06, 0xb0, 0x4f, 0xda + 0xd4, 0x00, 0x00, 0x00, + 0x00, 0x0b, 0x6b, 0x57, 0x06, 0xb0, + 0x4f, 0xda, // What is this ? }; - senf::WLANPacket p (senf::WLANPacket::create(data)); + senf::WLANPacket_CtrlFrame p (senf::WLANPacket_CtrlFrame::create(data)); BOOST_CHECK_EQUAL( p->version(), 0u ); BOOST_CHECK_EQUAL( p->type(), 1u ); @@ -203,22 +188,27 @@ BOOST_AUTO_UNIT_TEST(WLANPacket_ctrlFrame_packet) BOOST_CHECK_EQUAL( p->duration(), 0u ); - BOOST_CHECK_EQUAL( - p->ctrlFrame().receiverAddress().value(), - senf::MACAddress::from_string("00:0b:6b:57:06:b0") ); + BOOST_CHECK_EQUAL( p->receiverAddress().value(), + senf::MACAddress::from_string("00:0b:6b:57:06:b0") ); } - /* test parser with creating an ACK frame*/ BOOST_AUTO_UNIT_TEST(WLANPacket_ctrlFrame_create) { - senf::WLANPacket p (senf::WLANPacket::create()) ; -// std::cout << unsigned( senf::init_bytes::value ) << "\n"; - SENF_CHECK_NO_THROW(p->init_ctrlFrame()); -// std::cout << unsigned( senf::init_bytes::value ) << "\n"; - p->ctrlFrame().receiverAddress() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c"); - p->ctrlFrame().set_ack(); + senf::WLANPacket_CtrlFrame p (senf::WLANPacket_CtrlFrame::create()) ; + p->receiverAddress() = senf::MACAddress::from_string("00:1a:4d:3e:c7:5c"); + p->set_ack(); BOOST_CHECK_EQUAL( p->type(), 1u); BOOST_CHECK_EQUAL( p->subtype(), 13u); } + +// 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: diff --git a/Packets/80221Bundle/MIHPacket.cc b/Packets/80221Bundle/MIHPacket.cc index 3e8b050..388d450 100644 --- a/Packets/80221Bundle/MIHPacket.cc +++ b/Packets/80221Bundle/MIHPacket.cc @@ -102,29 +102,29 @@ prefix_ void senf::MIHPacketType::dump(packet p, std::ostream &os) { boost::io::ios_all_saver ias(os); os << "MIH Packet:\n" - << " protocol header:\n" - << " Version: " << unsigned( p->version()) << "\n" - << " Ack-Request: " << p->ackRequest() << "\n" - << " Ack-Response: " << p->ackResponse() << "\n" - << " UIR: " << p->uir() << "\n" - << " more fragment: " << p->moreFragment() << "\n" - << " fragment number: " << p->fragmentNr() << "\n" - << " message ID (MID): " << unsigned( p->messageId()) << "\n" - << " SID: " << unsigned( p->sid()) << "\n" - << " Opcode: " << unsigned( p->opcode()) << "\n" - << " AID: " << unsigned( p->aid()) << "\n" - << " Transaction ID: " << unsigned( p->transactionId()) << "\n" - << " payload length: " << unsigned( p->payloadLength()) << "\n" - << " source MIHF_Id TLV:\n" - << " type: " << unsigned (p->src_mihfId().type()) << "\n" - << " length: " << unsigned (p->src_mihfId().length()) << "\n" - << " value:\n"; + << " protocol header:\n" + << " version : " << unsigned( p->version()) << "\n" + << " ack request : " << p->ackRequest() << "\n" + << " ack response : " << p->ackResponse() << "\n" + << " UIR : " << p->uir() << "\n" + << " more fragments : " << p->moreFragment() << "\n" + << " fragment number : " << p->fragmentNr() << "\n" + << " message ID (MID) : " << unsigned( p->messageId()) << "\n" + << " sid : " << unsigned( p->sid()) << "\n" + << " opcode : " << unsigned( p->opcode()) << "\n" + << " aid : " << unsigned( p->aid()) << "\n" + << " transaction id : " << unsigned( p->transactionId()) << "\n" + << " payload length : " << unsigned( p->payloadLength()) << "\n" + << " source MIHF_Id TLV :\n" + << " type : " << unsigned (p->src_mihfId().type()) << "\n" + << " length : " << unsigned (p->src_mihfId().length()) << "\n" + << " value :\n"; std::string src_mihfId (p->src_mihfId().asString()); hexdump(src_mihfId.begin(), src_mihfId.end(), os); - os << " destination MIHF_Id TLV:\n" - << " type: " << unsigned (p->dst_mihfId().type()) << "\n" - << " length: " << unsigned (p->dst_mihfId().length()) << "\n" - << " value:\n"; + os << " destination MIHF_Id TLV:\n" + << " type : " << unsigned (p->dst_mihfId().type()) << "\n" + << " length : " << unsigned (p->dst_mihfId().length()) << "\n" + << " value :\n"; std::string dst_mihfId (p->dst_mihfId().asString()); hexdump(dst_mihfId.begin(), dst_mihfId.end(), os); } diff --git a/Packets/80221Bundle/TLVPacket.cc b/Packets/80221Bundle/TLVPacket.cc index 3c28c5b..1e0e997 100644 --- a/Packets/80221Bundle/TLVPacket.cc +++ b/Packets/80221Bundle/TLVPacket.cc @@ -210,9 +210,9 @@ prefix_ void senf::GenericTLVPacketType::dump(packet p, std::ostream & os) boost::io::ios_all_saver ias(os); os << "GenericTLVPacket:\n" << std::dec - << " type: " << unsigned( p->type()) << "\n" - << " length: " << unsigned( p->length()) << "\n" - << " value\n:"; + << " type : " << unsigned( p->type()) << "\n" + << " length : " << unsigned( p->length()) << "\n" + << " value\n : "; senf::hexdump( p->value().begin(), p->value().end(), os); } diff --git a/Packets/DefaultBundle/EthernetPacket.cc b/Packets/DefaultBundle/EthernetPacket.cc index 78fe56c..b3ba75b 100644 --- a/Packets/DefaultBundle/EthernetPacket.cc +++ b/Packets/DefaultBundle/EthernetPacket.cc @@ -51,11 +51,11 @@ prefix_ void senf::EthernetPacketType::dump(packet p, std::ostream & os) os << "Ethernet II (DIX)"; else os << "Ethernet 802.3 (bad ethertype >1500 and <1536)"; - os << ": \n" - << " destination : " << p->destination() << "\n" - << " source : " << p->source() << "\n" - << " type/length : 0x" - << std::hex << std::setw(4) << std::setfill('0') << p->type_length() << "\n"; + os << ": \n" + << " destination : " << p->destination() << "\n" + << " source : " << p->source() << "\n" + << " type/length : 0x" + << std::hex << std::setw(4) << std::setfill('0') << p->type_length() << "\n"; } prefix_ senf::PacketInterpreterBase::factory_t senf::EthernetPacketType::nextPacketType(packet p) @@ -81,12 +81,12 @@ prefix_ void senf::EthernetPacketType::finalize(packet p) prefix_ void senf::EthVLanPacketType::dump(packet p, std::ostream & os) { boost::io::ios_all_saver ias(os); - os << "Ethernet 802.1q (VLAN):\n" - << " priority : " << p->priority() << "\n" - << " cfi : " << p->cfi() << "\n" - << " vlan-ID : " << p->vlanId() << "\n" - << " ethertype : 0x" - << std::hex << std::setw(4) << std::setfill('0') << p->type() << "\n"; + os << "Ethernet 802.1q (VLAN):\n" + << " priority : " << p->priority() << "\n" + << " cfi : " << p->cfi() << "\n" + << " vlan-ID : " << p->vlanId() << "\n" + << " ethertype : 0x" + << std::hex << std::setw(4) << std::setfill('0') << p->type() << "\n"; } prefix_ void senf::EthVLanPacketType::finalize(packet p) diff --git a/Packets/DefaultBundle/ICMPv6Packet.cc b/Packets/DefaultBundle/ICMPv6Packet.cc index 9d5d104..66072db 100644 --- a/Packets/DefaultBundle/ICMPv6Packet.cc +++ b/Packets/DefaultBundle/ICMPv6Packet.cc @@ -74,9 +74,9 @@ prefix_ void senf::ICMPv6PacketType::dump(packet p, std::ostream &os) { boost::io::ios_all_saver ias(os); os << "ICMPv6 protocol:\n" - << "Type : " << p->type() <<"\n" - << "Code : " << p->code() <<"\n" - << "Checksum : " << p->checksum() << "\n"; + << " type : " << p->type() <<"\n" + << " code : " << p->code() <<"\n" + << " checksum : " << p->checksum() << "\n"; } ///////////////////////////////cc.e//////////////////////////////////////// diff --git a/Packets/DefaultBundle/IPv4Packet.cc b/Packets/DefaultBundle/IPv4Packet.cc index 2a9fa1a..131649c 100644 --- a/Packets/DefaultBundle/IPv4Packet.cc +++ b/Packets/DefaultBundle/IPv4Packet.cc @@ -65,21 +65,21 @@ prefix_ boost::uint16_t senf::IPv4PacketParser::calcChecksum() prefix_ void senf::IPv4PacketType::dump(packet p, std::ostream & os) { boost::io::ios_all_saver ias(os); - os << "Internet protocol Version 4:\n" - << " version : " << p->version() << "\n" - << " IHL : " << p->ihl() << "\n" - << " TOS : " << unsigned(p->tos()) << "\n" - << " length : " << p->length() << "\n" - << " identifier : " << p->identifier() << "\n" - << " DF : " << p->df() << "\n" - << " MF : " << p->mf() << "\n" - << " fragment : " << p->frag() << "\n" - << " TTL : " << unsigned(p->ttl()) << "\n" - << " protocol : " << unsigned(p->protocol()) << "\n" - << " checksum : 0x" + os << "Internet protocol Version 4:\n" + << " version : " << p->version() << "\n" + << " ip header length : " << p->ihl() << "\n" + << " tos : " << unsigned(p->tos()) << "\n" + << " length : " << p->length() << "\n" + << " identifier : " << p->identifier() << "\n" + << " dont fragment : " << p->df() << "\n" + << " more fragments : " << p->mf() << "\n" + << " fragment : " << p->frag() << "\n" + << " ttl : " << unsigned(p->ttl()) << "\n" + << " protocol : " << unsigned(p->protocol()) << "\n" + << " checksum : 0x" << std::hex << std::setw(4) << std::setfill('0') << p->checksum() << std::dec << "\n" - << " source : " << p->source() << "\n" - << " destination : " << p->destination() << "\n"; + << " source : " << p->source() << "\n" + << " destination : " << p->destination() << "\n"; } prefix_ void senf::IPv4PacketType::finalize(packet p) diff --git a/Packets/DefaultBundle/IPv6Extensions.cc b/Packets/DefaultBundle/IPv6Extensions.cc index f673986..0e39c65 100644 --- a/Packets/DefaultBundle/IPv6Extensions.cc +++ b/Packets/DefaultBundle/IPv6Extensions.cc @@ -46,21 +46,21 @@ namespace { prefix_ void senf::IPv6ExtensionType_Fragment::dump(packet p, std::ostream & os) { os << "Internet protocol Version 6 fragment extension:\n" - << " next header : " << unsigned(p->nextHeader()) << "\n" - << " fragment offset: " << std::hex << unsigned(p->fragmentOffset()) << "\n" - << " more fragments : " << (p->moreFragments()?"yes":"no") << "\n" - << " id : " << std::hex << unsigned(p->id()) << "\n"; + << " next header : " << unsigned(p->nextHeader()) << "\n" + << " fragment offset : " << std::hex << unsigned(p->fragmentOffset()) << "\n" + << " more fragments : " << (p->moreFragments()?"yes":"no") << "\n" + << " id : " << std::hex << unsigned(p->id()) << "\n"; } prefix_ void senf::IPv6ExtensionType_Routing::dump(packet p, std::ostream & os) { os << "Internet protocol Version 6 routing extension:\n" - << " next header : " << unsigned (p->nextHeader()) << "\n" - << " header length : " << unsigned (p->headerLength()) << "\n" - << " routing type : " << unsigned (p->routingType()) << "\n" - << " segments left : " << unsigned (p->segmentsLeft()) << "\n"; - IPv6Extension_Routing::Parser::hopAddresses_t::container hopAddresses (p->hopAddresses()); - os << " further Hop Addresses : \n"; + << " next header : " << unsigned (p->nextHeader()) << "\n" + << " header length : " << unsigned (p->headerLength()) << "\n" + << " routing type : " << unsigned (p->routingType()) << "\n" + << " segments left : " << unsigned (p->segmentsLeft()) << "\n"; + IPv6Extension_Routing::Parser::hopAddresses_t::container hopAddresses (p->hopAddresses()); + os << " further Hop Addresses : \n"; if ( p->segmentsLeft() != 0 ){ for (IPv6Extension_Routing::Parser::hopAddresses_t::container::iterator i (hopAddresses.begin()); i != hopAddresses.end(); ++i) os << *i << "\n"; @@ -70,15 +70,15 @@ prefix_ void senf::IPv6ExtensionType_Routing::dump(packet p, std::ostream & os) prefix_ void senf::IPv6ExtensionType_HopByHop::dump(packet p, std::ostream & os) { os << "Internet protocol Version 6 Hop-By-Hop extension:\n" - << " next header : " << unsigned (p->nextHeader()) << "\n" - << " header length : " << unsigned (p->headerLength()) << "\n"; + << " next header : " << unsigned (p->nextHeader()) << "\n" + << " header length : " << unsigned (p->headerLength()) << "\n"; } prefix_ void senf::IPv6ExtensionType_Destination::dump(packet p, std::ostream & os) { os << "Internet protocol Version 6 Destination Options extension:\n" - << " next header : " << unsigned (p->nextHeader()) << "\n" - << " header length : " << unsigned (p->headerLength()) << "\n"; + << " next header : " << unsigned (p->nextHeader()) << "\n" + << " header length : " << unsigned (p->headerLength()) << "\n"; } ///////////////////////////////cc.e//////////////////////////////////////// diff --git a/Packets/DefaultBundle/IPv6Packet.cc b/Packets/DefaultBundle/IPv6Packet.cc index a0f9083..4599276 100644 --- a/Packets/DefaultBundle/IPv6Packet.cc +++ b/Packets/DefaultBundle/IPv6Packet.cc @@ -46,17 +46,17 @@ namespace { prefix_ void senf::IPv6PacketType::dump(packet p, std::ostream & os) { boost::io::ios_all_saver ias(os); - os << "Internet protocol Version 6:\n" - << " version : " << unsigned(p->version()) << "\n" - << " traffic class : 0x" + os << "Internet protocol Version 6:\n" + << " version : " << unsigned(p->version()) << "\n" + << " traffic class : 0x" << std::hex << std::setw(2) << std::setfill('0') << unsigned(p->trafficClass()) << "\n" - << " flow label : 0x" + << " flow label : 0x" << std::hex << std::setw(5) << std::setfill('0') << unsigned(p->flowLabel()) << "\n" - << " payload length : " << std::dec << unsigned(p->length()) << "\n" - << " next header : " << unsigned(p->nextHeader()) << "\n" - << " hop limit : " << unsigned(p->hopLimit()) << "\n" - << " source : " << p->source() << "\n" - << " destination : " << p->destination() << "\n"; + << " payload length : " << std::dec << unsigned(p->length()) << "\n" + << " next header : " << unsigned(p->nextHeader()) << "\n" + << " hop limit : " << unsigned(p->hopLimit()) << "\n" + << " source : " << p->source() << "\n" + << " destination : " << p->destination() << "\n"; } prefix_ void senf::IPv6PacketType::finalize(packet p) diff --git a/Packets/DefaultBundle/LlcSnapPacket.cc b/Packets/DefaultBundle/LlcSnapPacket.cc index 4442463..ae14712 100644 --- a/Packets/DefaultBundle/LlcSnapPacket.cc +++ b/Packets/DefaultBundle/LlcSnapPacket.cc @@ -36,15 +36,15 @@ prefix_ void senf::LlcSnapPacketType::dump(packet p, std::ostream & os) { boost::io::ios_all_saver ias(os); - os << "LLC/SNAP\n" + os << "LLC/SNAP:\n" << std::hex << std::setfill('0') - << " LLC\n" - << " DSAP: 0x" << unsigned(p->dsap()) << "\n" - << " SSAP: 0x" << unsigned(p->ssap()) << "\n" - << " controlId: 0x" << unsigned(p->ctrl()) << "\n" - << " SNAP\n" - << " ProtocolId: 0x" << std::setw(6) << unsigned(p->protocolId()) << "\n" - << " type_length: 0x" << std::setw(4) << unsigned(p->type_length()) << "\n"; + << " LLC\n" + << " dsap : 0x" << unsigned(p->dsap()) << "\n" + << " ssap : 0x" << unsigned(p->ssap()) << "\n" + << " control id : 0x" << unsigned(p->ctrl()) << "\n" + << " SNAP\n" + << " protocol id : 0x" << std::setw(6) << unsigned(p->protocolId()) << "\n" + << " type/length : 0x" << std::setw(4) << unsigned(p->type_length()) << "\n"; } prefix_ senf::PacketInterpreterBase::factory_t senf::LlcSnapPacketType::nextPacketType(packet p) diff --git a/Packets/DefaultBundle/RTPPacket.cc b/Packets/DefaultBundle/RTPPacket.cc index 4e512ab..e69a298 100644 --- a/Packets/DefaultBundle/RTPPacket.cc +++ b/Packets/DefaultBundle/RTPPacket.cc @@ -64,16 +64,15 @@ prefix_ void senf::RTPPacketType::dump(packet p, std::ostream &os) { boost::io::ios_all_saver ias(os); os << "Real Time Protocol:\n" - << " Version : " << p->version() << "\n" - << " Padding : " << p->padding() << "\n" - << " Extension : " << p->extension() << "\n" - << " Contributing Source Count(CC) : " << p->csrcCount() << "\n" - << " Marker : " << p->marker() << "\n" - << " Payload Type : " << p->payloadType() << " "<< ptName(p->payloadType() ) <<"\n" - << " Sequence number : " << p->seqNumber() << "\n" - << " Timestamp : " << p->timeStamp() << "\n" - << " Synchronisation Source Identifier : " << p->synSourceId() << "\n"; - + << " version : " << p->version() << "\n" + << " padding : " << p->padding() << "\n" + << " extension : " << p->extension() << "\n" + << " contributing source cnt : " << p->csrcCount() << "\n" + << " marker : " << p->marker() << "\n" + << " payload type : " << p->payloadType() << " "<< ptName(p->payloadType() ) <<"\n" + << " sequence number : " << p->seqNumber() << "\n" + << " timestamp : " << p->timeStamp() << "\n" + << " sync source id : " << p->synSourceId() << "\n"; } #undef prefix_ diff --git a/Packets/DefaultBundle/UDPPacket.cc b/Packets/DefaultBundle/UDPPacket.cc index f3cfc56..57db0cc 100644 --- a/Packets/DefaultBundle/UDPPacket.cc +++ b/Packets/DefaultBundle/UDPPacket.cc @@ -101,10 +101,10 @@ prefix_ void senf::UDPPacketType::dump(packet p, std::ostream & os) { boost::io::ios_all_saver ias(os); os << "UDP:\n" - << " source port : " << p->source() << "\n" - << " dest port : " << p->destination() << "\n" - << " length : " << p->length() << "\n" - << " checksum : " + << " source port : " << p->source() << "\n" + << " dest port : " << p->destination() << "\n" + << " length : " << p->length() << "\n" + << " checksum : " << std::hex << std::setw(4) << std::setfill('0') << p->checksum() << "\n"; } diff --git a/Packets/MPEGDVBBundle/DTCPPacket.cc b/Packets/MPEGDVBBundle/DTCPPacket.cc index 48cb334..1c9f08f 100644 --- a/Packets/MPEGDVBBundle/DTCPPacket.cc +++ b/Packets/MPEGDVBBundle/DTCPPacket.cc @@ -40,15 +40,15 @@ prefix_ void senf::DTCPHelloPacketType::dump(packet p, std::ostream & os) "8", "9", "10", "11", "12", "13", "14", "15" }; boost::io::ios_all_saver ias(os); os << "DTCP HELLO Packet:" << std::endl - << " version : " << p->versionNumber() << std::endl - << " command : " << COMMANDS[p->command()] << std::endl - << " interval : " << unsigned(p->interval()) << std::endl - << " sequence number : " << p->sequenceNumber() << std::endl - << " receive capable feed : " << (p->receiveCapableFeed() ? "yes" : "no") << std::endl - << " ip version : " << p->ipVersion() << std::endl - << " tunnel protocol : " << unsigned(p->tunnelProtocol()) << std::endl - << " number of BDL ips : " << unsigned(p->fbipCount()) << std::endl - << " feed BDL ips : "; + << " version : " << p->versionNumber() << std::endl + << " command : " << COMMANDS[p->command()] << std::endl + << " interval : " << unsigned(p->interval()) << std::endl + << " sequence number : " << p->sequenceNumber() << std::endl + << " receive capable feed : " << (p->receiveCapableFeed() ? "yes" : "no") << std::endl + << " ip version : " << p->ipVersion() << std::endl + << " tunnel protocol : " << unsigned(p->tunnelProtocol()) << std::endl + << " number of BDL ips : " << unsigned(p->fbipCount()) << std::endl + << " feed BDL ips : "; switch (p->ipVersion()) { case 4 : { diff --git a/Packets/MPEGDVBBundle/DTCPPacket.test.cc b/Packets/MPEGDVBBundle/DTCPPacket.test.cc index c8edbc3..16df352 100644 --- a/Packets/MPEGDVBBundle/DTCPPacket.test.cc +++ b/Packets/MPEGDVBBundle/DTCPPacket.test.cc @@ -74,15 +74,15 @@ BOOST_AUTO_UNIT_TEST(dtcpPacket) hello.dump(ss); BOOST_CHECK_EQUAL( ss.str(), "DTCP HELLO Packet:\n" - " version : 1\n" - " command : JOIN\n" - " interval : 5\n" - " sequence number : 2571\n" - " receive capable feed : yes\n" - " ip version : 4\n" - " tunnel protocol : 23\n" - " number of BDL ips : 2\n" - " feed BDL ips : \n" + " version : 1\n" + " command : JOIN\n" + " interval : 5\n" + " sequence number : 2571\n" + " receive capable feed : yes\n" + " ip version : 4\n" + " tunnel protocol : 23\n" + " number of BDL ips : 2\n" + " feed BDL ips : \n" " 101.102.103.104\n" " 201.202.203.204\n" ); diff --git a/Packets/MPEGDVBBundle/GREPacket.cc b/Packets/MPEGDVBBundle/GREPacket.cc index 74ead8c..971bc58 100644 --- a/Packets/MPEGDVBBundle/GREPacket.cc +++ b/Packets/MPEGDVBBundle/GREPacket.cc @@ -41,8 +41,8 @@ prefix_ void senf::GREPacketType::dump(packet p, std::ostream & os) { boost::io::ios_all_saver ias(os); os << "GRE Encapsulation:\n" - << " checksum_present : " << p->checksum_present() << "\n" - << " protocol_type : 0x" << std::hex << p->protocol_type() << "\n" + << " checksum_present : " << p->checksum_present() << "\n" + << " protocol_type : 0x" << std::hex << p->protocol_type() << "\n" ; } diff --git a/Packets/MPEGDVBBundle/MPESection.cc b/Packets/MPEGDVBBundle/MPESection.cc index 0e1c1fe..0130ba7 100644 --- a/Packets/MPEGDVBBundle/MPESection.cc +++ b/Packets/MPEGDVBBundle/MPESection.cc @@ -52,27 +52,27 @@ prefix_ void senf::MPESectionType::dump(packet p, std::ostream & os) boost::io::ios_all_saver ias(os); os << "MPE Section:\n" << std::hex - << " table_id: 0x" << unsigned(p->table_id()) << "\n" - << " section_syntax_indicator: " << p->section_syntax_indicator() << "\n" - << " private_indicator: " << p->private_indicator() << "\n" + << " table_id : 0x" << unsigned(p->table_id()) << "\n" + << " section syntax indicator: " << p->section_syntax_indicator() << "\n" + << " private indicator : " << p->private_indicator() << "\n" << std::dec - << " section_length: " << p->section_length() << "\n" + << " section length : " << p->section_length() << "\n" << std::hex - << " MAC_address_6: 0x" << unsigned(p->mac_addr_6()) << "\n" - << " MAC_address_5: 0x" << unsigned(p->mac_addr_5()) << "\n" - << " payload_scrambling_control: 0x" << p->payload_scrmbl_ctrl() << "\n" - << " address_scrambling_control: 0x" << p-> addr_scrmbl_ctrl() << "\n" - << " LLC_SNAP_flag: 0x" << p->llc_snap_flag() << "\n" - << " current_next_indicator: 0x" << p->curr_next_indicator() << "\n" - << " section_number: 0x" << unsigned(p->section_num()) << "\n" - << " last_section_number: 0x" << unsigned(p->last_section_num()) << "\n" - << " real_time_parameters: \n" - << " delta_t: 0x" << unsigned(p->real_time_parameters().delta_t()) << "\n" - << " table_boundary: 0x" << unsigned(p->real_time_parameters().table_boundary()) << "\n" - << " frame_boundary: 0x" << unsigned(p->real_time_parameters().frame_boundary()) << "\n" - << " address: 0x" << unsigned(p->real_time_parameters().address()) << "\n" + << " MAC address 6 : 0x" << unsigned(p->mac_addr_6()) << "\n" + << " MAC address 5 : 0x" << unsigned(p->mac_addr_5()) << "\n" + << " payload scrambling ctrl : 0x" << p->payload_scrmbl_ctrl() << "\n" + << " address scrambling ctrl : 0x" << p-> addr_scrmbl_ctrl() << "\n" + << " LLC/SNAP flag : 0x" << p->llc_snap_flag() << "\n" + << " current next indicator : 0x" << p->curr_next_indicator() << "\n" + << " section number : 0x" << unsigned(p->section_num()) << "\n" + << " last section number : 0x" << unsigned(p->last_section_num()) << "\n" + << " real time parameters : \n" + << " delta_t : 0x" << unsigned(p->real_time_parameters().delta_t()) << "\n" + << " table boundary : 0x" << unsigned(p->real_time_parameters().table_boundary()) << "\n" + << " frame boundary : 0x" << unsigned(p->real_time_parameters().frame_boundary()) << "\n" + << " address : 0x" << unsigned(p->real_time_parameters().address()) << "\n" << std::dec - << " CRC: " << unsigned(p->crc()) << "\n"; + << " crc : " << unsigned(p->crc()) << "\n"; } prefix_ senf::PacketParserBase::size_type senf::MPESectionType::initSize() diff --git a/Packets/MPEGDVBBundle/SNDUPacket.cc b/Packets/MPEGDVBBundle/SNDUPacket.cc index 96709d0..9590310 100644 --- a/Packets/MPEGDVBBundle/SNDUPacket.cc +++ b/Packets/MPEGDVBBundle/SNDUPacket.cc @@ -90,12 +90,12 @@ prefix_ void senf::SNDUPacketType::dump(packet p, std::ostream & os) { os << "SNDUPacket:\n" << std::dec - << " d_bit: " << p->d_bit() << "\n" - << " length: " << unsigned(p->length()) << "\n" + << " d_bit : " << p->d_bit() << "\n" + << " length : " << unsigned(p->length()) << "\n" << std::hex - << " type: 0x" << unsigned(p->type()) << "\n" + << " type : 0x" << unsigned(p->type()) << "\n" << std::dec - << " crc: " << unsigned(p->crc()) << "\n"; + << " crc : " << unsigned(p->crc()) << "\n"; } prefix_ senf::PacketParserBase::size_type senf::SNDUPacketType::initSize() diff --git a/Packets/MPEGDVBBundle/TransportPacket.cc b/Packets/MPEGDVBBundle/TransportPacket.cc index 15fef02..514d95f 100644 --- a/Packets/MPEGDVBBundle/TransportPacket.cc +++ b/Packets/MPEGDVBBundle/TransportPacket.cc @@ -60,18 +60,18 @@ prefix_ void senf::TransportPacketType::dump(packet p, std::ostream & os) boost::io::ios_all_saver ias(os); os << "TransportPacket:\n" << std::hex - << " syncByte: 0x" << unsigned(p->sync_byte()) << "\n" - << " transport_error_indicator: 0x" << unsigned(p->transport_error_indicator()) << "\n" - << " payload_unit_start_indicator (pusi): 0x" << unsigned(p->pusi()) << "\n" - << " transport_priority: 0x" << unsigned(p->transport_priority()) << "\n" + << " syncByte : 0x" << unsigned(p->sync_byte()) << "\n" + << " transport error ind. : 0x" << unsigned(p->transport_error_indicator()) << "\n" + << " payload unit start ind. : 0x" << unsigned(p->pusi()) << "\n" + << " transport priority : 0x" << unsigned(p->transport_priority()) << "\n" << std::dec - << " pid: " << unsigned(p->pid()) << "\n" + << " pid : " << unsigned(p->pid()) << "\n" << std::hex - << " transport_scrambling_control: 0x" << unsigned(p->transport_scrmbl_ctrl()) << "\n" - << " adaptation_field_control: 0x" << unsigned(p->adaptation_field_ctrl()) << "\n" - << " continuity_counter: 0x" << unsigned(p->continuity_counter()) << "\n"; + << " transport scrambling c. : 0x" << unsigned(p->transport_scrmbl_ctrl()) << "\n" + << " adaptation field ctrl : 0x" << unsigned(p->adaptation_field_ctrl()) << "\n" + << " continuity counter : 0x" << unsigned(p->continuity_counter()) << "\n"; if (p->pusi()) - os << " pointer_field: 0x" << unsigned(p->pointer_field()) << "\n"; + os << " pointer field : 0x" << unsigned(p->pointer_field()) << "\n"; } ///////////////////////////////cc.e//////////////////////////////////////// diff --git a/Scheduler/ClockService.cci b/Scheduler/ClockService.cci index 791a403..c3a766f 100644 --- a/Scheduler/ClockService.cci +++ b/Scheduler/ClockService.cci @@ -56,6 +56,8 @@ prefix_ senf::ClockService::clock_type senf::ClockService::clock_m(abstime_type prefix_ senf::ClockService::abstime_type senf::ClockService::abstime_m(clock_type clock) { + if (clock == 0) + return abstime_type(); if (now() - baseClock_ > 1000000000ll) restart_m(); #ifdef BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG diff --git a/Socket/NetdeviceController.cc b/Socket/NetdeviceController.cc index a8f6a19..fa020d8 100644 --- a/Socket/NetdeviceController.cc +++ b/Socket/NetdeviceController.cc @@ -194,12 +194,10 @@ prefix_ senf::NetdeviceController::SockFd::SockFd() { if ( fd < 0) SENF_THROW_SYSTEM_EXCEPTION("Could not open socket for NetdeviceController."); - std::cerr << ">>Made SockFd: " << fd << std::endl; } prefix_ senf::NetdeviceController::SockFd::~SockFd() { - std::cerr << ">>Dispose SockFd: " << fd << std::endl; ::close(fd); } diff --git a/Socket/SocketHandle.test.cc b/Socket/SocketHandle.test.cc index 0b354ae..bc523a3 100644 --- a/Socket/SocketHandle.test.cc +++ b/Socket/SocketHandle.test.cc @@ -107,7 +107,7 @@ BOOST_AUTO_UNIT_TEST(socketHandle) } // Ensure, the destructor is called and calls the correct close() implementation - BOOST_CHECK_EQUAL( senf::test::SomeSocketProtocol::closeCount(), 1u ); + BOOST_CHECK( senf::test::SomeSocketProtocol::closeCount() > 1u ); } ///////////////////////////////cc.e//////////////////////////////////////// diff --git a/Utils/Console/Executor.cc b/Utils/Console/Executor.cc index 692af69..49e7eb9 100644 --- a/Utils/Console/Executor.cc +++ b/Utils/Console/Executor.cc @@ -114,6 +114,13 @@ prefix_ void senf::console::Executor::execute(std::ostream & output, ls( output, command.commandPath() ); break; + case ParseCommandInfo::BuiltinLL : + if (skipping()) + break; + // The parser ensures, we have either one or no argument + ll( output, command.commandPath() ); + break; + case ParseCommandInfo::BuiltinLR : if (skipping()) break; @@ -233,6 +240,18 @@ prefix_ void senf::console::Executor::cd(ParseCommandInfo::TokensRange dir) prefix_ void senf::console::Executor::ls(std::ostream & output, ParseCommandInfo::TokensRange path) { + Path dir (cwd_); + traverseDirectory(path, dir); + DirectoryNode & node (*dir.back().lock()); + DirectoryNode::child_iterator i (node.children().begin()); + DirectoryNode::child_iterator const i_end (node.children().end()); + for (; i != i_end; ++i) + output << i->first << "\n"; +} + +prefix_ void senf::console::Executor::ll(std::ostream & output, + ParseCommandInfo::TokensRange path) +{ # define HELP_COLUMN 28 unsigned width (senf::console::Client::getWidth(output, 80u, 60u)-(HELP_COLUMN+1)); diff --git a/Utils/Console/Executor.hh b/Utils/Console/Executor.hh index ba4cdce..cb1fab1 100644 --- a/Utils/Console/Executor.hh +++ b/Utils/Console/Executor.hh @@ -140,6 +140,7 @@ namespace console { void cd(ParseCommandInfo::TokensRange dir); void ls(std::ostream & output, ParseCommandInfo::TokensRange dir); + void ll(std::ostream & output, ParseCommandInfo::TokensRange dir); void lr(std::ostream & output, ParseCommandInfo::TokensRange dir); void pushd(ParseCommandInfo::TokensRange dir); void popd(); diff --git a/Utils/Console/Executor.test.cc b/Utils/Console/Executor.test.cc index d4df850..3198490 100644 --- a/Utils/Console/Executor.test.cc +++ b/Utils/Console/Executor.test.cc @@ -96,9 +96,9 @@ BOOST_AUTO_UNIT_TEST(executor) { std::stringstream os; - parser.parse("ls", &setCommand); + parser.parse("ll", &setCommand); executor(os, commands.back()); - BOOST_CHECK_EQUAL( commands.back().builtin(), senf::console::ParseCommandInfo::BuiltinLS ); + BOOST_CHECK_EQUAL( commands.back().builtin(), senf::console::ParseCommandInfo::BuiltinLL ); BOOST_CHECK_EQUAL( os.str(), "dir1/ \n" "dir2/ Helptext\n" @@ -107,9 +107,9 @@ BOOST_AUTO_UNIT_TEST(executor) { std::stringstream os; - parser.parse("ls dir1", &setCommand); + parser.parse("ll dir1", &setCommand); executor(os, commands.back()); - BOOST_CHECK_EQUAL( commands.back().builtin(), senf::console::ParseCommandInfo::BuiltinLS ); + BOOST_CHECK_EQUAL( commands.back().builtin(), senf::console::ParseCommandInfo::BuiltinLL ); BOOST_CHECK_EQUAL( os.str(), "dir3/ \n" ); } @@ -226,9 +226,9 @@ BOOST_AUTO_UNIT_TEST(executorPolicy) { std::stringstream os; - parser.parse("ls dir1", &setCommand); + parser.parse("ll dir1", &setCommand); executor(os, commands.back()); - BOOST_CHECK_EQUAL( commands.back().builtin(), senf::console::ParseCommandInfo::BuiltinLS ); + BOOST_CHECK_EQUAL( commands.back().builtin(), senf::console::ParseCommandInfo::BuiltinLL ); BOOST_CHECK_EQUAL( os.str(), "dir3/ \n" ); } diff --git a/Utils/Console/Parse.cc b/Utils/Console/Parse.cc index 5281be5..8723510 100644 --- a/Utils/Console/Parse.cc +++ b/Utils/Console/Parse.cc @@ -76,6 +76,11 @@ namespace detail { info_->builtin(ParseCommandInfo::BuiltinLS); setBuiltinPathArg(path); } + void builtin_ll(std::vector & path) + { info_->clear(); + info_->builtin(ParseCommandInfo::BuiltinLL); + setBuiltinPathArg(path); } + void builtin_lr(std::vector & path) { info_->clear(); info_->builtin(ParseCommandInfo::BuiltinLR); diff --git a/Utils/Console/Parse.hh b/Utils/Console/Parse.hh index e7712e0..59670ed 100644 --- a/Utils/Console/Parse.hh +++ b/Utils/Console/Parse.hh @@ -366,6 +366,7 @@ namespace console { enum BuiltinCommand { NoBuiltin, BuiltinCD, BuiltinLS, + BuiltinLL, BuiltinLR, BuiltinPUSHD, BuiltinPOPD, diff --git a/Utils/Console/Parse.ih b/Utils/Console/Parse.ih index 00745cc..fe95008 100644 --- a/Utils/Console/Parse.ih +++ b/Utils/Console/Parse.ih @@ -220,6 +220,9 @@ namespace detail { | self.keyword_p("ls") >> ! path >> eps_p [ bind(&PD::builtin_ls)(d_, path_) ] + | self.keyword_p("ll") + >> ! path + >> eps_p [ bind(&PD::builtin_ll)(d_, path_) ] | self.keyword_p("lr") >> ! path >> eps_p [ bind(&PD::builtin_lr)(d_, path_) ] diff --git a/Utils/Console/Parse.test.cc b/Utils/Console/Parse.test.cc index bbc2c68..fd15211 100644 --- a/Utils/Console/Parse.test.cc +++ b/Utils/Console/Parse.test.cc @@ -66,6 +66,8 @@ namespace { os_ << "builtin_cd( " << senf::stringJoin(path, "/") << " )\n"; } void builtin_ls(std::vector const & path) { os_ << "builtin_ls( " << senf::stringJoin(path, "/") << " )\n"; } + void builtin_ll(std::vector const & path) + { os_ << "builtin_ll( " << senf::stringJoin(path, "/") << " )\n"; } void builtin_lr(std::vector const & path) { os_ << "builtin_lr( " << senf::stringJoin(path, "/") << " )\n"; } void builtin_exit() diff --git a/Utils/Console/ParsedCommand.test.cc b/Utils/Console/ParsedCommand.test.cc index b9c095a..54c9f7c 100644 --- a/Utils/Console/ParsedCommand.test.cc +++ b/Utils/Console/ParsedCommand.test.cc @@ -301,7 +301,7 @@ BOOST_AUTO_UNIT_TEST(directoryReturn) { std::stringstream ss; SENF_CHECK_NO_THROW( - parser.parse("test/test { ls; }", + parser.parse("test/test { ll; }", boost::bind( boost::ref(executor), boost::ref(ss), _1 )) ); BOOST_CHECK_EQUAL( ss.str(), "\n" diff --git a/Utils/Console/UDPServer.test.cc b/Utils/Console/UDPServer.test.cc index 1aa61fb..8617926 100644 --- a/Utils/Console/UDPServer.test.cc +++ b/Utils/Console/UDPServer.test.cc @@ -71,7 +71,7 @@ BOOST_AUTO_UNIT_TEST(udpServer) nread = 0; flags = 0; data = ""; - socket.write("ls"); + socket.write("ll"); timer.timeout(delay(300)); senf::scheduler::process(); BOOST_CHECK_EQUAL( nread, 1 ); @@ -104,7 +104,7 @@ BOOST_AUTO_UNIT_TEST(udpServer) nread = 0; flags = 0; data = ""; - socket.write("ls"); + socket.write("ll"); timer.timeout(delay(300)); senf::scheduler::process(); BOOST_CHECK_EQUAL( nread, 1 );