X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FSocketSink.hh;h=f7f61a55d855cadce6e938ca2d39ee61eded5eb5;hb=55d09e34a5b9a9c7af23cc5ecb0ab79d58757a2d;hp=ed74d9b0ba2c9fc163b84d62b3604647835bceb0;hpb=ed0e2329281a50f80be8425938c17515fa70661b;p=senf.git diff --git a/PPI/SocketSink.hh b/PPI/SocketSink.hh index ed74d9b..f7f61a5 100644 --- a/PPI/SocketSink.hh +++ b/PPI/SocketSink.hh @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institute for Open Communication Systems (FOKUS) -// Competence Center NETwork research (NET), St. Augustin, GERMANY +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -35,6 +35,8 @@ #include "../Socket/CommunicationPolicy.hh" #include "Module.hh" #include "Connectors.hh" +#include "../Socket/Protocols/INet/INetAddressing.hh" +#include "IOEvent.hh" //#include "SocketSink.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -63,18 +65,47 @@ namespace ppi { \param[in] packet Packet to write */ }; + class IPv6SourceForcingDgramWriter + { + public: + IPv6SourceForcingDgramWriter(); + IPv6SourceForcingDgramWriter(senf::INet6Address sourceAddr, senf::INet6SocketAddress destAddr); + typedef senf::ClientSocketHandle< + senf::MakeSocketPolicy< senf::WriteablePolicy, + senf::DatagramFramingPolicy>::policy > Handle; + ///< Handle type supported by this writer + + void source(senf::INet6Address & source); + senf::INet6Address source(); + void destination(senf::INet6SocketAddress & dest); + senf::INet6SocketAddress destination(); + + void operator()(Handle handle, Packet packet); + ///< Write \a packet to \a handle + /**< Write the complete \a packet as a datagram to \a + handle. + \param[in] handle Handle to write data to + \param[in] packet Packet to write */ + private: + int sendtoandfrom(int sock, const void *data, size_t dataLen, const in6_addr *dst, int port, const in6_addr *src); + senf::INet6Address source_; + senf::INet6Address destination_; + unsigned int protocolId_; +}; + + }} namespace senf { namespace ppi { namespace module { - /** \brief Output module writing data to a FileHandle using the provided Writer. + /** \brief Output %module writing data to a FileHandle using the provided Writer. If using the default ConnectedDgramWriter the filehandle must be writable, connected and able to handle complete datagrams. - This output module will write data to a FileHandle object using a given \a Writer. This - output module is active. This requires the file handle to be able to signal its readiness to + This output %module will write data to a FileHandle object using a given \a Writer. This + output %module is active. This requires the file handle to be able to signal its readiness to accept more data via the Scheduler. The default \a Writer is senf::ppi::ConnectedDgramWriter which will write out the complete packet to @@ -87,8 +118,8 @@ namespace module { public: typedef unspecified Handle; // type of handle requested - SomeWriter(); // EITHER default constructible OR - SomeWriter(SomeWriter const & other); // copy constructible + SomeWriter(); // EITHER default constructible OR + SomeWriter(SomeWriter const & other); // copy constructible void operator()(Handle handle, Packet packet); // insertion function }; @@ -105,7 +136,7 @@ namespace module { public: typedef typename Writer::Handle Handle; ///< Handle type requested by writer - connector::ActiveInput input; ///< Input connector from which data is received + connector::ActiveInput<> input; ///< Input connector from which data is received ActiveSocketSink(Handle handle); ///< Create new writer for the given handle /**< Data will be written to \a handle using \a Writer. @@ -120,8 +151,6 @@ namespace module { socket */ Writer & writer(); ///< Access the Writer - void replaceHandle(Handle newHandle); - ///< Replace the handle to which the packets are written private: void write(); @@ -168,7 +197,7 @@ namespace module { public: typedef typename Writer::Handle Handle; ///< Handle type requested by writer - connector::PassiveInput input; ///< Input connector from which data is received + connector::PassiveInput<> input; ///< Input connector from which data is received PassiveSocketSink(Handle handle); ///< Create new writer for the given handle /**< Data will be written to \a handle using \a Writer. @@ -180,9 +209,18 @@ namespace module { \pre Requires \a Writer to be copy constructible \param[in] handle Handle to write data to */ - Writer & writer(); ///< Access the Writer + Writer & writer(); ///< Access the Writer + Handle & handle(); /**< Access the handle. This is intendet to be mainly used to reconnect + the underlying socket. */ + /* void reconnect(senf::SocketAddress newAddress); + ///< Reconnect the handle to which the packets are written + */ void replaceHandle(Handle newHandle); - ///< Replace the handle to which the packets are written + /**< Replace the handle to which the packets are written + * Normally you should access the handle and call connect with + * the new address. This also works for other + * (active) ConnectedSocketSinks/Sources */ + private: void write();