('<ext/algorithm>', '__gnu_cxx::copy_n', 'GNUCXX') ]
for include, name, define in versions:
ret = context.TryCompile("#include %s\n"
- "int main(int,char**) { int *a,*b; %s(a,0,b); }\n"
+ "int main(int,char**) { int *a (NULL); int *b (NULL); %s(a,0,b); }\n"
% (include, name),
".cc")
if ret:
'--param','large-function-growth=10000',
'--param', 'large-function-insns=10000',
'--param','inline-unit-growth=10000' ],
- INLINE_OPTS_NORMAL = [ '-finline-limit=5000', '--param', 'inline-unit-growth=60' ],
- INLINE_OPTS = [ '$INLINE_OPTS_NORMAL' ],
+ INLINE_OPTS_GCC = [ '-finline-limit=5000', '--param', 'inline-unit-growth=60' ],
+ INLINE_OPTS = [ '${str(CXX).split("/")[-1] == "g++" and "$INLINE_OPTS_GCC" or None}' ],
+ CXXFLAGS_CLANG = [ '-Wno-unneeded-internal-declaration' ], # needed for BOOST_PARAMETER_KEYWORD
CXXFLAGS = [ '-Wall', '-Woverloaded-virtual', '-Wno-long-long', '$INLINE_OPTS',
'-pipe', '$CXXFLAGS_', '-fno-strict-aliasing',
- "${profile and '-pg' or None}" ],
+ "${profile and '-pg' or None}",
+ '${str(CXX).split("/")[-1] == "clang++" and "$CXXFLAGS_CLANG" or None}' ],
CXXFLAGS_final = [ '-O3', '-fno-threadsafe-statics','-fno-stack-protector',
"${profile and ' ' or '-ffunction-sections'}" ],
CXXFLAGS_normal = [ '-O2', '-g' ],
env.Append(LIBS = [ '$LIBSENF$LIBADDSUFFIX',
'$BOOSTREGEXLIB', '$BOOSTSIGNALSLIB',
- '$BOOSTFSLIB', '$BOOSTSYSTEMLIB' ])
+ '$BOOSTFSLIB', '$BOOSTSYSTEMLIB', '$BOOSTDATETIMELIB' ])
###########################################################################
RouteInfoBase routes_;
template <class Source, class Target>
- friend class detail::RouteHelper;
+ friend struct detail::RouteHelper;
friend class senf::ppi::ModuleManager;
friend class connector::Connector;
friend class senf::ppi::detail::EventBindingBase;
#ifndef DOXYGEN
struct RunGuard;
- friend class RunGuard;
+ friend struct RunGuard;
#endif
ModuleRegistry moduleRegistry_;
senf::console::ScopedDirectory<> consoleDir_;
friend class module::Module;
- friend class Initializable;
+ friend struct Initializable;
};
}}
namespace module {
- namespace detail { class MultiConnectorMixinAccess; }
+ namespace detail { struct MultiConnectorMixinAccess; }
/** \brief Multi-Connector management
void disconnected(ConnectorType_ const & c);
- friend class detail::MultiConnectorMixinAccess;
+ friend struct detail::MultiConnectorMixinAccess;
friend class detail::MultiConnectorWrapper<Self_,ConnectorType_>;
ContainerType_ connectors_;
void disconnected(ConnectorType_ const & c);
- friend class detail::MultiConnectorMixinAccess;
+ friend struct detail::MultiConnectorMixinAccess;
friend class detail::MultiConnectorWrapper<Self_,ConnectorType_>;
ContainerType_ connectors_;
void disconnected(ConnectorType_ const & c);
- friend class detail::MultiConnectorMixinAccess;
+ friend struct detail::MultiConnectorMixinAccess;
friend class detail::MultiConnectorWrapper<Self_,ConnectorType_>;
};
BOOST_CHECK_EQUAL( data, input );
}
- runPPI( senf::ClockService::milliseconds(250));
+ runPPI( senf::ClockService::milliseconds(500));
BOOST_CHECK_EQUAL( udpSink.qAlgorithm().size(), 0);
}
namespace {
unsigned calls (0u);
- float ppss[] = { 13.333333f, 20.f, 13.333333f, 20.f, 13.333333f, 20.f };
float pps;
float bps;
void collectPPS(float packetsPerSecond)
{
+ static float ppss[] = { 13.333333f, 20.f, 13.333333f, 20.f, 13.333333f, 20.f };
// 2 + 3 + 2 + 3 + 2 + 3 packets / interval
// -> 13.333333 + 20. + 13.333333 + 20. + 13.333333 + 20. / 6 pps
// -> 16.666666 pps
ForwardingRouteImplementation(module::Module & module, Source & source, Target & target)
: Base(module,source,target)
{
- registerRoute(source);
- registerRoute(target);
+ Base::registerRoute(source);
+ Base::registerRoute(target);
}
template <class Source, class Target>
senf::ppi::detail::ForwardingRouteImplementation<Source,Target>::
~ForwardingRouteImplementation()
{
- unregisterRoute(this->source());
- unregisterRoute(this->target());
+ Base::unregisterRoute(this->source());
+ Base::unregisterRoute(this->target());
}
//-/////////////////////////////////////////////////////////////////////////////////////////////////
return (boost::format("localhost:%d") % port(i)).str();
}
- std::string localhost6str(unsigned i)
- {
- return (boost::format("[::1]:%d") % port(i)).str();
- }
}
SENF_AUTO_UNIT_TEST(passiveSocketSink)
return (boost::format("localhost:%d") % port(i)).str();
}
- std::string localhost6str(unsigned i)
- {
- return (boost::format("[::1]:%d") % port(i)).str();
- }
}
SENF_AUTO_UNIT_TEST(socketSource)
namespace module {
class Module;
namespace detail {
- template <class Source, class Target> class RouteHelper;
+ template <class Source, class Target> struct RouteHelper;
}
class PassiveJoin;
class PriorityJoin;
SENF_PARSER_FINALIZE ( RadiotapPacketParser_Flags );
- friend class RadiotapPacketParser;
+ friend struct RadiotapPacketParser;
};
/** \brief Parse in Radiotap Header channel frequency and flag field
static OffsetMap offsetMap_;
OffsetTable const * currentTable_;
- friend class RadiotapPacketType;
+ friend struct RadiotapPacketType;
};
/** \brief Radiotap packet
MACAddressParser destinationAddress() const;
MACAddressParser bssid() const;
- friend class WLANPacket_DataFrameType;
+ friend struct WLANPacket_DataFrameType;
};
/** \brief WLAN Data frame packet
version_() = 1;
}
- friend class MIHPacketType;
+ friend struct MIHPacketType;
};
/** \brief MIH packet
//typename boost::range_difference<ForwardReadableRange>::type rangeSize ( boost::size(range));
unsigned rangeSize ( boost::size(range));
if ( rangeSize != this->length() )
- resize( bytes(), rangeSize + senf::bytes(self()) );
+ Base::resize( bytes(), rangeSize + senf::bytes(self()) );
std::copy( boost::begin(range), boost::end(range), boost::next(
this->i(), senf::bytes( self())) );
this->length_() = rangeSize;
data_iterator i (AuxPolicy::WrapperPolicy::adjust(c.i(), c.state()));
data_iterator j (i);
for (size_type n (n_); n; --n, std::advance(j,senf::bytes(ElementParser(j,c.state())))) ;
- aux( std::distance(i,j), c.i(), c.state() );
+ AuxPolicy::WrapperPolicy::aux( std::distance(i,j), c.i(), c.state() );
#else
- aux ( aux(c.i(),c.state()) + c.data().size() - container_size_, c.i(), c.state() );
+ AuxPolicy::WrapperPolicy::aux( aux(c.i(),c.state()) + c.data().size() - container_size_, c.i(), c.state() );
#endif
container_size_ = c.data().size();
}
setEnd(container_type const & c, iterator_data & d)
const
{
- return boost::next(AuxPolicy::WrapperPolicy::adjust(c.i(), c.state()),aux(c.i(),c.state()));
+ return boost::next(AuxPolicy::WrapperPolicy::adjust(c.i(), c.state()),AuxPolicy::WrapperPolicy::aux(c.i(),c.state()));
}
template <class ElementParser, class AuxPolicy>
private:
friend class boost::iterator_core_access;
- template <class P> friend class ListParser_Container;
+ friend class ListParser_Container<typename Container::policy>;
value_type dereference() const;
bool equal(ListParser_Iterator const & other) const;
UInt32Parser crc() const { return parse<UInt32Parser>( data().size()-4 ); }
boost::uint32_t calcCrc() const;
- friend class MPESectionType;
+ friend struct MPESectionType;
private:
typedef boost::crc_optimal<32, 0x04C11DB7, 0xFFFFFFFF, 0, false, false> crc32_t;
std::ostream & operator<<(std::ostream & os, ComplexEmptyAnnotation const & v)
{ os << "(empty)"; return os; }
- struct InvalidAnnotation
- {
- std::string value;
- };
-
- std::ostream & operator<<(std::ostream & os, InvalidAnnotation const & v)
- { os << v.value; return os; }
-
}
SENF_AUTO_UNIT_TEST(packet)
#ifdef COMPILE_CHECK
+namespace {
+ struct InvalidAnnotation
+ {
+ std::string value;
+ };
+
+ std::ostream & operator<<(std::ostream & os, InvalidAnnotation const & v)
+ { os << v.value; return os; }
+}
+
COMPILE_FAIL(invalidAnnotation)
{
#if 0 // The traits check fails for user defined but trivial constructors so ...
// virtual interface
template <class PacketType>
-prefix_ typename senf::PacketInterpreter<PacketType>::optional_range
+prefix_ senf::PacketInterpreterBase::optional_range
senf::PacketInterpreter<PacketType>::v_nextPacketRange()
{
return type::nextPacketRange(ConcretePacket<PacketType>(ptr(this)));
}
template <class PacketType>
-prefix_ typename senf::PacketInterpreter<PacketType>::factory_t
+prefix_ senf::PacketInterpreterBase::factory_t
senf::PacketInterpreter<PacketType>::v_factory()
{
return factory();
}
template <class PacketType>
-prefix_ typename senf::PacketInterpreter<PacketType>::factory_t
+prefix_ senf::PacketInterpreterBase::factory_t
senf::PacketInterpreter<PacketType>::v_nextPacketType()
{
return type::nextPacketType(ConcretePacket<PacketType>(ptr(this)));
// senf::PacketInterpreter<PacketType>
template <class PacketType>
-prefix_ typename senf::PacketInterpreter<PacketType>::factory_t
+prefix_ senf::PacketInterpreterBase::factory_t
senf::PacketInterpreter<PacketType>::factory()
{
return & factory_;
// PacketType access
template <class PacketType>
-prefix_ typename senf::PacketInterpreter<PacketType>::size_type
+prefix_ senf::PacketInterpreterBase::size_type
senf::PacketInterpreter<PacketType>::initSize()
{
return type::initSize();
}
template <class PacketType>
-prefix_ typename senf::PacketInterpreter<PacketType>::size_type
+prefix_ senf::PacketInterpreterBase::size_type
senf::PacketInterpreter<PacketType>::initHeadSize()
{
size_type sz (type::initHeadSize());
namespace senf {
template <class PacketType> class PacketInterpreter;
+
+ void intrusive_ptr_add_ref(PacketInterpreterBase const * p);
+ void intrusive_ptr_release(PacketInterpreterBase const * p);
+
/** \brief Internal: Base packet interpreter class
\internal
friend class detail::PacketImpl;
friend class intrusive_refcount_base;
template <class PacketType> friend class PacketInterpreter;
- friend class detail::packet::test::TestDriver;
+ friend struct detail::packet::test::TestDriver;
friend class PacketParserBase;
friend void senf::intrusive_ptr_add_ref(PacketInterpreterBase const *);
friend void senf::intrusive_ptr_release(PacketInterpreterBase const *);
};
- void intrusive_ptr_add_ref(PacketInterpreterBase const * p);
- void intrusive_ptr_release(PacketInterpreterBase const * p);
-
/** \brief Internal: Concrete packet interpreter
\internal
static const FactoryImpl factory_;
- friend class detail::packet::test::TestDriver;
+ friend struct detail::packet::test::TestDriver;
friend class PacketInterpreterBase;
- friend class FactoryImpl;
+ friend struct FactoryImpl;
};
/** \brief Invalid packet chain operation
PacketData * data_;
template <class Parser> friend class SafePacketParserWrapper;
- friend class ParserProtector;
+ friend struct ParserProtector;
};
/** \brief Return raw size parsed by the given parser object
template <class Parser>
PacketParserBase::size_type bytes(Parser const & p);
- namespace detail { template <class Parser> class ParserInitBytes; }
- namespace detail { template <class Parser> class ParserIsFixed; }
+ namespace detail { template <class Parser> struct ParserInitBytes; }
+ namespace detail { template <class Parser> struct ParserIsFixed; }
/** \brief Return number of bytes to allocate to new object of given type
std::greater<int> > >,
boost::multi_index::ordered_unique<
boost::multi_index::tag<ByType>,
- boost::multi_index::mem_fun<Entry const,std::type_info const &,&Entry::type>,
+ boost::multi_index::const_mem_fun<Entry,std::type_info const &,&Entry::type>,
TypeInfoCompare> >
{};
namespace test {
- class TestDriver;
+ struct TestDriver;
}}}}
size_type oldSize( bytes() );
typedef typename boost::mpl::at<parsers, boost::mpl::int_<N> >::type NewParser;
- if (oldSize < senf::init_bytes<NewParser>::value) {
+ if (oldSize <= senf::init_bytes<NewParser>::value) {
data_iterator j (i());
std::advance(j, oldSize);
std::fill(i(), j, 0u);
template <BOOST_PP_CAT(name, _chooser_value_type) (*KeyFn)()> \
struct BOOST_PP_CAT(name, _key_value_template) \
: public senf::detail::VariantKey<BOOST_PP_CAT(name, _chooser_value_type), KeyFn> {}; \
- template <class T, T (*K)()> friend class senf::detail::VariantKey; \
+ template <class T, T (*K)()> friend struct senf::detail::VariantKey; \
typedef senf::detail::VariantKeyTransform< \
BOOST_PP_CAT(name,_chooser_value_type), \
boost::mpl::vector< \
prefix_ void senf::VectorParser<ElementParser,AuxPolicy>::init()
const
{
- aux(0, i(), state());
+ AuxPolicy::aux(0, i(), state());
iterator i (begin());
iterator const e (end());
for (; i!=e; ++i)
{}
template <class ElementParser, class AuxPolicy>
-prefix_ typename senf::VectorParser<ElementParser,AuxPolicy>::size_type
+prefix_ senf::PacketInterpreterBase::size_type
senf::VectorParser<ElementParser,AuxPolicy>::bytes()
const
{
// Container interface
template <class ElementParser, class AuxPolicy>
-prefix_ typename senf::VectorParser<ElementParser,AuxPolicy>::size_type
+prefix_ senf::PacketInterpreterBase::size_type
senf::VectorParser<ElementParser,AuxPolicy>::size()
const
{
- return aux(i(),state());
+ return AuxPolicy::aux(i(),state());
}
template <class ElementParser, class AuxPolicy>
senf::VectorParser<ElementParser,AuxPolicy>::begin()
const
{
- return iterator(adjust(i(),state()),state());
+ return iterator(AuxPolicy::adjust(i(),state()),state());
}
template <class ElementParser, class AuxPolicy>
senf::VectorParser_Container<ElementParser,AuxPolicy>::size()
const
{
- return aux(i(),state());
+ return AuxPolicy::WrapperPolicy::aux(i(),state());
}
template <class ElementParser, class AuxPolicy>
senf::VectorParser_Container<ElementParser,AuxPolicy>::begin()
const
{
- return iterator(adjust(i(),state()),state());
+ return iterator( AuxPolicy::WrapperPolicy::adjust(i(),state()),state());
}
template <class ElementParser, class AuxPolicy>
template <class ElementParser, class AuxPolicy>
prefix_ void senf::VectorParser_Container<ElementParser,AuxPolicy>::setSize(size_type value)
{
- aux(value, i(),state());
+ AuxPolicy::WrapperPolicy::aux(value, i(),state());
}
//-/////////////////////////////////////////////////////////////////////////////////////////////////
: public singleton<FIFORunner>
{
public:
- struct TaskInfo;
+ class TaskInfo;
private:
struct TaskListTag;
int events_;
int signaledEvents_;
- friend class detail::FdSetCompare;
+ friend struct detail::FdSetCompare;
friend class detail::FdDispatcher;
friend class detail::FileDispatcher;
};
typedef boost::intrusive::iset_base_hook<SignalSetTag> SignalSetBase;
struct SignalSetCompare;
struct FindNumericSignal;
- struct SignalDispatcher;
+ class SignalDispatcher;
}
/** \brief UNIX signal event
Callback cb_;
siginfo_t siginfo_;
- friend class detail::SignalSetCompare;
- friend class detail::FindNumericSignal;
+ friend struct detail::SignalSetCompare;
+ friend struct detail::FindNumericSignal;
friend class detail::SignalDispatcher;
};
ClockService::clock_type timeout_;
friend class detail::TimerDispatcher;
- friend class detail::TimerSetCompare;
+ friend struct detail::TimerSetCompare;
};
}}
tm.timeout(randomDelay());
}
- void preCb()
- {
- haveCb = false;
- }
-
- void postCb()
- {
- if (! haveCb)
- std::cerr << senf::scheduler::now() << '\n';
- }
-
- void idleCb(senf::scheduler::TimerEvent & tm)
- {
- tm.timeout( senf::scheduler::now());
- }
+// void preCb()
+// {
+// haveCb = false;
+// }
+//
+// void postCb()
+// {
+// if (! haveCb)
+// std::cerr << senf::scheduler::now() << '\n';
+// }
+//
+// void idleCb(senf::scheduler::TimerEvent & tm)
+// {
+// tm.timeout( senf::scheduler::now());
+// }
void jitterTest()
{
// senf::ClientSocketHandle<SPolicy>::read
#ifndef DOXYGEN
+
template <class SPolicy>
template <class ForwardWritableRange>
-prefix_ typename boost::range_iterator<ForwardWritableRange>::type
-senf::ClientSocketHandle<SPolicy>::
-read(ForwardWritableRange const & range,
- typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned> >::type *)
+prefix_ typename boost::disable_if<boost::is_convertible<ForwardWritableRange,unsigned>,
+typename boost::range_iterator<ForwardWritableRange>::type>::type
+senf::ClientSocketHandle<SPolicy>::read(ForwardWritableRange const & range)
{
return detail::ReadRange<
ClientSocketHandle<SPolicy>,
#ifndef DOXYGEN
template <class SPolicy>
template <class ForwardWritableRange>
-prefix_ typename boost::range_iterator<ForwardWritableRange>::type
-senf::ClientSocketHandle<SPolicy>::
-read(ForwardWritableRange & range,
- typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned> >::type *)
+prefix_ typename boost::disable_if<boost::is_convertible<ForwardWritableRange,unsigned>,
+typename boost::range_iterator<ForwardWritableRange>::type>::type
+senf::ClientSocketHandle<SPolicy>::read(ForwardWritableRange & range)
{
return detail::ReadRange<
ClientSocketHandle<SPolicy>,
\c recv.
*/
std::string read (unsigned limit=0);
- template <class ForwardWritableRange>
+
# ifndef DOXYGEN
- typename boost::range_iterator<ForwardWritableRange>::type
- read (ForwardWritableRange const & range,
- typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned> >::type * = 0);
+ template <class ForwardWritableRange>
+ typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned>,
+ typename boost::range_iterator<ForwardWritableRange>::type>::type
+ read(ForwardWritableRange const & range);
# else
+ template <class ForwardWritableRange>
typename boost::range_iterator<ForwardWritableRange>::type
read (ForwardWritableRange const & range);
///< Read data into range
# endif
# ifndef DOXYGEN
template <class ForwardWritableRange>
- typename boost::range_iterator<ForwardWritableRange>::type
- read (ForwardWritableRange & range,
- typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned> >::type * = 0);
+ typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned>,
+ typename boost::range_iterator<ForwardWritableRange>::type>::type
+ read(ForwardWritableRange & range);
# else
template <class ForwardWritableRange>
typename boost::range_iterator<ForwardWritableRange>::type
namespace senf {
- class MACAddress;
+ struct MACAddress;
/** \brief Netdevice Controller
prefix_ senf::ProtocolClientSocketHandle<SocketProtocol>
senf::ProtocolClientSocketHandle<SocketProtocol>::cast_dynamic(FileHandle handle)
{
- ClientSocketHandle<typename SocketProtocol::Policy> h(
+ ClientSocketHandle<typename SocketProtocol::Policy> h (
ClientSocketHandle<typename SocketProtocol::Policy>::cast_dynamic(handle));
// throw std::bad_cast if the protocol is invalid
- dynamic_cast<SocketProtocol const &>(static_cast<SocketBody&>(FileHandle::body(h)).protocol());
+ IGNORE( dynamic_cast<SocketProtocol const &>(static_cast<SocketBody&>(FileHandle::body(h)).protocol()) );
return cast_static(handle);
}
prefix_ senf::ProtocolServerSocketHandle<SocketProtocol>
senf::ProtocolServerSocketHandle<SocketProtocol>::cast_dynamic(FileHandle handle)
{
- ServerSocketHandle<typename SocketProtocol::Policy> h(
+ ServerSocketHandle<typename SocketProtocol::Policy> h (
ServerSocketHandle<typename SocketProtocol::Policy>::cast_dynamic(handle));
// throw std::bad_cast if the protocol is invalid
- dynamic_cast<SocketProtocol const &>(static_cast<SocketBody&>(FileHandle::body(h)).protocol());
+ IGNORE( dynamic_cast<SocketProtocol const &>(static_cast<SocketBody&>(FileHandle::body(h)).protocol()) );
return cast_static(handle);
}
namespace senf {
- class EUI64;
- class MACAddress;
+ struct EUI64;
+ struct MACAddress;
class INet6Network;
/** \brief INet6 network address
#include <sys/types.h>
#include <sys/ioctl.h>
-#include <sys/wait.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "RawINetSocketHandle.hh"
-#include <iostream>
+#include "net.test.hh"
#include <senf/Utils/auto_unit_test.hh>
#include <boost/test/test_tools.hpp>
-namespace {
-
- void error(char const * fn, char const * proc="")
- {
- std::cerr << "\n" << proc << ((*proc)?": ":"") << fn << ": " << strerror(errno) << std::endl;
- }
-
- void fail(char const * proc, char const * fn)
- {
- error(fn,proc);
- _exit(1);
- }
-
- int server_pid = 0;
-
- void start(void (*fn)())
- {
- server_pid = ::fork();
- if (server_pid < 0) BOOST_FAIL("fork()");
- if (server_pid == 0) {
- (*fn)();
- _exit(0);
- }
- }
-
- void wait()
- {
- int status;
- if (waitpid(server_pid,&status,0)<0)
- BOOST_FAIL("waitpid()");
- BOOST_CHECK_EQUAL( status , 0 );
- }
-
- void stop()
- {
- if (server_pid) {
- kill(server_pid,9);
- wait();
- server_pid = 0;
- }
- }
-
-}
-
//-/////////////////////////////////////////////////////////////////////////////////////////////////
+using namespace senf::test;
+
namespace {
void server_v4() //listen for packets with proto=47 (GRE) and resend them with proto=48
#define prefix_
//-/////////////////////////////////////////////////////////////////////////////////////////////////
-//-/////////////////////////////////////////////////////////////////////////////////////////////////
+using namespace senf::test;
namespace {
#define prefix_
//-/////////////////////////////////////////////////////////////////////////////////////////////////
-//-/////////////////////////////////////////////////////////////////////////////////////////////////
+using namespace senf::test;
namespace {
if (close(sock) < 0) fail("server_v4","close()");
}
- void server_v6()
- {
- int sock = socket(PF_INET6,SOCK_DGRAM,0);
- if (sock<0) fail("server_v6","socket()");
- struct sockaddr_in6 sin;
- ::memset(&sin,0,sizeof(sin));
- sin.sin6_family = AF_INET6;
- sin.sin6_port = htons(port(0));
- sin.sin6_addr = in6addr_loopback;
- if (bind(sock,(struct sockaddr *)&sin,sizeof(sin))<0) fail("server_v6","bind()");
-
- sin.sin6_port = htons(port(1));
- char buffer[1024];
- while (1) {
- int n = read(sock,buffer,1024);
- if (n == 4 && strncmp(buffer,"QUIT",4) == 0)
- break;
- sendto(sock,buffer,n,0,(struct sockaddr *)&sin,sizeof(sin));
- }
-
- if (close(sock) < 0) fail("server_v6","close()");
- }
+// void server_v6()
+// {
+// int sock = socket(PF_INET6,SOCK_DGRAM,0);
+// if (sock<0) fail("server_v6","socket()");
+// struct sockaddr_in6 sin;
+// ::memset(&sin,0,sizeof(sin));
+// sin.sin6_family = AF_INET6;
+// sin.sin6_port = htons(port(0));
+// sin.sin6_addr = in6addr_loopback;
+// if (bind(sock,(struct sockaddr *)&sin,sizeof(sin))<0) fail("server_v6","bind()");
+//
+// sin.sin6_port = htons(port(1));
+// char buffer[1024];
+// while (1) {
+// int n = read(sock,buffer,1024);
+// if (n == 4 && strncmp(buffer,"QUIT",4) == 0)
+// break;
+// sendto(sock,buffer,n,0,(struct sockaddr *)&sin,sizeof(sin));
+// }
+//
+// if (close(sock) < 0) fail("server_v6","close()");
+// }
}
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2009
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+//
+// The contents of this file are subject to the Fraunhofer FOKUS Public License
+// Version 1.0 (the "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+// http://senf.berlios.de/license.html
+//
+// The Fraunhofer FOKUS Public License Version 1.0 is based on,
+// but modifies the Mozilla Public License Version 1.1.
+// See the full license text for the amendments.
+//
+// Software distributed under the License is distributed on an "AS IS" basis,
+// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+// for the specific language governing rights and limitations under the License.
+//
+// The Original Code is Fraunhofer FOKUS code.
+//
+// The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
+// (registered association), Hansastraße 27 c, 80686 Munich, Germany.
+// All Rights Reserved.
+//
+// Contributor(s):
+// Stefan Bund <g0dil@berlios.de>
+
+/** \file
+ \brief net.test public header */
+
+#include "net.test.hh"
+
+// Custom includes
+#include <iostream>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <boost/format.hpp>
+#include <senf/Utils/auto_unit_test.hh>
+#include <boost/test/test_tools.hpp>
+
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
+namespace {
+ int base_pid = 0;
+ int server_pid = 0;
+}
+
+void senf::test::error(char const * fn, char const * proc)
+{
+ std::cerr << "\n" << proc << ((*proc)?": ":"") << fn << ": " << strerror(errno) << std::endl;
+}
+
+void senf::test::fail(char const * proc, char const * fn)
+{
+ error(fn,proc);
+ _exit(1);
+}
+
+void senf::test::start(void (*fn)())
+{
+ if (! base_pid)
+ base_pid = ::getpid();
+ server_pid = ::fork();
+ if (server_pid < 0) BOOST_FAIL("fork()");
+ if (server_pid == 0) {
+ signal(SIGCHLD, SIG_IGN);
+ (*fn)();
+ _exit(0);
+ }
+ signal(SIGCHLD, SIG_DFL);
+ sleep(1);
+}
+
+void senf::test::wait()
+{
+ int status;
+ if (waitpid(server_pid,&status,0)<0)
+ BOOST_FAIL("waitpid()");
+ BOOST_CHECK_EQUAL( status , 0 );
+}
+
+void senf::test::stop()
+{
+ if (server_pid) {
+ kill(server_pid,9);
+ wait();
+ server_pid = 0;
+ }
+}
+
+unsigned senf::test::port(unsigned i)
+{
+ if (! base_pid)
+ base_pid = ::getpid();
+ return 23456u + (((base_pid^(base_pid>>8)^(base_pid>>16)^(base_pid>>24))&0xff)<<2) + i;
+}
+
+std::string senf::test::localhost4str(unsigned i)
+{
+ return (boost::format("localhost:%d") % port(i)).str();
+}
+
+std::string senf::test::localhost6str(unsigned i)
+{
+ return (boost::format("[::1]:%d") % port(i)).str();
+}
+
+
+//-/////////////////////////////////////////////////////////////////////////////////////////////////
+//#include "net.test.cci"
+//#include "net.test.ct"
+//#include "net.test.cti"
+
+\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:
#define HH_SENF_senf_Socket_Protocols_INet_net_test_ 1
// Custom includes
-#include <boost/format.hpp>
-#include <boost/test/test_tools.hpp>
+#include <string>
-//#include "net.test.mpp"
//-/////////////////////////////////////////////////////////////////////////////////////////////////
-namespace {
-
- void error(char const * fn, char const * proc="")
- {
- std::cerr << "\n" << proc << ((*proc)?": ":"") << fn << ": " << strerror(errno) << std::endl;
- }
-
- void fail(char const * proc, char const * fn)
- {
- error(fn,proc);
- _exit(1);
- }
-
- int base_pid = 0;
- int server_pid = 0;
-
- void start(void (*fn)())
- {
- if (! base_pid)
- base_pid = ::getpid();
- server_pid = ::fork();
- if (server_pid < 0) BOOST_FAIL("fork()");
- if (server_pid == 0) {
- signal(SIGCHLD, SIG_IGN);
- (*fn)();
- _exit(0);
- }
- signal(SIGCHLD, SIG_DFL);
- sleep(1);
- }
-
- void wait()
- {
- int status;
- if (waitpid(server_pid,&status,0)<0)
- BOOST_FAIL("waitpid()");
- BOOST_CHECK_EQUAL( status , 0 );
- }
-
- void stop()
- {
- if (server_pid) {
- kill(server_pid,9);
- wait();
- server_pid = 0;
- }
- }
-
- unsigned port(unsigned i)
- {
- if (! base_pid)
- base_pid = ::getpid();
- return 23456u + (((base_pid^(base_pid>>8)^(base_pid>>16)^(base_pid>>24))&0xff)<<2) + i;
- }
-
- std::string localhost4str(unsigned i)
- {
- return (boost::format("localhost:%d") % port(i)).str();
- }
-
- std::string localhost6str(unsigned i)
- {
- return (boost::format("[::1]:%d") % port(i)).str();
- }
-
-}
+namespace senf {
+namespace test {
+
+ void error(char const * fn, char const * proc="");
+
+ void fail(char const * proc, char const * fn);
+
+ void start(void (*fn)());
+
+ void wait();
+
+ void stop();
+
+ unsigned port(unsigned i);
+
+ std::string localhost4str(unsigned i);
+
+ std::string localhost6str(unsigned i);
+
+}}
//-/////////////////////////////////////////////////////////////////////////////////////////////////
//#include "net.test.cci"
namespace senf {
- class MACAddress;
+ struct MACAddress;
/** \brief EUI-64 data type
\ingroup addr_group
*/
- class EUI64
+ struct EUI64
: public boost::array<boost::uint8_t,8>,
public senf::comparable_safe_bool<EUI64>
{
- public:
//-////////////////////////////////////////////////////////////////////////
///\name Structors and default members
//\{
static EUI64 const None; ///< The empty (0) address
- // default copy constructor
- // default copy assignment
- // default destructor
- // no conversion constructors
-
explicit EUI64(boost::uint64_t v=0u); ///< Construct EUI-64
explicit EUI64(senf::NoInit_t); ///< Construct <em>uninitialized</em> EUI-64
namespace senf {
- class EUI64;
+ struct EUI64;
/** \brief Ethernet MAC address
//-/////////////////////////////////////////////////////////////////////////////////////////////////
// senf::detail::StateMapOrdering
-namespace {
- bool contains(std::string::const_iterator b, std::string::const_iterator e, char c)
- {
- for (; b != e; ++b)
- if (*b == c)
- return true;
- return false;
- }
-}
-
prefix_ std::string senf::detail::dumpState(SocketStateMap const & map)
{
std::stringstream s;
// for two reasons:
// a) since the handle is passed back by value, we cannot return
// something like a null handle
- // b) it is simpler to implement cast_dynamic throwig bad_cast on
+ // b) it is simpler to implement cast_dynamic throwing bad_cast on
// failure than implementing cast_check
try {
Target::cast_dynamic(handle);
/// \addtogroup protocol_group
//\{
- class SocketPolicyBase;
+ struct SocketPolicyBase;
/** \brief Socket Protocol base class
///\name Structors and default members
//\{
- explicit ConfigFile(std::string const & filename, DirectoryNode & root = root());
+ explicit ConfigFile(std::string const & filename, DirectoryNode & root = senf::console::root());
///< Create ConfigFile object for \a filename
/**< The \a filename configuration file will be parsed using
parse() calls. All configuration statements will be
\related ConfigFile
*/
- void parseFile(std::string const & filename, DirectoryNode & root = root());
+ void parseFile(std::string const & filename, DirectoryNode & root = senf::console::root());
/** \brief ConfigBundle source reading a configuration file
for (; k != k_end; ++k)
if (k->name == arg.name && k->defaultValue == arg.defaultValue) {
if (! arg.doc.empty() && k->doc.empty()) {
- k->doc == arg.doc;
+ k->doc = arg.doc;
haveDocumentedArg = true;
}
break;
#endif
template <>
- struct position_policy<senf::console::detail::FilePositionWithIndex>
+ class position_policy<senf::console::detail::FilePositionWithIndex>
: public position_policy<file_position>
{
+ public:
typedef position_policy<file_position> Base;
void next_line(senf::console::detail::FilePositionWithIndex & pos)
prefix_ bool senf::console::CommandParser::isSpecialChar(char ch)
{
- return Impl::Grammar::special_p.test(ch);
+ return Impl::Grammar::special_p().test(ch);
}
prefix_ bool senf::console::CommandParser::isPunctuationChar(char ch)
{
- return Impl::Grammar::punctuation_p.test(ch);
+ return Impl::Grammar::punctuation_p().test(ch);
}
prefix_ bool senf::console::CommandParser::isSpaceChar(char ch)
{
- return Impl::Grammar::space_p.test(ch);
+ return Impl::Grammar::space_p().test(ch);
}
prefix_ bool senf::console::CommandParser::isInvalidChar(char ch)
{
- return Impl::Grammar::invalid_p.test(ch);
+ return Impl::Grammar::invalid_p().test(ch);
}
prefix_ bool senf::console::CommandParser::isWordChar(char ch)
{
- return Impl::Grammar::word_p.test(ch);
+ return Impl::Grammar::word_p().test(ch);
}
//-/////////////////////////////////////////////////////////////////////////////////////////////////
namespace senf {
namespace console {
- namespace detail { class FilePositionWithIndex; }
+ namespace detail { struct FilePositionWithIndex; }
namespace detail { struct ParserAccess; }
boost::scoped_ptr<Impl> impl_;
- friend class SetIncremental;
+ friend struct SetIncremental;
};
}}
//-/////////////////////////////////////////////////////////////////////////////////////////
// charachter sets
- static boost_spirit::chset<> special_p;
- static boost_spirit::chset<> punctuation_p;
- static boost_spirit::chset<> space_p;
- static boost_spirit::chset<> invalid_p;
- static boost_spirit::chset<> word_p;
- static boost_spirit::distinct_parser<> keyword_p;
+ static boost_spirit::chset<> & special_p() {
+ static boost_spirit::chset<> p ("/(){};\"");
+ return p;
+ }
+ static boost_spirit::chset<> & punctuation_p() {
+ static boost_spirit::chset<> p (",=");
+ return p;
+ }
+ static boost_spirit::chset<> & space_p() {
+ static boost_spirit::chset<> p (" \t\n\r");
+ return p;
+ }
+ static boost_spirit::chset<> & invalid_p() {
+ static boost_spirit::chset<> p ((boost_spirit::chset<>('\0') | boost_spirit::chset<>("\x01-\x20")) - space_p() );
+ return p;
+ }
+ static boost_spirit::chset<> & word_p() {
+ static boost_spirit::chset<> p (boost_spirit::anychar_p - special_p() - punctuation_p() - space_p() - invalid_p());
+ return p;
+ }
+ static boost_spirit::distinct_parser<> & keyword_p() {
+ static boost_spirit::distinct_parser<> p (word_p() | boost_spirit::ch_p('/'));
+ return p;
+ }
//-/////////////////////////////////////////////////////////////////////////////////////////
// Errors
;
builtin
- = self.keyword_p("cd")
+ = self.keyword_p()("cd")
>> path_expected(path)
>> eps_p [ bind(&PD::builtin_cd)(d_, path_) ]
- | self.keyword_p("ls")
+ | self.keyword_p()("ls")
>> ! path
>> eps_p [ bind(&PD::builtin_ls)(d_, path_) ]
- | self.keyword_p("ll")
+ | self.keyword_p()("ll")
>> ! path
>> eps_p [ bind(&PD::builtin_ll)(d_, path_) ]
- | self.keyword_p("lr")
+ | self.keyword_p()("lr")
>> ! path
>> eps_p [ bind(&PD::builtin_lr)(d_, path_) ]
- | self.keyword_p("exit") [ bind(&PD::builtin_exit)(d_) ]
- | self.keyword_p("help")
+ | self.keyword_p()("exit") [ bind(&PD::builtin_exit)(d_) ]
+ | self.keyword_p()("help")
>> ! path
>> eps_p [ bind(&PD::builtin_help)(d_, path_) ]
;
| ch_p(';') [ token_ = construct_<Token>(
Token::CommandTerminator,
";") ]
- | self.punctuation_p [ token_ = construct_<Token>(
+ | self.punctuation_p() [ token_ = construct_<Token>(
Token::OtherPunctuation,
construct_<std::string>(1u, arg1),
pos_) ]
= eps_p [ pos_ = positionOf(arg1) ]
>> lexeme_d
[
- (+ self.word_p) [ str_ = construct_<std::string>(arg1, arg2) ]
+ (+ self.word_p()) [ str_ = construct_<std::string>(arg1, arg2) ]
]
>> eps_p [ token_ = construct_<Token>(
Token::Word,
;
skip
- = self.space_p | comment_p('#')
+ = self.space_p() | comment_p('#')
;
//-/////////////////////////////////////////////////////////////////////////////////
- start_parsers(
+ this->start_parsers(
command, // CommandParser
skip, // SkipParser
arguments, // ArgumentsParser
};
};
- template <class PD> boost_spirit::chset<> CommandGrammar<PD>::special_p (
- "/(){};\"");
- template <class PD> boost_spirit::chset<> CommandGrammar<PD>::punctuation_p (
- ",=");
- template <class PD> boost_spirit::chset<> CommandGrammar<PD>::space_p (
- " \t\n\r");
- template <class PD> boost_spirit::chset<> CommandGrammar<PD>::invalid_p (
- (boost_spirit::chset<>('\0') | boost_spirit::chset<>("\x01-\x20")) - space_p );
- template <class PD> boost_spirit::chset<> CommandGrammar<PD>::word_p (
- boost_spirit::anychar_p - special_p - punctuation_p - space_p - invalid_p);
- template <class PD> boost_spirit::distinct_parser<> CommandGrammar<PD>::keyword_p (
- word_p | boost_spirit::ch_p('/'));
-
#endif
}}}
namespace senf {
namespace console {
- namespace detail { class ArgumentInfoBase; }
+ namespace detail { struct ArgumentInfoBase; }
/** \brief CommandOverload implementation with automatic argument parsing
template <class O, unsigned i, bool f>
friend class ParsedArgumentAttributor;
- friend class detail::ParsedCommandAddNodeAccess;
+ friend struct detail::ParsedCommandAddNodeAccess;
};
#ifndef DOXYGEN
template <class O, unsigned i, bool f>
friend class ParsedArgumentAttributor;
- friend class detail::ParsedCommandAddNodeAccess;
+ friend struct detail::ParsedCommandAddNodeAccess;
};
#endif
///\name Structors and default members
//\{
- ProgramOptions(int argc, char const ** argv, DirectoryNode & root = root());
+ ProgramOptions(int argc, char const ** argv, DirectoryNode & root = senf::console::root());
///< Create ProgramOptions parser for given options
/**< The given argc/argv values are those passed to main by
the operating system. Especially argv[0] is \e not an
\related ProgramOptions
*/
- void parseOptions(int argc, char const ** argv, DirectoryNode & root = root());
+ void parseOptions(int argc, char const ** argv, DirectoryNode & root = senf::console::root());
/** \brief ConfigBundle source reading command line options
#define prefix_
//-/////////////////////////////////////////////////////////////////////////////////////////////////
-prefix_ senf::console::SysInfo::Proxy::Proxy(std::string const & descr, unsigned pos)
+prefix_ senf::console::SysInfo::Proxy::Proxy(std::string const & descr, int pos)
{
SysInfo::instance().addEntry( descr, pos);
}
sysdir().add("info", factory::Command(&SysInfo::dump, this));
}
-prefix_ void senf::console::SysInfo::addEntry(std::string const & descr, unsigned pos)
+prefix_ void senf::console::SysInfo::addEntry(std::string const & descr, int pos)
{
if (pos < 0)
descr_.push_back( descr);
friend class singleton<SysInfo>;
using singleton<SysInfo>::instance;
- void addEntry(std::string const & descr, unsigned pos=-1);
+ void addEntry(std::string const & descr, int pos=-1);
void dump(std::ostream & os) const;
struct Proxy {
- Proxy(std::string const & descr, unsigned pos=-1);
+ Proxy(std::string const & descr, int pos=-1);
};
private:
return (boost::format("localhost:%d") % port(i)).str();
}
- std::string localhost6str(unsigned i)
- {
- return (boost::format("[::1]:%d") % port(i)).str();
- }
-
unsigned nread (0);
unsigned flags (0);
std::string data;
Registry registry_;
friend class senf::singleton<AreaRegistry>;
- friend class detail::AreaBase;
+ friend struct detail::AreaBase;
friend class Target;
};
namespace detail {
- class StreamBase;
+ struct StreamBase;
/** \brief Internal: Area base class */
struct AreaBase
#define SENF_LOG_PREDECL_long(seq) \
BOOST_PP_SEQ_FOLD_RIGHT( SENF_LOG_PREDECL_, \
- class SENF_PP_SEQ_BACK(seq);, \
+ struct SENF_PP_SEQ_BACK(seq);, \
BOOST_PP_SEQ_POP_BACK(seq) )
#define SENF_LOG_PREDECL_short(seq) \
- BOOST_PP_IF( SENF_LOG_IS_NA( SENF_PP_SEQ_BACK(seq) ), ; , class SENF_PP_SEQ_BACK(seq); )
+ BOOST_PP_IF( SENF_LOG_IS_NA( SENF_PP_SEQ_BACK(seq) ), ; , struct SENF_PP_SEQ_BACK(seq); )
#define SENF_LOG_PREDECL(seq) \
BOOST_PP_CAT(SENF_LOG_PREDECL_, \
namespace senf {
namespace log {
- class DefaultArea;
- class Debug;
- class NONE;
+ struct DefaultArea;
+ struct Debug;
+ struct NONE;
namespace detail {
- class StreamBase;
- class AreaBase;
- class LevelBase;
- class AliasBase;
+ struct StreamBase;
+ struct AreaBase;
+ struct LevelBase;
+ struct AliasBase;
/// Internal: Parameter extractor
template <class Base, class Param, unsigned N>
Registry registry_;
friend class senf::singleton<StreamRegistry>;
- friend class detail::StreamBase;
+ friend struct detail::StreamBase;
friend class Target;
};
return 23456u + (((base_pid^(base_pid>>8)^(base_pid>>16)^(base_pid>>24))&0xff)<<2) + i;
}
- std::string localhost4str(unsigned i)
- {
- return (boost::format("localhost:%d") % port(i)).str();
- }
-
- std::string localhost6str(unsigned i)
- {
- return (boost::format("[::1]:%d") % port(i)).str();
- }
-
}
SENF_AUTO_UNIT_TEST(syslogUDPTarget)
namespace log {
namespace detail { class TargetRegistry; }
- namespace detail { class AreaBase; }
+ namespace detail { struct AreaBase; }
namespace detail { struct LogParameters; }
namespace detail { struct StreamBase; }
console::LazyDirectory consoleDir_;
- friend class detail::AreaBase;
+ friend struct detail::AreaBase;
friend class detail::TargetRegistry;
};
ClockService::clock_type requestTimeout_;
scheduler::TimerEvent timeout_;
- friend class TelnetHandler;
+ friend struct TelnetHandler;
};
/** \brief Telnet handler base class
namespace senf {
template <class Self> class intrusive_refcount_t;
+
+ template <class Self>
+ void intrusive_ptr_add_ref(intrusive_refcount_t<Self> const * p);
+ template <class Self>
+ void intrusive_ptr_release(intrusive_refcount_t<Self> const * p);
+
/** \brief Reference count mixin interface baseclass
intrusive_refcount();
};
- template <class Self>
- void intrusive_ptr_add_ref(intrusive_refcount_t<Self> const * p);
- template <class Self>
- void intrusive_ptr_release(intrusive_refcount_t<Self> const * p);
-
}
//-/////////////////////////////////////////////////////////////////////////////////////////////////
# define Begin() SENF_MPL_SLOT_DEF(accum, 0)
# define Add(n) SENF_MPL_SLOT_SET(accum, SENF_MPL_SLOT_GET(accum)+n)
-# define End() BOOST_STATIC_CONSTANT(unsigned, total = SENF_MPL_SLOT_GET(accum))
+# define End() BOOST_STATIC_CONSTANT(unsigned long, total = SENF_MPL_SLOT_GET(accum))
struct Test
{
#define HH_SENF_Utils_senfassert_ 1
// Custom includes
+#include "IgnoreValue.hh"
//#include "senfassert.mpp"
//-/////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef SENF_DEBUG
# define SENF_ASSERT(x, comment)
-# define SENF_ASSERT_EXPRESSION(expression, comment) expression
+# define SENF_ASSERT_EXPRESSION(expression, comment) senf::IGNORE( expression )
#else
env['BUILDERS']['BoostUnitTest'] = AutoObjectBoostUnitTest
env['_UNIT_TEST_LIST'] = []
env.Append(EXTRA_LIBS = [ '$BOOSTREGEXLIB', '$BOOSTSIGNALSLIB',
- '$BOOSTFSLIB', '$BOOSTSYSTEMLIB' ])
+ '$BOOSTFSLIB', '$BOOSTSYSTEMLIB', '$BOOSTDATETIMELIB' ])
# This needs to be called after all build targets have been set
# up. This is important since the list of object targets needs to be
CXXFLAGS = [ '-Wno-long-long', '-fno-strict-aliasing' ],
LINKFLAGS = [ '-rdynamic' ],
LIBS = [ 'senf$LIBADDSUFFIX', 'rt', '$BOOSTREGEXLIB',
- '$BOOSTSIGNALSLIB', '$BOOSTFSLIB', '$BOOSTSYSTEMLIB' ],
+ '$BOOSTSIGNALSLIB', '$BOOSTFSLIB', '$BOOSTSYSTEMLIB',
+ '$BOOSTDATETIMELIB' ],
)
try:
BOOSTFSLIB = 'boost_filesystem$_BOOST_VARIANT',
BOOSTIOSTREAMSLIB = 'boost_iostreams$_BOOST_VARIANT',
BOOSTSIGNALSLIB = 'boost_signals$_BOOST_VARIANT',
+ BOOSTDATETIMELIB = 'boost_date_time$_BOOST_VARIANT',
_BOOSTSYSTEMLIB = '${HAS_BOOST_SYSTEM and "boost_system" or ""}',
BOOSTSYSTEMLIB = '$_BOOSTSYSTEMLIB',