///////////////////////////////cti.p///////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
+// senf::ppi::TargetDgramWriter<HandleType>
+
+template <class HandleType>
+prefix_ senf::ppi::TargetDgramWriter<HandleType>::TargetDgramWriter()
+{}
+
+template <class HandleType>
+prefix_ senf::ppi::TargetDgramWriter<HandleType>::
+TargetDgramWriter(typename Handle::Address const & target)
+: target_ (target)
+{}
+
+template <class HandleType>
+prefix_ typename senf::ppi::TargetDgramWriter<HandleType>::Handle::Address
+senf::ppi::TargetDgramWriter<HandleType>::target()
+ const
+{
+ return target_;
+}
+
+template <class HandleType>
+prefix_ void
+senf::ppi::TargetDgramWriter<HandleType>::target(typename Handle::Address const & target)
+{
+ target_ = target;
+}
+
+template <class HandleType>
+prefix_ void senf::ppi::TargetDgramWriter<HandleType>::operator()(Handle handle,
+ Packet const & packet)
+{
+ if (target_)
+ handle.writeto(target_, packet.data());
+}
+
+///////////////////////////////////////////////////////////////////////////
// senf::ppi::module::ActiveSocketSink<Writer>
template <class Writer>
\param[in] packet Packet to write */
};
+ template <class HandleType>
+ class TargetDgramWriter
+ {
+ public:
+ typedef HandleType Handle;
+
+ TargetDgramWriter();
+ TargetDgramWriter(typename Handle::Address const & target);
+
+ typename Handle::Address target() const;
+ void target(typename Handle::Address const & target);
+
+ void operator()(Handle handle, Packet const & packet);
+
+ private:
+ typename Handle::Address target_;
+ };
+
class IPv4SourceForcingDgramWriter : ConnectedDgramWriter
{
public:
prefix_ senf::scheduler::detail::EventManager::EventManager()
{
#ifndef SENF_DISABLE_CONSOLE
- consoleDir_().add("events", senf::membind(&EventManager::consoleEvents, this))
+ consoleDir_().add("events", senf::membind(&EventManager::listEvents, this))
.doc("List all scheduler events sorted by priority\n"
"\n"
"Columns:\n"
#endif
}
-prefix_ void senf::scheduler::detail::EventManager::consoleEvents(std::ostream & os)
+prefix_ void senf::scheduler::detail::EventManager::listEvents(std::ostream & os)
{
// On an 80 column display, this wraps nicely directly before the INFO column
boost::format fmt ("%s %-55.55s 0x%08x %8d %s %s\n");
iterator begin() const;
iterator end() const;
+ void listEvents(std::ostream & os);
+
protected:
private:
friend class singleton<EventManager>;
#ifndef SENF_DISABLE_CONSOLE
- void consoleEvents(std::ostream & os);
-
console::LazyDirectory consoleDir_;
#endif
};
doIoctl( ifr, SIOCSIFFLAGS);
}
+prefix_ bool senf::NetdeviceController::isUp()
+ const
+{
+ struct ifreq ifr;
+ ifrName(ifr);
+ doIoctl(ifr, SIOCGIFFLAGS);
+ return ifr.ifr_flags & IFF_UP;
+}
+
+prefix_ void senf::NetdeviceController::up()
+{
+ struct ifreq ifr;
+ ifrName(ifr);
+ doIoctl(ifr, SIOCGIFFLAGS);
+ ifr.ifr_flags |= IFF_UP;
+ doIoctl(ifr, SIOCSIFFLAGS);
+}
+
+prefix_ void senf::NetdeviceController::down()
+{
+ struct ifreq ifr;
+ ifrName(ifr);
+ doIoctl(ifr, SIOCGIFFLAGS);
+ ifr.ifr_flags &= ~IFF_UP;
+ doIoctl(ifr, SIOCSIFFLAGS);
+}
+
prefix_ int senf::NetdeviceController::interfaceIndex()
const
{
bool promisc() const; ///< return \c true if interface is in promiscuous mode
void promisc(bool mode); ///< enable/disable promiscuous mode of the interface
/**< Note, that this is a privileged operation. */
-
+
+ bool isUp() const; ///< return \c true if interface is up
+ void up(); ///< ifconfig up interface
+ void down(); ///< ifconfig down interface
+
private:
void openSocket();
void doIoctl(ifreq& ifr, int request) const;
<< " Could not open \"" << stdoutLog_ << "\" for redirecting stdout.";
stdout_ = fd;
}
- if (stderrLog_ == stdoutLog_) {
- stderr_ = ::dup(fd);
- if (stderr_ < 0)
- SENF_THROW_SYSTEM_EXCEPTION("::dup()");
- }
- else if (! stderrLog_.empty()) {
- fd = ::open(stdoutLog_.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0666);
- if (fd < 0)
- SENF_THROW_SYSTEM_EXCEPTION("")
- << " Could not open \"" << stderrLog_ << "\" for redirecting stderr.";
- stderr_ = fd;
+ if (! stderrLog_.empty()) {
+ if (stderrLog_ == stdoutLog_) {
+ stderr_ = ::dup(fd);
+ if (stderr_ < 0)
+ SENF_THROW_SYSTEM_EXCEPTION("::dup()");
+ }
+ else {
+ fd = ::open(stdoutLog_.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0666);
+ if (fd < 0)
+ SENF_THROW_SYSTEM_EXCEPTION("")
+ << " Could not open \"" << stderrLog_ << "\" for redirecting stderr.";
+ stderr_ = fd;
+ }
}
}
LIBC_CALL( ::sigaddset, (&cldsig, SIGCHLD) );
LIBC_CALL( ::sigprocmask, (SIG_BLOCK, &cldsig, &oldsig) );
- if (! senf::scheduler::empty() )
+ if (! senf::scheduler::empty() ) {
std::cerr <<
"\n"
"*** WARNING ***\n"
"Scheduler not empty before fork(). THIS MUST NOT HAPPEN.\n"
- "The scheduler will be reinitialized by the fork() and lose all registrations.\n"
- "*** WARNING ***\n"
+ "The scheduler will be reinitialized by the fork() and lose all registrations.\n\n";
+ senf::scheduler::detail::EventManager::instance().listEvents(std::cerr);
+ std::cerr <<
+ "\n*** WARNING ***\n"
"\n";
+ }
LIBC_CALL_RV( pid, ::fork, () );