reinterpret_cast<in_addr*>(*(ent->h_addr_list))->s_addr);
}
-prefix_ std::string senf::INet4Address::toString() const {
- char buffer[4*4];
- ::in_addr ina;
- ina.s_addr = (*this).inaddr();
- ::inet_ntop(AF_INET, & ina , buffer, sizeof(buffer));
- buffer[sizeof(buffer)-1] = 0;
- return buffer;
-}
-
prefix_ bool senf::INet4Address::local()
const
{
/**< This member returns the address as an integer number in
host byte order. This representation allows simple
network math operations. */
- std::string toString() const;
- ///< get the string representation of this INet4Address
-
////@}
private:
return ina;
}
-prefix_ std::string senf::INet6Address::toString() const {
- char buffer[5*8];
- ::in6_addr ina = (*this).toin6_addr();
- ::inet_ntop(AF_INET6, & ina , buffer, sizeof(buffer));
- buffer[sizeof(buffer)-1] = 0;
- return buffer;
-}
-
prefix_ std::ostream & senf::operator<<(std::ostream & os, INet6Address const & addr)
{
- os << addr.toString();
+ ::in6_addr ina;
+ char buffer[5*8];
+ std::copy(addr.begin(),addr.end(),&ina.s6_addr[0]);
+ ::inet_ntop(AF_INET6,&ina,buffer,sizeof(buffer));
+ buffer[sizeof(buffer)-1] = 0;
+ os << buffer;
return os;
}
#undef prefix_
//#include "INet6Address.mpp"
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100
\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)
-
+ in6_addr toin6_addr() const; ///< get the linux in6_addr struct (convinience only)
///@}
///////////////////////////////////////////////////////////////////////////
#include "INet6Address.cti"
#endif
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100
else
throw senf::AddressSyntaxException();
}
-
+
template <class Range>
boost::uint8_t hexToByte(Range const & range)
{
senf::MACAddress const senf::MACAddress::Broadcast = senf::MACAddress(0xFFFFFFFFFFFFull);
senf::MACAddress const senf::MACAddress::None;
-prefix_ std::string senf::MACAddress::toString() const {
- std::ostringstream tmp;
- tmp << (*this);
- return tmp.str();
-}
///////////////////////////////////////////////////////////////////////////
// namespace members
#undef prefix_
//#include "MACAddress.mpp"
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100
namespace senf {
/** \brief Ethernet MAC address
-
+
The Ethernet MAC is modelled as a fixed-size container/sequence of 6 bytes.
The following statements all create the same MAC address <code>00:1A:2B:3C:4D:5F</code>
\ingroup addr_group
*/
struct MACAddress
- : public boost::array<boost::uint8_t,6>,
+ : public boost::array<boost::uint8_t,6>,
public comparable_safe_bool<MACAddress>
{
static MACAddress const Broadcast; ///< The broadcast address
accepted as a delimiter.
\throws AddressSyntaxException */
- template <class InputIterator>
+ template <class InputIterator>
static MACAddress from_data(InputIterator i);
///< Construct address from raw data
/**< Copies the data from \a i into the MAC address.
boost::uint32_t oui() const; ///< Return first 3 bytes of the address
boost::uint32_t nic() const; ///< Return last 3 bytes of the address
-
- boost::uint64_t eui64() const; ///< Build EUI-64 from the MAC address
- boost::uint64_t uint64() const; ///< Return MAC address as uint64 value
-
- std::string toString() const; ///< Return string representation of MAC address like 12:34:56:78:90:ab
+ boost::uint64_t eui64() const; ///< Build EUI-64 from the MAC address
+ boost::uint64_t uint64() const; ///< Return MAC address as uint64 value
};
/** \brief Output MAC instance as it's string representation
//#include "MACAddress.cti"
#endif
-\f
+
// Local Variables:
// mode: c++
// fill-column: 100