// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** \file
- \brief
-
+ \brief
+
*/
#include "TunTapSocketHandle.hh"
#define prefix_
///////////////////////////////cc.p////////////////////////////////////////
-prefix_ void senf::TapSocketProtocol::init_client()
+prefix_ std::string senf::TapSocketProtocol::init_client()
const
{
- init_client(std::string());
+ return init_client(std::string());
}
-prefix_ void senf::TapSocketProtocol::init_client(std::string const & interface_name, bool const NO_PI)
+prefix_ std::string senf::TapSocketProtocol::init_client(std::string const & interface_name, bool const NO_PI)
const
{
int f;
interface_name.copy( ifr.ifr_name, IFNAMSIZ);
if (::ioctl(f, TUNSETIFF, (void *) &ifr) < 0 )
SENF_THROW_SYSTEM_EXCEPTION( "Could not create tap device: ") << ifr.ifr_name << ".";
+ ifaceIndex_ = if_nametoindex(ifr.ifr_name);
fd(f);
+ return ifaceName();
}
prefix_ unsigned senf::TapSocketProtocol::available()
return false;
}
+prefix_ unsigned int senf::TapSocketProtocol::ifaceIndex()
+ const
+{
+ return ifaceIndex_;
+}
+
+prefix_ std::string senf::TapSocketProtocol::ifaceName()
+ const
+{
+ char buf[IF_NAMESIZE];
+ if_indextoname(ifaceIndex_, buf);
+ return std::string(buf);
+}
+
///////////////////////////////cc.e////////////////////////////////////////
#undef prefix_
//#include "TunTapSocketHandle.mpp"
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100
public:
///\name Constructors
///@{
- void init_client() const;
+ std::string init_client() const;
///< Create TAP socket
/**< \todo document me */
/**< \note This member is implicitly called from the
ProtocolClientSocketHandle::ProtocolClientSocketHandle()
constructor */
- void init_client(std::string const & interface_name, bool const NO_PI=true) const;
+ std::string init_client(std::string const & interface_name, bool const NO_PI=true) const;
///< Create TAP socket
/**< \todo document me
\param[in] address remote address to connect to */
/**< \note This member is implicitly called from the
ProtocolClientSocketHandle::ProtocolClientSocketHandle()
constructor */
-
+
///@}
///\name Abstract Interface Implementation
unsigned available() const;
bool eof() const;
+ unsigned int ifaceIndex() const;
+ std::string ifaceName() const;
+ private:
+ mutable unsigned int ifaceIndex_;
///@}
};
//#include "TunTapSocketHandle.mpp"
#endif
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100