// $Id$
//
-// Copyright (C) 2008
+// Copyright (C) 2008
// Fraunhofer Institute for Open Communication Systems (FOKUS)
// Competence Center NETwork research (NET), St. Augustin, GERMANY
// Stefan Bund <g0dil@berlios.de>
Timer events are implemented using POSIX timers. Depending on kernel features, the timer
resolution will be far more precise than the linux clock tick resolution. The nominal timer
resolution is 1 nanosecond.
-
+
The timeout time is set as \e absolute time as returned by the senf::ClockService. After
expiration, the timer will be disabled. It may be re-enabled by setting a new timeout time.
It is also possible to change a running timer resetting the timeout time.
automatically. Use enable() to do so.
\param[in] name Descriptive timer name (purely
informational)
+ \param[in] timeout timeout time after the timer
+ will be disabled
\param[in] cb Callback to call
\param[in] initiallyEnabled if set \c false, do not
enable callback automatically. */
///< Create a timer event
/**< Creates a timer event for callback \a cb. The timer is
initially disabled. Use the timeout() member to set the
- timeout time.
+ timeout time.
\param[in] name Descriptive timer name (purely
informational)
\param[in] cb Callback to call. */
{
typename boost::range_iterator<ForwardWritableRange>::type const i (boost::begin(range));
char * const ic (reinterpret_cast<char*>(storage_iterator(i)));
- return i + (handle.read( ic,
+ return i + (handle.read( ic,
reinterpret_cast<char*>(storage_iterator(boost::end(range))) )
- ic);
}
{
typename boost::range_iterator<ForwardWritableRange>::type const i (boost::begin(range));
char * const ic (reinterpret_cast<char*>(storage_iterator(i)));
- return i + (handle.readfrom( ic,
+ return i + (handle.readfrom( ic,
reinterpret_cast<char*>(storage_iterator(boost::end(range))),
addr )
- ic);
senf::detail::WriteRange<Handle, ForwardReadableRange, true>::
write(Handle & handle, ForwardReadableRange & range)
{
- typename boost::range_const_iterator<ForwardReadableRange>::type i
+ typename boost::range_const_iterator<ForwardReadableRange>::type i
(boost::const_begin(range));
char const * const ic (reinterpret_cast<char const *>(storage_iterator(i)));
std::advance(i, handle.write(ic,
senf::detail::WriteRange<Handle, ForwardReadableRange, true>::
writeto(Handle & handle, ForwardReadableRange & range, typename Handle::Address const & addr)
{
- typename boost::range_const_iterator<ForwardReadableRange>::type i
+ typename boost::range_const_iterator<ForwardReadableRange>::type i
(boost::const_begin(range));
char const * const ic (reinterpret_cast<char const *>(storage_iterator(i)));
std::advance(i, handle.writeto(addr, ic,
prefix_ senf::ClientSocketHandle<SPolicy>::
ClientSocketHandle(ClientSocketHandle<OtherPolicy> other,
typename SocketHandle<SPolicy>::template IsCompatible<OtherPolicy>::type *)
- : SocketHandle<SPolicy>(other,true)
+ : SocketHandle<SPolicy>(other,true)
{}
#else
template <class SPolicy>
template <class SPolicy>
prefix_ senf::ClientSocketHandle<SPolicy>::ClientSocketHandle(FileHandle other, bool isChecked)
- : SocketHandle<SPolicy>(other, isChecked)
+ : SocketHandle<SPolicy>(other, isChecked)
{}
template <class SPolicy>
prefix_
senf::ClientSocketHandle<SPolicy>::ClientSocketHandle(std::auto_ptr<SocketBody> body)
- : SocketHandle<SPolicy>(body)
+ : SocketHandle<SPolicy>(body)
{}
#ifndef DOXYGEN
assign(other);
return *this;
}
-#else
+#else
template <class SPolicy>
template <class OtherPolicy>
prefix_ OtherPolicy const &
read(ForwardWritableRange const & range,
typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned> >::type *)
{
- return detail::ReadRange<
- ClientSocketHandle<SPolicy>,
- ForwardWritableRange const,
+ return detail::ReadRange<
+ ClientSocketHandle<SPolicy>,
+ ForwardWritableRange const,
contiguous_storage_iterator<
typename boost::range_iterator<ForwardWritableRange>::type
>::value && sizeof(typename boost::range_value<ForwardWritableRange>::type)==sizeof(char)
read(ForwardWritableRange & range,
typename boost::disable_if< boost::is_convertible<ForwardWritableRange,unsigned> >::type *)
{
- return detail::ReadRange<
- ClientSocketHandle<SPolicy>,
- ForwardWritableRange,
+ return detail::ReadRange<
+ ClientSocketHandle<SPolicy>,
+ ForwardWritableRange,
contiguous_storage_iterator<
typename boost::range_iterator<ForwardWritableRange>::type
>::value && sizeof(typename boost::range_value<ForwardWritableRange>::type)==sizeof(char)
prefix_ typename boost::range_iterator<ForwardWritableRange const>::type
senf::ClientSocketHandle<SPolicy>::readfrom(ForwardWritableRange const & range, Address & from)
{
- return detail::ReadRange<
- ClientSocketHandle<SPolicy>,
- ForwardWritableRange const,
+ return detail::ReadRange<
+ ClientSocketHandle<SPolicy>,
+ ForwardWritableRange const,
contiguous_storage_iterator<
typename boost::range_iterator<ForwardWritableRange>::type
>::value && sizeof(typename boost::range_value<ForwardWritableRange>::type)==sizeof(char)
prefix_ typename boost::range_iterator<ForwardWritableRange>::type
senf::ClientSocketHandle<SPolicy>::readfrom(ForwardWritableRange & range, Address & from)
{
- return detail::ReadRange<
- ClientSocketHandle<SPolicy>,
- ForwardWritableRange,
+ return detail::ReadRange<
+ ClientSocketHandle<SPolicy>,
+ ForwardWritableRange,
contiguous_storage_iterator<
typename boost::range_iterator<ForwardWritableRange>::type
>::value && sizeof(typename boost::range_value<ForwardWritableRange>::type)==sizeof(char)
// senf::ClientSocketHandle<SPolicy>::bind
template <class SPolicy>
-prefix_ void senf::ClientSocketHandle<SPolicy>::
-bind(typename boost::call_traits<typename SPolicy::AddressingPolicy::Address>::param_type addr)
+prefix_ void senf::ClientSocketHandle<SPolicy>::bind(AddressParam addr)
const
{
SPolicy::AddressingPolicy::bind(*this, addr);
/** \brief INet6 network address
- This implementation of an INet6 address is based strictly on
+ This implementation of an INet6 address is based strictly on
<a href="http://tools.ietf.org/html/rfc4291">RFC 4291</a>: Internet Protocol
Version 6 (INet6) Addressing Architecture. This class provides accessors to all the
information fields defined in this document.
2002::/16 prefix
\li <a href="http://tools.ietf.org/html/rfc3849">RFC 3849</a>:
INet6 Address Prefix Reserved for Documentation. Defines the 2001:db8::/32 prefix
-
+
Here an overview of well-known prefixes:
\htmlonly
/** \brief Possible scope values
List of all possible scope values. This list includes all scope values defined for
- multicast addresses in <a href="http://tools.ietf.org/html/rfc4291">RFC 4291</a>.
- The values \ref LinkScope, \ref SiteScope and \ref GlobalScope are also used with
+ multicast addresses in <a href="http://tools.ietf.org/html/rfc4291">RFC 4291</a>.
+ The values \ref LinkScope, \ref SiteScope and \ref GlobalScope are also used with
unicast addresses.
*/
enum ScopeId {
, ReservedScope = 0 /**< Reserved scope value */
, UnassignedScope = 6 /**< Unassigned scope, may be defined locally */
- };
+ };
///////////////////////////////////////////////////////////////////////////
///\name Structors and default members
boost::uint16_t a3=0u, boost::uint16_t a4=0u, boost::uint16_t a5=0u,
boost::uint16_t a6=0u, boost::uint16_t a7=0u);
///< Construct an address constant
-
+
static INet6Address from_in6addr(in6_addr const & in6addr); ///< Construct from std C struct
static INet6Address from_string(std::string const & s, Resolve_t resolve = ResolveINet6);
protocol like DNS or NIS
\throws AddressSyntaxException if the address cannot be
converted for some reason
- \param[in] s Address literal or hostname
+ \param[in] s Address literal or hostname
\param[in] resolve If this is set to \c ResolveINet4,
the call will additionally try to interpret \a s as
an INet4 address if no valid INet6 address is
found. The address will be returned as mapped INet6
address. */
- template <class InputIterator>
+ template <class InputIterator>
static INet6Address from_data(InputIterator i);
///< Construct address from 16 bytes of raw data
/**< from_data will build an address from 16 bytes of raw
/**< This will construct an address of the form
<tt>::FFFF::w.x.y.z</tt> where <tt>w.x.y.z</tt> is
the INet4Address value. This kind of address is called
- an INet6-mapped INet4 address (see
+ an INet6-mapped INet4 address (see
<a href="http://tools.ietf.org/html/rfc4291">RFC 4291</a>).
- \par
+ \par
INet4 compatible INet6 addresses are not directly
supported, they are deprecated in the RFC. */
std::string toString() const;
///< get the string representation of this INet6Address
in6_addr toin6_addr() const;
- ///< get the linux in6_addr struct (convinience only)
-
-
+ ///< get the linux in6_addr struct (convinience only)
+
+
///@}
///////////////////////////////////////////////////////////////////////////
///\name Accessors
site or global scope (where site scope is deprecated),
multicast address can have a number of scope values of
which local, site and global are a few. See the \ref
- ScopeId enumerators. */
+ ScopeId enumerators. */
bool globalScope() const; ///< \c true, if address is global unicast or multicast
bool linkScope() const; ///< \c true, if address is link-local unicast or multicast
is given by the last 32 bits of the INet6 address. \par
The value returned is only a valid INet4 address if
either inet4Compatible() or inet4Mapped() return \c
- true. */
+ true. */
bool inet4Compatible() const; ///< \c true, if address is INet4 compatible
/**< INet4 compatible INet6 addresses are deprecated. */
bool inet4Mapped() const; ///< \c true, if address is INet4 mapped
bool globalMulticastAddr() const; ///< \c true, if T bit is \e not set
/**< Any multicast address with a cleared T bit must be
- globally assigned. See
+ globally assigned. See
<a href="http://tools.ietf.org/html/rfc4291">RFC 4291</a>. */
bool prefixMulticastAddr() const; ///< \c true, if P bit is set
/**< In <a href="http://tools.ietf.org/html/rfc4291">RFC 4291</a>,
the P bit is specified as defining a
- unicast prefix based multicast address. See
- <a href="http://tools.ietf.org/html/rfc3306">RFC 3306</a>. */
+ unicast prefix based multicast address. See
+ <a href="http://tools.ietf.org/html/rfc3306">RFC 3306</a>. */
bool embeddedRpAddr() const; ///< \c true, if R bit is set
/**< In <a href="http://tools.ietf.org/html/rfc4291">RFC 4291</a>,
- the R bit is specified as defining a multicast address
+ the R bit is specified as defining a multicast address
with embedded rendezvous point. See
<a href="http://tools.ietf.org/html/rfc3956">RFC 3956</a>. */
///@}
///\name Mutators
///@{
-
+
void network(boost::uint64_t net); ///< Set network part of address
void id(boost::uint64_t id); ///< Set interface id part of address
std::ostream & operator<<(std::ostream & os, INet6Address const & addr);
/** \brief Check INet6Address against a fixed network prefix
-
+
This helper allows to easily and efficiently check an INet6Address against an arbitrary but
constant network prefix. It takes from 1 to 8 arguments for the network address and an
additional last argument providing the prefix length. So
... <tt>,</tt> <i>prefix_len</i> <tt>></tt>
represents the network
-
+
\par ""
<i>addr_1</i> <tt>:</tt> <i>addr_2</i> <tt>:</tt> ... <tt>::/</tt> <i>prefix_len</i> .
The class exposes a single static member <tt>match(</tt> <i>addr</i> <tt>)</tt> which
matches the INet6Address \a addr against the prefix:
-
+
\code
if (senf::CheckINet6Network<0x2000u,0xDB8u,32u>::match(addr)) {
// 'addr' is within in the 2001:db8::/32 documentation-only network
template <unsigned a0, unsigned a1, unsigned a2=0u, unsigned a3=0u, unsigned a4=0u,
unsigned a5=0u, unsigned a6=0u, unsigned a7=0u, unsigned a8=0u>
struct CheckINet6Network
+#ifndef DOXYGEN
: public detail::CheckINet6Network_impl<a0,a1,a2,a3,a4,a5,a6,a7,a8>
+#endif
{};
/** \brief INet6 network prefix
- This class represents an INet6 network prefix in CIDR notation.
+ This class represents an INet6 network prefix in CIDR notation.
*/
class INet6Network
- : public boost::equality_comparable<INet6Network>,
+ : public boost::equality_comparable<INet6Network>,
public comparable_safe_bool<INet6Network>
{
public:
bool boolean_test() const; ///< \c true, if INet6Network is non-empty
bool operator==(INet6Network const & other) const;
///< Compare two networks for equality
-
+
bool match(INet6Address addr) const; ///< \c true, if the network includes \a addr
bool match(INet6Network net) const; ///< \c true, if the network includes \a net
/**< The is true, if \a net is sub-network (or the same as)
\code
INet6Network("2001:db8::/32").subnet(0x12u,40u) == INet6Network("2001:db8:1200::/40")
INet6Network("2001:db8:1200::/40").subnet(0x2345,64u) == INet6Network("2001:db8:1200:2345::/64")
- \endcode
+ \endcode
\param[in] net network number
\param[in] prefix_len length of subnet prefix */
<span coords="41,191,180,219">\ref ReadPolicyBase</span>
</div>
\htmlonly <img src="SocketPolicy.png" border="0" alt="SocketPolicy" usemap="#SocketPolicy"> \endhtmlonly
-
+
\section policy_group_introduction Introduction to the Policy Framework
The policy framework conceptually implements a list of parallel inheritance hierarchies each
from the axis base class <tt>FramingPolicyBase</tt>. This base class also doubles as
<tt>UnspecifiedFramingPolicy</tt> (which is just a typedef alias). If a policy axis is assigned
this Unspecified type, the axis is left unspecified, the concrete policy will be incomplete.
-
+
The senf::SocketPolicy template defines the behavior of a socket handle. The socket handle
instances do not implement any socket functionality themselves instead deferring the
implementation to the policy classes. The SocketHandle interface is therefore \e not implemented
meta-programming are needed. However, this information is only needed if you want to write new
policy classes or want to use the policy framework explicitly for your own involved
optimizations ... or if you are just plain curious :-)
-
+
In the following discussion we will use the following conventions:
\li \e Axis is one or \c AddressingPolicy, \c FramingPolicy, \c CommunicationPolicy, \c
ReadPolicy or \c WritePolicy
The \c listen member is straight forward. The \c accept() member must return a new file
descriptor (which will be used to create a new SocketHandle of the correct
- type).
+ type).
\note This Policy only has two meaningful states: ConnectedCommunicationPolicy and
UnconnectedCommunicationPolicy. It is probably not sensible to define a new
information.
*/
AddressingPolicyBase const & theAddressingPolicy() const = 0;
+
+ virtual ~SocketPolicyBase();
};
/** \brief Collection of policy classes