Exemple #1
0
network_v4 network_v4::from_string( const std::string& network )
{
    std::size_t found = network.find_last_of( "/" );
    if ( found == 0 )
    {
        // FIXME: Throw exception
    }

    boost::asio::ip::address_v4 addr = boost::asio::ip::address_v4::from_string( network.substr( 0, found ) );
    unsigned short cidr = boost::lexical_cast<unsigned short>( network.substr( found + 1 ) );

    return network_v4( addr.to_ulong(), cidr );
}
/**
 * @relates address_v4
 */
inline network_v4 make_network_v4(
    const address_v4& addr, const address_v4& mask)
{
  return network_v4(addr, mask);
}
/**
 * @relates address_v4
 */
inline network_v4 make_network_v4(
    const address_v4& addr, unsigned short prefix_len)
{
  return network_v4(addr, prefix_len);
}